1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Unit Created Event [snippet for mod makers] 2016-10-05

Unit Created Event [snippet for mod makers]

  1. Machiavelli24
    This mod contains code that defines a lua event that fires off when a unit is created. The event does not fire when a unit is upgraded. The lua event provides the information you need to get the owning player object and the unit object.

    If you want to delete the unit don't use "unit:Kill()" as that could cause other code hooked into this event to crash. Instead use "unit:SetHasPromotion(GameInfoTypes["PROMOTION_UCE_MARKED_FOR_DEATH"], true)". The UCE stands for Unit created event. Units with that promotion will automatically be killed after all functions hooked into the event are executed.

    If an end-user is playing with multiple mods that use this snippet it will work properly.

    IMPORTANT: Because this snippet adds a promotion users of any mod that incorporates this snippet will need to "enable->back->re-enable" your mod for to avoid the flaw in Fraxis's design for UnitPanel. If they don't do this all their units will be killed when they start or load a game (along with general rending issues for the UnitPanel).

    More information at the discussion thread.


    1. unitcreatedevent_6Y6.jpg