• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Bounty and Experience

Status
Not open for further replies.
Level 4
Joined
Apr 25, 2008
Messages
60
Can you help me to make a trigger? I need to add experience and gold for kill customly.

Something like: hero kills a certain unit. It do not gain any gold and no experience by defaults. Then it gains 300 experience and 190 gold.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Well, you can turn off the default XP gain in Gameplay Constants.
To turn off bounty, you can either do it in the object editor, or use this action at map init:
  • Player - Turn Gives bounty Off for Neutral Hostile
(Player -> Turn Player Flag On/Off).

To give the Experience and gold to the killing unit, you can set up a simple table at map init as well (right below the bounty-action) which goes a bit like this:
  • Actions
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Footman
    • Set BountyBase[UnitCount] = 10
    • Set ExpBase[UnitCount] = 50
    • -------- --------
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Rifleman
    • Set BountyBase[UnitCount] = 50
    • Set ExpBase[UnitCount] = 100
    • -------- --------
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Knight
    • Set BountyBase[UnitCount] = 180
    • Set ExpBase[UnitCount] = 500
Where:
  • UnitType[X] = the unit type of the killed unit (unit type variable with array).
  • BountyBase[X] = the gold received when the unit is killed (integer variable with array).
  • ExpBase[X] = the xp gained when the unit is killed (integer variable with array).
  • UnitCount = a regular integer variable to count the amount of units.


When this is done, you can create a trigger that activates every time a unit dies.
It will check the unit type of the dying unit and will give XP and gold according to that type.

  • Bounty XP
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to UnitType[LoopInt]
            • Then - Actions
              • Hero - Add ExpBase[LoopInt] experience to (Killing unit), Hide level-up graphics
              • Player - Add BountyBase[LoopInt] to (Owner of (Killing unit)) Current gold
            • Else - Actions
(LoopInt is an integer variable)

If you want the XP/Bounty to appear as a text in the game, you need to add a lot of actions - but it can be worth it ^^

  • Bounty XP
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to UnitType[LoopInt]
            • Then - Actions
              • Set TempLoc = (Position of (Killing unit))
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetKillingUnit()) then
              • Floating Text - Create floating text that reads |c007788cc+ ExpBase[LoopInt] |r at TempLoc with Z offset 10.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 52.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00
              • Custom script: endif
              • Hero - Add ExpBase[LoopInt] experience to (Killing unit), Hide level-up graphics
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetKillingUnit()) then
              • Floating Text - Create floating text that reads |c00ffdc00+ BountyBase[LoopInt] |r at TempLoc with Z offset 80.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 52.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00
              • Custom script: endif
              • Custom script: call RemoveLocation(udg_TempLoc)
              • Player - Add BountyBase[LoopInt] to (Owner of (Killing unit)) Current gold
            • Else - Actions
Something like this...
 
Level 16
Joined
Oct 17, 2009
Messages
1,579
you can use apocalypse's idea but this is much simpler
event:Unit-A unit dies

condition:(for specific units)(Triggering unit) Equal to (unit)
(for unit types)(Unit-type of (Triggering unit) Equal to (Unit type)

Action:Hero-Add (number of exp) experience to (Killing unit), Show(or hide) level-up graphics
Player-Add (number of gold) to (Owner of (Killing unit)) Current gold

heres the trigger. hope i helped.
 
  • Trigger1
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable Map Area) matching ((Matching unit) is a Hero) Equal to True) and do (Actions)
      • Loop - Actions
        • Hero - Disable experience gain for (Picked unit)
    • For each (Integer A) from 1 to 12, do (Actions)
      • Loop - Actions
        • Player - Turn Gives bounty Off for (Player((Integer A)))
  • Trigger2
  • Events
    • Unit - A unit finishes training a unit
    • Unit - A unit finishes reviving
  • Conditions
  • Actions
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (Trained unit) Equal to No unit
      • Then - Actions
        • Hero - Disable experience gain for (Triggering unit)
      • Else - Actions
        • Hero - Disable experience gain for (Trained unit)
  • Trigger3
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Killing unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True {Boolean Comparison - Unit - Unit belongs to an enemy of player}
    • ((Killing unit) is a Hero) Equal to True {Boolean Comparison - Unit - Unit classification check}
  • Actions
    • Hero - Add 300 experience to (Killing unit), Show level-up graphics
    • Player - Add 190 to (Owner of (Killing unit))'s Current gold
Edit: Way too late.
 
Level 4
Joined
Apr 25, 2008
Messages
60
But this way, I need to add custom expereince and gold for every unit hero kills and I need to do this only for one unit hero kills. I need bounty and expereince to work for all others kills.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You should've made that clear that in the first place >.>
Learn how to write a proper question.

Quickly Enabling/Disabling the bounty/experience won't work.
Is there anything else we need to know that could be useful? Are there any other units near that 'boss', do you have to enter some kind of area, ...?

And just to get things straight: you can't calculate the amount of XP it gives by default and substract it from 300, right?
(so if it usually gives 120xp, you could trigger it to give +180xp for a total of 300xp - which is exactly the same result).
And the bounty can also not be done through the object editor? (Since you CAN let a single creep give +190 gold by default).
And may I also know why all of this isn't possible?
 
Level 4
Joined
Apr 25, 2008
Messages
60
There aren't any other special conditions.

