• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Custom Bounty System

Status
Not open for further replies.
Level 22
Joined
Aug 27, 2013
Messages
3,973
It's me again. So I've been making a custom bounty system. I want my player to get gold when an enemy dies nearby even if my player's unit isn't the one who killed it but of course with reduced amount. I wanted the system to have floating text just like the default one.

This is what I ended up with. It worked perfectly before I added the floating text but as soon as I added the floating text functions to the trigger, especially GetLocalPlayer, I no longer get gold from my ally's kills.
  • Bounty System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set BountS_Area = 1000.00
      • Set BountS_RandomFactor = (Random integer number between 1 and 15)
      • Set BountS_Group = (Units within BountS_Area of TempLoc[1] matching (((Owner of (Matching unit)) Not equal to Neutral Passive) and (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)))
      • Unit Group - Pick every unit in BountS_Group and do (Actions)
        • Loop - Actions
          • Set GetLocalPlayer = (Owner of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Equal to (Killing unit)
            • Then - Actions
              • Set BountS_Final = ((20 x (Level of (Triggering unit))) + BountS_RandomFactor)
              • Player - Add BountS_Final to GetLocalPlayer Current gold
              • Set BountS_String = <Empty String>
              • Custom script: if GetLocalPlayer() == udg_GetLocalPlayer then
              • Set BountS_String = (|cffffcc00+ + ((String(BountS_Final)) + |r))
              • Custom script: endif
              • Floating Text - Create floating text that reads BountS_String at TempLoc[1] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.50 seconds
            • Else - Actions
              • Set BountS_Final = ((20 x (Level of (Triggering unit))) + BountS_RandomFactor)
              • Set BountS_Final = (BountS_Final / (Number of players in BountS_PGroup))
              • Player - Add BountS_Final to GetLocalPlayer Current gold
              • Set BountS_String = <Empty String>
              • Custom script: if GetLocalPlayer() == udg_GetLocalPlayer then
              • Set BountS_String = (|cffffcc00+ + ((String(BountS_Final)) + |r))
              • Custom script: endif
              • Floating Text - Create floating text that reads BountS_String at TempLoc[1] with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 1.50 seconds
      • Custom script: call DestroyGroup(udg_BountS_Group)
      • Custom script: call RemoveLocation(udg_TempLoc[1])
Do tell me if I did it wrong and a way to achieve my goal. Thank you very much in advance.
 
Last edited:
Level 13
Joined
Mar 24, 2013
Messages
1,105
Well I didn't notice the update, but here is an a slightly "better" way to do it xD.

  • Bounty
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempPlayer = (Owner of TempUnit)
      • Set TempPoint = (Position of TempUnit)
      • Set TempGroup = (Units within 1000.00 of TempPoint)
      • Set RNG = (Random integer number between 1 and 15)
      • Set BountyGold = (20 + ((Level of TempUnit) + RNG))
      • Custom script: set udg_TempForce = CreateForce()
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit2 = (Picked unit)
          • Set TempPlayer2 = (Owner of TempUnit2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempPlayer2 Not equal to Neutral Passive
              • (TempUnit2 belongs to an enemy of TempPlayer) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TempPlayer2 is in TempForce) Equal to False
                • Then - Actions
                  • Player Group - Add TempPlayer2 to TempForce
                • Else - Actions
            • Else - Actions
      • Player Group - Pick every player in TempForce and do (Actions)
        • Loop - Actions
          • Set TempPlayer3 = (Picked player)
          • Set TempInteger = (BountyGold / (Number of players in TempForce))
          • Player - Add TempInteger to TempPlayer3 Current gold
          • Custom script: if GetLocalPlayer() == udg_TempPlayer3 then
          • Floating Text - Create floating text that reads (+ + (String(TempInteger))) at TempPoint with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempTag = (Last created floating text)
          • Floating Text - Set the velocity of TempTag to 64.00 towards 90.00 degrees
          • Floating Text - Change TempTag: Disable permanence
          • Floating Text - Change the lifespan of TempTag to 2.00 seconds
          • Floating Text - Change the fading age of TempTag to 1.50 seconds
          • Custom script: endif
      • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call DestroyGroup(udg_TempGroup)
      • Custom script: call DestroyForce(udg_TempForce)
Btw, you can create the texttag inside the local player block.
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
I see, thanks for the tip. :D
Since you did it before the update, it isn't exactly what I was looking for.

Here's the trigger after I fixed it. In case anyone is interested. *coughs*
  • Bounty System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set BountS_Area = 1000.00
      • Set BountS_RandomFactor = (Random integer number between 1 and 15)
      • Set BountS_Group = (Units within BountS_Area of TempLoc[1] matching (((((Matching unit) is A Hero) Equal to True) and ((Owner of (Matching unit)) Not equal to Neutral Passive)) and (((Matching unit) belongs to an enemy of (Triggering player)) Equal to True)))
      • Unit Group - Pick every unit in BountS_Group and do (Actions)
        • Loop - Actions
          • Set GetLocalPlayer = (Owner of (Picked unit))
          • Player Group - Add GetLocalPlayer to BountS_PGroup
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Equal to (Killing unit)
            • Then - Actions
              • Set BountS_Final = ((20 x (Level of (Triggering unit))) + (BountS_RandomFactor + 15))
            • Else - Actions
              • Set BountS_Final = (((20 x (Level of (Triggering unit))) + BountS_RandomFactor) / (Number of players in BountS_PGroup))
          • Player - Add BountS_Final to GetLocalPlayer Current gold
          • Set BountS_String = <Empty String>
          • Custom script: if GetLocalPlayer() == udg_GetLocalPlayer then
          • Set BountS_String = (|cffffcc00+ + ((String(BountS_Final)) + |r))
          • Custom script: endif
          • Floating Text - Create floating text that reads BountS_String at TempLoc[1] with Z offset 10.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.50 seconds
      • Custom script: call DestroyGroup(udg_BountS_Group)
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Player Group - Remove all players from BountS_PGroup

The system will give the player a gold whenever nearby enemy unit dies within 1000 range. The player will get bonus gold if they kill enemy unit. The player will get normal gold if the enemy is killed by ally and no friendly hero nearby. The player will get reduced gold if the enemy is killed by ally/friendly hero and there is friendly hero nearby.

I still won't say the trigger I made is the best way to do it, though. So do tell me if there's a better way to improve this method, especially in efficiency. :p

Edit:
Still require further testing to prove this is bug-free and flawless as intended, though.

Edit2:
After several testing, seems like my method still has some flaw.
So I applied pOke's method and voila! works wonderfully! (so far :p )
  • Bounty System
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A structure) Equal to False
    • Actions
      • Set TempLoc[1] = (Position of (Triggering unit))
      • Set BountS_Area = 1000.00
      • Set BountS_RandomFactor = (Random integer number between 1 and 15)
      • Set BountS_Group = (Units within BountS_Area of TempLoc[1])
      • Custom script: set udg_BountS_PGroup = CreateForce()
      • Unit Group - Pick every unit in BountS_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Neutral Passive
              • ((Picked unit) is A Hero) Equal to True
              • ((Picked unit) belongs to an enemy of (Triggering player)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Picked unit)) is in BountS_PGroup) Equal to False
                • Then - Actions
                  • Player Group - Add (Owner of (Picked unit)) to BountS_PGroup
                • Else - Actions
            • Else - Actions
      • Player Group - Pick every player in BountS_PGroup and do (Actions)
        • Loop - Actions
          • Set GetLocalPlayer = (Picked player)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GetLocalPlayer Equal to (Owner of (Killing unit))
            • Then - Actions
              • Set BountS_Final = ((20 x (Level of (Triggering unit))) + (BountS_RandomFactor + 15))
            • Else - Actions
              • Set BountS_Final = (((20 x (Level of (Triggering unit))) + BountS_RandomFactor) / (Number of players in BountS_PGroup))
          • Player - Add BountS_Final to GetLocalPlayer Current gold
          • Set BountS_String = <Empty String>
          • Custom script: if GetLocalPlayer() == udg_GetLocalPlayer then
          • Set BountS_String = (|cffffcc00+ + ((String(BountS_Final)) + |r))
          • Custom script: endif
          • Floating Text - Create floating text that reads BountS_String at TempLoc[1] with Z offset 10.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.50 seconds
      • Custom script: call DestroyGroup(udg_BountS_Group)
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Custom script: call DestroyForce(udg_BountS_PGroup)

Thank you very much!
 
Last edited:
Status
Not open for further replies.
Top