Some JASS tips needed, thanks!

duckne55

New Member
Reaction score
2
1. How do i cast a negative spell on my hero with a text command? (i only need one spell, its polymorph if its of any importance)
2. How do i limit the number of heroes i can have? (eg, set max 1 per game) <- probably not jass, but i still wish to know
3. How can i prevent enemy units from entering a warp gate?
4. How do i remove all the gold from every player after 30s of game start?

Help is appreiciated. if i had violated any rules or if you need more details or any thing please notify me, i will try my best to help you help me, thanks again. :)
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
You're obviously new to JASS. My advice for a beginner (i do this myself) is to create a trigger in GUI that does what you want it to, then convert it to custom text, and find out which functions cause what you want to happen to happen.

1. Look for the "Issue order targeting a unit" GUI action
2. There is an action in GUI that can do it, or can set maximum heroes by modifiying the game constants
3. Try creating a custom warp gate ability, and change the targets allowed to 'friend'
4.
Trigger:
  • Events
    • Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Pick every player in (All players) and do multiple actions:
        • Set (Picked Player) current gold = 0
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
GUI is simple enough, try opening up the scenario maps that come with the game (found in Frozen Throne/Scenario, if u don't know) and see how their triggers work.

Glad I could help :D
 

duckne55

New Member
Reaction score
2
EDIT: nvm solved it lol.
EDIT2:
JASS:
function Trig_Unstuck2_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, &#039;h00z&#039;, GetEnumPlayer(), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
    call IssueTargetOrder( GetTriggerUnit(), &quot;slow&quot;, GetEnumUnit() )
endfunction

//===========================================================================
function InitTrig_Unstuck2 takes nothing returns nothing
    set gg_trg_Unstuck2 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Unstuck2, Player(0), &quot;-unstuck2&quot;, true )
    call TriggerAddAction( gg_trg_Unstuck2, function Trig_Unstuck2_Actions )
endfunction

how do i get it to cast polymorph? (say, spell id is A000)
i know its casting slow now...
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
Well, I jumped into vJASS without very much GUI knowledge. Only thing I don't fully understand is structs (which I can use, somewhat) /offtopic
And I think Sgqvur answered the question.
In case you didn't see it, I believe it was this:

the Call needs to be call.
So it would look like

But then again, I kinda skimmed it, so meh.
 

duckne55

New Member
Reaction score
2
ahem, this one, i fixed the previous one.

EDIT: nvm solved it lol.
EDIT2:
JASS:
function Trig_Unstuck2_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, &#039;h00z&#039;, GetEnumPlayer(), GetUnitLoc(GetEnumUnit()), bj_UNIT_FACING )
    call IssueTargetOrder( GetTriggerUnit(), &quot;slow&quot;, GetEnumUnit() )
endfunction

//===========================================================================
function InitTrig_Unstuck2 takes nothing returns nothing
    set gg_trg_Unstuck2 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Unstuck2, Player(0), &quot;-unstuck2&quot;, true )
    call TriggerAddAction( gg_trg_Unstuck2, function Trig_Unstuck2_Actions )
endfunction

how do i get it to cast polymorph? (say, spell id is A000)
i know its casting slow now...
and yes im using newgen, and yes im avoiding the hassle of learning both GUI and JASS when i could just learn one.
 

Viikuna

No Marlo no game.
Reaction score
265
NewGen has a pretty good function list, so you can search for functions you need.

Also, you should probably use it to check what this function does:



When you do this, you see that it does loads of useless stuff, you dont really wanna do. The only thing you need is function CreateUnit.

You should probably find some tutorial about local variables and basic Jass stuff, such as loops and if/then/elseif/else.

For example, creating a dummy caster to cast slow, when some unit triggers some trigger:

JASS:


