Trinitycore: Summoned vehicles despawn immediately after exit

Created on 16 Oct 2016  路  24Comments  路  Source: TrinityCore/TrinityCore

Summoned vehicles despawn immediately after exit:

Current behaviour: Summoned vehicles despawn immediately after exit

Expected behaviour: Summoned vehicles should not despawn immediately after exit

Fixing issue will solve problem:

  1. While scripting the "Enter the Maelstrom" quest at a point during the ride player must change seats to change the camera. When spell 86967 is cast the player leaves seat 2 and the vehicle despawns.

Branch(es): 3.3.5 / 6.x

TC hash/commit:

TDB version:

Operating system:

Branch-3.3.5a Branch-master Comp-Core Sub-Vehicles

Most helpful comment

When should they despawn?

All 24 comments

When should they despawn?

Why treat them differently at all?
We have PassengerBoarded(Unit* who, int8 seatId, bool apply), to use for the cases where they should actually despawn.

Edit: Don't actually know if it's default behavior for summoned vehicles to always despawn, but changing a seat should not cause a ExitVehicle/EnterVehicle event, should it?
The only code I see despawning the vehicle is in the Unit::_ExitVehicle function.

It's due to VehicleAI despawning, probably

Another example which I mentioned before is the version of gymer which is summoned for the stormkings vengence the npc should say line 'Farewell, friend. May we meet again under better circumstances. I'll never forget what you did for me!' and despawn a few seconds later it is scripted to do this but this never occurs as vehicle despawns instant when player dismounts

Yeah there should be a despawn timer.

Same like the Traveler's mammoth, instant despawn. Can't we script a delay into them? With a c++ you can atleast.

And still nothing...

This only happens if said vehicle is conditioned (using conditions.SourceTypeOrReferenceId = 16)

Some news about this? The bug is still exist

@Faq is https://github.com/TrinityCore/TrinityCore/issues/24722#issuecomment-698574244 related to this issue too ?

About exiting, valid for 335 on a770ad0476a32007a356c3539309f7a111893145
for https://github.com/TrinityCore/TrinityCore/issues/18089#issuecomment-254069707
Steps:
.gm on
.go c id 29647
.q add 12919
Mount him and use exit button, he will despawn asap without saying that text.

That vehicle with steps is from using https://github.com/TrinityCore/TrinityCore/issues/18089#issuecomment-292766509 :
`` SELECT creature_template.name, conditions.SourceEntry, conditions.Comment`
FROM
conditions,
creature_template
WHERE
conditions.SourceTypeOrReferenceId = 16 AND
conditions.SourceEntry = creature_template.entry
````

For vehicle type mounts de-spawn should be asap like now. Some mount examples:
Traveler's Tundra Mammoth
Mechano-hog

I search witch part of code the vehicle is despawned and i found this on follow function:
void Unit::_ExitVehicle(Position const* exitPosition)
{
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION) && vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
if (((Minion*)vehicle->GetBase())->GetOwner() == this)
vehicle->GetBase()->ToCreature()->DespawnOrUnsummon(1);
}

That is the part how vehicle comes in and despawn on seat changes or somethin other.
To Test it, i blocked the part of "vehicle->GetBase()->ToCreature()->DespawnOrUnsummon(1);" and the vehicle isn't despawn, the seat change with spell works.
Its need a reason to block this in case of seat change - but not on leave the vehicle or with a delay..

void Unit::_ExitVehicle(Position const* exitPosition)
{
    if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION) && vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
        if (((Minion*)vehicle->GetBase())->GetOwner() == this)
            vehicle->GetBase()->ToCreature()->DespawnOrUnsummon(1);
}

(for readability, add MD code block with syntax highlighting)

<%jackpoz>I was wondering about https://github.com/TrinityCore/TrinityCore/issues/18089#issuecomment-750491012 if we should delay the unsummon of the vehicle long enough that it can be cancelled when changing seat
or if we should pass around a bool "changing seat"
<%Shauren> i'd do the bool

I look around about some videos with vehicles. And i found this: https://youtu.be/YtnXw3syMOs?t=38
here can you see that the vehicle move away after player is exit.
So its need a way to pass this part long enough if needed - not only at changing seat.

i look around my old old sniffs, this vehicle in the video above despawn ca. 22sec after player eject
edit: the vehicle move ~19sec without the player befor its despawned

I add a function: https://github.com/gonzo1247/TrinityCore/commit/3b4544edab64f33588bdc3828ce3848aa0084918
and with this changes you can change the seats without despawning the vehicle.
but missing is: if player exit and vehicle should still exist longer for other action

edit:
its add for master but i think is easy to port for 335
edit 2: idk where the timer for a longer despawn time is come. Some summons spells has a Duration how long the Summoned Vehicle is spawned but more has as Duration '-1'
here i think we need a other function to set/get a additionale despawn time - with 1 ms as default value.
and this must be add to SmartScript and other needed places.
If something like that okey or more a hack? I really have no idea how blizz is it do. in sniffs i can not found a special spell or other that controlled did - at the above video vehicle my only idea is, that they never despawn from default and first despawn if he reach the end of the waypoint

would it be possible to pass the bool variable as parameter around instead of having a state variable in Unit (that might get desynch'd with the ingame status) ?

mhm i can look that i changed it to a paramter of Unit::_ExitVehicle , _EnterVehicle and RemovePassenger
if it works i push it again

i hang on this part:
if (!(mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT)) caster->_ExitVehicle();
that is called while the controll_vehicle aura is removed - whats happend after "change" the old aura shall removed and than he kill the vehicle.
it's need to check if player/unit leave the vehicle final or "leave" only for change seat

With the hint from Shauren i look more and found an easyer way to handelt all this.
https://github.com/gonzo1247/TrinityCore/commit/7f5096472d344ce0c0ae92a6de9719b9242fd364
i add only one new line and remove the old stuff
if (!vehicle->GetBase()->HasAuraType(SPELL_AURA_CONTROL_VEHICLE))

Test and works:
Player can change seats on vehicle without despawn - testet with follow spells: 86683, 84224 and 52391
Player switch seats correctly and after all this player was ejected by 50630 and vehicle despawn.

next part would be the timed delay despawn if needed

Timed despawn is needed, you can see that reading up previous comments with examples.

@gonzo1247 can you PR the "don't despawn when switching seat" fix for now so we can merge that ? having small focused PRs increases the chance to getting them merged

@jackpoz first i will look for shauren's way to fix this(https://gist.github.com/Shauren/a5a7ebf7f0004ca1dbb8e0aac283bebb )
when all done i create a PR
even for the timed despawn

I think this issue can now be closed. Both parts are fixed, vehicle don't despawn at seat changes and is now possiblo to delay the despawn after exit from a vehicle

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Blasphemous picture Blasphemous  路  3Comments

cbcs picture cbcs  路  3Comments

Jonne733 picture Jonne733  路  3Comments

Jildor picture Jildor  路  3Comments

Teppic1 picture Teppic1  路  3Comments