JASS functions

Lightstalker

New Member
Reaction score
55
I converted a few triggers from GUI to JASS and now I am rewriting them in vJASS, except I don't know what to fill in for some of the natives.

1) BJ:


Native (according to jasshelper):
JASS:
if p != p then
                    return
                endif


How does that tell WC3 to ally the players :confused:

2) BJ:


Native (for IntegerTertiaryOp):
JASS:
if flag then
        return valueA
    else
        return valueB
    endif


How does that work?

3) BJ:
JASS:
call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", GetSoldUnit() )


Native:
JASS:
call IssueTargetOrder(dummy, "thunderbolt", targetWidget)


In the native, what am I supposed to fill in for ``targetWidget``?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
I dunno what's wrong with JassHelper here... Look it up on wc3jass.com: http://wc3jass.com/viewtopic.php?t=792#setplayeralliancestatebj

That looks like a BJ you might want to leave in! :eek:

Native (for IntegerTertiaryOp):
JASS:
if flag then
        return valueA
    else
        return valueB
    endif


How does that work?
You have to pay attention to the arguments it takes: http://wc3jass.com/viewtopic.php?t=357#integertertiaryop

Pretty much, you give it two values and a flag, and if it's true it returns the first value, and if false it returns the second value.

3) BJ:
JASS:
call IssueTargetOrderBJ( GetLastCreatedUnit(), "thunderbolt", GetSoldUnit() )


Native:
JASS:
call IssueTargetOrder(dummy, "thunderbolt", targetWidget)


In the native, what am I supposed to fill in for ``targetWidget``?
Again, just pay attention to the arguments: http://wc3jass.com/viewtopic.php?t=1005#issuetargetorderbj

So to convert the BJ, whichUnit is GetLastCreatedUnit(), order is "thunderbolt", and targetWidget is GetSoldUnit().
 

Zaraf

New Member
Reaction score
22


Since it's clear that you're using Alliance Allied (and assuming you're not going to change that, you might as well just do this to get rid of the BJ:

JASS:
call SetPlayerAllianceStateAllyBJ(        sourcePlayer, otherPlayer, true  )
call SetPlayerAllianceStateVisionBJ(      sourcePlayer, otherPlayer, false )
call SetPlayerAllianceStateControlBJ(     sourcePlayer, otherPlayer, false )
call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false )


Now in your case, you want to do something like this:

JASS:
local integer i = 0
local integer Target = 5

loop
    exitwhen i > 11
    if Player(i) != Player(Target) then
        call SetPlayerAllianceStateAllyBJ(        Player(i), Player(Target), true  )
        call SetPlayerAllianceStateVisionBJ(      Player(i), Player(Target), false )
        call SetPlayerAllianceStateControlBJ(     Player(i), Player(Target), false )
        call SetPlayerAllianceStateFullControlBJ( Player(i), Player(Target), false )
    endif
    set i = i + 1
endloop


The if statement there is meant to prevent these actions from happening to the source player. You can adjust the "exitwhen" condition to whatever number you need for however many players you want this to cycle through. Or give it a different initial value to change the starting point.

Weep has sufficiently answered the other two questions.
 

Zaraf

New Member
Reaction score
22
return can't work with if, it works with function

For e.g.

JASS:
function HELLO takes nothing returns boolean
    return true
endfunction

function WASSUP takes nothing returns real
    return 100.00 * 200.00
endfunction

Actually a return like that DOES work, and what it does is stops the function right there. You can even use it if the function returns nothing, since you aren't specifying a variable type to return.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Returning ends the function. It is actually useful even in functions that return nothing. Return works with if's, go convert a gui condition...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top