blob: fafdd04dbfda2fec933d729554c93704f22ccc54 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// inpc/items.c -- Die richtige Ausruestung tragen
4//
5// $Id: items.c 6571 2007-10-21 14:41:10Z Zesstra $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
10#pragma pedantic
11
12#define NEED_PROTOTYPES
13
14#include <thing.h>
15#include <inpc.h>
16#include <properties.h>
17#include <moving.h>
18
19protected void create() {
20 SetProp(P_ITEMS,({0}));
21}
22
23protected void create_super() {
24 set_next_reset(-1);
25}
26
27void AddWeapon(string nm, string path) {
28 object ob;
29 mixed *it;
30
31 if (!path || !nm) return;
32 if (ob=clone_object(path)) {
33 ob->move(this_object(),M_NOCHECK);
34 command("zuecke "+nm);
35 }
36 it=QueryProp(P_ITEMS);
37 if (!pointerp(it) || !sizeof(it)) it=({0});
38 it[0]=({ob,path,nm});
39 SetProp(P_ITEMS,it);
40}
41
42void AddArmour(string nm, string path) {
43 object ob;
44 mixed *it;
45
46 if (!path || !nm) return;
47 if (ob=clone_object(path)) {
48 ob->move(this_object(),M_NOCHECK);
49 command("zieh "+nm+" an");
50 }
51 it=QueryProp(P_ITEMS);
52 if (!pointerp(it) || !sizeof(it)) it=({0});
53 it+=({ob,path,nm});
54 SetProp(P_ITEMS,it);
55}
56
57void reset() {
58 mixed *it,x;
59 int i;
60 object ob;
61
62 if (!pointerp(it=QueryProp(P_ITEMS))) return;
63 for (i=sizeof(it)-1;i>=0;i--) {
64 x=it[i];
65 if (!pointerp(x) || sizeof(x)<3) continue;
66 if (!objectp(x[0])) {
67 if (ob=clone_object(x[1]))
68 ob->move(this_object(),M_NOCHECK);
69 x[0]=ob;
70 }
71 if (objectp(x[0])) {
72 if (i)
73 command("zieh "+x[2]+" an");
74 else
75 command("zuecke "+x[2]);
76 }
77 }
78}