I'm attempting to write a script in Jass (Preferably a single trigger). The script will activate every 4 levels, and display a dialog box. This Dialog box has three buttons, one for each stat, and when one is clicked that stat should increase by one.
Here is the code I have made so far.
Any help would be greatly appreciated.
Here is the code I have made so far.
JASS:
function Increase takes unit leveler, button Str, button Agi, button Int returns nothing
if (GetClickedButtonBJ == Str) then
call ModifyHeroStat( bj_HEROSTAT_STR, leveler, bj_MODIFYMETHOD_ADD, 1 )
endif
if (GetClickedButtonBJ == Agi) then
call ModifyHeroStat( bj_HEROSTAT_AGI, leveler, bj_MODIFYMETHOD_ADD, 1 )
endif
if (GetClickedButtonBJ == Int) then
call ModifyHeroStat( bj_HEROSTAT_INT, leveler, bj_MODIFYMETHOD_ADD, 1 )
endif
leveler = null
Str = null
Agi = null
Int = null
endfunction
function StatIncrease takes unit leveler returns nothing
local dialog Dialog
local button Strength
local button Agility
local button Intelligence
call DialogSetMessageBJ( Dialog, "Choose Which Stat to Increase" )
set Strength = call DialogAddButtonBJ( Dialog, "Strength" )
set Agility = call DialogAddButtonBJ( Dialog, "Agility" )
set Intelligence = call DialogAddButtonBJ( Dialog, "Intelligence" )
call DialogDisplayBJ( true, Dialog, GetOwningPlayer(leveler) )
//Function to detect which Button is pressed
call DialogClearBJ( Dialog )
call Increase( leveler, Strength, Agility, Intelligence)
Dialog = null
Strength = null
Agility = null
Intelligence = null
endfunction
function Trig_StatIncrease_Conditions takes nothing returns boolean
if ( not ( ModuloInteger(GetHeroLevel(GetTriggerUnit()), 4) == 0 ) ) then
return false
endif
return true
endfunction
function Trig_StatIncrease_Actions takes nothing returns nothing
local unit leveler
set leveler = GetLevelingUnit
call StatIncrease( leveler )
set leveler = null
endfunction
//===========================================================================
function InitTrig_StatIncrease takes nothing returns nothing
set gg_trg_StatIncrease = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_StatIncrease, EVENT_PLAYER_HERO_LEVEL )
call TriggerAddCondition( gg_trg_StatIncrease, Condition( function Trig_StatIncrease_Conditions ) )
call TriggerAddAction( gg_trg_StatIncrease, function Trig_StatIncrease_Actions )
endfunction
Any help would be greatly appreciated.