• 🏆 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!

How to decrease Heros xp in region?

Status
Not open for further replies.
  • Trigger
  • Events
    • Unit - A unit enters Region
  • Conditions
    • ((Triggering unit) is a Hero) Equal to True
  • Actions
    • Unit Group - Add (Triggering unit) to DecreasedExp
  • Trigger1
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • Set Temp_R = 1000.00 //Replace 1000.00 with the Experience range of your map (from Game Play Constants)
    • Set Temp_P = (Position of (Triggering unit))
    • Set Temp_G = (Units within Temp_R of (Temp_P) matching ((Matching unit) is a Hero) Equal to True)) and ((Matching unit) belongs to an enemy of (Owner of (Triggering unit))))
    • Unit Group - Pick every unit within Temp_G and do (Actions)
      • Loop - Acitons
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • ((Picked unit) is in (DecreasedExp)) Equal to True
          • Then - Actions
            • Hero - Set (Picked unit) experience to (((Picked unit) experience)) - (0.1 * (Picked unit) experience))
          • Else - Actions
    • Custom script: call RemoveLocation (udg_Temp_P)
    • Custom script: call DestroyGroup (udg_Temp_G)
  • Trigger2
  • Events
    • Unit - A unit leaves Region
  • Conditions
    • ((Triggering unit) is in (DecreasedExp)) Equal to True
  • Actions
    • Unit Group - Remove (Triggering unit) from (DecreasedExp)
 
Level 9
Joined
Dec 12, 2007
Messages
489
  • DecreaseXP
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set Group = (Units in Region <gen> matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) experience to ((Hero experience of (Picked unit)) - 10), Hide level-up graphics
      • Custom script: call DestroyGroup(udg_Group)
something like this?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
^I would rather add units to a unit group when they enter the area, and save a timer (integer) value for them. Then use a periodic trigger that updates, let's say once every second, and reduces the timer value for each unit. When the timer hits zero reduce exp and restart the integer counter. If the unit is not in the region, remove it from the unit group.

That way it's more accurate. Your way makes it possible for a unit to be in the area for one second and it gets it's exp reduced.
 
Level 9
Joined
Dec 12, 2007
Messages
489
^I would rather add units to a unit group when they enter the area, and save a timer (integer) value for them. Then use a periodic trigger that updates, let's say once every second, and reduces the timer value for each unit. When the timer hits zero reduce exp and restart the integer counter. If the unit is not in the region, remove it from the unit group.

That way it's more accurate. Your way makes it possible for a unit to be in the area for one second and it gets it's exp reduced.
Yeah, I understand your point, but that way would be too complicated, I believe that this is the basic way, and he can develop it better himself later.
 
Level 19
Joined
Aug 31, 2008
Messages
1,779
  • Trigger
  • Events
    • Unit - A unit enters Region
  • Conditions
    • ((Triggering unit) is a Hero) Equal to True
  • Actions
    • Unit Group - Add (Triggering unit) to DecreasedExp
  • Trigger1
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • Set Temp_R = 1000.00 //Replace 1000.00 with the Experience range of your map (from Game Play Constants)
    • Set Temp_P = (Position of (Triggering unit))
    • Set Temp_G = (Units within Temp_R of (Temp_P) matching ((Matching unit) is a Hero) Equal to True)) and ((Matching unit) belongs to an enemy of (Owner of (Triggering unit))))
    • Unit Group - Pick every unit within Temp_G and do (Actions)
      • Loop - Acitons
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • ((Picked unit) is in (DecreasedExp)) Equal to True
          • Then - Actions
            • Hero - Set (Picked unit) experience to (((Picked unit) experience)) - (0.1 * (Picked unit) experience))
          • Else - Actions
    • Custom script: call RemoveLocation (udg_Temp_P)
    • Custom script: call DestroyGroup (udg_Temp_G)
  • Trigger2
  • Events
    • Unit - A unit leaves Region
  • Conditions
    • ((Triggering unit) is in (DecreasedExp)) Equal to True
  • Actions
    • Unit Group - Remove (Triggering unit) from (DecreasedExp)

I guess learned something from someone's thread LOL, can you tell me all the variables used? i might use this one also..
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I'm not sure how Pharaoh's system should work, maybe I undestood incorrectly what the OP wants. I'd do it like this:

  • Melee Initialization
    • Actions
      • Hashtable - Create a hashtable
      • Set Spell_Hash = (Last created hashtable)

  • Untitled Trigger 044
    • Events
      • Unit - A unit enters Region 015 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Add (Triggering unit) to Unit_Group
      • Hashtable - Save 5 as (Key timer) of (Key (Triggering unit)) in Spell_Hash
      • Trigger - Turn on Untitled Trigger 045 <gen>
  • Untitled Trigger 045
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Unit_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Integer_1 = (Load (Key timer) of (Key (Picked unit)) from Spell_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • (Region 015 <gen> contains (Picked unit)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Temp_Integer_1 Greater than 0
                • Then - Actions
                  • Hashtable - Save (Temp_Integer_1 - 1) as (Key timer) of (Key (Picked unit)) in Spell_Hash
                • Else - Actions
                  • Hashtable - Save 5 as (Key timer) of (Key (Picked unit)) in Spell_Hash
                  • Hero - Set (Picked unit) experience to ((Hero experience of (Picked unit)) - 100), Hide level-up graphics
            • Else - Actions
              • Unit Group - Remove (Picked unit) from Unit_Group
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in Spell_Hash
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit_Group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
It's just that you can set hero's exp to lower value than what it is, so you have to find a workaround for that. Like set the level to lower value than what it was and then add exp.
 
Status
Not open for further replies.
Top