MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // Aenderungshistorie: |
| 2 | // 25.07.2015, Amaryllis: QueryFish implementiert, AddFishFood an/von Fraggle adaptiert |
| 3 | |
| 4 | inherit "/std/container"; |
| 5 | |
| 6 | #include <moving.h> |
| 7 | #include <fishing.h> |
| 8 | #include <language.h> |
| 9 | #include <properties.h> |
| 10 | #include <defines.h> |
| 11 | #include <money.h> |
| 12 | |
| 13 | #define TP this_player() |
| 14 | #define BS(x) break_string(x, 78) |
| 15 | |
| 16 | private int good_price, bad_price, FAC, FOC, DIV; |
| 17 | private int waagen_preis_faktor=4; // Um wieviel teurer als in Laeden wird |
| 18 | // der Fisch verkauft / Im Fisch wird durch |
| 19 | // 4 geteilt, das wird hier wieder ausgeglichen. |
| 20 | |
| 21 | private int get_price(); |
| 22 | private void RemoveFish(); |
| 23 | |
| 24 | // Amaryllis, 25.07.2015: QueryFish "quick and dirty" reingehackt, |
| 25 | // damits funktioniert. Kann man sicher besser machen... |
| 26 | private int QueryFish(object ob); // wird hier im Objekt in PreventInsert verwendet |
| 27 | |
| 28 | private int QueryFish(object ob) { |
| 29 | return (objectp(ob))&&(ob->id(FISCH_ID)); |
| 30 | } |
| 31 | |
| 32 | private int SetFactors(int good_value, int bad_value) { |
| 33 | FAC=good_value; |
| 34 | FOC=bad_value; |
| 35 | DIV=100; |
| 36 | if(!(FAC && FOC && DIV)) |
| 37 | SetFactors(100,50); |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | protected void create() { |
| 42 | if (!clonep(this_object())) return; |
| 43 | ::create(); |
| 44 | SetFactors(100,50); //100% fuer frische, 50% fuer alte Fische |
| 45 | SetProp(P_NAME, "Fischwaage"); |
| 46 | AddId(({"waage","fischwaage"})); |
| 47 | SetProp(P_GENDER, FEMALE); |
| 48 | SetProp(P_SHORT, "Eine Fischwaage"); |
| 49 | SetProp(P_LONG, |
| 50 | "Eine sehr genaue Fischwaage mit einem grossen Zeiger. Du kannst\n" |
| 51 | "Deine Beute drauflegen, den Zeiger ablesen und, sofern Du mit\n" |
| 52 | "dem Preis einverstanden bist, die Verkaufsglocke laeuten.\n"); |
| 53 | SetProp(P_DEST_PREPOSITION, "auf"); |
| 54 | SetProp(P_SOURCE_PREPOSITION, "von"); |
| 55 | SetProp(P_MATERIAL, MAT_MISC_METAL); |
| 56 | SetProp(P_TRANSPARENT, 1); |
| 57 | SetProp(P_NOGET, 1); |
| 58 | SetProp(P_MAX_WEIGHT, 10000); |
| 59 | SetProp(P_WEIGHT, 5000); |
| 60 | |
| 61 | AddDetail(({"zeiger"}), BS( |
| 62 | "Der Zeiger besteht aus Metall. Du kannst ihn ablesen, wenn Du " |
| 63 | "genau wissen willst, was Dein Fang wert ist.")); |
| 64 | AddDetail(({"fang","beute"}), function string (string key) { |
| 65 | return BS(sizeof(all_inventory())?"Du schaust zufrieden auf die Beute, " |
| 66 | "die auf der Waage liegt. Welcher Preis sich dafuer wohl erzielen " |
| 67 | "laesst?":"Du muesstest erst einmal etwas drauflegen."); |
| 68 | }); |
| 69 | AddReadDetail(({"zeige","zeiger ab"}), function string (string key) { |
| 70 | int current_weight = query_weight_contents(); |
| 71 | get_price(); |
| 72 | return |
| 73 | "Du schaust auf den grossen Zeiger der Waage, der erstaunlicherweise\n" |
| 74 | "nicht nur das Gewicht, sondern auch den Preis anzeigt.\n" |
| 75 | "Der Zeiger steht auf "+ |
| 76 | (current_weight?current_weight+" Gramm.\n":"Null.\n")+ |
| 77 | (good_price?good_price+" Goldmuenzen fuer fangfrischen Fisch.\n":"")+ |
| 78 | (bad_price?bad_price+" Goldmuenzen fuer etwas aelteren Fisch.\n":""); |
| 79 | }); |
| 80 | AddDetail(({"glocke"}), BS( |
| 81 | "An der Waage befindet sich eine kleine Glocke die Du laeuten kannst, " |
| 82 | "um den Inhalt der Waage zu verkaufen. Und warte damit nicht zu lange, " |
| 83 | "je aelter der Fisch, desto niedriger der Preis!")); |
| 84 | |
| 85 | AddCmd("laeute&glocke|verkaufsglocke","cmd_laeute", |
| 86 | "Was willst Du denn laeuten?"); |
| 87 | } |
| 88 | |
| 89 | static int cmd_laeute(string str, mixed *param) { |
| 90 | tell_room(ME, TP->Name()+" laeutet eine kleine Glocke an der Fischwaage.", |
| 91 | ({TP})); |
| 92 | tell_object(TP, "Du laeutest die Glocke, um Deine Ware zu verkaufen.\n"); |
| 93 | foreach(object ob: all_inventory(ME)) { |
| 94 | if ( !ob->id(FISCH_ID) ) { |
| 95 | tell_object(TP, |
| 96 | "Auf der Waage liegt nicht nur Fisch!\n" |
| 97 | "Du solltest nicht versuchen, hier zu betruegen!\n"); |
| 98 | tell_room(ME, TP->Name()+" macht sich hier gerade unbeliebt.\n",({TP})); |
| 99 | return 1; |
| 100 | } |
| 101 | if ( ob->QueryQuality()<=0 ) { |
| 102 | tell_object(TP, "Auf der Waage liegt alter, gammliger Fisch.\n" |
| 103 | "Den kannst Du nicht verkaufen!\n"); |
| 104 | tell_room(ME, TP->Name()+" macht sich hier gerade unbeliebt.\n",({TP})); |
| 105 | return 1; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | int price=get_price(); |
| 110 | if( !price ) { |
| 111 | tell_object(TP, |
| 112 | "Du solltest Deine Beute erstmal auf die Waage legen!\n"); |
| 113 | return 1; |
| 114 | } |
| 115 | tell_object(TP, "Du erhaeltst "+price+" Goldmuenzen fuer Deinen Fisch.\n"); |
| 116 | tell_room(ME, TP->Name()+" erhaelt haufenweise Geld fuer "+ |
| 117 | TP->QueryPossPronoun(MALE, WEN)+" Fisch.\n",({TP})); |
| 118 | //ZZ: AddMoney() gibt die werte von move() zurueck, d.h. !=0 geht nicht. |
| 119 | if (this_player()->AddMoney(price) != MOVE_OK) { |
| 120 | object money=clone_object(GELD); |
| 121 | tell_object(TP, BS( |
| 122 | "Du kannst das Geld nicht mehr tragen. Es faellt klimpernd zu " |
| 123 | "Boden.")); |
| 124 | money->SetProp(P_AMOUNT, price); |
| 125 | money->move(environment(ME), M_MOVE_ALL|M_PUT); |
| 126 | } |
| 127 | RemoveFish(); |
| 128 | return 1; |
| 129 | } |
| 130 | |
| 131 | private int get_price() { |
| 132 | int preis, preis_von_diesem; |
| 133 | int gewicht; |
| 134 | |
| 135 | good_price = 0; |
| 136 | bad_price = 0; |
| 137 | |
| 138 | foreach(object ob : all_inventory(ME)) { |
| 139 | preis_von_diesem = ob->QueryProp(P_VALUE); |
| 140 | if(ob->QueryQuality()>2) |
| 141 | good_price += preis_von_diesem*FAC/DIV; |
| 142 | else |
| 143 | bad_price +=preis_von_diesem *FOC/DIV; |
| 144 | } |
| 145 | |
| 146 | good_price *= waagen_preis_faktor; |
| 147 | bad_price *= waagen_preis_faktor; |
| 148 | return (good_price + bad_price); |
| 149 | } |
| 150 | |
| 151 | int PreventInsert(object obj) { |
| 152 | // if( objectp(obj) && obj->QueryFish() ) |
| 153 | if( objectp(obj) && QueryFish(obj) ) |
| 154 | return ::PreventInsert(obj); |
| 155 | write("Das ist eine Fischwaage! Und keine Waage fuer "+obj->name(WEN)+ |
| 156 | ".\n"); |
| 157 | return 1; |
| 158 | } |
| 159 | |
| 160 | #define ETO environment(this_object()) |
| 161 | |
| 162 | private void RemoveFish() { |
| 163 | string pubname = ETO->GetPub(); |
| 164 | object pub; |
| 165 | |
| 166 | if ( stringp(pubname) ) |
| 167 | pub = load_object(pubname); |
| 168 | else |
| 169 | pub = ETO; |
| 170 | |
| 171 | foreach(object ob : all_inventory(ME)) { |
| 172 | // pub->AddFishFood(ob); |
| 173 | // Amaryllis, 25.07.2015: Angepasst wegen AddFishFood von Fraggle |
| 174 | pub->AddFishFood(ob->name(WER,0),ob->QueryProp(P_WEIGHT),ob->QueryQuality()); |
| 175 | ob->remove(); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | #undef ETO |