blob: 3483bf8ce17f40da2832082eed77a7b4f7101ffc [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
MG Mud User88f12472016-06-24 23:31:02 +020013
14inherit "/std/thing/properties";
15inherit "/std/hook_provider";
16inherit "/std/living/description";
17inherit "/std/living/light";
18inherit "/std/living/life";
19inherit "/std/living/attributes";
20inherit "/std/npc/moving";
21inherit "/std/living/skill_attributes";
22inherit "/std/living/skills";
23inherit "/std/living/clothing";
24inherit "/std/npc/combat";
25inherit "/std/npc/chat";
26inherit "/std/npc/comm";
27inherit "/std/container/restrictions";
28inherit "/std/thing/commands";
29inherit "/std/thing/language";
30inherit "/std/npc/info";
31inherit "/std/npc/put_and_get";
32inherit "/std/npc/items";
Zesstra44030452018-11-12 22:34:02 +010033inherit "/std/container/vitems";
MG Mud User88f12472016-06-24 23:31:02 +020034inherit "/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();
Bugfix98ea85e2021-01-23 14:30:33 +010071 helpers::create();
MG Mud User88f12472016-06-24 23:31:02 +020072 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}