( Leonardo Herrera: Push Code (for players)  )
Snippet Contributed by greerga on Wednesday August 12, @11:19PM, from the Commands dept.
Added Dec 8, 1997. Click the link below to read it or download it.
From: Leonardo Herrera <leherrer@ENTELCHILE.NET>
Subject: My Push command :)

Hum... here is my first contribution. I apologize for my english (I
think that I said that before :) ).

There is a push command. Please, somebody correct the messages, I wrote
this command in spanish... :)

(I used this in a circle bpl8, but just today I compiled a circle under
Windows 95, so I test this and... well, is just a beta version :) )

Push command - beta version 0.000000000000001
by Leonardo Herrera -
If you use this code, or find it useful, please drop me a mail.

(I put these in the act.offensive.c... and, how somebody here says,
Banzai!)

-------------------------------------
void log_push_to_death( struct char_data * ch, struct char_data *attacker)
{
  extern struct room_data *world;
  sprintf( buf, "%s pushed to Death Trap #%d (%s)", GET_NAME(ch),
           world[ch->in_room].number, world[ch->in_room].name);
  mudlog(buf, BRF, LVL_IMMORT, TRUE);
  sprintf(buf, "Pushed by %s", GET_NAME(attacker) );
  mudlog(buf, BRF, LVL_IMMORT, TRUE);
}

int perform_push(struct char_data *ch, int dir, int need_specials_check,
            struct char_data *attacker )
{
  extern char *dirs[];
  int was_in;
  int House_can_enter(struct char_data * ch, sh_int house);
  void death_cry(struct char_data * ch);
  int special(struct char_data *ch, int cmd, char *arg);

  if (need_specials_check && special(ch, dir + 1, ""))
    return 0;

  /* charmed? */
  if (IS_AFFECTED(ch, AFF_CHARM) && ch->master && ch->in_room == ch->master->in
_room) {
    send_to_char("The thought of leaving your master makes you weep.\r\n.\r\n",
 ch);
    act("$n burst into tears.", FALSE, ch, 0, 0, TO_ROOM);
    return 0;
  }

  if (IS_SET(ROOM_FLAGS(ch->in_room), ROOM_ATRIUM)) {
    if (!House_can_enter(ch, world[EXIT(ch, dir)->to_room].number)) {
      send_to_char("You are pushed, but you can''t tresspassing!\r\n",
       ch);
      return 0;
    }
  }
  if (IS_SET(ROOM_FLAGS(EXIT(ch, dir)->to_room), ROOM_TUNNEL) &&
      world[EXIT(ch, dir)->to_room].people != NULL) {
    send_to_char("You are pushed, but there isn''t enough room\r\n", ch);
    return 0;
  }
  sprintf(buf2, "$n is pushed to the %s by $N .",
          dirs[dir] );
  act(buf2, TRUE, ch, 0, attacker, TO_NOTVICT);
  was_in = ch->in_room;
  char_from_room(ch);
  char_to_room(ch, world[was_in].dir_option[dir]->to_room);

  if (!IS_AFFECTED(ch, AFF_SNEAK))
    act("$n fall rolling on the ground", TRUE, ch, 0, 0, TO_ROOM);

  if (ch->desc != NULL)
    look_at_room(ch, 0);

  if (IS_SET(ROOM_FLAGS(ch->in_room), ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT
)
  {
    log_push_to_death(ch, attacker);
    death_cry(ch);
    extract_char(ch);
    return 0;
  }
  return 1;
}


ACMD(do_push)
{
  char name[100], todir[256];
  int to;
  struct char_data *victim=NULL;
  extern char *dirs[];

  half_chop(argument, name, todir);
  if (!*name || !*todir)
    send_to_char("Push whom where?\r\n", ch);
  else if (!(victim = get_char_room_vis(ch, name)) )
    send_to_char("Nowhere by that name here.\r\n", ch);
  else if (ch == victim)
    send_to_char("But... can you walk?\r\n", ch);
  else if (IS_AFFECTED(ch, AFF_CHARM))
    send_to_char("No, no....\r\n", ch);
  else if ((to = search_block(todir, dirs, FALSE)) < 0) {
    send_to_char( "That is not a direction.\r\n", ch );
    return;
  } else {
    strcpy( todir, dirs[to] );
    if (GET_POS(victim) <= POS_SITTING ) {
      send_to_char( "You can''t push anybody while is lying on the ground", ch )
;
      return;
    }
    if (GET_POS(victim) == POS_FIGHTING) {
      sprintf( buf, "No! you can''t push %s while fighting!\r\n", HSSH(ch) );
      send_to_char( buf, ch );
      return;
    }
    sprintf(buf, "$n is trying to push you to the %s!", todir);
    act( buf, FALSE, ch, 0, victim, TO_VICT );
    act( "$n is trying to push $N", FALSE, ch, 0, victim, TO_NOTVICT);
    if (!CAN_GO( victim, to)) {
      sprintf( buf, "Can''t push %s there\r\n", HSSH(ch) );
      send_to_char( buf, ch );
    } else if ( GET_LEVEL(victim) >= LVL_IMMORT && GET_LEVEL(ch) != LVL_IMPL )
{
      send_to_char( "Oh, no, no, no.\r\n", ch );
      send_to_char( "Is trying to push you... what a mistake!\r\n", victim);
    } else if ( GET_LEVEL(victim) - GET_LEVEL(ch) > 4 ) {
      sprintf( buf, "You can''t push %s.\r\n", HMHR(victim) );
      send_to_char( buf, ch );
      sprintf( buf, "%s can''t push you.\r\n", GET_NAME(ch) );
      send_to_char( buf, victim );
    } else if ( MOB_FLAGGED(victim, MOB_NOBASH)) {
      send_to_char( "Ouch! Is too big for you!\r\n", ch );
    } else if ((dice(1,20)+3)-(GET_STR(ch)-GET_STR(victim)) < GET_STR(ch)) {
     /* You can balance the check above, this works fine for me */
      if (perform_push(victim, to, TRUE, ch)) {
        send_to_char( "Ciao, ciao!\r\n", ch);
        sprintf( buf, "%s has pushed you!", GET_NAME(ch) );
        send_to_char( buf, victim );
      }
    } else {
      send_to_char( "Oops... you fail.", ch );
      sprintf( buf, "%s fail.\r\n", HSSH(ch) );
      *buf = UPPER(*buf);
      send_to_char( buf, victim );
    }
  }
}



<< Soren P. Skou: Purify Spell | Reply | Threaded | Frollo (Added Jul 20, 1998): Quest Shops >>

 

Related Links
download
Related Articles
More by greerga
Features
This is the new CircleMUD News site. It is based off the Slashdot 0.2 Perl code and will resemble Slashdot.org site for awhile.
Quick Links
The CircleMUD home page Alex's Snippets