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,463
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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top