/* PK OFFICE * * This object simply adds and removes player killers * * v2.01 Angel, July 1996 * v1.01 Angel, Nov 1994 */ #include <mudlib.h> #include <linewrap.h> #include <living.cfg> #define SAVE_VILLANS "ob_saves/pk" /* do we save the villans on reboot? */ #define BOUNTY 1000 /* 1 gold is default bounty */ #define NAME (string)this_player()->query_name() /***************************************************************************** * Fn Prototypes */ void save_me(); void add_villan(string name, string victim, string crime); mapping villans; inherit ROOM; void reset(status arg) { if(arg) return; set_short("pk office"); set_weather(2, 2, 0); #ifdef SAVE_VILLANS restore_object(SAVE_VILLANS); #endif villans = ([ ]); } status query_villan(string name) { if(villans[name]) return 1; return 0; } int query_bounty(string name) { mixed *tmp; tmp = villans[name]; return tmp[0]; /* first element is bouty value */ } status query_victim(string killer, string victim) { mixed *tmp; if(!villans[killer]) return 0; tmp = villans[killer]; tmp = tmp[1]; /* array of victim names */ return (member_array(victim, tmp) == -1) ? 0 : 1; } mixed *query_victims(string name) { mixed *tmp; if(!villans[name]) return 0; tmp = villans[name]; return tmp[1]; } mixed *query_all_victims(string name) { return query_victims(name); } void remove_villan(string name) { villans = m_delete(villans, name); save_me(); } void add_villan(string name, string victim, string crime) { mixed *tmp, temp; int amount; if(!victim) victim = "the innocent"; if(!crime) crime = "terrible crimes!"; if(!query_villan(name)) villans += ([ name : ({ BOUNTY, ({ victim, }), ({ crime, }), }), ]); else { if(query_victim(name, victim)) { tmp = villans[name]; /* returns array value */ tmp = tmp[1]; /* the victims of 'name' */ tmp += ({ victim, }); temp = villans[name]; temp = temp[2]; temp += crime; amount = query_bounty(name); villans[name] = ({ amount, tmp, temp, }); } } save_me(); } void change_bounty(string name, int amount) { mixed *tmp, temp; if(!query_villan(name)) return; tmp = villans[name]; tmp = tmp[1]; /* all victims */ temp = villans[name]; temp = temp[2]; villans[name] = ({ (BOUNTY + amount), tmp, temp, }); save_me(); } mapping query_all_data() { return villans; } void save_me() { save_object(SAVE_VILLANS); } void init() { ::init(); add_action("pk_give", "give"); add_action("pk_sign", "read"); } status pk_sign(string str) { mixed *keys, *values; string tmp; int i; if(!str) { notify_fail("Read what?\n"); return 0; } if(str != "sign") { notify_fail("Read the sign?\n"); return 0; } keys = m_indices(villans); values = m_values(villans); write("Ille Coronos City Guards Office\n"+ "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); tmp = ""; /* initialise string */ for(i=0; i<sizeof(keys); i++) { tmp += "A reward of "+MONEY->convert(values[i][0])+" is offered for "; tmp += "the head of "+capitalize(keys[i])+", for "; tmp += implode(values[i][2], ", "); tmp += "\n"; writelw(tmp); tmp = ""; } return 1; } status pk_give(string str) { object ob; int amount; string tmp1, tmp2; string name; if(!present("curzon")) { write("There's no one present in the guard's office right now...\n"); return 1; } if(!(ob=present("head", this_player()))) { write("Curzon exclaims: You don't have a head to give me!\n"); return 1; } write("test: "+ob->short()+"\n"); name = (string)ob->query_alias_name(); if(!name) { write("Curzon asks: Why are you giving THAT to me?\n"); return 1; } if(!query_villan(name)) { write("Curzon says: But "+name+" is not a criminal.\n"); return 1; } write("You give "+ob->short()+" to Curzon.\n"); say(NAME+" gives "+ob->short()+" to Curzon.\n", this_player()); amount = query_bounty(name); write("Curzon says: Here is the reward money.\n"+ "Curzon gives you "+(string)MONEY->convert(amount)+".\n"); this_player()->add_money(amount); destruct(ob); this_player()->recalc_carry(); remove_villan(name); save_me(); return 1; }