#include "copyright.h"
#include "config.h"
#include "mudconf.h"
#include "db.h"
#include "interface.h"
#include "match.h"
#include "externs.h"
#include "alloc.h"
#include "attrs.h"
#include "powers.h"
#include "p.comsys.h"
Include dependency graph for rob.c:
Go to the source code of this file.
Functions | |
void | do_kill (dbref player, dbref cause, int key, char *what, char *costchar) |
static void | give_thing (dbref giver, dbref recipient, int key, char *what) |
static void | give_money (dbref giver, dbref recipient, int key, int amount) |
void | do_give (dbref player, dbref cause, int key, char *who, char *amnt) |
Definition at line 353 of file rob.c.
References AMBIGUOUS, give_money(), give_thing(), Guest, init_match(), is_number(), Long_Fingers, match_absolute(), match_me(), match_neighbor(), match_player(), match_possession(), match_result(), NOTHING, notify, and TYPE_PLAYER.
00354 { 00355 dbref recipient; 00356 00357 /* 00358 * check recipient 00359 */ 00360 00361 init_match(player, who, TYPE_PLAYER); 00362 match_neighbor(); 00363 match_possession(); 00364 match_me(); 00365 if(Long_Fingers(player)) { 00366 match_player(); 00367 match_absolute(); 00368 } 00369 recipient = match_result(); 00370 switch (recipient) { 00371 case NOTHING: 00372 notify(player, "Give to whom?"); 00373 return; 00374 case AMBIGUOUS: 00375 notify(player, "I don't know who you mean!"); 00376 return; 00377 } 00378 00379 if(Guest(recipient)) { 00380 notify(player, "Guest really doesn't need money or anything."); 00381 return; 00382 } 00383 if(is_number(amnt)) { 00384 give_money(player, recipient, key, atoi(amnt)); 00385 } else { 00386 give_thing(player, recipient, key, amnt); 00387 } 00388 }
Definition at line 19 of file rob.c.
References A_AKILL, A_KILL, A_OKILL, alloc_lbuf, AMBIGUOUS, controls, did_it(), divest_object(), free_lbuf, giveto(), halt_que(), Haven, HOME, init_match(), KILL_KILL, KILL_SLAY, confdata::killguarantee, confdata::killmax, confdata::killmin, Location, Long_Fingers, confdata::many_coins, match_absolute(), match_here(), match_me(), match_neighbor(), match_player(), match_result(), move_via_generic(), mudconf, Name(), NOTHING, notify, notify_printf(), notify_with_cause, Owner, payfor(), confdata::paylimit, Pennies(), Quiet, random, send_channel(), StringCopy, Suspect, TYPE_PLAYER, TYPE_THING, Typeof, Unkillable, and Wizard.
00020 { 00021 dbref victim; 00022 char *buf1, *buf2; 00023 int cost; 00024 00025 init_match(player, what, TYPE_PLAYER); 00026 match_neighbor(); 00027 match_me(); 00028 match_here(); 00029 if(Long_Fingers(player)) { 00030 match_player(); 00031 match_absolute(); 00032 } 00033 victim = match_result(); 00034 00035 switch (victim) { 00036 case NOTHING: 00037 notify(player, "I don't see that player here."); 00038 break; 00039 case AMBIGUOUS: 00040 notify(player, "I don't know who you mean!"); 00041 break; 00042 default: 00043 if((Typeof(victim) != TYPE_PLAYER) && (Typeof(victim) != TYPE_THING)) { 00044 notify(player, "Sorry, you can only kill players and things."); 00045 break; 00046 } 00047 if((Haven(Location(victim)) && !Wizard(player)) || 00048 (controls(victim, Location(victim)) && 00049 !controls(player, Location(victim))) || Unkillable(victim)) { 00050 notify(player, "Sorry."); 00051 break; 00052 } 00053 /* 00054 * go for it 00055 */ 00056 00057 cost = atoi(costchar); 00058 if(key == KILL_KILL) { 00059 if(cost < mudconf.killmin) 00060 cost = mudconf.killmin; 00061 if(cost > mudconf.killmax) 00062 cost = mudconf.killmax; 00063 00064 /* 00065 * see if it works 00066 */ 00067 00068 if(!payfor(player, cost)) { 00069 notify_printf(player, "You don't have enough %s.", 00070 mudconf.many_coins); 00071 return; 00072 } 00073 } else { 00074 cost = 0; 00075 } 00076 00077 if(!(((random() % mudconf.killguarantee) < cost) || 00078 (key == KILL_SLAY)) || Wizard(victim)) { 00079 00080 /* 00081 * Failure: notify player and victim only 00082 */ 00083 00084 notify(player, "Your murder attempt failed."); 00085 buf1 = alloc_lbuf("do_kill.failed"); 00086 sprintf(buf1, "%s tried to kill you!", Name(player)); 00087 notify_with_cause(victim, player, buf1); 00088 if(Suspect(player)) { 00089 StringCopy(buf1, Name(player)); 00090 if(player == Owner(player)) { 00091 send_channel("Suspect", "%s tried to kill %s(#%d).", buf1, 00092 Name(victim), victim); 00093 } else { 00094 buf2 = alloc_lbuf("do_kill.SUSP.failed"); 00095 StringCopy(buf2, Name(Owner(player))); 00096 send_channel("Suspect", 00097 "%s <via %s(#%d)> tried to kill %s(#%d).", 00098 buf2, buf1, player, Name(victim), victim); 00099 free_lbuf(buf2); 00100 } 00101 } 00102 free_lbuf(buf1); 00103 break; 00104 } 00105 /* 00106 * Success! You killed him 00107 */ 00108 00109 buf1 = alloc_lbuf("do_kill.succ.1"); 00110 buf2 = alloc_lbuf("do_kill.succ.2"); 00111 if(Suspect(player)) { 00112 StringCopy(buf1, Name(player)); 00113 if(player == Owner(player)) { 00114 send_channel("Suspect", "%s killed %s(#%d).", 00115 buf1, Name(victim), victim); 00116 } else { 00117 StringCopy(buf2, Name(Owner(player))); 00118 send_channel("Suspect", "%s <via %s(#%d)> killed %s(#%d).", 00119 buf2, buf1, player, Name(victim), victim); 00120 } 00121 } 00122 sprintf(buf1, "You killed %s!", Name(victim)); 00123 sprintf(buf2, "killed %s!", Name(victim)); 00124 if(Typeof(victim) != TYPE_PLAYER) 00125 if(halt_que(NOTHING, victim) > 0) 00126 if(!Quiet(victim)) 00127 notify(Owner(victim), "Halted."); 00128 did_it(player, victim, A_KILL, buf1, A_OKILL, buf2, A_AKILL, 00129 (char **) NULL, 0); 00130 00131 /* 00132 * notify victim 00133 */ 00134 00135 sprintf(buf1, "%s killed you!", Name(player)); 00136 notify_with_cause(victim, player, buf1); 00137 00138 /* 00139 * Pay off the bonus 00140 */ 00141 00142 if(key == KILL_KILL) { 00143 cost /= 2; /* 00144 * victim gets half 00145 */ 00146 if(Pennies(Owner(victim)) < mudconf.paylimit) { 00147 sprintf(buf1, "Your insurance policy pays %d %s.", cost, 00148 mudconf.many_coins); 00149 notify(victim, buf1); 00150 giveto(Owner(victim), cost); 00151 } else { 00152 notify(victim, "Your insurance policy has been revoked."); 00153 } 00154 } 00155 free_lbuf(buf1); 00156 free_lbuf(buf2); 00157 00158 /* 00159 * send him home 00160 */ 00161 00162 move_via_generic(victim, HOME, NOTHING, 0); 00163 divest_object(victim); 00164 break; 00165 } 00166 }
Definition at line 244 of file rob.c.
References A_APAY, A_COST, A_LUSE, A_OPAY, A_PAY, atr_pget(), could_doit(), did_it(), free_lbuf, GIVE_QUIET, giveto(), confdata::many_coins, mudconf, Name(), notify, notify_printf(), notify_with_cause, confdata::one_coin, payfor(), confdata::paylimit, Pennies(), Steal, tprintf(), TYPE_PLAYER, TYPE_THING, Typeof, and Wizard.
Referenced by do_give().
00245 { 00246 dbref aowner; 00247 int cost, aflags; 00248 char *str; 00249 00250 /* 00251 * do amount consistency check 00252 */ 00253 00254 if(amount < 0 && !Steal(giver)) { 00255 notify_printf(giver, 00256 "You look through your pockets. Nope, no negative %s.", 00257 mudconf.many_coins); 00258 return; 00259 } 00260 if(!amount) { 00261 notify_printf(giver, "You must specify a positive number of %s.", 00262 mudconf.many_coins); 00263 return; 00264 } 00265 if(!Wizard(giver)) { 00266 if((Typeof(recipient) == TYPE_PLAYER) && 00267 (Pennies(recipient) + amount > mudconf.paylimit)) { 00268 notify_printf(giver, "That player doesn't need that many %s!", 00269 mudconf.many_coins); 00270 return; 00271 } 00272 if(!could_doit(giver, recipient, A_LUSE)) { 00273 notify_printf(giver, "%s won't take your money.", 00274 Name(recipient)); 00275 return; 00276 } 00277 } 00278 /* 00279 * try to do the give 00280 */ 00281 00282 if(!payfor(giver, amount)) { 00283 notify_printf(giver, "You don't have that many %s to give!", 00284 mudconf.many_coins); 00285 return; 00286 } 00287 /* 00288 * Find out cost if an object 00289 */ 00290 00291 if(Typeof(recipient) == TYPE_THING) { 00292 str = atr_pget(recipient, A_COST, &aowner, &aflags); 00293 cost = atoi(str); 00294 free_lbuf(str); 00295 00296 /* 00297 * Can't afford it? 00298 */ 00299 00300 if(amount < cost) { 00301 notify(giver, "Feeling poor today?"); 00302 giveto(giver, amount); 00303 return; 00304 } 00305 /* 00306 * Negative cost 00307 */ 00308 00309 if(cost < 0) { 00310 return; 00311 } 00312 } else { 00313 cost = amount; 00314 } 00315 00316 if(!(key & GIVE_QUIET)) { 00317 if(amount == 1) { 00318 notify_printf(giver, "You give a %s to %s.", mudconf.one_coin, 00319 Name(recipient)); 00320 notify_with_cause(recipient, giver, 00321 tprintf("%s gives you a %s.", Name(giver), 00322 mudconf.one_coin)); 00323 } else { 00324 notify_printf(giver, "You give %d %s to %s.", amount, 00325 mudconf.many_coins, Name(recipient)); 00326 notify_with_cause(recipient, giver, 00327 tprintf("%s gives you %d %s.", Name(giver), 00328 amount, mudconf.many_coins)); 00329 } 00330 } 00331 /* 00332 * Report change given 00333 */ 00334 00335 if((amount - cost) == 1) { 00336 notify_printf(giver, "You get 1 %s in change.", mudconf.one_coin); 00337 giveto(giver, 1); 00338 } else if(amount != cost) { 00339 notify_printf(giver, "You get %d %s in change.", (amount - cost), 00340 mudconf.many_coins); 00341 giveto(giver, (amount - cost)); 00342 } 00343 /* 00344 * Transfer the money and run PAY attributes 00345 */ 00346 00347 giveto(recipient, cost); 00348 did_it(giver, recipient, A_PAY, NULL, A_OPAY, NULL, A_APAY, 00349 (char **) NULL, 0); 00350 return; 00351 }
Definition at line 173 of file rob.c.
References A_ADROP, A_AGFAIL, A_ARFAIL, A_ASUCC, A_DROP, A_GFAIL, A_LGIVE, A_LRECEIVE, A_ODROP, A_OGFAIL, A_ORFAIL, A_OSUCC, A_RFAIL, A_SUCC, alloc_lbuf, AMBIGUOUS, controls, could_doit(), did_it(), divest_object(), Enter_ok, free_lbuf, GIVE_QUIET, init_match(), match_me(), match_possession(), match_result(), move_via_generic(), Name(), NOTHING, notify, notify_with_cause, safe_chr, safe_str, StringCopy, tprintf(), TYPE_PLAYER, TYPE_THING, and Typeof.
Referenced by do_give().
00174 { 00175 dbref thing; 00176 char *str, *sp; 00177 00178 init_match(giver, what, TYPE_THING); 00179 match_possession(); 00180 match_me(); 00181 thing = match_result(); 00182 00183 switch (thing) { 00184 case NOTHING: 00185 notify(giver, "You don't have that!"); 00186 return; 00187 case AMBIGUOUS: 00188 notify(giver, "I don't know which you mean!"); 00189 return; 00190 } 00191 00192 if(thing == giver) { 00193 notify(giver, "You can't give yourself away!"); 00194 return; 00195 } 00196 if(((Typeof(thing) != TYPE_THING) && (Typeof(thing) != TYPE_PLAYER)) 00197 || !(Enter_ok(recipient) || controls(giver, recipient))) { 00198 notify(giver, "Permission denied."); 00199 return; 00200 } 00201 if(!could_doit(giver, thing, A_LGIVE)) { 00202 sp = str = alloc_lbuf("do_give.gfail"); 00203 safe_str((char *) "You can't give ", str, &sp); 00204 safe_str(Name(thing), str, &sp); 00205 safe_str((char *) " away.", str, &sp); 00206 *sp = '\0'; 00207 00208 did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL, A_AGFAIL, 00209 (char **) NULL, 0); 00210 free_lbuf(str); 00211 return; 00212 } 00213 if(!could_doit(thing, recipient, A_LRECEIVE)) { 00214 sp = str = alloc_lbuf("do_give.rfail"); 00215 safe_str(Name(recipient), str, &sp); 00216 safe_str((char *) " doesn't want ", str, &sp); 00217 safe_str(Name(thing), str, &sp); 00218 safe_chr('.', str, &sp); 00219 *sp = '\0'; 00220 00221 did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL, A_ARFAIL, 00222 (char **) NULL, 0); 00223 free_lbuf(str); 00224 return; 00225 } 00226 move_via_generic(thing, recipient, giver, 0); 00227 divest_object(thing); 00228 if(!(key & GIVE_QUIET)) { 00229 str = alloc_lbuf("do_give.thing.ok"); 00230 StringCopy(str, Name(giver)); 00231 notify_with_cause(recipient, giver, tprintf("%s gave you %s.", str, 00232 Name(thing))); 00233 notify(giver, "Given."); 00234 notify_with_cause(thing, giver, tprintf("%s gave you to %s.", str, 00235 Name(recipient))); 00236 free_lbuf(str); 00237 } 00238 did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP, 00239 (char **) NULL, 0); 00240 did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC, 00241 (char **) NULL, 0); 00242 }