function Slow_Actions takes nothing returns nothing
    local unit u=GetTriggerUnit()

    // wc3 uses these x and y coordinates for telling          
    // where stuff is in the map.

    local real x=GetUnitX(u)  // GUI works with locations ( aka points ). 
    local real y=GetUnitY(u) // so if we did GUI, we would have here Location(x,y)

    local unit dummy=CreateUnit(Player(13),&#039;dumy&#039;,x,y,0)
    call IssueTargetOrder(dummy,&quot;slow&quot;,u)
   
    set u=null
    set dummy=null

endfunction
 

duckne55

New Member
Reaction score
2
bump,
JASS:
function GetHp takes nothing returns nothing
    local unit u = GetTriggerUnit ()
    local real hp = GetUnitState (u, UNIT_STATE_LIFE)
    call DisplayTextToPlayer (GetLocalPlayer(),0,0,&quot; + R2S(hp) + &quot;)
endfunction

function Chat_GetHp takes nothing returns nothing
    local integer i=0
    set gg_trg_GetHp = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerChatEvent( gg_trg_GetHp, Player(i), &quot;-hp&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_GetHp, function GetHp )
endfunction

how about this? (player types -hp, gets hp of selected unit)

also, the polymorph spell didn't work
JASS:
function Sheepify takes nothing returns nothing
    local unit u=GetTriggerUnit()
    local real x=GetUnitX(u)
    local real y=GetUnitY(u)
    local unit dummy=CreateUnit(Player(13),&#039;h00z&#039;,x,y,0) // dummy unit
    call IssueTargetOrderById(dummy,&#039;A08X&#039;,u) // polymorph spell
    call RemoveUnit (dummy)
    set dummy=null
    set u=null
endfunction

function Chat_Sheepify takes nothing returns nothing
    local integer i=0
    set gg_trg_Sheepify = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerChatEvent( gg_trg_Sheepify, Player(i), &quot;-sheepify&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_Sheepify, function Sheepify )
endfunction

help is appericiated :D
 

jwallstone

New Member
Reaction score
33
There's no triggering unit for a chat event. Why did you think there would be? What unit were you assuming that would be?
 

GetTriggerUnit-

DogEntrepreneur
Reaction score
129
(Triggering Unit) or GetTriggerUnit() always refer to the unit that act in the event.

i.e.
Trigger:
  • Unit - A unit start the effect of an ability

It will refer to the casting unit.

In the case of a chat event, there's no unit acting in the event. You can't use (Triggering Unit) or GetTriggerUnit()

However you can use GetTriggeringPlayer() for an event where a player acts in.
 

duckne55

New Member
Reaction score
2
hmm ok, how about:
JASS:
function GetHp takes nothing returns nothing   
    local real hp = GetUnitState ((GetPlayerId(GetTriggerPlayer())), UNIT_STATE_LIFE)
    call DisplayTextToPlayer (GetLocalPlayer(),0,0,10.00,&quot; + R2S(hp) + &quot;)
endfunction

function Chat_GetHp takes nothing returns nothing
    local integer i=0
    set gg_trg_GetHp = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerChatEvent( gg_trg_GetHp, Player(i), &quot;-hp&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_GetHp, function GetHp )
endfunction

but wouldn't it work for only the player? or will it be for the unit the player selects?

this one should work too now right?
JASS:
function Sheepify takes nothing returns nothing
    local real x=GetUnitX(u)
    local real y=GetUnitY(u)
    local unit dummy=CreateUnit(Player(13),&#039;h00z&#039;,x,y,0) // dummy unit
    call IssueTargetOrderById(dummy,&#039;A08X&#039;,((GetPlayerId(GetTriggerPlayer()))) // polymorph spell
    call RemoveUnit (dummy)
    set dummy=null
    set u=null
endfunction

function Chat_Sheepify takes nothing returns nothing
    local integer i=0
    set gg_trg_Sheepify = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerChatEvent( gg_trg_Sheepify, Player(i), &quot;-sheepify&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_Sheepify, function Sheepify )
endfunction
 

Viikuna

No Marlo no game.
Reaction score
265
(GetPlayerId(GetTriggerPlayer()) is an integer, not an unit.

If you want to get units selected by player, when player types something, you need to use other functions for that one.
 

duckne55

New Member
Reaction score
2
*crossfingers* do they work now?
JASS:
function Sheepify takes nothing returns nothing
    local unit u= GetTriggerUnit()
    local real x=GetUnitX(u)
    local real y=GetUnitY(u)
    local unit dummy=CreateUnit(Player(13),&#039;h00z&#039;,x,y,0) // dummy unit
    call IssueTargetOrderById(dummy,&#039;A08X&#039;,u) // Sheepify spell
    call RemoveUnit (dummy)
    set dummy=null
    set u=null
endfunction

function Chat_Sheepify takes nothing returns nothing
    local integer i=0
    set gg_trg_Unstuck2 = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerUnitEvent( gg_trg_Sheepify, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
        call TriggerRegisterPlayerChatEvent( gg_trg_Sheepify, Player(i), &quot;-Sheepify&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_Sheepify, function Sheepify )
endfunction

JASS:
function GetHp takes nothing returns nothing
    local unit u = GetTriggerUnit ()
    local real hp = GetUnitState (u, UNIT_STATE_LIFE)
    call DisplayTextToPlayer (GetLocalPlayer(),0,0,&quot; + R2S(hp) + &quot;)
endfunction

function Chat_GetHp takes nothing returns nothing
    local integer i=0
    set gg_trg_GetHp = CreateTrigger(  )
    loop
        exitwhen i&gt;11
        call TriggerRegisterPlayerUnitEvent( gg_trg_GetHp, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
        call TriggerRegisterPlayerChatEvent( gg_trg_GetHp, Player(i), &quot;-hp&quot;, true )
        set i=i+1
    endloop
    call TriggerAddAction( gg_trg_GetHp, function GetHp )
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top