All things in your list are impossible because the unit which is killed triggers destruction of many other units and buildings. So Hero gets xp from all buildings and gold from all units.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
All things in your list are impossible because the unit which is killed triggers destruction of many other units and buildings. So Hero gets xp from all buildings and gold from all units.
That doesn't make it impossible at all.

If you want the hero to gain experience/gold from all the buildings/units he destroys, then you should just set the values in the object editor to let the boss give +190 gold and trigger it to give +X gold (where X is 300 - the default experience it gives).

If you don't want the hero to gain experience/gold from those, then you should disable the experience/bounty with the event "Boss is attacked" (which will be activated right before it hits) and re-enable when the boss died (or a second after the impact if the boss is still alive).
 
Level 4
Joined
Apr 25, 2008
Messages
60
Ok, I will try this.
That's what I did and it still don't work:
  • Events
    • Unit - A unit Is attacked
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Unit-type of (Attacking unit)) Equal to Mountain King
    • (Unit-type of (Attacked unit)) Equal to Footmen
  • Actions
    • Set atkunit = (Attacking unit)
    • Player - Turn Gives bounty Off for (Owner of atkunit)
    • Hero - Disable experience gain for atkunit
    • Wait 2.00 seconds
    • Trigger - Run After attack <gen> (ignoring conditions)
"After attack" trigger
  • Actions
    • Player - Turn Gives bounty On for (Owner of atkunit)
    • Hero - Enable experience gain for iatkunit
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
The attacked event runs before damage is dealt >.< You should use a damage event instead. Also you have to disable the bounty for the owner of theattacked/damaged units and please no double posts
No, that was exactly the point: the bounty should be turned off before the unit dies, otherwise he would still get the bounty.

The "Run After Attack" is useless though, why didn't you just put the other actions after the wait instead of creating a seperate trigger for them?

So the Mountain King is your hero and the footman is the unit that you don't want to give default exp/gold, right?
I'll check it out later, gotta study now.
 
Level 9
Joined
Jun 25, 2009
Messages
427
Well, you can turn off the default XP gain in Gameplay Constants.
To turn off bounty, you can either do it in the object editor, or use this action at map init:
  • Player - Turn Gives bounty Off for Neutral Hostile
(Player -> Turn Player Flag On/Off).

To give the Experience and gold to the killing unit, you can set up a simple table at map init as well (right below the bounty-action) which goes a bit like this:
  • Actions
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Footman
    • Set BountyBase[UnitCount] = 10
    • Set ExpBase[UnitCount] = 50
    • -------- --------
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Rifleman
    • Set BountyBase[UnitCount] = 50
    • Set ExpBase[UnitCount] = 100
    • -------- --------
    • Set UnitCount = (UnitCount + 1)
    • Set UnitType[UnitCount] = Knight
    • Set BountyBase[UnitCount] = 180
    • Set ExpBase[UnitCount] = 500
Where:
  • UnitType[X] = the unit type of the killed unit (unit type variable with array).
  • BountyBase[X] = the gold received when the unit is killed (integer variable with array).
  • ExpBase[X] = the xp gained when the unit is killed (integer variable with array).
  • UnitCount = a regular integer variable to count the amount of units.


When this is done, you can create a trigger that activates every time a unit dies.
It will check the unit type of the dying unit and will give XP and gold according to that type.

  • Bounty XP
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to UnitType[LoopInt]
            • Then - Actions
              • Hero - Add ExpBase[LoopInt] experience to (Killing unit), Hide level-up graphics
              • Player - Add BountyBase[LoopInt] to (Owner of (Killing unit)) Current gold
            • Else - Actions
(LoopInt is an integer variable)

If you want the XP/Bounty to appear as a text in the game, you need to add a lot of actions - but it can be worth it ^^

  • Bounty XP
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer LoopInt) from 1 to UnitCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to UnitType[LoopInt]
            • Then - Actions
              • Set TempLoc = (Position of (Killing unit))
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetKillingUnit()) then
              • Floating Text - Create floating text that reads |c007788cc+ ExpBase[LoopInt] |r at TempLoc with Z offset 10.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 52.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00
              • Custom script: endif
              • Hero - Add ExpBase[LoopInt] experience to (Killing unit), Hide level-up graphics
              • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetKillingUnit()) then
              • Floating Text - Create floating text that reads |c00ffdc00+ BountyBase[LoopInt] |r at TempLoc with Z offset 80.00, using font size 9.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 52.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 3.00
              • Custom script: endif
              • Custom script: call RemoveLocation(udg_TempLoc)
              • Player - Add BountyBase[LoopInt] to (Owner of (Killing unit)) Current gold
            • Else - Actions
Something like this...

Doesn't using Getlocalplayer cause desyncs, or something wtf while used too much or somethin? :confused: Just a question :grin:
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Axarion said:
@ ap0calypse: The damage event runs too before the unit dies >.<
Correct, I mixed it up with "Unit dies" event - sorry for the mixup :p
Either way, I don't see the point in creating a damage detection system (or copy one) if the "Unit is attacked" can't be abused here and should work as well :p

Doesn't using Getlocalplayer cause desyncs, or something wtf while used too much or somethin? :confused: Just a question :grin:
Only when handling locals, that's why I put the location out of the GetLocalPlayer() function.

No, I just put them as examples but no difference.
I know that... that's what I meant.
I'll edit this post once I found whatever it is you want (still not sure what you want though).
 
Status
Not open for further replies.
Top