• 🏆 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] Penance

Status
Not open for further replies.
Level 9
Joined
Dec 16, 2017
Messages
343
Hello guys, i've made penance spell from wow, it works fine in test map, in my map,it laggs very hard when i try to heal ally,when i dmg an enemy it works right,what could be the reason? These are the triggers:
  • Penance
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Penance (Priest DISCIPLINE)
    • Actions
      • Set PenanceCaster = (Triggering unit)
      • Set PenanceTarget = (Target unit of ability being cast)
      • Set PenanceDamage = ((Real((Level of Penance (Priest DISCIPLINE) for (Triggering unit)))) x 45.00)
      • Set PenanceHeal = ((Real((Level of Penance (Priest DISCIPLINE) for (Triggering unit)))) x 90.00)
      • Set PenanceDuration = 6
      • Set PenanceCasterPosition = (Position of PenanceCaster)
      • Unit - Create 1 Dummy (Unstable Affliction-Warlock Affliction) for (Owner of PenanceCaster) at PenanceCasterPosition facing Default building facing degrees
      • Unit - Add a 6.00 second Generic expiration timer to (Last created unit)
      • Set PenanceDummy = (Last created unit)
      • Unit - Add |r PenanceDummy(Priest DISCIPLINE) to PenanceDummy
      • Trigger - Turn on PenanceLoop <gen>
      • Trigger - Turn on PenanceStopCast <gen>
  • PenanceLoop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set PenanceTargetPosition = (Position of PenanceTarget)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of PenanceCaster) Equal to (Order(channel))
          • PenanceCaster Not equal to No unit
          • PenanceTarget Not equal to No unit
          • (Life of PenanceCaster) Greater than 0.00
          • (Life of PenanceTarget) Greater than 0.00
          • (PenanceTarget is visible to (Owner of PenanceCaster)) Equal to True
          • (PenanceTarget is Magic Immune) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PenanceTarget belongs to an enemy of (Owner of PenanceCaster)) Equal to True
            • Then - Actions
              • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching ((((Matching unit) belongs to an enemy of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))
              • Unit Group - Pick every unit in PenanceGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
                  • Unit - Cause PenanceCaster to damage (Picked unit), dealing PenanceDamage damage of attack type Magic and damage type Divine
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\BloodElfMissile\BloodElfMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set PenanceDuration = (PenanceDuration - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True
            • Then - Actions
              • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching (((PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))
              • Unit Group - Pick every unit in PenanceGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
                  • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + PenanceHeal)
                  • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\FaerieDragonMissile\FaerieDragonMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set PenanceDuration = (PenanceDuration - 1)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between PenanceCasterPosition and PenanceTargetPosition) Greater than 900.00
        • Then - Actions
          • Set PenanceCaster = No unit
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PenanceDuration Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Trigger - Turn off PenanceStopCast <gen>
        • Else - Actions
      • Custom script: call DestroyGroup(udg_PenanceGroup)
      • Custom script: call RemoveLocation(udg_PenanceTargetPosition)
      • Custom script: call RemoveLocation(udg_PenanceCasterPosition)
  • PenanceStopCast
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • For each (Integer PenanceDuration) from 1 to PenanceDuration, do (Actions)
        • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PenanceCaster Equal to (Triggering unit)
        • Then - Actions
          • Set PenanceCaster = No unit
        • Else - Actions
 
Last edited:
Level 21
Joined
Dec 4, 2007
Messages
1,477
Okay that's weird, any custom models/effects used here?
Or a lot of particles/fog/ubersplats?

If not, look to decrease your functions step by step to find the culprit.
Normally it should be somewhere in the loop.
 
Level 9
Joined
Dec 16, 2017
Messages
343
Okay that's weird, any custom models/effects used here?
Or a lot of particles/fog/ubersplats?

If not, look to decrease your functions step by step to find the culprit.
Normally it should be somewhere in the loop.
Well, the loop has only the damage to be casted or heal, the model is creating on the first trigger so it's not like a spam of units..i have the penance effect used on the acid bomb spell, that is why i need it to be casted in the loop each time the dmg procs, i am new to modding and i don't know how to make the unit travel to the enemy with that effect i need, so i came up with the acid bomb thing..
 
Level 12
Joined
Nov 3, 2013
Messages
989
While probably not the issue that causes lag, this looks like a problem to me:


  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • PenanceDuration Equal to 0
    • Then - Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn off PenanceStopCast <gen>
the trigger will never turn off since you only check for the duration, but the duration isn't decreased if PenenceCaster is no unit

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between PenanceCasterPosition and PenanceTargetPosition) Greater than 900.00
    • Then - Actions
      • Set PenanceCaster = No unit
