BlackDragonN001 / FERemastered

11 stars 5 forks source link

Make evkami pilot die after ejecting #200

Closed Rhade1 closed 1 year ago

Rhade1 commented 1 year ago

Do not merge yet!

How this works: if a pilot is ejected, the event functions always trigger in this order: ObjectKilled(KilledVehicle) or PlayerEjected(KilledVehicle) -> AddObject(Pilot) -> DeleteObject(KilledVehicle) By setting a flag in ObjectKilled, it is possible to catch the handle of the pilot that is ejected out of it. This flag is cleared in AddObject, as the pilot is always forced to eject from the evkami, in this first version, at least. Otherwise clearing the flag has to be done in DeleteObject.

The pilot is killed by setting its lifespan to 1e-30, which kills it right after being ejected. (Unless somehow enters an empty vehicle right after ejecting) Another drawback is that the pilot is killed regardless of its CurHealth or MaxHealth.

In multiplayer, this also makes a player die twice (vehicle, pilot), which may need to be compensated somehow, as scores may be affected.

There are some issues, that has to be adressed, such as _FeCore.ObjectKilled or _FeCore.PlayerEjected not being called in mission scripts.

Events, that require return values in the mission script should call the helper functions in a similar way to this example:

function PlayerEjected(h)
    -- function body, if needed
    return _FeCore.PlayerEjected(h) or DoEjectRatio(h)
end

This is why _FeCore.PlayerEjected, and other helper functions except the last one should return nil, if they do nothing on the Handle.

Rhade1 commented 3 months ago

Still needs a better implementation and some fixes, but with the new patch, this idea may not work anymore. In that case, you should revert these changes.