• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] A System instead of IF-Else

Status
Not open for further replies.
Level 8
Joined
Mar 23, 2007
Messages
302
Hi,

hey there, i need some ideas/help solving this problem:

So we have a Unit called u
Red vaule called R
Green vaule called G
Blue vaule called B

6 Skills that are distributed like this

R rb B bg G gr


so when "u" gets a specific total number of (R+G+B)
the Triggers Check what is the biggest amount of it OR what 2 biggest amounts are.

if R dominates, then u Get the skill saved under R, easy so far.
All this is true for the other stuff. If B and G are equal (and the total numbers
are set to have a maximum of 2 equal vaults) the u get the abilit under "bg".

ok i did this and it works well.

Now i want to repeat this step.
The specific total number is now bigger.
there is no problem in check what amount and so on.
But problem is in Giving Abilities.
If this unit already has this ability, it would gain the next closest Ability


So
R rb B bg G gr

and if R is used alread but R vaule is still the biggest u get either "rb" or "gr"
-------------------------------------------------------------------------


sofar whats about, ok im about to do all this in If-Else statments,
but isnt there any other better solution?

I thought about 3 Arrays (bacause i want this step to be repeatet 2 times, so that a unit would could have any combination of 3 out of 6)
1 Array for every check, so if that array would have already a 1 somwhere
it couldnt be in the same position on the other arrays, but this would
again lead to a mass of If-Else.

ehm, mb its just late and i cant conzentrate.

Anyway, i say THX to all those that help me ;)

greets equal
 
Level 8
Joined
Mar 23, 2007
Messages
302
This doesnt help my much, i read a bit about them in internet and it seems like
its about cluster the tasks down to easier steps, But i have a
problem in imagine how to divide it down. However, thx for answer ^^ and here is what i have working right now:

CODE:
JASS:
function Trig_Get_Morphose_1_Actions takes nothing returns nothing
local unit u = GetKillingUnit()
local integer lvl = GetUnitAbilityLevel(u,'A00D')
local integer MAX
local integer DOUBLE 
local integer R = GetHandleInt(u,"minR")
local integer G = GetHandleInt(u,"minG")
local integer B = GetHandleInt(u,"minB")

if R+G+B == 5 or R+G+B == 20 or R+G+B == 54 then

if lvl == 1 then
set MAX = 3
elseif lvl == 2 then
set MAX = 8
else
set MAX = 19
endif
set DOUBLE = MAX-1

if R >= MAX then
if GetUnitAbilityLevel(u,'A005') == 1 then
if GetUnitAbilityLevel(u,'A004') == 1 then
call UnitAddAbility(u,'A002')
call UnitAddAbility(u,'A00A')
else
call UnitAddAbility(u,'A004')
call UnitAddAbility(u,'A008')
endif
else
call UnitAddAbility(u,'A005')
call UnitAddAbility(u,'A00B')
endif

elseif R >=DOUBLE and B >= DOUBLE then
if GetUnitAbilityLevel(u,'A004') == 1 then
if GetUnitAbilityLevel(u,'A000') == 1 then
call UnitAddAbility(u,'A005')
call UnitAddAbility(u,'A00B')
else
call UnitAddAbility(u,'A000')
call UnitAddAbility(u,'A007')
endif
else
call UnitAddAbility(u,'A004')
call UnitAddAbility(u,'A008')
endif

elseif B >= MAX then
if GetUnitAbilityLevel(u,'A000') == 1 then
if GetUnitAbilityLevel(u,'A001') == 1 then
call UnitAddAbility(u,'A004')
call UnitAddAbility(u,'A008')
else
call UnitAddAbility(u,'A001')
call UnitAddAbility(u,'A009')
endif
else
call UnitAddAbility(u,'A000')
call UnitAddAbility(u,'A007')
endif

elseif B >=DOUBLE and G >= DOUBLE then
if GetUnitAbilityLevel(u,'A001') == 1 then
if GetUnitAbilityLevel(u,'A003') == 1 then
call UnitAddAbility(u,'A000')
call UnitAddAbility(u,'A007')
else
call UnitAddAbility(u,'A003')
call UnitAddAbility(u,'A00C')
endif
else
call UnitAddAbility(u,'A001')
call UnitAddAbility(u,'A009')
endif

elseif B >=DOUBLE and G >= DOUBLE then
if GetUnitAbilityLevel(u,'A003') == 1 then
if GetUnitAbilityLevel(u,'A002') == 1 then
call UnitAddAbility(u,'A001')
call UnitAddAbility(u,'A009')
else
call UnitAddAbility(u,'A002')
call UnitAddAbility(u,'A00A')
endif
else
call UnitAddAbility(u,'A003')
call UnitAddAbility(u,'A00C')
endif

elseif G >= MAX then
if GetUnitAbilityLevel(u,'A002') == 1 then
if GetUnitAbilityLevel(u,'A005') == 1 then
call UnitAddAbility(u,'A003')
call UnitAddAbility(u,'A00C')
else
call UnitAddAbility(u,'A005')
call UnitAddAbility(u,'A00B')
endif
else
call UnitAddAbility(u,'A002')
call UnitAddAbility(u,'A00A')
endif

elseif G >=DOUBLE and R >= DOUBLE then
if GetUnitAbilityLevel(u,'A005') == 1 then
if GetUnitAbilityLevel(u,'A004') == 1 then
call UnitAddAbility(u,'A002')
call UnitAddAbility(u,'A00A')
else
call UnitAddAbility(u,'A004')
call UnitAddAbility(u,'A008')
endif
else
call UnitAddAbility(u,'A005')
call UnitAddAbility(u,'A00B')
endif
endif

call SetUnitAbilityLevel(u,'A00D',lvl+1)

endif
set u = null
endfunction

//===========================================================================
function InitTrig_Get_Morphose_1 takes nothing returns nothing
    set gg_trg_Get_Morphose_1 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Get_Morphose_1, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Get_Morphose_1, function Trig_Get_Morphose_1_Actions )
endfunction

This function is not always needed, after every player reached the 54 Mins, i will turn this trigger off.
 
Status
Not open for further replies.
Top