MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | // MorgenGrauen MUDlib |
| 2 | // |
| 3 | // npc.c -- a generic npc (non player character) |
| 4 | // |
| 5 | // Testversion mit support fuer AddItem |
| 6 | // soll spaeter in npc.c aufgehen |
| 7 | // |
| 8 | // $Id: npc.c 9478 2016-02-19 21:18:35Z Zesstra $ |
| 9 | #pragma strong_types |
| 10 | #pragma save_types |
| 11 | #pragma range_check |
| 12 | #pragma no_clone |
| 13 | #pragma pedantic |
| 14 | |
| 15 | inherit "/std/thing/properties"; |
| 16 | inherit "/std/hook_provider"; |
| 17 | inherit "/std/living/description"; |
| 18 | inherit "/std/living/light"; |
| 19 | inherit "/std/living/life"; |
| 20 | inherit "/std/living/attributes"; |
| 21 | inherit "/std/npc/moving"; |
| 22 | inherit "/std/living/skill_attributes"; |
| 23 | inherit "/std/living/skills"; |
| 24 | inherit "/std/living/clothing"; |
| 25 | inherit "/std/npc/combat"; |
| 26 | inherit "/std/npc/chat"; |
| 27 | inherit "/std/npc/comm"; |
| 28 | inherit "/std/container/restrictions"; |
| 29 | inherit "/std/thing/commands"; |
| 30 | inherit "/std/thing/language"; |
| 31 | inherit "/std/npc/info"; |
| 32 | inherit "/std/npc/put_and_get"; |
| 33 | inherit "/std/npc/items"; |
| 34 | inherit "/std/thing/envchk"; |
| 35 | inherit "/std/living/helpers"; |
| 36 | |
| 37 | #include <config.h> |
| 38 | #include <properties.h> |
| 39 | #include <ansi.h> |
| 40 | #include <wizlevels.h> |
| 41 | #include <living.h> |
| 42 | #include <language.h> |
| 43 | #include <attributes.h> |
| 44 | #include <defines.h> |
| 45 | #include <health.h> |
| 46 | #include <npc.h> |
| 47 | #include <moving.h> |
| 48 | #include <guard.h> |
| 49 | |
| 50 | static int _set_level(int arg); |
| 51 | |
| 52 | protected void create() |
| 53 | { |
| 54 | seteuid(getuid()); |
| 55 | properties::create(); |
| 56 | restrictions::create(); |
| 57 | commands::create(); |
| 58 | light::create(); |
| 59 | description::create(); |
| 60 | attributes::create(); |
| 61 | clothing::create(); |
| 62 | life::create(); |
| 63 | enable_commands(); |
| 64 | comm::create(); |
| 65 | combat::create(); |
| 66 | info::create(); |
| 67 | put_and_get::add_put_and_get_commands(); |
| 68 | add_team_commands(); |
| 69 | items::create(); |
| 70 | envchk::create(); |
| 71 | moving::create(); |
| 72 | |
| 73 | add_action("UseSpell","",1); |
| 74 | |
| 75 | SetProp(P_LIGHT_MODIFIER, 1); |
| 76 | SetProp(P_WEIGHT_PERCENT, 100); |
| 77 | SetProp(P_NAME, "Niemand"); |
| 78 | SetProp(P_MSGIN, "kommt an"); |
| 79 | SetProp(P_MSGOUT, "geht"); |
| 80 | SetProp(P_MMSGIN, "erscheint in einer Rauchwolke"); |
| 81 | SetProp(P_MMSGOUT, "verschwindet mit Knall und Schwefelduft"); |
| 82 | SetProp(P_GENDER, NEUTER ); |
| 83 | SetProp(P_WEIGHT, 75000); |
| 84 | SetProp(P_MAX_WEIGHT, 50000); |
| 85 | SetProp(P_RACE, "Npc"); |
| 86 | SetProp(P_MAX_HP,100); |
| 87 | SetProp(P_MAX_SP,100); |
| 88 | SetProp(P_HP,50); |
| 89 | SetProp(P_SP,50); |
| 90 | SetProp(P_MAX_ALCOHOL,100); |
| 91 | SetProp(P_MAX_DRINK,100); |
| 92 | SetProp(P_MAX_FOOD,100); |
| 93 | SetProp(P_DRINK, 0); |
| 94 | SetProp(P_FOOD, 0); |
| 95 | SetProp(P_ALCOHOL, 0); |
| 96 | SetProp(P_HANDS, ({ "", 30 }) ); |
| 97 | SetProp(P_MAX_HANDS, 2); |
| 98 | SetProp(P_NPC, 1); |
| 99 | SetProp(P_GUARD,100); |
| 100 | SetProp(P_NO_TPORT,NO_TPORT_IN); |
| 101 | |
| 102 | set_heart_beat(1); |
| 103 | heartbeat=1; |
| 104 | } |
| 105 | |
| 106 | protected void create_super() { |
| 107 | set_next_reset(-1); |
| 108 | } |
| 109 | |
| 110 | void reset(){ |
| 111 | items::reset(); |
| 112 | combat::reset(); |
| 113 | } |
| 114 | |
| 115 | static int _set_level(int arg) |
| 116 | { |
| 117 | Set(P_LEVEL, arg); |
| 118 | SetAttr(A_CON, arg); |
| 119 | SetAttr(A_DEX, arg); |
| 120 | SetAttr(A_INT, arg); |
| 121 | SetAttr(A_STR, arg); |
| 122 | return(arg); //Rueckgabewert noetig! |
| 123 | } |
| 124 | |
| 125 | varargs void create_default_npc(int level, int maxhp) |
| 126 | { |
| 127 | if(level < 1) return; |
| 128 | SetProp(P_LEVEL, level); |
| 129 | if (maxhp<=0) maxhp = 42 + level*8; |
| 130 | SetProp(P_MAX_HP, maxhp); |
| 131 | SetProp(P_MAX_SP, maxhp); |
| 132 | SetProp(P_HANDS, ({" mit blossen Haenden", level*10 }) ); |
| 133 | SetProp(P_BODY, (level*20)/3); |
| 134 | SetProp(P_XP, level * maxhp * 50); |
| 135 | } |
| 136 | |
| 137 | protected void heart_beat() |
| 138 | { |
| 139 | if( environment() ) life::heart_beat(); |
| 140 | if (!this_object()) return; // Evtl. an Gift gestorben... |
| 141 | combat::heart_beat(); |
| 142 | chat::heart_beat(); |
| 143 | } |
| 144 | |
| 145 | void give_notify(object ob) |
| 146 | { |
| 147 | put_and_get::give_notify(ob); |
| 148 | } |
| 149 | |
| 150 | // Force the monster to do a command. |
| 151 | int command_me(string cmd) { return command(cmd); } |
| 152 | |
| 153 | void init() |
| 154 | { |
| 155 | combat::init(); |
| 156 | info::init(); |
| 157 | commands::init(); |
| 158 | // description::init(); |
| 159 | } |
| 160 | |
| 161 | // items initialisieren? |
| 162 | protected void NotifyMove(object dest, object oldenv, int method) { |
| 163 | |
| 164 | ::NotifyMove(dest, oldenv, method); |
| 165 | // gestorben? |
| 166 | if (!objectp(this_object())) return; |
| 167 | |
| 168 | if ( Query(NPC_NEEDS_ITEM_INIT, F_VALUE)) |
| 169 | _clone_items(); |
| 170 | } |
| 171 | |
| 172 | string _query_race() |
| 173 | { |
| 174 | if (stringp(Query(P_RACE))) return capitalize(Query(P_RACE)); |
| 175 | } |