Custom Hero Bounty Problem

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...

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
 

Ice Snake

Cool Member
Reaction score
3
Yes, i think your map is Footy Frenzy, I love FF! <3

But you should put your code to JASS tag... :)
 

Embrace_It

New Member
Reaction score
9
Change your conditions to:

JASS:

function Trig_Hero_Bounty_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)
endfunction


Also, you can just set your element values in the InitTrig_Hero_Bounty function.

This is probably what you want in the actions:

JASS:

function GetBountyAmount takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + HeroBounty[GetHeroLevel(source) - 1])

    set source = null
    set owner = null
endfunction


Array elements start at index 0, not 1(that is why I subtract 1 from the killed hero's level in the actions) so change your array to:

JASS:

   set HeroBounty[0]=100
   set HeroBounty[1]=125
   set HeroBounty[2]=150
   set HeroBounty[3]=175
   set HeroBounty[4]=200
   set HeroBounty[5]=225
   set HeroBounty[6]=250
   set HeroBounty[7]=275
   set HeroBounty[8]=300
   set HeroBounty[9]=325
   set HeroBounty[10]=350
   set HeroBounty[11]=375
   set HeroBounty[12]=400
   set HeroBounty[13]=425
   set HeroBounty[14]=450
   set HeroBounty[15]=500
   set HeroBounty[16]=500
   set HeroBounty[17]=500


I dont have WC3 in front of me atm, so everything might not compile properly cos I cant remember the native calls :p Anyways, hope this helps.

PS: You could have this equation instead of the array (I know you want an array, I'm just saying :)):

JASS:

function GetHeroGoldBounty takes integer lvl returns real
    if lvl &gt; 16 then
        return 500.
    else
        return (lvl - 1) * BOUNTY_PER_LEVEL + STARTING_BOUNTY
    endif
endfunction


BOUNTY_PER_LEVEL = 25.
STARTING_BOUNTY = 125.
 

roaaaarrrr

New Member
Reaction score
33
Thanks for the help. I am no longer getting any compile errors, but for some reason it still isnt working. I kill the hero but still get the base hero amount (266 gold - the number from the object editor). Any ideas?

Here's the code (I added text-tags from Cohadar's tag system)

JASS:
globals
    integer array HeroBounty
endglobals

function GetBountyAmount takes nothing returns nothing
    set HeroBounty[0]=100
   set HeroBounty[1]=125
   set HeroBounty[2]=150
   set HeroBounty[3]=175
   set HeroBounty[4]=200
   set HeroBounty[5]=225
   set HeroBounty[6]=250
   set HeroBounty[7]=275
   set HeroBounty[8]=300
   set HeroBounty[9]=325
   set HeroBounty[10]=350
   set HeroBounty[11]=375
   set HeroBounty[12]=400
   set HeroBounty[13]=425
   set HeroBounty[14]=450
   set HeroBounty[15]=500
   set HeroBounty[16]=500
   set HeroBounty[17]=500
   set HeroBounty[18]=500
   set HeroBounty[19]=500
   set HeroBounty[20]=500
endfunction

function Trig_Hero_Bounty_Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)
endfunction
 

function Trig_Hero_Bounty_Actions takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + HeroBounty[GetHeroLevel(source) - 1])
    call TextTag_GoldBounty(source,&quot;+&quot;+I2S(R2I(HeroBounty[GetHeroLevel(source) - 1])) ,owner)
    set source = null
    set owner = null
endfunction

//===========================================================================
function InitTrig_Hero_Bounty takes nothing returns nothing
    set gg_trg_Hero_Bounty = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hero_Bounty, function Trig_Hero_Bounty_Actions )
endfunction
 

saw792

Is known to say things. That is all.
Reaction score
280
You have no event any more. You need that TriggerRegisterAnyUnitEventBJ(...) line for the actions to run.
 

roaaaarrrr

New Member
Reaction score
33
lol oops. Not sure how that got deleted. Now its working, except it gives me 0 gold and Im not sure why.
 

Embrace_It

New Member
Reaction score
9
Quoting myself...

Also, you can just set your element values in the InitTrig_Hero_Bounty function.

The function GetBountyAmount is never called, and thus your array does not contain the proper values (apart for some trash prolly). Set the array values in the InitTrig_Hero_Bounty, and change GetBountyAmount to:

JASS:

function GetBountyAmount takes integer lvl returns integer
   return HeroBounty[lvl]
endfunction


and the gold giving + texttag to:

JASS:

call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + GetBountyAmount(GetHeroLevel(source) - 1))
    call TextTag_GoldBounty(source,&quot;+&quot;+I2S(R2I(GetBountyAmount(GetHeroLevel(source) - 1)) ,owner)
 

millz-

New Member
Reaction score
25
JASS:

function Trig_Hero_Bounty_Actions takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + HeroBounty[GetHeroLevel(source) - 1])
    call TextTag_GoldBounty(source,&quot;+&quot;+I2S(R2I(HeroBounty[GetHeroLevel(source) - 1])) ,owner)
    set source = null
    set owner = null
endfunction
to
JASS:

function Trig_Hero_Bounty_Actions takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local player owner = GetOwningPlayer(GetKillingUnit())
    local integer Bounty = (GetHeroLevel(source)-1) * 25 + 100

    if Bounty &gt; 500 then
        set Bounty = 500
    endif

    call SetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(owner, PLAYER_STATE_RESOURCE_GOLD) + Bounty)
    call TextTag_GoldBounty(source,&quot;+&quot;+I2S(Bounty),owner)
    set source = null
    set owner = null
endfunction


And you wouldn't need that wall of variables.
 

roaaaarrrr

New Member
Reaction score
33
Yeah, those numbers are just examples. I wanted an array so I can customize each value independently.
 

millz-

New Member
Reaction score
25
There is definitely a way to set the equation. Unless your bounty amount are all jumbled up e.g.: lvl 1 100 gold lvl 2 300 gold lvl 3 50 gold, which doesn't really makes sense?
It's just a suggestion, but I think your trigger is already working the way you want it, so ignore this.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top