• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Pick every "Whatever" help

Status
Not open for further replies.
Level 8
Joined
Mar 23, 2007
Messages
302
Hi ,
i wanted to do a spell that destroys all trees and all stones
(and if i get rid of this even more stuff), after that returning
a number of what (trees and stones)
and how many of that was destroyed. problem is to do this in LOCALS -.- .

JASS:
globals 
    integer udg_trees = 0
    integer udg_stones = 0
endglobals

function Trig_TerraGolem_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_TerraGolem_Func001Func001C takes nothing returns boolean
    return IsDestructableAliveBJ(GetEnumDestructable()) == true and GetDestructableTypeId(GetEnumDestructable()) == 'LTlt' 
endfunction

function Trig_TerraGolem_Func001Func002C takes nothing returns boolean
    return IsDestructableAliveBJ(GetEnumDestructable()) == true and GetDestructableTypeId(GetEnumDestructable()) == 'LTrc' 
endfunction

function Msg takes string s returns nothing
  call DisplayTextToForce ( GetPlayersAll (), s)
endfunction

function Trig_TerraGolem_Func001A takes nothing returns nothing
    if ( Trig_TerraGolem_Func001Func001C() ) then
        call KillDestructable( GetEnumDestructable() )
        set udg_trees = udg_trees+1
    elseif( Trig_TerraGolem_Func001Func002C() ) then
        call KillDestructable( GetEnumDestructable() )
        set udg_stones = udg_stones+1
    endif
endfunction

function Trig_TerraGolem_Actions takes nothing returns nothing
    call EnumDestructablesInCircleBJ( ( 700.00 + ( 30.00 * I2R(GetUnitAbilityLevelSwapped('A000', GetSpellAbilityUnit())) ) ), GetSpellTargetLoc(), function Trig_TerraGolem_Func001A )
    call Msg (I2S(udg_trees) + " trees and " + I2S(udg_stones) + " stones")
    set udg_trees = 0
    set udg_stones = 0
endfunction

yeah this works but is not realy MUI, what if 2 players do this at same time,

i tryed it to do in local form but then i just got like 30 messages , this looks like that:
1 trees and 0 stones
1 trees and 0 stones
1 trees and 0 stones
0 trees and 1 stones
1 trees and 0 stones
1 trees and 0 stones
....

Could pls some one be that helpfully to show me how
i can turn this into local form? :eekani:

i just dont get it how to combinate local form with "pick every" stuff...
(sry for gramatical misstakes)
 
Level 8
Joined
Mar 23, 2007
Messages
302
ofc but how? i need some one to help me out,
i can only get this with an example.

JASS:
function Trig_TerraGolem_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_TerraGolem_Func001Func001C takes nothing returns boolean
    return IsDestructableAliveBJ(GetEnumDestructable()) == true and GetDestructableTypeId(GetEnumDestructable()) == 'LTlt' 
endfunction

function Trig_TerraGolem_Func001Func002C takes nothing returns boolean
    return IsDestructableAliveBJ(GetEnumDestructable()) == true and GetDestructableTypeId(GetEnumDestructable()) == 'LTrc' 
endfunction

function Msg takes string s returns nothing
  call DisplayTextToForce ( GetPlayersAll (), s)
endfunction

function Trig_TerraGolem_Func001A takes nothing returns nothing
   local integer trees = 0
   local integer stones = 0

    if ( Trig_TerraGolem_Func001Func001C() ) then
        call KillDestructable( GetEnumDestructable() )
        set trees = trees+1
    elseif( Trig_TerraGolem_Func001Func002C() ) then
        call KillDestructable( GetEnumDestructable() )
        set stones = stones+1
    endif
    call Msg (I2S(trees) + " trees and " + I2S(stones) + " stones")
endfunction

function Trig_TerraGolem_Actions takes nothing returns nothing
    call EnumDestructablesInCircleBJ( ( 700.00 + ( 30.00 * I2R(GetUnitAbilityLevelSwapped('A000', GetSpellAbilityUnit())) ) ), GetSpellTargetLoc(), function Trig_TerraGolem_Func001A )
endfunction

and y i did it with GUI help, i do all my jass stuff with this;
making as far as possible with gui, Convert it to Jass,
use locals then clean up leaks , DONE.
whats wrong with that?

this is as far as i got but as already told i dont know how to fix it.
 
Level 11
Joined
Jun 13, 2007
Messages
570
there is no real point in taking a GUI trigger, hitting convert to jass, then leaving it as is

the first step should be to clean up the code to make it easier for others to read. Calling a function inside an if () then statment is pointless, just put the boolean statement inside the if: if (thisIsTrue == true) then

You also leak the Location of the target spell eevry time your function is fired. I havent used the EnumDestructbale much, but if that creates a group just like Unit Group and Player Group, that leaks memory as well

Back to your original problem though, use you global variables without any sort of array index, while the way JASS works though, it will keep firing code until it finishes the function, or hits a "wait" before moving to the next trigger in que, so technically it shouldn't be a problem, however it is best to make your trees/stones variables an array and use the player number of the triggering player to store their integers in
 
Level 8
Joined
Mar 23, 2007
Messages
302
1 of all , this is not a talk about look-how-i-use-jass -.-,
the only thing that i wanted is to know how to solve my
problem,

@Vexen.X : i dont htink i get what u mean , mh ...
u want me to still use globals but include arrays for specific players?
this could work but is still not 100% MUI

about the LEAK, all BJ funktions and the statment that i just leave it as it is:

man -.- i try to fix up the leak so good i can (after spell works usualy),
i will remove the BJ funktions and i do not just convert to TEXT
and leave it so >.< .oO(would be absolutly pointless)

i will go on with my work and guess i do it like let
the "GetEnumDestructable()" return a integer for trees and
another "GetEnumDestructable()" return a integer for stones.
 
Status
Not open for further replies.
Top