Same deal with the whole PenanceStopCast trigger, besides setting PenenceCaster to No Unit it should set PenanceDuration to 0.



Also, what's this?
  • For each (Integer PenanceDuration) from 1 to PenanceDuration, do (Actions)
    • Loop - Actions
 
Level 9
Joined
Dec 16, 2017
Messages
343
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between PenanceCasterPosition and PenanceTargetPosition) Greater than 900.00
    • Then - Actions
      • Set PenanceCaster = No unit
ok, fixed.

  • For each (Integer PenanceDuration) from 1 to PenanceDuration, do (Actions)
    • Loop - Actions
this is if unit order is different than channeling with [Events], to stop the spell with what duration it had at that time, or at least that was my idea,i am thinking that this might make it fix in case that the spell stops at 4 seconds instead of 6, so next time it is casted is going to last 6 seconds, not just 2(that remained from the previous cast)

now that i look again through triggers, i think this should be transformed?
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PenanceTarget belongs to an enemy of (Owner of PenanceCaster)) Equal to True
    • Then - Actions
      • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching ((((Matching unit) belongs to an enemy of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))
      • Unit Group - Pick every unit in PenanceGroup and do (Actions)
        • Loop - Actions
          • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
          • Unit - Cause PenanceCaster to damage (Picked unit), dealing PenanceDamage damage of attack type Magic and damage type Divine
          • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\BloodElfMissile\BloodElfMissile.mdl
          • Special Effect - Destroy (Last created special effect)
          • Set PenanceDuration = (PenanceDuration - 1)
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True
      • Then - Actions
        • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching (((PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))
        • Unit Group - Pick every unit in PenanceGroup and do (Actions)
          • Loop - Actions
            • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
            • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) + PenanceHeal)
            • Special Effect - Create a special effect attached to the chest of (Picked unit) using Abilities\Weapons\FaerieDragonMissile\FaerieDragonMissile.mdl
            • Special Effect - Destroy (Last created special effect)
            • Set PenanceDuration = (PenanceDuration - 1)
So i add the "heal loop" to the else of the "damage loop" ? Because i am thinking that it runs the both loops in the same time even if the target is ok, and that is why it laggs?
 
Last edited:
Level 12
Joined
Nov 3, 2013
Messages
989
So i add the "heal loop" to the else of the "damage loop" ? Because i am thinking that it runs the both loops in the same time even if the target is ok, and that is why it laggs?
That's a good idea I think, though the conditions (PenanceTarget belongs to an enemy of (Owner of PenanceCaster)) Equal to True and (PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True are mutually exclusive, as I don't see how you could be both allies and enemies with the same player at the same time.

So I don't think both ever happened at the same time.


But what you can do is change it to a single IF THEN ELSE, if the target is an enemy then do the enemy stuff, and in the else portion do the healing stuff, because if it's not an enemy then it's either neutral or an ally.

Or alternatively if you want it to also damage neutral then do the opposite, heal if it's an ally and damage if it's not.


Something that could reduce lag a bit is to change
  • (Owner of PenanceCaster)
