YesNoOk
avatar

Setting var at intervals of damage by 100 (Read 732 times)

Started by Noctis, May 27, 2015, 06:52:15 am
Share this topic:
Setting var at intervals of damage by 100
New #1  May 27, 2015, 06:52:15 am
  • ****
  • Hey, I'm Grump!
    • USA
    • soldier.ucoz.net/
Put simply. I don't know how to code a var so that it increases by 1 for every 100 damage done to my opponent. I mean..I could code it through a very long process of "this equals that if this and if not, then it equals this and don't do this if that equals this otherwise this will happen and I won't work because that's how I roll and a persistent with a value of 0 will not stop me from adding numbers until I hit the F'ING MOON!!"
Rather, I have been doing just that but it's not working out for me. I always struggle with this type of situation of vars.

Any insight? How would I go about coding this?

(Youtube) (WIP) (Mediafire) (New Anime Shop) My Manga Reviews! Personal favorite Patreon! Check her out!

"There is nothing either good or bad, but thinking makes it so."
Last Edit: May 27, 2015, 08:27:39 pm by Noctis

GT

Re: Setting var at intervals of damage by 100
#2  May 27, 2015, 08:12:55 am
  • *****
    • USA
    • Skype - gt_ruby
This is what I have. Probably not optimized but w/e


Code:
[State -2, VarSet]
type = VarSet ; Reset the var
trigger1 = roundstate = [0,1]
v = 20
value = 0
ignorehitpause = 1

[State -2, VarAdd] ; Tracking the damage
type = VarAdd
trigger1 = numtarget
v = 20
value =  floor(target,gethitvar(damage)) 
ignorehitpause = 1 
;persistent = 0

[State -2, VarAdd]
type = VarSet
trigger1 = var(20) 
v = 21
;value = (floor(var(20))/100) * 100 ; This is the value divided and multiplied to return an interval of 100.
value = floor((var(20))/100) ; This is the value divided by 100 and then floored.
ignorehitpause = 1
persistent = 0

For every 100 dmg the var can increase by 1 or 100!
This doesn't work if the damage inflicted at one time is over 999! :grrr:
Yeah Titiln, in fact, You Made Him
Last Edit: May 27, 2015, 08:16:08 am by D.D. Yzan
Re: Setting var at intervals of damage by 100
#3  May 27, 2015, 03:51:41 pm
  • ****
  • Robotics Engineer
    • USA
    • altoiddealer@gmail.com
I have some comments!

-Just chiming in that (I'm 99.9% sure) the persistent parameter is useless in State -2.  It doesn't look like you are depending on it here, but just pointing it out.

-The code above will total all damage dealt, including damage dealt to helpers or multiple opponents in a team match.  If you need to differentiate between different opponents that would add a bit more complexity.

If you want to exclude damage dealt to helpers, I think you just need to add trigger1 = target,!IsHelper

Code:
[State -2, VarAdd] ; Tracking the damage
type = VarAdd
trigger1 = numtarget
trigger1 = target,!IsHelper
v = 20
value =  floor(target,gethitvar(damage)) 
ignorehitpause = 1

Re: Setting var at intervals of damage by 100
New #4  May 27, 2015, 04:57:33 pm
  • ****
  • Hey, I'm Grump!
    • USA
    • soldier.ucoz.net/
This is what I have. Probably not optimized but w/e


Code:
[State -2, VarSet]
type = VarSet ; Reset the var
trigger1 = roundstate = [0,1]
v = 20
value = 0
ignorehitpause = 1

[State -2, VarAdd] ; Tracking the damage
type = VarAdd
trigger1 = numtarget
v = 20
value =  floor(target,gethitvar(damage)) 
ignorehitpause = 1 
;persistent = 0

[State -2, VarAdd]
type = VarSet
trigger1 = var(20) 
v = 21
;value = (floor(var(20))/100) * 100 ; This is the value divided and multiplied to return an interval of 100.
value = floor((var(20))/100) ; This is the value divided by 100 and then floored.
ignorehitpause = 1
persistent = 0

For every 100 dmg the var can increase by 1 or 100!
This doesn't work if the damage inflicted at one time is over 999! :grrr:

You know its funny because I tried exactly this. I must not of paid close enough attention because my code was slightly different from this. I had it doing something like floor(var(8) / 100 + 0.5) * 1 or close to that. I was pretty exhausted at the time. I was just trying random things by that point. Regardless, you saved me a lot of pain, time and clarified that I already had the right idea. Thank you!

And also to altoiddealer. I always forget to include small details like that so I appreciate that as well. Thanks a lot.

I'll leave it unsolved as I have yet to try it out and see how I can make this code my own.
Okay I think I understand it as much as I'm going to, now. Thanks a lot once again!

(Youtube) (WIP) (Mediafire) (New Anime Shop) My Manga Reviews! Personal favorite Patreon! Check her out!

"There is nothing either good or bad, but thinking makes it so."
Last Edit: May 27, 2015, 08:27:25 pm by Noctis