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.
#Creating Conditional Damage Modifiers
1 messages · Page 1 of 1 (latest)
yo
wsp man
You wat to make it so dmg it higher when low hp?
yeah but Im also making a lot of other conditional cards
so somthing customizable would be nice
** You are now Level 2! **
the ones in the original post are good examples
And only while the person is low hp does the dmg go higher
yes?
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.
One letter variables were actually geeked
im too tired to do this shit properly 😭
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
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
Hum.HealthChanged:Connect
i mean for all the cards though
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
yeah i guess so
this game sucks to make man it better be good 😭
thanks for the tips 💯
No prob gang pursuit your developer dreams - Kleb Apple out
I recommend on doing a dictionary of what each effects does, so for example
local effectsFuncs = {
["General Dmg Add"] = function() ...
-- OR (more scalability of using separate modules)
["General Dmg Add"] = require(script.GeneralDmgAdd)
}```
and then just get it
```lua
local effectFunc = effectsFuncs[k]
effectFunc()
that works for simpler ones, but again for conditional ones and especially cards that depend on outside factors such as the target it doesnt seem to work
wdym for simpler ones?
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...
yk that really does sound like it would work 😭
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
well you can do the same for this
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
first of all put all ur effects in a table/dictionary
and for ur specific case of more dmg when hp low
oh wait u did a module
thats probably fine
well this depends on how the card works
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
handle damage through a module script
then you can do something like
if ConditionIfTheyHaveLowHp then
damage *= 1.25
end
DealDamage(target,damage)
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.
this specific section is kinda a wave-based bullet hell
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