into a player variable,
  • set player variable PenancePlayer = Owner of PenanceCaster
that way it won't have to do that extra function in the loops


Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching ((((Matching unit) belongs to an enemy of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))

Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching (((PenanceTarget belongs to an ally of (Owner of PenanceCaster)) Equal to True) and (((Matching unit) is dead) Equal to False)))


Oh, and it should be
  • (Matching unit) belongs to an ally of (Owner of PenanceCaster)
not
  • (PenanceTarget belongs to an ally of (Owner of PenanceCaster)
in unit group filter
 
Level 9
Joined
Dec 16, 2017
Messages
343
My idea reduced the lag for the first and second casts, after that, it starts to lag again.. I will try the player thing you said now aswell
I am new to modding, it is better to store a variable all the time instead of using it raw(picked unit) etc.?

Later edit:
This is how the loop trigger looks now and still lags..could it be the spell that i order the dummy to cast?
  • PenanceLoop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set PenanceTargetPosition = (Position of PenanceTarget)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of PenanceCaster) Equal to (Order(channel))
          • PenanceCaster Not equal to No unit
          • PenanceTarget Not equal to No unit
          • (Life of PenanceCaster) Greater than 0.00
          • (Life of PenanceTarget) Greater than 0.00
          • (PenanceTarget is visible to (Owner of PenanceCaster)) Equal to True
          • (PenanceTarget is Magic Immune) Equal to False
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PenanceTarget belongs to an enemy of PenancePlayer) Equal to True
            • Then - Actions
              • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching (((Matching unit) is dead) Equal to False))
              • Unit Group - Pick every unit in PenanceGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
                  • Unit - Cause PenanceCaster to damage PenanceTarget, dealing PenanceDamage damage of attack type Magic and damage type Divine
                  • Special Effect - Create a special effect attached to the chest of PenanceTarget using Abilities\Weapons\BloodElfMissile\BloodElfMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set PenanceDuration = (PenanceDuration - 1)
            • Else - Actions
              • Set PenanceGroup = (Units within 30.00 of PenanceTargetPosition matching (((Matching unit) is dead) Equal to False))
              • Unit Group - Pick every unit in PenanceGroup and do (Actions)
                • Loop - Actions
                  • Unit - Order PenanceDummy to Neutral Alchemist - Acid Bomb PenanceTarget
                  • Unit - Set life of PenanceTarget to ((Life of PenanceTarget) + PenanceHeal)
                  • Special Effect - Create a special effect attached to the chest of PenanceTarget using Abilities\Weapons\FaerieDragonMissile\FaerieDragonMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set PenanceDuration = (PenanceDuration - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PenanceDuration Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_PenanceGroup)
      • Custom script: call RemoveLocation(udg_PenanceTargetPosition)
      • Custom script: call RemoveLocation(udg_PenanceCasterPosition)
Or is it maybe the way i do the duration of the spell? That i set directly a fixed value and i make it in loop to do fixed value - 1
And to turn off when it is 0?
Is it better if i just do fixed value +1 and when it hits 6 to stop?

I tried with value+1 and stop at 6, it's the same..
 
Last edited:
Level 12
Joined
Nov 3, 2013
Messages
989
I don't see a problem with the trigger, have you tried turning off all other triggers when testing to make sure that this is the trigger that cause lag?
 
Level 9
Joined
Dec 16, 2017
Messages
343
I don't see a problem with the trigger, have you tried turning off all other triggers when testing to make sure that this is the trigger that cause lag?
i haven't tried to turn off whole triggers in the map, but will try that tommorrow, without this spell,my map is clean of crashes,leaks and so on..as far as i know, i've implemented 2 systems in this version that i haven't tested yet with full house of players, but in solo or with comps,they are ok.

Later edit and problem solved:
I have found the lag maker, it is the acid bomb spell, seems that if it is looped, it laggs..
 
Last edited:
Status
Not open for further replies.
Top