blob: f612f1ef848f448961ea2f5127550ea1a27c458c [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// 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
15inherit "/std/thing/properties";
16inherit "/std/hook_provider";
17inherit "/std/living/description";
18inherit "/std/living/light";
19inherit "/std/living/life";
20inherit "/std/living/attributes";
21inherit "/std/npc/moving";
22inherit "/std/living/skill_attributes";
23inherit "/std/living/skills";
24inherit "/std/living/clothing";
25inherit "/std/npc/combat";
26inherit "/std/npc/chat";
27inherit "/std/npc/comm";
28inherit "/std/container/restrictions";
29inherit "/std/thing/commands";
30inherit "/std/thing/language";
31inherit "/std/npc/info";
32inherit "/std/npc/put_and_get";
33inherit "/std/npc/items";
34inherit "/std/thing/envchk";
35inherit "/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
50static int _set_level(int arg);
51
52protected 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
106protected void create_super() {
107 set_next_reset(-1);
108}
109
110void reset(){
111 items::reset();
112 combat::reset();
113}
114
115static 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
125varargs 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
137protected 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
145void give_notify(object ob)
146{
147 put_and_get::give_notify(ob);
148}
149
150// Force the monster to do a command.
151int command_me(string cmd) { return command(cmd); }
152
153void init()
154{
155 combat::init();
156 info::init();
157 commands::init();
158// description::init();
159}
160
161// items initialisieren?
162protected 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
172string _query_race()
173{
174 if (stringp(Query(P_RACE))) return capitalize(Query(P_RACE));
175}