home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / d-linux.zip / dm-dist / act.offensive. < prev    next >
Text File  |  1991-03-01  |  10KB  |  415 lines

  1. /* ************************************************************************
  2. *  file: act.offensive.c , Implementation of commands.    Part of DIKUMUD *
  3. *  Usage : Offensive commands.                                            *
  4. *  Copyright (C) 1990, 1991 - see 'license.doc' for complete information. *
  5. ************************************************************************* */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. #include "structs.h"
  11. #include "utils.h"
  12. #include "comm.h"
  13. #include "interpreter.h"
  14. #include "handler.h"
  15. #include "db.h"
  16. #include "spells.h"
  17. #include "limits.h"
  18.  
  19. /* extern variables */
  20.  
  21. extern struct room_data *world;
  22. extern struct descriptor_data *descriptor_list;
  23. extern struct room_data *world;
  24.  
  25.  
  26. void raw_kill(struct char_data *ch);
  27.  
  28.  
  29. void do_hit(struct char_data *ch, char *argument, int cmd)
  30. {
  31.     char arg[MAX_STRING_LENGTH];
  32.     char buffer[MAX_STRING_LENGTH];
  33.     struct char_data *victim;
  34.  
  35.     one_argument(argument, arg);
  36.  
  37.     if (*arg) {
  38.         victim = get_char_room_vis(ch, arg);
  39.         if (victim) {
  40.             if (victim == ch) {
  41.                 send_to_char("You hit yourself..OUCH!.\n\r", ch);
  42.                 act("$n hits $mself, and says OUCH!", FALSE, ch, 0, victim, TO_ROOM);
  43.             } else {
  44.                 if (IS_AFFECTED(ch, AFF_CHARM) && (ch->master == victim)) {
  45.                     act("$N is just such a good friend, you simply can't hit $M.",
  46.                       FALSE, ch,0,victim,TO_CHAR);
  47.                     return;
  48.                 }
  49.                 if ((GET_POS(ch)==POSITION_STANDING) &&
  50.                     (victim != ch->specials.fighting)) {
  51.                     hit(ch, victim, TYPE_UNDEFINED);
  52.                     WAIT_STATE(ch, PULSE_VIOLENCE+2); /* HVORFOR DET?? */
  53.                 } else {
  54.                     send_to_char("You do the best you can!\n\r",ch);
  55.                 }
  56.             }
  57.         } else {
  58.             send_to_char("They aren't here.\n\r", ch);
  59.         }
  60.     } else {
  61.         send_to_char("Hit who?\n\r", ch);
  62.     }
  63. }
  64.  
  65.  
  66.  
  67. void do_kill(struct char_data *ch, char *argument, int cmd)
  68. {
  69.     static char arg[MAX_STRING_LENGTH];
  70.     char buf[70];
  71.     struct char_data *victim;
  72.  
  73.     if ((GET_LEVEL(ch) < 24) || IS_NPC(ch)) {
  74.         do_hit(ch, argument, 0);
  75.     return;
  76.     }
  77.  
  78.     one_argument(argument, arg);
  79.  
  80.     if (!*arg)
  81.     {
  82.         send_to_char("Kill who?\n\r", ch);
  83.     }
  84.     else
  85.     {
  86.         if (!(victim = get_char_room_vis(ch, arg)))
  87.            send_to_char("They aren't here.\n\r", ch);
  88.         else
  89.            if (ch == victim)
  90.           send_to_char("Your mother would be so sad.. :(\n\r", ch);
  91.            else {
  92.                 act("You chop $M to pieces! Ah! The blood!", FALSE, ch, 0, victim, TO_CHAR);
  93.                 act("$N chops you to pieces!", FALSE, victim, 0, ch, TO_CHAR);
  94.                 act("$n brutally slays $N", FALSE, ch, 0, victim, TO_NOTVICT);
  95.                 raw_kill(victim);
  96.             }
  97.     }
  98. }
  99.  
  100.  
  101.  
  102. void do_backstab(struct char_data *ch, char *argument, int cmd)
  103. {
  104.     struct char_data *victim;
  105.     char name[256];
  106.     byte percent;
  107.  
  108.     one_argument(argument, name);
  109.  
  110.     if (!(victim = get_char_room_vis(ch, name))) {
  111.         send_to_char("Backstab who?\n\r", ch);
  112.         return;
  113.     }
  114.  
  115.     if (victim == ch) {
  116.         send_to_char("How can you sneak up on yourself?\n\r", ch);
  117.         return;
  118.     }
  119.  
  120.     if (!ch->equipment[WIELD]) {
  121.         send_to_char("You need to wield a weapon, to make it a succes.\n\r",ch);
  122.         return;
  123.     }
  124.  
  125.     if (ch->equipment[WIELD]->obj_flags.value[3] != 11) {
  126.         send_to_char("Only piercing weapons can be used for backstabbing.\n\r",ch);
  127.         return;
  128.     }
  129.  
  130.     if (victim->specials.fighting) {
  131.         send_to_char("You can't backstab a fighting person, too alert!\n\r", ch);
  132.         return;
  133.     }
  134.  
  135.     percent=number(1,101); /* 101% is a complete failure */
  136.  
  137.     if (AWAKE(victim) && (percent > ch->skills[SKILL_BACKSTAB].learned))
  138.         damage(ch, victim, 0, SKILL_BACKSTAB);
  139.     else
  140.         hit(ch,victim,SKILL_BACKSTAB);
  141. }
  142.  
  143.  
  144.  
  145. void do_order(struct char_data *ch, char *argument, int cmd)
  146. {
  147.   char name[100], message[256];
  148.     char buf[256];
  149.     bool found = FALSE;
  150.     int org_room;
  151.     struct char_data *victim;
  152.     struct follow_type *k;
  153.  
  154.   half_chop(argument, name, message);
  155.  
  156.     if (!*name || !*message)
  157.         send_to_char("Order who to do what?\n\r", ch);
  158.     else if (!(victim = get_char_room_vis(ch, name)) &&
  159.              str_cmp("follower", name) && str_cmp("followers", name))
  160.             send_to_char("That person isn't here.\n\r", ch);
  161.     else if (ch == victim)
  162.         send_to_char("You obviously suffer from skitzofrenia.\n\r", ch);
  163.  
  164.     else {
  165.         if (IS_AFFECTED(ch, AFF_CHARM)) {
  166.             send_to_char("Your superior would not aprove of you giving orders.\n\r",ch);
  167.             return;
  168.         }
  169.  
  170.         if (victim) {
  171.             sprintf(buf, "$N orders you to '%s'", message);
  172.             act(buf, FALSE, victim, 0, ch, TO_CHAR);
  173.             act("$n gives $N an order.", FALSE, ch, 0, victim, TO_ROOM);
  174.  
  175.             if ( (victim->master!=ch) || !IS_AFFECTED(victim, AFF_CHARM) )
  176.                 act("$n has an indifferent look.", FALSE, victim, 0, 0, TO_ROOM);
  177.             else {
  178.                 send_to_char("Ok.\n\r", ch);
  179.                 command_interpreter(victim, message);
  180.             }
  181.         } else {  /* This is order "followers" */
  182.             sprintf(buf, "$n issues the order '%s'.", message);
  183.             act(buf, FALSE, ch, 0, victim, TO_ROOM);
  184.  
  185.             org_room = ch->in_room;
  186.  
  187.             for (k = ch->followers; k; k = k->next) {
  188.                 if (org_room == k->follower->in_room)
  189.                     if (IS_AFFECTED(k->follower, AFF_CHARM)) {
  190.                         found = TRUE;
  191.                         command_interpreter(k->follower, message);
  192.                     }
  193.             }
  194.             if (found)
  195.                 send_to_char("Ok.\n\r", ch);
  196.             else
  197.                 send_to_char("Nobody here are loyal subjects of yours!\n\r", ch);
  198.         }
  199.     }
  200. }
  201.  
  202.  
  203.  
  204. void do_flee(struct char_data *ch, char *argument, int cmd)
  205. {
  206.     int i, attempt, loose, die;
  207.  
  208.     void gain_exp(struct char_data *ch, int gain);
  209.     int special(struct char_data *ch, int cmd, char *arg);
  210.  
  211.     if (!(ch->specials.fighting)) {
  212.         for(i=0; i<6; i++) {
  213.             attempt = number(0, 5);  /* Select a random direction */
  214.             if (CAN_GO(ch, attempt) &&
  215.             !IS_SET(world[EXIT(ch, attempt)->to_room].room_flags, DEATH)) {
  216.                 act("$n panics, and attempts to flee.", TRUE, ch, 0, 0, TO_ROOM);
  217.                 if ((die = do_simple_move(ch, attempt, FALSE))== 1) {
  218.                     /* The escape has succeded */
  219.                     send_to_char("You flee head over heels.\n\r", ch);
  220.                 } else {
  221.                     if (!die) act("$n tries to flee, but is too exhausted!", TRUE, ch, 0, 0, TO_ROOM);
  222.                     return;
  223.                 }
  224.             }
  225.         } /* for */
  226.         /* No exits was found */
  227.         send_to_char("PANIC! You couldn't escape!\n\r", ch);
  228.         return;
  229.     }
  230.  
  231.     for(i=0; i<6; i++) {
  232.         attempt = number(0, 5);  /* Select a random direction */
  233.         if (CAN_GO(ch, attempt) &&
  234.            !IS_SET(world[EXIT(ch, attempt)->to_room].room_flags, DEATH)) {
  235.             act("$n panics, and attempts to flee.", TRUE, ch, 0, 0, TO_ROOM);
  236.             if ((die = do_simple_move(ch, attempt, FALSE))== 1) { 
  237.               /* The escape has succeded */
  238.                 loose = GET_MAX_HIT(ch->specials.fighting)-GET_HIT(ch->specials.fighting);
  239.                 loose *= GET_LEVEL(ch->specials.fighting);
  240.  
  241.                 if (!IS_NPC(ch))
  242.                     gain_exp(ch, -loose);
  243.  
  244.                 send_to_char("You flee head over heels.\n\r", ch);
  245.  
  246.                 /* Insert later when using huntig system        */
  247.                 /* ch->specials.fighting->specials.hunting = ch */
  248.  
  249.                 if (ch->specials.fighting->specials.fighting == ch)
  250.                     stop_fighting(ch->specials.fighting);
  251.                 stop_fighting(ch);
  252.                 return;
  253.             } else {
  254.                 if (!die) act("$n tries to flee, but is too exhausted!", TRUE, ch, 0, 0, TO_ROOM);
  255.                 return;
  256.             }
  257.         }
  258.     } /* for */
  259.  
  260.     /* No exits was found */
  261.     send_to_char("PANIC! You couldn't escape!\n\r", ch);
  262. }
  263.  
  264.  
  265.  
  266. void do_bash(struct char_data *ch, char *argument, int cmd)
  267. {
  268.     struct char_data *victim;
  269.     char name[256], buf[256];
  270.     byte percent;
  271.  
  272.     one_argument(argument, name);
  273.  
  274.     if (GET_CLASS(ch) != CLASS_WARRIOR) {
  275.         send_to_char("You better leave all the martial arts to fighters.\n\r", ch);
  276.         return;
  277.     }
  278.  
  279.     if (!(victim = get_char_room_vis(ch, name))) {
  280.         if (ch->specials.fighting) {
  281.             victim = ch->specials.fighting;
  282.         } else {
  283.             send_to_char("Bash who?\n\r", ch);
  284.             return;
  285.         }
  286.     }
  287.  
  288.  
  289.     if (victim == ch) {
  290.         send_to_char("Aren't we funny today...\n\r", ch);
  291.         return;
  292.     }
  293.  
  294.     if (!ch->equipment[WIELD]) {
  295.         send_to_char("You need to wield a weapon, to make it a success.\n\r",ch);
  296.         return;
  297.     }
  298.  
  299.     percent=number(1,101); /* 101% is a complete failure */
  300.  
  301.     if (percent > ch->skills[SKILL_BASH].learned) {
  302.         damage(ch, victim, 0, SKILL_BASH);
  303.         GET_POS(ch) = POSITION_SITTING;
  304.     } else {
  305.         damage(ch, victim, 1, SKILL_BASH);
  306.         GET_POS(victim) = POSITION_SITTING;
  307.         WAIT_STATE(victim, PULSE_VIOLENCE*2);
  308.     }
  309.     WAIT_STATE(ch, PULSE_VIOLENCE*2);
  310. }
  311.  
  312.  
  313.  
  314. void do_rescue(struct char_data *ch, char *argument, int cmd)
  315. {
  316.     struct char_data *victim, *tmp_ch;
  317.     int percent;
  318.     char victim_name[240];
  319.     char buf[240];
  320.  
  321.     one_argument(argument, victim_name);
  322.  
  323.     if (!(victim = get_char_room_vis(ch, victim_name))) {
  324.         send_to_char("Who do you want to rescue?\n\r", ch);
  325.         return;
  326.     }
  327.  
  328.     if (victim == ch) {
  329.         send_to_char("What about fleeing instead?\n\r", ch);
  330.         return;
  331.     }
  332.  
  333.     if (ch->specials.fighting == victim) {
  334.         send_to_char("How can you rescue someone you are trying to kill?\n\r",ch);
  335.         return;
  336.     }
  337.  
  338.     for (tmp_ch=world[ch->in_room].people; tmp_ch &&
  339.         (tmp_ch->specials.fighting != victim); tmp_ch=tmp_ch->next_in_room)  ;
  340.  
  341.     if (!tmp_ch) {
  342.         act("But nobody is fighting $M?", FALSE, ch, 0, victim, TO_CHAR);
  343.         return;
  344.     }
  345.  
  346.  
  347.     if (GET_CLASS(ch) != CLASS_WARRIOR)
  348.         send_to_char("But only true warriors can do this!", ch);
  349.     else {
  350.         percent=number(1,101); /* 101% is a complete failure */
  351.         if (percent > ch->skills[SKILL_RESCUE].learned) {
  352.             send_to_char("You fail the rescue.\n\r", ch);
  353.             return;
  354.         }
  355.  
  356.         send_to_char("Banzai! To the rescue...\n\r", ch);
  357.         act("You are rescued by $N, you are confused!", FALSE, victim, 0, ch, TO_CHAR);
  358.         act("$n heroically rescues $N.", FALSE, ch, 0, victim, TO_NOTVICT);
  359.  
  360.         if (victim->specials.fighting == tmp_ch)
  361.             stop_fighting(victim);
  362.         if (tmp_ch->specials.fighting)
  363.             stop_fighting(tmp_ch);
  364.         if (ch->specials.fighting)
  365.             stop_fighting(ch);
  366.  
  367.         set_fighting(ch, tmp_ch);
  368.         set_fighting(tmp_ch, ch);
  369.  
  370.         WAIT_STATE(victim, 2*PULSE_VIOLENCE);
  371.     }
  372.  
  373. }
  374.  
  375.  
  376.  
  377. void do_kick(struct char_data *ch, char *argument, int cmd)
  378. {
  379.     struct char_data *victim;
  380.     char name[256], buf[256];
  381.     byte percent;
  382.  
  383.  
  384.     if (GET_CLASS(ch) != CLASS_WARRIOR) {
  385.         send_to_char("You better leave all the martial arts to fighters.\n\r", ch);
  386.         return;
  387.     }
  388.  
  389.     one_argument(argument, name);
  390.  
  391.     if (!(victim = get_char_room_vis(ch, name))) {
  392.         if (ch->specials.fighting) {
  393.             victim = ch->specials.fighting;
  394.         } else {
  395.             send_to_char("Kick who?\n\r", ch);
  396.             return;
  397.         }
  398.     }
  399.  
  400.     if (victim == ch) {
  401.         send_to_char("Aren't we funny today...\n\r", ch);
  402.         return;
  403.     }
  404.  
  405.     percent=((10-(GET_AC(victim)/10))<<1) + number(1,101); /* 101% is a complete failure */
  406.  
  407.     if (percent > ch->skills[SKILL_KICK].learned) {
  408.         damage(ch, victim, 0, SKILL_KICK);
  409.     } else {
  410.         damage(ch, victim, GET_LEVEL(ch)>>1, SKILL_KICK);
  411.     }
  412.     WAIT_STATE(ch, PULSE_VIOLENCE*3);
  413. }
  414.  
  415.