Custom Hero Bounty

roaaaarrrr

New Member
Reaction score
33
Trying to work the kinks out of my custom hero bounty. The trigger works just fine normally, but there are two heroes that I want to give more gold than everything else. The only function I could see that gets a hero id is IsHeroUnitID. But that doesn't seem to be doing what I need it to.

JASS:



function Trig_Hero_Bounty_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitEnemy(GetTriggerUnit(), GetOwningPlayer(GetKillingUnit())) 
endfunction



function Trig_Hero_Bounty_Actions takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())
    local integer Bounty
    if IsHeroUnitId('N00O')==true then
        set Bounty = (GetHeroLevel(source)-1) * 25 + 300
    elseif IsHeroUnitId('H01D')==true then
        set Bounty = (GetHeroLevel(source)-1) * 25 + 300
    else
        set Bounty = (GetHeroLevel(source)-1) * 25 + 100
    endif

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + Bounty)
    call TextTag_GoldBounty(source,"+"+I2S(Bounty),owner)
    set source = null
    set owner = null
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


I tested it on level 21 heroes, and it gives me 725 gold no matter what the hero is. If anyone has any ideas I'd appreciate it!!
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Just a note, this should be in the "Jass Help" section...

Anyways, the native you're looking for there is [ljass]GetUnitTypeId(whichUnit)[/ljass] ;)

So it'll look something like this:
JASS:
function Trig_Hero_Bounty_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) and IsUnitEnemy(GetTriggerUnit(), GetOwningPlayer(GetKillingUnit())) 
endfunction


function Trig_Hero_Bounty_Actions takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())
    local integer Bounty
    if GetUnitTypeId(source)=='N00O' or GetUnitTypeId(source)=='H01D' then
        set Bounty = (GetHeroLevel(source)-1) * 25 + 300
    else
        set Bounty = (GetHeroLevel(source)-1) * 25 + 100
    endif

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + Bounty)
    call TextTag_GoldBounty(source,"+"+I2S(Bounty),owner)
    set source = null
    set owner = null
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


There you go :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top