blob: 5cb7fcf1ba9585d4eacb36f3e85332b5b9a512a4 [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";
Zesstra44030452018-11-12 22:34:02 +010034inherit "/std/container/vitems";
MG Mud User88f12472016-06-24 23:31:02 +020035inherit "/std/thing/envchk";
36inherit "/std/living/helpers";
37
38#include <config.h>
39#include <properties.h>
40#include <ansi.h>
41#include <wizlevels.h>
42#include <living.h>
43#include <language.h>
44#include <attributes.h>
45#include <defines.h>
46#include <health.h>
47#include <npc.h>
48#include <moving.h>
49#include <guard.h>
50
51static int _set_level(int arg);
52
53protected void create()
54{
55 seteuid(getuid());
56 properties::create();
57 restrictions::create();
58 commands::create();
59 light::create();
60 description::create();
61 attributes::create();
62 clothing::create();
63 life::create();
64 enable_commands();
65 comm::create();
66 combat::create();
67 info::create();
68 put_and_get::add_put_and_get_commands();
69 add_team_commands();
70 items::create();
71 envchk::create();
72 moving::create();
73
74 add_action("UseSpell","",1);
75
76 SetProp(P_LIGHT_MODIFIER, 1);
77 SetProp(P_WEIGHT_PERCENT, 100);
78 SetProp(P_NAME, "Niemand");
79 SetProp(P_MSGIN, "kommt an");
80 SetProp(P_MSGOUT, "geht");
81 SetProp(P_MMSGIN, "erscheint in einer Rauchwolke");
82 SetProp(P_MMSGOUT, "verschwindet mit Knall und Schwefelduft");
83 SetProp(P_GENDER, NEUTER );
84 SetProp(P_WEIGHT, 75000);
85 SetProp(P_MAX_WEIGHT, 50000);
86 SetProp(P_RACE, "Npc");
87 SetProp(P_MAX_HP,100);
88 SetProp(P_MAX_SP,100);
89 SetProp(P_HP,50);
90 SetProp(P_SP,50);
91 SetProp(P_MAX_ALCOHOL,100);
92 SetProp(P_MAX_DRINK,100);
93 SetProp(P_MAX_FOOD,100);
94 SetProp(P_DRINK, 0);
95 SetProp(P_FOOD, 0);
96 SetProp(P_ALCOHOL, 0);
97 SetProp(P_HANDS, ({ "", 30 }) );
98 SetProp(P_MAX_HANDS, 2);
99 SetProp(P_NPC, 1);
100 SetProp(P_GUARD,100);
101 SetProp(P_NO_TPORT,NO_TPORT_IN);
102
103 set_heart_beat(1);
104 heartbeat=1;
105}
106
107protected void create_super() {
108 set_next_reset(-1);
109}
110
111void reset(){
112 items::reset();
Zesstra44030452018-11-12 22:34:02 +0100113 vitems::reset();
MG Mud User88f12472016-06-24 23:31:02 +0200114 combat::reset();
Zesstraf17d3a02018-11-12 22:29:00 +0100115 envchk::reset();
MG Mud User88f12472016-06-24 23:31:02 +0200116}
117
118static int _set_level(int arg)
119{
120 Set(P_LEVEL, arg);
121 SetAttr(A_CON, arg);
122 SetAttr(A_DEX, arg);
123 SetAttr(A_INT, arg);
124 SetAttr(A_STR, arg);
125 return(arg); //Rueckgabewert noetig!
126}
127
128varargs void create_default_npc(int level, int maxhp)
129{
130 if(level < 1) return;
131 SetProp(P_LEVEL, level);
132 if (maxhp<=0) maxhp = 42 + level*8;
133 SetProp(P_MAX_HP, maxhp);
134 SetProp(P_MAX_SP, maxhp);
135 SetProp(P_HANDS, ({" mit blossen Haenden", level*10 }) );
136 SetProp(P_BODY, (level*20)/3);
137 SetProp(P_XP, level * maxhp * 50);
138}
139
140protected void heart_beat()
141{
142 if( environment() ) life::heart_beat();
143 if (!this_object()) return; // Evtl. an Gift gestorben...
144 combat::heart_beat();
145 chat::heart_beat();
146}
147
148void give_notify(object ob)
149{
150 put_and_get::give_notify(ob);
151}
152
153// Force the monster to do a command.
154int command_me(string cmd) { return command(cmd); }
155
Zesstra5b71ebb2018-03-07 20:50:35 +0100156public varargs void init(object origin)
MG Mud User88f12472016-06-24 23:31:02 +0200157{
Zesstra5b71ebb2018-03-07 20:50:35 +0100158 combat::init(origin);
159 info::init(origin);
160 commands::init(origin);
161// description::init(origin);
MG Mud User88f12472016-06-24 23:31:02 +0200162}
163
164// items initialisieren?
165protected void NotifyMove(object dest, object oldenv, int method) {
166
167 ::NotifyMove(dest, oldenv, method);
168 // gestorben?
169 if (!objectp(this_object())) return;
170
171 if ( Query(NPC_NEEDS_ITEM_INIT, F_VALUE))
172 _clone_items();
173}
174
Bugfix5a9775f2017-02-17 13:48:56 +0100175public void NotifyInsert(object ob, object oldenv)
176{
177 restrictions::NotifyInsert(ob,oldenv);
178 description::NotifyInsert(ob,oldenv);
179}
180
181public void NotifyLeave(object ob, object dest)
182{
183 restrictions::NotifyLeave(ob,dest);
184 description::NotifyLeave(ob,dest);
185}
186
187
MG Mud User88f12472016-06-24 23:31:02 +0200188string _query_race()
189{
190 if (stringp(Query(P_RACE))) return capitalize(Query(P_RACE));
191}