Welcome to the Builder Academy

Question Calculating saving throw in a DG script

More
23 Feb 2020 00:40 #8576 by Nero
Trying to have a mob apply a strength debuff but first I want it to calculate the saving throw and level of a player..the greater the level/saving throw, the less chance it has of actually applying the debuff. For some reason it just keeps failing to apply the debuff and giving me my fail message. Not sure how to fix this.


Code:
set actor %self.fighting% if (%already_fighting%) wait 6 secs unset already_fighting else switch %random.3% case 1 if (%target.affect(CHARM)% || %target.is_pc%) eval ss %target.saving_spell% if %random.150% > %ss% %send% %actor% You feel the undead tree draw the strength out of your body. %actor.str% %randomizer% %target.saving_spell% else end dg_affect %target% STR -1 on 5 else %send% %actor% You resist the undead tree's attempt to draw the strength from your body. %actor.str% %randomizer% %target.saving_spell% else end break default break done set already_fighting 1 global already_fighting end

Please Log in or Create an account to join the conversation.

More
23 Feb 2020 17:38 - 23 Feb 2020 17:59 #8580 by krell
What exactly is the error message?

As for the script, I'll have to think it over some more, but one thing I've noticed is that you unset the global variable. I don't recall there's a better way to do that? I'll look into it and let you know if I think of anything.

Addendum:

Shouldn't you use %actor.varexists(variable)% on your targeted victim when using globals?
Last edit: 23 Feb 2020 17:59 by krell.

Please Log in or Create an account to join the conversation.

More
24 Feb 2020 09:19 #8584 by Nero
I've been playing around with it and have it somewhat solved
My only problem is trying to figure out how to make this where the affect considers the players level/saving throw to determine if the affect lands or they resist.
As of right now it always lands and removes the target's strength.
Code:
set actor %self.fighting% if (%actor.affect(CHARM)% || %actor.is_pc%) switch %random.5% case 1 wait 7s eval ss %actor.saving_spell% if (%random.100%-(%ss%)>=0) %send% %actor% You feel the undead tree draw the strength out of your body. dg_affect %actor% STR -1 5 else %send% %actor% You resist the undead tree's attempt to draw the strength from your body. end break default break end

Please Log in or Create an account to join the conversation.

More
24 Feb 2020 12:04 #8585 by krell
Your switch statement doesn't appear to be closed. This might not be the issue, but it certainly can't be good.
Code:
end break default break *done <-- needed here end

Please Log in or Create an account to join the conversation.

More
25 Feb 2020 09:36 #8586 by Nero
Thanks, I corrected that. I am still struggling to figure out how to balance this. As the player's level goes up, the saving spell goes down. So trying to figure out a logical way to code this that allows a higher level player more chance to resist the mobs affect.

Please Log in or Create an account to join the conversation.

More
25 Feb 2020 11:45 #8587 by krell
What's the point of your switch statement? Are you hoping to have other effects besides strength reduction?

Couldn't you have a series of if/elseif statements for different calculations of your random value versus saving throw?

ie
Code:
set drain_str %random.100% if (%drain_str% - %ss% <= 100) && (%drain_str% - %ss% > 90) * do something elseif (%drain_str% - %ss% <= 90) && (%drain_str% - %ss% > 80) * do something else elseif (%drain_str% - %ss% <= 80) && (%drain_str% - %ss% > 70) *do another thing ... elseif (%drain_strain% - %ss% <= 10) && (%drain_str% - %ss% >= 0) *do final thing else *message character of failed attack end.

Please Log in or Create an account to join the conversation.

Time to create page: 0.267 seconds