Stun Skill [by Ryan Stapleton]
Snippet Posted Wednesday, August 12th @ 11:37:39 PM, by George Greer in the Skills dept.
Added Jul 6, 1998. Click the link below to read it or download it.

From: Ryan Stapleton <raal@penn.com>
Subject: stun skill

Here is my stun code.  I use it for a Ranger on my mud.
you must include AFF_STUN in structs.h in the AFF section.

in update_pos in fight.c  you need to add a test for stun.
Mine looks like this.


void update_pos(struct char_data * victim)
{
  if (  ( (GET_HIT(victim) > 0) && (GET_POS(victim) > POS_STUNNED) ) )
    return;
  else if ( ( IS_AFFECTED(victim, AFF_STUN)) && ( GET_HIT(victim) > 0 ) ) {
    GET_POS(victim) = POS_STUNNED;
    return;
  } else if (GET_HIT(victim) > 0)
    GET_POS(victim) = POS_STANDING;
  else if (GET_HIT(victim) <= -11)
    GET_POS(victim) = POS_DEAD;
  else if (GET_HIT(victim) <= -6)
    GET_POS(victim) = POS_MORTALLYW;
...


I hope this helps, if there are any problems please let me know.
raal@penn.com

Here is my stun code.


ACMD(do_stun)
{
  struct char_data *vict;
  struct affected_type af;
  int diff_lev, percent, prob;
  int chance;

  one_argument(argument, arg);
  log ("do_stun\r\n");

  if (!GET_SKILL(ch, SKILL_STUN) ) {
    send_to_char("You do not know this skill.\r\n", ch);
  } else  if (!*arg) {
    send_to_char("Stun who?\r\n", ch);
  } else if (!(vict = get_char_room_vis(ch, arg))) {
    send_to_char("They don't seem to be here.\r\n", ch);
  } else if ( ! IS_NPC(vict) ){
    send_to_char("You can not attack another PC.\r\n", ch);
  } else if (vict == ch) {
    send_to_char("You Stun yourself...OUCH!.\r\n", ch);
    act("$n tries to stun $mself, and says OUCH!", FALSE, ch, 0, vict, TO_ROOM)
;
  } else if (IS_AFFECTED(ch, AFF_CHARM) && (ch->master == vict)) {
    act("$N is just such a good friend, you simply can't stun $M.", FALSE, ch,
0, vict, TO_CHAR);
  } else if (ROOM_FLAGGED(ch->in_room, ROOM_PEACEFUL)) {
    send_to_char("This room just has such a peaceful, easy feeling...\r\n", ch)
;
  } else if ( ! (GET_MOVE(ch) >= 10) ) {
    send_to_char("I am sorry, but you seem to tired to try to do that.\r\n", ch
);
  } else {
    percent = number(1, 101);   /* 101% is a complete failure */
    prob = GET_SKILL(ch, SKILL_STUN);

    if ( percent < prob ) {
      GET_MOVE(ch) -= 10;
      diff_lev = GET_LEVEL(vict) - GET_LEVEL(ch);

      chance = 33 - (diff_lev ) ;

      if (chance > 100)
        chance = 100;

      chance -= GET_DEX(vict);
      percent = number(1, 101);

      if ( chance > percent ) {
        af.bitvector = AFF_STUN;
        af.duration = 0;
        affect_to_char(vict, &af);

        stop_fighting(vict);
        GET_POS(vict) = POS_STUNNED;

        act("You stun $N.", FALSE, ch, 0, vict, TO_CHAR);
        act("$n stuns $N.", TRUE, ch, 0, vict, TO_NOTVICT);
        act("$n stuns you.", TRUE, ch, 0, ch->master, TO_VICT);

      } else {
        send_to_char("You Fail to stun.\r\n", ch);
        if ( number(1,101) <= 1) {
          if (GET_LEVEL(ch) < LVL_IMMORT) {
            send_to_char("Oops, You stuned your self.\r\n", ch);
            af.bitvector = AFF_STUN;
            af.duration = 0;
            affect_to_char(ch, &af);
            GET_POS(ch) = POS_STUNNED;
          }
        }
      }

    } else {
      send_to_char("You Fail to stun him.\r\n", ch);
      if ( number(1,101) <= 1) {
        if (GET_LEVEL(ch) < LVL_IMMORT) {
          send_to_char("Oops, You stuned your self.\r\n", ch);
          af.bitvector = AFF_STUN;
          af.duration = 0;
          affect_to_char(ch, &af);
          GET_POS(ch) = POS_STUNNED;
        }
      }
    }
    hit(ch, vict, TYPE_UNDEFINED);
    WAIT_STATE(ch, PULSE_VIOLENCE * 4);
  }

}


<< Spring Creation Spell [by Chuck Carson] | Reply | View as text | Threaded | Summon Mob Spell [by Fili] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.