#Creating Conditional Damage Modifiers

1 messages · Page 1 of 1 (latest)

tall plover
#

I have a card system, and while simple speed increases are easy enough, I'm having trouble with more complex ones, like a card that makes you do more damage when you're low health, or every 3rd dodge gives you HP. Should I add a folder in Replicated Storage for them with scripts attached? I'm really not sure. First ss is how I'm storing the cards in a ModuleScript, second is how I'm trying to apply them to the character.

runic jasper
#

👋

#

@tall plover

tall plover
#

yo

tall plover
runic jasper
tall plover
#

yeah but Im also making a lot of other conditional cards

#

so somthing customizable would be nice

runic jasper
#

conditional cards?

soft cosmosBOT
#

studio** You are now Level 2! **studio

tall plover
#

the ones in the original post are good examples

runic jasper
#

And only while the person is low hp does the dmg go higher

tall plover
#

yes?

runic jasper
#

Are you doing a attribute value on the character? if so then just make it go to the higher value you want while the hp is higher in a while loop and go back to base value if its higher then the low hp you picked.

weak cypress
#

One letter variables were actually geeked

tall plover
weak cypress
#

Damage = (Health / 100) * Damage— returns a percentage value
This decreases damage with less health, to increase do
Damage = (100 / Health) * Damage

#

That should do you well

#

Interchange 100 with him.MaxHealth

tall plover
#

so when I write that script out, how would I apply it to the player? I'm thinking just to make a script with a function for every card in the game but I'm not sure if its efficient

weak cypress
#

Hum.HealthChanged:Connect

tall plover
#

i mean for all the cards though

weak cypress
#

You should do Damage = (MaxHealth / CurrentHealth + 1) * Damage

#

All cards you should have one script with all the nessecary connections

#

Most cards you won’t have to connect

#
  • card Every 5 hits cause an explosion
    you would go in your damage script and detect when it’s their 5th hit and cause the explosion to happen
#

It’s easier to plan out how you will make it work before doing it

tall plover
#

yeah i guess so

#

this game sucks to make man it better be good 😭

#

thanks for the tips 💯

weak cypress
#

No prob gang pursuit your developer dreams - Kleb Apple out

grave ginkgo
tall plover
grave ginkgo
#

that works with anything

#

if you want that when you make damage you make the damage depending on their health you can handle it in the way you want, for example a boolvalue inside a player, when you damage, you check if it's true, if it is deal this X damage...

tall plover
#

I have that exact script, for example for every time the player hits smth i check if it has the Vigor Instance, if it's true it does X more damage

grave ginkgo
#

well you can do the same for this

tall plover
#

I'm going to the exact script where it should be, nothing should be wrong, but it doesnt find it

#

I even paste the code into a different script and it works

stiff lichen
#

and for ur specific case of more dmg when hp low

#

oh wait u did a module

#

thats probably fine

stiff lichen
#

and what kind of game this is

#

generally speaking though you could take the difference of ur max health and current health of the player

#

and then add that to the strength strat

#

and then multiply by whatever depending on

#

how you want it tow ork

#

actually let me make this more scaleable/useable

#

local MaxHealth = 100
local basestrength = 5
local ModifierOutputOfThisFunction = 0
local DamageModifierAdditive = ModifierOutputOfThisFunction + whatever other functions you have
local strength = basestrength + DamageModifierAdditive

function damagemodifierthing()
if attack or whatever makes u lose hp== true then
local CurrentHealthDifference = MaxHealth-humanoid.health
ModifierOutputOfThisFunction = basestrength + CurrentHealthDifference
return ModifierOutputOfThisFunction
end
end

oh and then run the function somewhere

sorry i got busy but something of this general pattern culd work

shy mulch
#

handle damage through a module script

#

then you can do something like
if ConditionIfTheyHaveLowHp then
damage *= 1.25
end
DealDamage(target,damage)

quick flame
#

Have a card module script and within the card module script have folders for cards based on what system they customize. For example if you have a card active that customizes the damage then store it within a table that is for cards that only customize the damage system. Within your module script/system that handles damage call the card module script for that specific folder and your card module script should call all of the active cards that relate to the damage system.

#

The active cards that are stored when called either do something or returns a value, so basically store them as methods.

shy mulch
tall plover
#

for some reason when I checked if the card was present in ldr.Cards it would always show me zero, but when I swapped from using folders to boolValues it worked out

#

so now whenever the plr does damage i just check if the boolValue is true