• 🏆 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 add percentage experience?

Status
Not open for further replies.
Level 20
Joined
Aug 29, 2012
Messages
825
You should be able to do that with a trigger. Replace the Tome of experience condition with your item (make sure it doesn't give any experience by itself)

  • Experience
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
    • Actions
      • Set Integer = ((100 x 1) + (((Hero level of (Triggering unit)) x 100) + 0))
      • Hero - Add (Integer / 2) experience to (Triggering unit), Show level-up graphics
The "difficulty" is to calculate how much EXP the hero needs to reach the next level, that's what the "Set Integer" variable is calculating.

I've run a quick test in a map and it seems to work like that :)

Edit: attached the test map
 

Attachments

  • TestExperience.w3x
    17.5 KB · Views: 3
Level 6
Joined
Jul 12, 2017
Messages
139
That's great :) Also, I must note that whole math things depends on the gameplay constants for XP in your map. If you edit these, you'll need to ajust the formula.
Understood, but I have one more question, not sure if I can ask it here or need to create a new thread.

This trigger does not work sometimes and I don't know why. Is there anything wrong with it?

  • Golem Hurl Boulder Wall
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to (Golem) Hurl Boulder Dummy
    • Actions
      • Set VariableSet Point1 = (Position of (Dying unit))
      • Set VariableSet Real1 = (Strength of PlayerHero[(Player number of (Owner of (Dying unit)))] (Include bonuses))
      • Set VariableSet Real2 = (Agility of PlayerHero[(Player number of (Owner of (Dying unit)))] (Include bonuses))
      • Unit - Create 1 Boulder Wall (Golem) for (Owner of (Dying unit)) at Point1 facing Default building facing degrees
      • Set VariableSet Golem_HurlBoulderWall = (Last created unit)
      • Unit - Set Max HP of Golem_HurlBoulderWall to ((1000 x (Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))])) + (Real1 x (10 x (Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))]))))
      • Unit - Set life of Golem_HurlBoulderWall to 100.00%
      • Unit - Set Armor of Golem_HurlBoulderWall to ((5.00 x (Real((Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))])))) + ((Real(Real2)) x (0.10 x (Real((Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))]))))))
      • Unit - Add a 180.00 second Generic expiration timer to Golem_HurlBoulderWall
      • Set VariableSet UnitGroup1 = (Units within 300.00 of Point1 matching (((Matching unit) belongs to an enemy of (Owner of (Dying unit)).) Equal to True).)
      • Unit Group - Pick every unit in UnitGroup1 and do (Actions)
        • Loop - Actions
          • Unit - Cause (Dying unit) to damage (Picked unit), dealing ((200.00 x (Real((Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))])))) + ((Real(Real1)) x (2.00 x (Real((Level of (Golem) Hurl Boulder Wall for PlayerHero[(Player number of (Owner of (Dying unit)))])))))) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation(udg_Point1)
      • Custom script: call DestroyGroup(udg_UnitGroup1)
The problem is, it can do damage just fine but sometimes the rock wall doesn't spawn.
 
Level 20
Joined
Aug 29, 2012
Messages
825
Not sure really, can't really see anything wrong with the trigger in itself, maybe it's the boulder wall unit that has something wrong, perhaps collision? I don't know.

Try to spawn something else like a peasant to see whether the problem lies in the trigger or the unit
 
Level 6
Joined
Jul 12, 2017
Messages
139
Not sure really, can't really see anything wrong with the trigger in itself, maybe it's the boulder wall unit that has something wrong, perhaps collision? I don't know.

Try to spawn something else like a peasant to see whether the problem lies in the trigger or the unit
Oh I figured it out that I forgot to fix the boulder all right it's working now. Thanks for everything!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,510
Oh I figured it out that I forgot to fix the boulder all right it's working now. Thanks for everything!
I'm not 100% sure but using (Dying unit) like that may cause a problem if the damage it's dealing kills the (Picked unit):
  • Unit - Cause (Dying unit) to damage (Picked unit)
I use (Triggering unit) whenever possible as I know it works without issues.
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
I'm not 100% sure but using (Dying unit) like that may cause a problem
Dying Unit: Working correctly
 
Status
Not open for further replies.
Top