blob: 8ec29f41b977b2736e33cb02151f28a963474796 [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();
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();
Zesstra44030452018-11-12 22:34:02 +0100112 vitems::reset();
MG Mud User88f12472016-06-24 23:31:02 +0200113 combat::reset();
Zesstraf17d3a02018-11-12 22:29:00 +0100114 envchk::reset();
MG Mud User88f12472016-06-24 23:31:02 +0200115}
116
117static int _set_level(int arg)
118{
119 Set(P_LEVEL, arg);
120 SetAttr(A_CON, arg);
121 SetAttr(A_DEX, arg);
122 SetAttr(A_INT, arg);
123 SetAttr(A_STR, arg);
124 return(arg); //Rueckgabewert noetig!
125}
126
127varargs void create_default_npc(int level, int maxhp)
128{
129 if(level < 1) return;
130 SetProp(P_LEVEL, level);
131 if (maxhp<=0) maxhp = 42 + level*8;
132 SetProp(P_MAX_HP, maxhp);
133 SetProp(P_MAX_SP, maxhp);
134 SetProp(P_HANDS, ({" mit blossen Haenden", level*10 }) );
135 SetProp(P_BODY, (level*20)/3);
136 SetProp(P_XP, level * maxhp * 50);
137}
138
139protected void heart_beat()
140{
141 if( environment() ) life::heart_beat();
142 if (!this_object()) return; // Evtl. an Gift gestorben...
143 combat::heart_beat();
144 chat::heart_beat();
145}
146
147void give_notify(object ob)
148{
149 put_and_get::give_notify(ob);
150}
151
152// Force the monster to do a command.
153int command_me(string cmd) { return command(cmd); }
154
Zesstra5b71ebb2018-03-07 20:50:35 +0100155public varargs void init(object origin)
MG Mud User88f12472016-06-24 23:31:02 +0200156{
Zesstra5b71ebb2018-03-07 20:50:35 +0100157 combat::init(origin);
158 info::init(origin);
159 commands::init(origin);
160// description::init(origin);
MG Mud User88f12472016-06-24 23:31:02 +0200161}
162
163// items initialisieren?
164protected void NotifyMove(object dest, object oldenv, int method) {
165
166 ::NotifyMove(dest, oldenv, method);
167 // gestorben?
168 if (!objectp(this_object())) return;
169
170 if ( Query(NPC_NEEDS_ITEM_INIT, F_VALUE))
171 _clone_items();
172}
173
Bugfix5a9775f2017-02-17 13:48:56 +0100174public void NotifyInsert(object ob, object oldenv)
175{
176 restrictions::NotifyInsert(ob,oldenv);
177 description::NotifyInsert(ob,oldenv);
178}
179
180public void NotifyLeave(object ob, object dest)
181{
182 restrictions::NotifyLeave(ob,dest);
183 description::NotifyLeave(ob,dest);
184}
185
186
MG Mud User88f12472016-06-24 23:31:02 +0200187string _query_race()
188{
189 if (stringp(Query(P_RACE))) return capitalize(Query(P_RACE));
190}