MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | /* Hinweis zu diesem Beispielobjekt: Lebensmittel lassen sich besser von |
| 2 | * /std/food ableiten, das bringt viele Funktionalitaeten mit, die man sonst |
| 3 | * muehsam selber basteln muss. |
| 4 | */ |
| 5 | |
| 6 | inherit "/std/thing"; |
| 7 | |
| 8 | #include <moving.h> |
| 9 | #include <properties.h> |
| 10 | #include <wizlevels.h> |
| 11 | |
| 12 | #define SAETTIGUNG 2 |
| 13 | #define HEILUNG 20 |
| 14 | #define EAT_DELAY 1200 // 20 Minuten |
| 15 | |
| 16 | #define BS78(x) break_string(x,78) |
| 17 | |
| 18 | protected void create() |
| 19 | { |
| 20 | ::create(); |
| 21 | |
| 22 | // Gemeinsamer Teil des create |
| 23 | AddId("obst"); |
| 24 | SetProp( P_VALUE, 60+random(10) ); |
| 25 | |
| 26 | // AddCmd( ({"iss","esse"}), "act_essen"); |
| 27 | // new style AddCmd |
| 28 | AddCmd( "iss|esse&@ID","act_essen","Was willst Du denn essen?"); |
| 29 | |
| 30 | // Nach ca. 10 Minuten resetet das Obst, im Reset wird es destructet, |
| 31 | // so spare ich call_outs |
| 32 | set_next_reset(600); |
| 33 | |
| 34 | // Name, ID, Gender, Desc und Gewicht sind Abhaengig von der Obstart |
| 35 | switch (random(11)){ |
| 36 | default: |
| 37 | SetProp( P_GENDER, MALE ); |
| 38 | SetProp( P_NAME, "Apfel" ); |
| 39 | AddId( "apfel" ); |
| 40 | SetProp( P_SHORT, "Ein Apfel" ); |
| 41 | SetProp( P_LONG, BS78( |
| 42 | "Ein saftiger Apfel. Dir laeuft das Wasser im Munde zusammen." |
| 43 | )); |
| 44 | SetProp( P_WEIGHT, 80 ); |
| 45 | break; |
| 46 | case 1: |
| 47 | SetProp( P_GENDER, FEMALE ); |
| 48 | SetProp( P_NAME, "Birne" ); |
| 49 | AddId( "birne" ); |
| 50 | SetProp( P_SHORT, "Eine Birne" ); |
| 51 | SetProp( P_LONG, BS78( |
| 52 | "Eine koestliche, reife Birne. Die ist sicher lecker." |
| 53 | )); |
| 54 | SetProp( P_WEIGHT, 90 ); |
| 55 | break; |
| 56 | case 2: |
| 57 | SetProp( P_GENDER, FEMALE ); |
| 58 | SetProp( P_NAME, "Banane" ); |
| 59 | AddId( "banane" ); |
| 60 | SetProp( P_SHORT, "Eine Banane" ); |
| 61 | SetProp( P_LONG, BS78( |
| 62 | "Die Banane sieht wirklich lecker aus, am besten gleich essen." |
| 63 | )); |
| 64 | SetProp( P_WEIGHT, 110 ); |
| 65 | break; |
| 66 | case 3: |
| 67 | SetProp( P_GENDER, FEMALE ); |
| 68 | SetProp( P_NAME, "Kiwi" ); |
| 69 | AddId( "kiwi" ); |
| 70 | SetProp( P_SHORT, "Eine Kiwi" ); |
| 71 | SetProp( P_LONG, BS78( |
| 72 | "Klein und gruen, aber mit leckeren Innenleben. Yam yam." |
| 73 | )); |
| 74 | SetProp( P_WEIGHT, 50 ); |
| 75 | break; |
| 76 | case 4: |
| 77 | SetProp( P_GENDER, FEMALE ); |
| 78 | SetProp( P_NAME, "Erdbeere" ); |
| 79 | AddId( "erdbeere" ); |
| 80 | SetProp( P_SHORT, "Eine Erdbeere" ); |
| 81 | SetProp( P_LONG, BS78( |
| 82 | "Eine ueberdurchschnittlich grosse Erdbeere. Sie " |
| 83 | "ist sicher suess und saftig." |
| 84 | )); |
| 85 | SetProp( P_WEIGHT, 20 ); |
| 86 | break; |
| 87 | case 5: |
| 88 | SetProp( P_GENDER, FEMALE ); |
| 89 | SetProp( P_NAME, "Kirsche" ); |
| 90 | AddId( "kirsche" ); |
| 91 | SetProp( P_SHORT, "Eine Kirsche" ); |
| 92 | SetProp( P_LONG, BS78( |
| 93 | "Zwar nur klein ist diese Kirsche, aber so dunkel wie sie " |
| 94 | "aussieht, ist sie sicher total suess und lecker." |
| 95 | )); |
| 96 | SetProp( P_WEIGHT, 15 ); |
| 97 | break; |
| 98 | case 6: |
| 99 | SetProp( P_GENDER, FEMALE ); |
| 100 | SetProp( P_NAME, "Orange" ); |
| 101 | AddId( "orange" ); |
| 102 | SetProp( P_SHORT, "Eine Orange" ); |
| 103 | SetProp( P_LONG, BS78( |
| 104 | "Eine grosse, gelbe Orange. Eine von diesen suessen, die sich so " |
| 105 | "leicht schaelen lassen und keine Zicken machen, so wie Saftorangen." |
| 106 | )); |
| 107 | SetProp( P_WEIGHT, 90 ); |
| 108 | break; |
| 109 | case 7: |
| 110 | SetProp( P_GENDER, FEMALE ); |
| 111 | SetProp( P_NAME, "Mandarine" ); |
| 112 | AddId( "mandarine" ); |
| 113 | SetProp( P_SHORT, "Eine Mandarine" ); |
| 114 | SetProp( P_LONG, BS78( |
| 115 | "Suess und saftig und gesund. So muss das Essen im Paradies " |
| 116 | "gewesen sein." |
| 117 | )); |
| 118 | SetProp( P_WEIGHT, 60 ); |
| 119 | break; |
| 120 | case 8: |
| 121 | SetProp( P_GENDER, FEMALE ); |
| 122 | SetProp( P_NAME, "Zitrone" ); |
| 123 | AddId( "zitrone" ); |
| 124 | SetProp( P_SHORT, "Eine Zitrone" ); |
| 125 | SetProp( P_LONG, BS78( |
| 126 | "Sauer, sauer und nochmals sauer. Aber ultralecker. Na, sabberst Du " |
| 127 | "schon auf die Tastatur?" |
| 128 | )); |
| 129 | SetProp( P_WEIGHT, 60 ); |
| 130 | break; |
| 131 | case 9: |
| 132 | SetProp( P_GENDER, MALE ); |
| 133 | SetProp( P_NAME, "Granatapfel" ); |
| 134 | AddId( "granatapfel" ); |
| 135 | SetProp( P_SHORT, "Ein Granatapfel" ); |
| 136 | SetProp( P_LONG, BS78( |
| 137 | "Er ist zwar etwas schwieriger, den zu essen, aber der Aufwand " |
| 138 | "lohnt sich." |
| 139 | )); |
| 140 | SetProp( P_WEIGHT, 90 ); |
| 141 | break; |
| 142 | case 10: |
| 143 | SetProp( P_GENDER, FEMALE ); |
| 144 | SetProp( P_NAME, "Pflaume" ); |
| 145 | AddId( "pflaume" ); |
| 146 | SetProp( P_SHORT, "Eine Pflaume" ); |
| 147 | SetProp( P_LONG, BS78( |
| 148 | "Eine grosse, blaue Pflaume. Lass sie Dir doch schmecken." |
| 149 | )); |
| 150 | SetProp( P_WEIGHT, 20 ); |
| 151 | break; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | void reset() |
| 156 | { |
| 157 | object env = environment(this_object()); |
| 158 | |
| 159 | if (env) { |
| 160 | if (query_once_interactive(env)){ |
| 161 | // Mein Env is ein User |
| 162 | tell_object(env, BS78( |
| 163 | capitalize(this_object()->name(WER))+" verschwindet mit einem "+ |
| 164 | "\"PLOPP\" aus deinem Inventar. Da scheint Magie im Spiel zu sein." |
| 165 | )); |
| 166 | } else if (sizeof(all_inventory(env)&users())){ |
| 167 | // In meinem Environment sind User (Es ist ein Raum) |
| 168 | tell_room(env, BS78( |
| 169 | capitalize(this_object()->name(WER))+" verschwindet mit einem "+ |
| 170 | "\"PLOPP\". Da scheint Magie im Spiel zu sein." |
| 171 | )); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // Objekt zerstoeren |
| 176 | remove(1); |
| 177 | } |
| 178 | |
| 179 | static int act_essen(string args) |
| 180 | { |
| 181 | // Nur ein Demo-Objekt |
| 182 | if (!IS_LEARNING(this_player())) |
| 183 | { |
| 184 | write("Schwups, nun ist @@name@@ verschwunden. War wohl eine Illusion."); |
| 185 | remove(1); |
| 186 | } |
| 187 | |
| 188 | // Der Syntaxtest ist unnoetig, der ist schon im new style |
| 189 | // AddCmd() eingebaut. |
| 190 | |
| 191 | // Wenn das Objekt ein Environment hat (hoff ich doch) |
| 192 | // und das Environment nicht this_player() ist, |
| 193 | // hat der Spieler das Obst nich im Inv - das geht doch nicht ... |
| 194 | if (environment(this_object()) && (environment(this_object()) != this_player()) ) |
| 195 | { |
| 196 | write(BS78( |
| 197 | "Du solltest "+ this_object()->name(WER,1) + " erstmal nehmen." |
| 198 | )); |
| 199 | return 1; |
| 200 | } |
| 201 | |
| 202 | // DEBUG ("Satt?"); |
| 203 | if (this_player()->eat_food(SAETTIGUNG)) |
| 204 | { |
| 205 | // DEBUG("Noe!"); |
| 206 | if (this_player()->check_and_update_timed_key(EAT_DELAY,"vanion_zach_obst")==-1) |
| 207 | { |
| 208 | write(BS78( |
| 209 | "Du isst genuesslich "+this_object()->name(WEN,0)+ |
| 210 | ". Du fuehlst Dich gestaerkt." |
| 211 | )); |
| 212 | say(BS78( |
| 213 | this_player()->name()+" isst mit vollem Genuss "+this_object()->name(WEN,0)+". " |
| 214 | "Dir laeuft das Wasser im Munde zusammen." |
| 215 | )); |
| 216 | // Heilen und aufessen :) |
| 217 | this_player()->heal_self(HEILUNG); |
| 218 | } |
| 219 | else { // if (check_and_update_timed_key()) |
| 220 | // Wenn es noch zu frueh ist, wieder welches zu essen |
| 221 | // Keine Heilung, aber Saettigung |
| 222 | write(BS78( |
| 223 | "Du solltest "+this_object()->name(WEN,1)+" lieber jemandem geben, " |
| 224 | "den Du magst, statt alles selbst zu futtern, findest Du nicht? " |
| 225 | "Deine Gier hat Dir jetzt nur einen vollen Bauch und ein schlechtes " |
| 226 | "Gewissen bescheert." |
| 227 | )); |
| 228 | } // end if (check_and_update_timed_key()) |
| 229 | if (!remove()) destruct(this_object()); |
| 230 | } // end of eat_food |
| 231 | return 1; |
| 232 | } |