• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] a would-be simple jass trig, but war3 editor wont accept it!

Status
Not open for further replies.
Level 2
Joined
Nov 3, 2006
Messages
8
This is my trigger, its ment to revive creeps after a certain amount of time, but still allow the corpses to be exploded, raised, what ever. GUI cant handle it so i tried this, but wce bites!

JASS:
function jassreviveconds takes nothing returns boolean
    if (not(GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
        return false
    endif
    return true
endfunction

function jassreviveact takes nothing returns nothing
  local unit res = GetTriggerUnit()
    call CreateNUnitsAtLoc( 1 , GetUnitTypeId(GetTriggerUnit()), Player(PLAYER_NEUTRAL_AGGRESSIVE), GetUnitX( res ), GetUnitY( res ) , bj_UNIT_FACING )
    set res = null
endfunction

//====================================
function gg_trg_jassrevive takes nothing returns nothing
     call gg_trg_jassrevive (CreateTrigger(  ))
     call TriggerRegisterUnitEvent ( gg_trg_jassrevive , EVENT_PLAYER_UNIT_DEATH ) // this has "invalid number of arguments"
     call TriggerAddCondition ( gg_trg_jassrevive, Condition( function jassreviveconds ) ) // this has " expected '(' "
     call TriggerAddAction ( gg_trg_jassrevive, function jassreviveact ) // this also wants the '('
endfunction
 
Level 5
Joined
May 22, 2006
Messages
150
Looks converted... Partly at last.

...
Hell, where did you get this from!?
No wonder, why the compiler did not want it:
It cannot work as "CreateNUnitsAtLoc" requires a location object, not two real primitives.
It cannot work, as "gg_trg_jassrevive" is a variable, no function and thus cannot be called.
It cannot work as "TriggerRegisterPlayerUnitEvent" takes a player object on call.
It cannot work as a function of name "InitTrig_<name of trigger>" has to exist, which is auto-called on map initialisation.

I did not seek for more mistakes, just rewrote the whole thing:

JASS:
function jassreviveact takes nothing returns nothing
  local unit res = GetTriggerUnit()
  call TriggerSleepAction(1.74)
  call CreateUnit(Player(12),GetUnitTypeId(res),GetUnitX(res),GetUnitY(res),0)
  set res = null
endfunction

function InitTrig_Jassrevive takes nothing returns nothing
  set gg_trg_Jassrevive = CreateTrigger()
  call TriggerRegisterPlayerUnitEvent(gg_trg_Jassrevive,Player(12),EVENT_PLAYER_UNIT_DEATH,null)
  call TriggerAddAction(gg_trg_Jassrevive,function jassreviveact)
endfunction
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
<<Kicks in the condition so that you write them well in the future>>

Well, in this case, you dont need a condition, cuz only Neutral Aggressive can trigger it in the first place, but when youre writing your conditions, instead of the crappy GUI way

JASS:
function jassreviveconds takes nothing returns boolean
if (not(GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) ) ) then
return false
endif
return true
endfunction

write it the JASS way.

JASS:
function jassreviveconds takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE)
endfunction

PS. i hate how firefox doesnt get linebreaks while copying from this site :?
 
Level 2
Joined
Nov 3, 2006
Messages
8
Sweet!

Thanks very much you two, iv been struggling with that trigger for like a week! ima go test that right away :D
once more, THANKS!

--RE-edit--
man im a newb >.> i just figured out what was wrong with MY trigger lol.. either way, yours is far more efficient, Thanks some more lol
 
Status
Not open for further replies.
Top