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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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