Bounty System

farold

New Member
Reaction score
3
I have never seen something like that nor in Hive or TheHelper and Wc3campaigns isn't working for me. So, I request a bounty system which give gold to player depending on how much they damaged the unit let say... A soldier gives 40-48 gold. A player damaged him for 50% of his life, another damaged him for 20% and creeps damaged him for 30%. So, the first player will get 50% of 43 (random number rolled betwenn min. and max. bounty) the second 20% of it while the A.I team (that own the creeps) will get 30%.
I also want to improves that with abilities/items that can increases bounty as well creeps don't give bounty if denied (Killed by enemies)
 

mapguy

New Member
Reaction score
46
When a unit takes damage you store that damage in a real that is attached to that unit.
each unit has to have 6 reals attached (1 for each player (6 players))
when the unit dies you split gold based on:
(gold) / (damage dealed by unit / total damage dealed to unit)
also create a trigger that reduces this reals values by 10% every 1.00 second.

unit takes damage

IF owner of damage source equal to player 1
set realdamage1[custom value of triggering unit] = damage taken + realdamage1[custom value of triggering unit]
IF owner of damage source euqla to player 2
set realdamage2[custom value of triggering unit] = damage taken + realdamage2[custom value of triggering unit]
and so on
important, each unit in your map have to have an unique custom value that never changes.
 

Ayanami

칼리
Reaction score
288
When a unit takes damage you store that damage in a real that is attached to that unit.
each unit has to have 6 reals attached (1 for each player (6 players))
when the unit dies you split gold based on:
(gold) / (damage dealed by unit / total damage dealed to unit)
also create a trigger that reduces this reals values by 10% every 1.00 second.


important, each unit in your map have to have an unique custom value that never changes.

Why use custom value when you can use hashtables? Custom values are limited and you have to set a unique number of each unit. However, hashtable makes use of the unit handle, which is a unique integer that every unit has, which is of course different for every single unit. First of all, you'll need to give bounty by triggers, and not default Warcraft 3 Bounty system. Here's the basic bounty giving action.

Trigger:
  • Actions
    • Player - Add 500 to Player 1 (Red) Current gold


You can add floating text to display the golden +xx if you want. So that's the basics of the basics. Moving on, now you need to detect the damage dealt. You can use Weep's GUI Friendly Damage Snippet (GDD) for damage detection. It's simple, efficient, GUI-Friendly and it really works. So get it. Now you'll need hashtable, so create a variable called "Hashtable" and set it in map initialization.

Trigger:
  • Initialize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)


Now, you need to set the bounty to each specific unit types. You'll have to specifically check which unit-type it is and set the bounty in this trigger.

Trigger:
  • Set Bounty
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman
        • Then - Actions
          • Set TempInt = (Random integer number between 40 and 50) <-- Set bounty here
          • Custom script: call SaveInteger(udg_Hashtable, GetHandleId(GetTriggerUnit()), StringHash("bounty"), udg_TempInt)
        • Else - Actions


After that's done, use this trigger. You'll need a real variable called TempReal, integer variable called TempInt, unit variable called TempUnit and a boolean variable called TempBoolean. Note that I'm using custom script for hashtables as my GUI version of it is bugged.

Trigger:
  • Damage Detection Bounty
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit belongs to an enemy of (Owner of GDD_DamageSource)) Equal to True
    • Actions
      • Custom script: local integer i = 0
      • Set TempBoolean = False
      • Custom script: set udg_TempInt = LoadInteger(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("integer"))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Greater than 0
        • Then - Actions
          • Custom script: loop
          • Custom script: exitwhen i == udg_TempInt or udg_TempBoolean == true
          • Custom script: set i = i + 1
          • Custom script: set udg_TempUnit = LoadUnitHandle(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), i)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempUnit Equal to GDD_DamageSource
            • Then - Actions
              • Set TempBoolean = True
              • Custom script: set udg_TempInt = i
            • Else - Actions
          • Custom script: endloop
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempBoolean Equal to False
        • Then - Actions
          • Set TempInt = (TempInt + 1)
          • Custom script: call SaveUnitHandle(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), udg_TempInt, udg_GDD_DamageSource)
          • Custom script: call SaveInteger(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("integer"), udg_TempInt)
          • Else - Actions
      • Custom script: call SaveReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), GetHandleId(udg_GDD_DamageSource), LoadReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), GetHandleId(udg_GDD_DamageSource)) + udg_GDD_Damage)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • GDD_Damage Greater than (Life of GDD_DamagedUnit)
          • Then - Actions
            • Custom script: call SaveReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("totaldamage"), LoadReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("totaldamage")) + GetUnitState(udg_GDD_DamagedUnit, UNIT_STATE_LIFE))
          • Else - Actions
            • Custom script: call SaveReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("totaldamage"), LoadReal(udg_Hashtable, GetHandleId(udg_GDD_DamagedUnit), StringHash("totaldamage")) + udg_GDD_Damage)


