| 05-29-2004, 03:09 AM | #1 |
I have had much difficulty with the following trigger. It does not seem to run. Code:
function Conditio takes nothing returns boolean
if ( not ( UnitHasBuffBJ(GetDyingUnit(), udg_CoSBuff) == true ) ) then
return false
endif
return true
endfunction
function BANG takes nothing returns nothing
local location temploc = GetUnitLoc(GetDyingUnit())
local unit locative = null
call DisplayTextToForce( GetPlayersAll(), "Doom!" )
call RemoveUnit( GetDyingUnit() )
call CreateNUnitsAtLoc( 1, udg_CoSCorpseBomb, Player(PLAYER_NEUTRAL_AGGRESSIVE), temploc, bj_UNIT_FACING )
set locative = GetLastCreatedUnit()
call TriggerSleepAction (1.00)
call AddSpecialEffectLocBJ( udg_temploc, "Objects\\Spawnmodels\\Undead\\UndeadLargeDeathExplode\\UndeadLargeDeathExplode.mdl" )
call RemoveLocation(temploc)
call KillUnit( locative )
set locative = null
endfunction
//===========================================================================
function InitTrig_CorpseExplosion takes nothing returns nothing
set gg_trg_CorpseExplosion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CorpseExplosion, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_CorpseExplosion, Condition( function Conditio ) )
call TriggerAddAction( gg_trg_CorpseExplosion, function BANG )
endfunctionOr, the GUI-ized version: Code:
Events: A unit dies Conditions: Dying unit has buff CoSBuff equal to true Actions: Create a local point variable named temploc and set it to (Unit Location of (Dying Unit)) Create a local unit variable named locative and set it to No Unit Game - Display text message Doom! Remove Dying unit from the game Create 1 CoSCorpseBomb at temploc for Neutral Hostile set locative equal to Last Created Unit Wait 1 second Create a special effect using Undead Large Death Explode at temploc Remove location temploc from the game Kill locative Set locative equal to No Unit The global variables CoSCorpseBomb is a unit type set earlier and the CoSBuff is a buff type set earlier. For those who question the local variables part or the remove location, they are Jass only functions and do not exist in GUI so I made up a represenatation of them. Remve location removes a location and reduces memory leak. Local variables are special variables that are created within a function and only exist inside that function. |
| 05-29-2004, 03:28 AM | #2 |
It might not count most buffs after the units dead, otherwise I dont see any problems with the trigger. You know you can copy the GUI version directly as well. Just right click on the triggers name in the World Editor(in the area where the actions go, not the trigger list) and select "Copy As Text". Then you can paste it straight into a post. Also you dont have to set the unit variable to null at the start. If theres a local variable you want to use later in the trigger just call it like Code:
local unit locative |
| 05-29-2004, 03:31 AM | #3 |
You might be right about the buff after death. I'll have to check into that. Also, the trigger was in Jass, so I had to hand write it in a more GUI-like way. |
| 05-29-2004, 03:19 PM | #4 |
As a general rule you NEVER want to use unitialized variables. Its accepted because of the GUI trick but really shouldn't. Shimrra, buffs exist the instant (a timer of 0.15 after everything on him is gone) the unit is dead, However, the event may fire only after the game flags him as dead, not when his HP reaches 0 (his actual death). |
| 05-29-2004, 04:41 PM | #5 |
When a unit dies, it loses all the buffs, I can confirm that, so you need a A unit's life becomes less than or equal to 0 event for that |
| 05-29-2004, 07:36 PM | #6 | |
Quote:
|
