Calculating saving throw in a DG script

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 2 weeks ago #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.


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
1 month 2 weeks ago - 1 month 2 weeks ago #8580 by Krell
Replied by Krell on topic Calculating saving throw in a DG script
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: 1 month 2 weeks ago by Krell.

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 2 weeks ago #8584 by Nero
Replied by Nero on topic Calculating saving throw in a DG script
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.
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
1 month 2 weeks ago #8585 by Krell
Replied by Krell on topic Calculating saving throw in a DG script
Your switch statement doesn't appear to be closed. This might not be the issue, but it certainly can't be good.
    end
    break
  default
    break
  *done <-- needed here 
end

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 2 weeks ago #8586 by Nero
Replied by Nero on topic Calculating saving throw in a DG script
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
1 month 2 weeks ago #8587 by Krell
Replied by Krell on topic Calculating saving throw in a DG script
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
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.

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 2 weeks ago #8588 by Nero
Replied by Nero on topic Calculating saving throw in a DG script
I thought by increasing adding switch random.5 it would decrease the likeliness of the strength drain being spammed by the mob as I don't want them casting it every round. Is that wrong, and is there a better way to do that?

This code may be what I am looking for though, I will test it out later.

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

More
1 month 2 weeks ago - 1 month 2 weeks ago #8589 by Krell
Replied by Krell on topic Calculating saving throw in a DG script

Nero wrote: I thought by increasing adding switch random.5 it would decrease the likeliness of the strength drain being spammed by the mob as I don't want them casting it every round. Is that wrong, and is there a better way to do that?


Actually, that makes perfect sense. So your mob will only have a 20% chance of using the spell. Got it.

Alternatively you could have a higher level if/else such as:

if (‰random.5 == 1)

But a switch statement works just as well.

This code may be what I am looking for though, I will test it out later.


Good luck.
Last edit: 1 month 2 weeks ago by Krell.

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
More
1 month 2 weeks ago - 1 month 2 weeks ago #8590 by Nero
Replied by Nero on topic Calculating saving throw in a DG script
Thanks,

Your above suggestion was, in a round about way, what I was looking for
set actor %self.fighting%
if (%already_fighting%)
  wait 6 secs
  unset already_fighting
else
  switch %random.3%
    case 1
if  (%actor.affect(CHARM)% || %actor.is_pc%)
    if (%actor.str% <= 14)
      %send% %actor% You resist the undead tree's attempt to draw the strength from your body.
      %echoaround% %actor% %actor.name% resists the undead tree's attempt to draw the strength from %actor.hisher% body.
    elseif (%actor.str% > 14)
      eval ss %actor.saving_spell%
        if (%ss% < 15)
                %send% %actor% %self.name% attempts to draw the strength from your body, but fails because you are already in a weakened state.
                %echoaround% %actor% %self.name% attempts to draw the strength from %actor.hisher% body, but %actor.heshe% is too frail to be weakened any further right now.
        elseif (%ss% >= 15)
          eval roll %random.100%
            if (%roll% >= 50)
                %send% %actor% You feel the undead tree draw the strength out of your body.
                %echoaround% %actor% %self.name% draws strength from %actor.name%'s body.
                dg_affect %actor% STR -1 5
            elseif (%roll% < 50)
                %send% %actor% You resist the undead tree's attempt to draw the strength from your body.
                %echoaround% %actor% %actor.name% resists the undead tree's attempt to draw the strength from %actor.hisher% body.
            else
                %send% %actor% You resist the undead tree's attempt to draw the strength from your body.
                %echoaround% %actor% %actor.name% resists the undead tree's attempt to draw the strength from %actor.hisher% body.
            end
        end
    end
end
    break
    default
    break
  done
  set already_fighting 1
  global already_fighting
end
Last edit: 1 month 2 weeks ago by Nero.

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

More
1 month 2 weeks ago #8591 by Krell
Replied by Krell on topic Calculating saving throw in a DG script

Nero wrote: Thanks,
Your above suggestion was, in a round about way, what I was looking for


Heh. Well I'm glad I was able to at least help guide you in the direction you needed to go. :)

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

Time to create page: 0.274 seconds