• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] I'm new to JASS and have a problem with a trigger

Status
Not open for further replies.
Level 1
Joined
Sep 16, 2008
Messages
2
Hi Guys,

I have problems with my first self wirtten JASS trigger. The trigger is supposed to spawn an unit for each player (it's a very basic trigger so I assume that my map is only played by 6 persons) and then add an special effect to the unit. This should happen at map initialisation.

Used Globals:
udg_Quest1Unit
udg_Quest1Gebiet

so here's my code

JASS:
function Trig_CreateHero1_Actions takes nothing returns nothing
    local integer p =0
    local unit array a

        loop
            exitwhen (p > 5)
            
                call CreateNUnitsAtLoc (1, udg_Quest1Unit, ConvertedPlayer(p), GetRandomLocInRect(udg_Quest1Gebiet), bj_UNIT_FACING )                
                set a =GetLastCreatedUnit()
                call AddSpecialEffectTargetUnitBJ( "hand, right", a, "war3mapImported\\Odd Sword.mdx" )
                call SelectUnitForPlayerSingle( a, ConvertedPlayer(p) )
                set p =p+1
        endloop 

endfunction

//==== Init Trigger CreateHero1 ====
function InitTrig_CreateHero1 takes nothing returns nothing
    set gg_trg_CreateHero1 = CreateTrigger()
    //call TriggerRegister__(gg_trg_CreateHero1, )
    call TriggerAddAction(gg_trg_CreateHero1, function Trig_CreateHero1_Actions)
endfunction

It does not cause the game to crash but if I start the game the trigger does simply nothing.
I have spent more than two hours to make it work but I can't figure out what's wrong.
Can someone help me please?
Thanks in advance.
 
Last edited:
Level 3
Joined
Mar 25, 2009
Messages
32
You dont need to call it just set it
JASS:
set a = CreateNUnitAtLoc(1,'h000',which player,loc,real face)
make sure quest unit is in rawcode. Avoid using bj's thing cause they are slow. You can use this
JASS:
 CreateUnitAtLoc(player id, unit id, loc, real face)
to replace CreateNUnitAtLoc. Read tutorial for that.
 
Level 3
Joined
Mar 25, 2009
Messages
32
Why use a variable for a unit type?.

What i mean is, if he want to use globals outside jass function. So he needs to create variable Quest1Unit - unit type. Example:
  • Set Quest1Unit = Peasant
so in jass
JASS:
set udg_Quest1Unit = 'hpea'
 
Level 1
Joined
Sep 16, 2008
Messages
2
I've overworked my old trigger to this version and ticked the box 'Run on Map Initialization'.
JASS:
function Trig_CreateHero1_Actions takes nothing returns nothing
    local integer p =0
    local unit array a

        loop
            exitwhen (p > 5)
                            
                set a = CreateUnitAtLoc (Player (p), 'H000', GetRandomLocInRect(gg_rct_000Start) , 0)
                call AddSpecialEffectTargetUnitBJ( "hand, right", a, "war3mapImported\\Odd Sword.mdx" )
                call SelectUnitForPlayerSingle( a, ConvertedPlayer(p) )
                set p =p+1
        endloop 

endfunction

//==== Init Trigger CreateHero1 ====
function InitTrig_CreateHero1 takes nothing returns nothing
    set gg_trg_CreateHero1 = CreateTrigger()
    //call TriggerRegister__(gg_trg_CreateHero1, )
    call TriggerAddAction(gg_trg_CreateHero1, function Trig_CreateHero1_Actions)
endfunction

But now my game gets an critical error when I test the map.
 
Level 3
Joined
Mar 25, 2009
Messages
32
I don't know if you using jass or vjass. Here the example:
 
Last edited:
Status
Not open for further replies.
Top