roaaaarrrr
New Member
- Reaction score
- 33
I'm trying to add a custom hero bounty to my map so that you get a different amount of gold depending on the level of the killed hero. I wanted to create an array so that the values can be completely customizable and don't have to follow a specific equation.
This is the basic idea of what I want to do, but I know I am doing it wrong...
This is the basic idea of what I want to do, but I know I am doing it wrong...
JASS:
globals
integer array HeroBounty
endglobals
function GetBountyAmount takes nothing returns nothing
set HeroBounty[1]=100
set HeroBounty[2]=125
set HeroBounty[3]=150
set HeroBounty[4]=175
set HeroBounty[5]=200
set HeroBounty[6]=225
set HeroBounty[7]=250
set HeroBounty[8]=275
set HeroBounty[9]=300
set HeroBounty[10]=325
set HeroBounty[11]=350
set HeroBounty[12]=375
set HeroBounty[13]=400
set HeroBounty[14]=425
set HeroBounty[15]=450
set HeroBounty[16]=500
set HeroBounty[17]=500
set HeroBounty[18]=500
endfunction
function Trig_Hero_Bounty_Conditions takes nothing returns boolean
if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == true ) ) then
return false
endif
return true
endfunction
function Trig_Hero_Bounty_Actions takes nothing returns nothing
local integer L
set L = GetHeroLevel(GetDyingUnit())
call AdjustPlayerStateBJ( GetBountyAmount(L)), GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
endfunction
//===========================================================================
function InitTrig_Hero_Bounty takes nothing returns nothing
set gg_trg_Hero_Bounty = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hero_Bounty, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Hero_Bounty, Condition( function Trig_Hero_Bounty_Conditions ) )
call TriggerAddAction( gg_trg_Hero_Bounty, function Trig_Hero_Bounty_Actions )
endfunction