/* $Header: /u1b/games/TINYMUCK/development/src/RCS/rob.c,v 1.2 1992/02/15 20:51:12 games Exp $ */ /* * $Log: rob.c,v $ * Revision 1.2 1992/02/15 20:51:12 games * REAL initial checkin * * Revision 1.1 92/02/15 23:03:24 awozniak * Initial revision * */ /* rob and kill */ /* This software is Copyright 1989, 1990, 1992, 1993 by various individuals. Please see the accompanying file COPYRIGHT for details. */ #include "db.h" #include "match.h" #include "money.h" #include "config.h" #include "params.h" #include "random.h" #include "externs.h" #include "interface.h" void do_rob(dbref player, const char *what) { dbref thing; char buf[BUFFER_LEN]; struct match_data md; SERIAL playser; SERIAL thingser; init_match(player,what,TYPE_PLAYER,&md); match_neighbor(&md); match_me(&md); if (Royalty(player)) { match_absolute(&md); match_player(&md); } thing = match_result(&md); switch (thing) { case NOTHING: notify(player,"Rob whom?"); break; case AMBIGUOUS: notify(player,"I don't know whom you mean!"); break; default: playser = DBFETCH(player)->serial; thingser = DBFETCH(thing)->serial; if (Typeof(thing) != TYPE_PLAYER) { notify(player,"Sorry, you can only rob other players."); } else if (DBFETCH(thing)->sp.player.pennies < 1) { sprintf(buf,OUT_MON,NAME(thing)); /* money.h */ notify(player,buf); sprintf(buf,OUT_YOU,NAME(player)); /* money.h */ notify(thing,buf); } else if (can_doit(player,thing,"Your conscience tells you not to.")) { /* steal a penny */ if ( (DBFETCH(player)->serial != playser) || (DBFETCH(thing)->serial != thingser) ) return; add_pennies(player,1,"rob %s",NAME(thing)); add_pennies(thing,-1,"rob %s",NAME(player)); notify(player,STOLE); /* defined in money.h */ sprintf(buf,STOLE_Y,NAME(player)); /* defined in money.h */ notify(thing,buf); } break; } } void do_kill(dbref player, const char *what, int cost) { dbref victim; char buf[BUFFER_LEN]; struct match_data md; init_match(player,what,TYPE_PLAYER,&md); match_neighbor(&md); match_me(&md); if (Royalty(player)) { match_player(&md); match_absolute(&md); } victim = match_result(&md); switch (victim) { case NOTHING: notify(player,"I don't see that player here."); break; case AMBIGUOUS: notify(player,"I don't know who you mean!"); break; default: if (Typeof(victim) != TYPE_PLAYER) { notify(player,"Sorry, you can only kill other players."); } else { /* go for it */ /* set cost */ if (cost < KILL_MIN_COST) cost = KILL_MIN_COST; if (FLAGS(DBFETCH(player)->location) & HAVEN) { notify(player,"You can't kill anyone here!"); break; } /* see if it works */ if (!payfor(player,cost,"kill %s",NAME(victim))) { notify(player,OUT_ERR); /* defined in money.h */ } else if (((int)rnd(KILL_BASE_COST) < cost) && !Wizard(victim)) { /* success! */ if (DBFETCH(victim)->drop_message != NOSTR) { /* give him the drop message */ notify_str(player,DBFETCH(victim)->drop_message); } else { sprintf(buf,"You killed %s!",NAME(victim)); notify(player,buf); } /* now notify everybody else */ if (DBFETCH(victim)->odrop != NOSTR) { sprintf(buf,"%s killed %s! %s",NAME(player),NAME(victim),pronoun_substitute_str(player,DBFETCH(victim)->odrop)); } else { sprintf(buf,"%s killed %s!",NAME(player),NAME(victim)); } notify_except(player,DBFETCH(player)->location,player,buf); /* maybe pay off the bonus */ #ifdef MAX_PENNIES if (DBFETCH(victim)->sp.player.pennies < MAX_PENNIES) #endif { sprintf(buf,INSUR,KILL_BONUS); /* money.h */ notify(victim,buf); add_pennies(victim,KILL_BONUS,"kill"); } #ifdef MAX_PENNIES else { notify(victim,"Your insurance policy has been revoked."); } #endif send_home(victim); } else { /* notify player and victim only */ notify(player,"Your murder attempt failed."); sprintf(buf,"%s tried to kill you!",NAME(player)); notify(victim,buf); } break; } break; } } void do_give(dbref player, const char *recipient, int amount) { dbref who; char buf[BUFFER_LEN]; struct match_data md; /* do amount consistency check */ if(amount < 0 && !Wizard(player)) { notify(player, "Try using the \"rob\" command."); return; } else if(amount == 0) { notify(player, POS_ERR ); /* defined in money.h */ return; } /* check recipient */ init_match(player, recipient, TYPE_PLAYER, &md); match_neighbor(&md); match_me(&md); if(Royalty(player)) { match_player(&md); match_absolute(&md); } switch(who = match_result(&md)) { case NOTHING: notify(player, "Give to whom?"); return; case AMBIGUOUS: notify(player, "I don't know who you mean!"); return; default: if(!Wizard(player)) { if(Typeof(who) != TYPE_PLAYER) { notify(player, "You can only give to other players."); return; } #ifdef MAX_PENNIES else if (DBFETCH(who)->sp.player.pennies + amount > MAX_PENNIES) { notify(player, OVER_ERR ); /* defined in money.h */ return; } #endif } break; } /* try to do the give */ if(!payfor(player,amount,"give %s",NAME(who))) { notify(player, UNDR_ERR ); /* defined in money.h */ } else { /* he can do it */ switch(Typeof(who)) { case TYPE_PLAYER: add_pennies(who,amount,"%s give",NAME(player)); sprintf(buf, "You give %d %s to %s.", amount, amount == 1 ? PLUR_TRI, /* defined in money.h */ NAME(who)); notify(player, buf); sprintf(buf, "%s gives you %d %s.", NAME(player), amount, amount == 1 ? PLUR_TRI ); /* defined in money.h */ notify(who, buf); break; case TYPE_THING: DBFETCH(who)->sp.thing.value += amount; sprintf(buf, "You change the value of %s to %d %s.", NAME(who), DBFETCH(who)->sp.thing.value, DBFETCH(who)->sp.thing.value == 1 ? PLUR_TRI); /* money.h */ notify(player, buf); break; default: notify(player, GIV_ERR ); /* defined in money.h */ break; } DBDIRTY(who); } }