Saturday, April 21, 2012

JASS triger does not work

Hello there,

I want a respawn system for units, and when they die that a same type of unit comes in it's place.

Now, I made this trigger in GUI, converted it in JASS and changed some things (My first attempt at JASS).

But when I try the trigger, it did not work, but neither did it give any errors.

Here is the code:


Code:
function Trig_CreepLevel1_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'h00G' ) ) then
return false
endif
return true
endfunction

function Trig_CreepLevel1_Actions takes nothing returns nothing
local unit i = GetTriggerUnit()
local location 1 = GetUnitLoc( i )
call UnitSuspendDecayBJ( true, i )
call TriggerSleepAction( 35.00 )
call CreateNUnitsAtLocFacingLocBJ( 1, 'h00G', Player(PLAYER_NEUTRAL_AGGRESSIVE), 1, 1)
call RemoveLocation( 1 )
call RemoveUnit( i )
endfunction

//===========================================================================
function InitTrig_CreepLevel1 takes nothing returns nothing
set gg_trg_CreepLevel1 = CreateTrigger( )
call DisableTrigger( gg_trg_CreepLevel1 )
call TriggerRegisterPlayerUnitEventSimple( gg_trg_CreepLevel1, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_CreepLevel1, Condition( function Trig_CreepLevel1_Conditions ) )
call TriggerAddAction( gg_trg_CreepLevel1, function Trig_CreepLevel1_Actions )
endfunction

As always, thank you for your time.

EDIT: I also would like to know how to set a Real to null, because if I do: set RealVariableName = null

I get an error stating type mismatch assignment.|||Code:
    local location 1 = GetUnitLoc( i )

You can't use a number as a variable name in the global variable editor and I think that also holds true for JASS (although I could be wrong).


Quote:






View Post

I also would like to know how to set a Real to null, because if I do: set RealVariableName = null

I get an error stating type mismatch assignment.




Why would you even attempt to set a real to null? If anything, set it to 0. But there's no point in trying to clear the value of reals, they aren't objects and they don't leak.|||Ah I see, then is this trigger cleared of all leaks? If not, which ones and how to fix them?


Code:
function Trig_Unit_Revive_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'n001' ) ) then
return false
endif
return true
endfunction

function Trig_Unit_Revive_Actions takes nothing returns nothing
local real realX = GetUnitX(GetTriggerUnit())
local real realY = GetUnitY(GetTriggerUnit())
local real facePoint = GetUnitFacing(GetTriggerUnit())
local unit i = GetTriggerUnit()
call TriggerSleepAction( 35.00 )
call CreateUnit(GetOwningPlayer(GetTriggerUnit()), 'n001', realX, realY, facePoint)
call RemoveUnit( i )
endfunction



//===========================================================================
function InitTrig_CreepReviveLevel1 takes nothing returns nothing
set gg_trg_CreepReviveLevel1 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CreepReviveLevel1, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_CreepReviveLevel1, Condition( function Trig_Unit_Revive_Conditions ) )
call TriggerAddAction( gg_trg_CreepReviveLevel1, function Trig_Unit_Revive_Actions )
endfunction

And again, thank you for your time.|||Well, you should probably set the local unit variable to 'null' before you remove it, but otherwise, you aren't even generating any leaks.

No comments:

Post a Comment