Set damage based on two stats

DragonBlade

Member
Reaction score
0
Hi,
I am trying to make a trigger that sets the damage of an unit based on Agility and Intelect. Something like this:
Current DMG: 5
Int: 10
Agi: 14
Adding DMG: (10+14)/2
New DMG: 17
I know how to add the damage, but I don't know how to stop the trigger from adding to much damage, or to little

And I need the damage to change when the stats are changing too.
Here is how I think it needs to be but i don't know at the loop from X to Y
Code:
Events
  Unit - A unit Gains a level
  Conditions
  Actions
  Set DmgHeroes = (((Agility of (Triggering unit) (Include bonuses)) + (Intelligence of (Triggering unit) (Include bonuses))) / 2)
  For each (Integer A) from ?? to ??, do (Actions)
  Loop - Actions
  Unit - Add +1 Dmg  to (Triggering unit)
  Unit - Increase level of +1 Dmg  for (Triggering unit)
  Unit - Remove +1 Dmg  from (Triggering unit)
PS: I tried to use [noparse][/noparse], but it didn't work
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Can the attributes ever be decreased or do they only grow?
If they can only grow then the solution is trivial, keep count of the attack bonuses you have already added to a unit and only add as much as is needed when the attributes change.
If they can also decrease somehow then you need to have a mirrored ability to decrease attack damage (abusing the same glitch) and set the damage according to the difference between total atk bonus given and current current attributes.


To keep track of bonuses given so far you can either use an array, if your system is MPI, or a hashtable for a MUI system.
 

DragonBlade

Member
Reaction score
0
Is correct this way?
Trigger:
  • Test
    • Events
      • Unit - A unit enters (Playable map area)
      • Unit - A unit Gains a level
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to User
    • Actions
      • For each (Integer A) from 1 to 16, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Human Novice
            • Then - Actions
              • Set DmgHeroes[(Integer A)] = ((Intelligence of (Triggering unit) (Include bonuses))+ Agility)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DmgHeroes[(Integer A)] Greater than OldDamageHeroes[(Integer A)]
                • Then - Actions
                  • For each (Integer A) from 1 to New-OldDamageHeroes[(Integer A)], do (Actions)
                    • Loop - Actions
                      • Unit - Add +1 Dmg to (Triggering unit)
                      • Unit - Increase level of +1 Dmg for (Triggering unit)
                      • Unit - Remove +1 Dmg from (Triggering unit)
                    • Else - Actions
                      • For each (Integer A) from 1 to Old-NewDamageHeroes[(Integer A)], do (Actions)
                        • Loop - Actions
                          • Unit - Add -1 Dmg to (Triggering unit)
                          • Unit - Increase level of -1 Dmg for (Triggering unit)
                          • Unit - Remove -1 Dmg from (Triggering unit)
            • Else - Actions
        • Set OldDamageHeroes[(Integer A)] = DmgHeroes[(Integer A)]
 

jonas

You can change this now in User CP.
Reaction score
67
No, you are looping twice with integer A. You need to use a different index for each nested loop.
 
Last edited:

vypur85

Hibernate
Reaction score
803
You can try using 'Set Damage' which can be found in my signature below.
Check out how to use the snippet and implement it to your map.
Then for your case, try using the below trigger:
Trigger:
  • Some trigger
    • Events
      • Unit - A unit enters (Playable map area)
      • Unit - A unit Gains a level
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to User
    • Actions
      • Set Int_DamageSys_SETdamage = 12 <-- This will be the amount of damage based on your calculations
      • Set Unit_DamageSys_Unit = (Triggering unit)
      • Trigger - Run Damage System <gen> (checking conditions)
 

kingkwong92

Well-Known Member
Reaction score
25
I recommend adding a periodic timer every few seconds just to make sure the damage is set correctly as there maybe other ways that your attributes increase or decrease. I assume there wont be that many Heroes on the map like that so you could add when the unit attacks as well.
 

DragonBlade

Member
Reaction score
0
@vypur85: I have tried your system, I have put the Set Int_DamageSys_SETdamage = Int(+bonus)
But, I have a problem, the damage is ok when the unit enters the map, when picking up multiple items, but when that unit drops the items is perfect until the last item, when it drops the damage remains the same
Starting int: 5
Starting damage: 5(base) + 5
Pick up first item: +5 int
Curent int: 5+5
Curent dmg: 5 + 10
Drop item: int: 5 and dmg still: 5+10

@kingkwing92 I have 10 heroes in the map, one for each player, and I want to change the HP, Mana, Dmg, Attack Speed dependent of Agi/Int/Str and different for every type unit(the reason I don't use the gameplay constants
If I use a periodic timer for every player(having them different or not type units), won't the triggers reduce the FPS on the map?
 

vypur85

Hibernate
Reaction score
803
Go with the periodic method. Add 10 heroes to a unitgroup when they enter the map, and then run every second.
Pretty sure you know how to do the triggering.
Running every 1 second should be fine for the game. Since there is no SFX or intense action. Only changing the ability level.

On a related note, try posting your most current trigger. Just in case.
 

DragonBlade

Member
Reaction score
0
If I go with the periodic method I don't have the problem with the remaining damage
Here is the last trigger:
Trigger:
  • Damage Human
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set DmgHeroes[(Integer A)] = ((Intelligence of Heroes[(Integer A)] (Include bonuses)) x 2)
          • Set Int_DamageSys_SETdamage = DmgHeroes[(Integer A)]
          • Set Unit_DamageSys_Unit = Heroes[(Integer A)]
          • Trigger - Run Damage System <gen> (checking conditions)

Your system can be used for others stats such as HP, Mana, Attack Speed? I tried to change the spells from Dmg to HP, and nothing happens
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top