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

[Solved] Experience Splitting

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
When you have 1 hero, that hero gets all the experience. When you have 2 or more heroes, the experience gained from killing units is split amogst the nearby allied heroes. When you have 4 or so heroes, XP progress becomes very slow.

How can I turn off split XP. I want it shared, but not split if that is possible.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You could set the point value of each unit type to the exp it gives, and use this:
  • Untitled Trigger 076
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Set point = (Position of (Triggering unit))
      • Set i = (Point-value of (Triggering unit))
      • Set group = (Units within 512.00 of point matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Set i1 = (Number of units in group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i1 Not equal to 0
        • Then - Actions
          • Set i = (i / i1)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in group and do (Actions)
            • Loop - Actions
              • Hero - Add i experience to (Picked unit), Show level-up graphics
        • Else - Actions
      • Custom script: call RemoveLocation(udg_point)
You should make units give 0 exp in Advanced - Hero exp gained fields.
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=68382
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
You could set the point value of each unit type to the exp it gives, and use this:
  • Untitled Trigger 076
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • Set point = (Position of (Triggering unit))
      • Set i = (Point-value of (Triggering unit))
      • Set group = (Units within 512.00 of point matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Set i1 = (Number of units in group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i1 Not equal to 0
        • Then - Actions
          • Set i = (i / i1)
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in group and do (Actions)
            • Loop - Actions
              • Hero - Add i experience to (Picked unit), Show level-up graphics
        • Else - Actions
      • Custom script: call RemoveLocation(udg_point)
You should make units give 0 exp in Advanced - Hero exp gained fields.
http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=68382

Say I were not to use the check if there are 0 people in the group "i1 not equal to 0", could that cause problems? And also, you ensured not to pick dead units. If you didnt perform this check, could picking dead units and adding exp to them cause problems?

Just curious about these things because I have similar coding where I dont perform these kinds of checks.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I didn't want to add exp to dead units because they don't deserve it :)

Dividing by 0 should be avoided in all programming as the result is not defined. It is impossible to give an aswer to that calculation. Dividing by zero causes the execution of the function (trigger) to be aborted.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Yes, this can cause a fatal error.

Ok, we've confirmed its bad to divide anything by 0, is it also bad to perform actions on 0 units (If it picks 0 units and performs the actions anyway on those 0 units)? This goes for picking players where 0 players are actually picked and performing actions on them too, or even destructibles. Could this cause fatal errors too?
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
For clarification, I'm generally speaking now. I have already made the experience system. So in other words, the thread is kind of offtopic now. However, I'm still curious about those things:

Ok, we've confirmed its bad to divide anything by 0, is it also bad to perform actions on 0 units (If it picks 0 units and performs the actions anyway on those 0 units)? This goes for picking players where 0 players are actually picked and performing actions on them too, or even destructibles. Could this cause fatal errors too?
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Ok, we've confirmed its bad to divide anything by 0, is it also bad to perform actions on 0 units (If it picks 0 units and performs the actions anyway on those 0 units)? This goes for picking players where 0 players are actually picked and performing actions on them too, or even destructibles. Could this cause fatal errors too?

No, that's completely okay. When you pick units and do things, the code is doing the things on the units one at a time. If no units are picked, the code simply doesn't run.
 
Status
Not open for further replies.
Top