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. :)
 
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
 
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
 
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...
 
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.
 
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.
 
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
 
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
 
There's no triggering unit for a chat event. Why did you think there would be? What unit were you assuming that would be?
 
(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.
 
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
 
(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.
 
*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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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