The above trigger is to check the damage taken and store the damage dealt by individual units. And now comes the bounty giving part. You need another real variable, but a real array and another integer variable.. I'll name the arrayed real variable as PlayerReal and the integer variable as BountyCount.

Trigger:
  • Give Bounty
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) belongs to an enemy of (Owner of (Killing unit))) Equal to True
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local integer i = 0
      • Custom script: set udg_BountyCount = LoadInteger(udg_Hashtable, GetHandleId(u), StringHash("bounty"))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set PlayerReal[(Integer A)] = 0.00
      • Custom script: set udg_TempInt = LoadInteger(udg_Hashtable, GetHandleId(u), StringHash("integer"))
      • Custom script: loop
      • Custom script: exitwhen i == udg_TempInt
      • Custom script: set i = i + 1
      • Custom script: set udg_TempUnit = LoadUnitHandle(udg_Hashtable, GetHandleId(u), i)
      • Custom script: set udg_TempReal = LoadReal(udg_Hashtable, GetHandleId(u), GetHandleId(udg_TempUnit))
      • Set PlayerReal[(Player number of (Owner of TempUnit))] = (PlayerReal[(Player number of (Owner of TempUnit))] + TempReal)
      • Custom script: endloop
      • Custom script: set udg_TempReal = LoadReal(udg_Hashtable, GetHandleId(u), StringHash("totaldamage"))
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • PlayerReal[(Integer A)] Greater than 0.00
            • Then - Actions
              • Player - Add (Integer(((Real(BountyCount)) x (PlayerReal[(Integer A)] / TempReal)))) to (Player((Integer A))) Current gold
              • <Add Floating text here if you want>
            • Else - Actions
      • Custom script: set u = null


And there, you have your bounty system based on damage dealt. I'm not sure if this works, so you might want to test it out.
 

mapguy

New Member
Reaction score
46
I will ask in another thread how the hell I use hashtables.
you can PM me glen, so I dont need to create a thread.
 

tommerbob

Minecraft. :D
Reaction score
110
I didn't read through all of Glenphir's system, but did you take into account whether or not the unit heals after being dealt damage? Does it take into account a scenario example where a hero almost kills a unit, but the unit escapes, goes to heal, and then returns, and is killed by a different hero than the first? Will the first hero receive any bounty for that kill?
 

Ayanami

칼리
Reaction score
288
I didn't read through all of Glenphir's system, but did you take into account whether or not the unit heals after being dealt damage? Does it take into account a scenario example where a hero almost kills a unit, but the unit escapes, goes to heal, and then returns, and is killed by a different hero than the first? Will the first hero receive any bounty for that kill?

Hmm, actually I didn't take that in account. Well this actually depends. Most "bounty by damage" would have a sort of timer that resets damage taken by a damage source if the damage source doesn't deal any damage within x seconds. But not sure what farold wants as of now.
 

Bogrim

y hello thar
Reaction score
154
There isn't a proper way to detect healing done. However, if you save all the damage done to a creep then split the gold by a percentage of the total damage done, you could easily achieve an accurate effect.

Glenphir, it would be much simpler to just add the damaging units to a unit group, then save the real value of the damage caused to the damaging unit using the damaged unit's ID, and add the damage amount to the damaged unit's current "damage taken" amount. When the unit then dies, load the total damage amount from the hashtable amount and run through all the units in your group variable, granting them a percentage of gold using the percentage difference in the total damage done and the unit's damage caused. Then furthermore, use point value for bounty than creating it a system of its own.
 

farold

New Member
Reaction score
3
Strange... But I have nothing related to Hashtable in my WE, even if I have Jass Newgen :/
No Hashtable Variable's type... No trigger etc... :confused:

Bogrim : I think your's can give an accurate effect like u said, but I unfortunately have no Idea how to do that.
 

Ayanami

칼리
Reaction score
288
There isn't a proper way to detect healing done. However, if you save all the damage done to a creep then split the gold by a percentage of the total damage done, you could easily achieve an accurate effect.

Glenphir, it would be much simpler to just add the damaging units to a unit group, then save the real value of the damage caused to the damaging unit using the damaged unit's ID, and add the damage amount to the damaged unit's current "damage taken" amount. When the unit then dies, load the total damage amount from the hashtable amount and run through all the units in your group variable, granting them a percentage of gold using the percentage difference in the total damage done and the unit's damage caused. Then furthermore, use point value for bounty than creating it a system of its own.

Well yeah, a unit group would be simpler. However, if you use point-value, you wouldn't be able to create a range right? Like 40-50 gold.

Strange... But I have nothing related to Hashtable in my WE, even if I have Jass Newgen :/
No Hashtable Variable's type... No trigger etc... :confused:

Bogrim : I think your's can give an accurate effect like u said, but I unfortunately have no Idea how to do that.

What is your Warcraft version?
 
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