blob: 0b9e586b63716e69a2f43410b0dc271fe4b279e3 [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
MG Mud User88f12472016-06-24 23:31:02 +020010
11#define NEED_PROTOTYPES
12
13#include <thing.h>
14#include <inpc.h>
15#include <properties.h>
16#include <moving.h>
17
18protected void create() {
19 SetProp(P_ITEMS,({0}));
20}
21
22protected void create_super() {
23 set_next_reset(-1);
24}
25
26void AddWeapon(string nm, string path) {
27 object ob;
28 mixed *it;
29
30 if (!path || !nm) return;
31 if (ob=clone_object(path)) {
32 ob->move(this_object(),M_NOCHECK);
33 command("zuecke "+nm);
34 }
35 it=QueryProp(P_ITEMS);
36 if (!pointerp(it) || !sizeof(it)) it=({0});
37 it[0]=({ob,path,nm});
38 SetProp(P_ITEMS,it);
39}
40
41void AddArmour(string nm, string path) {
42 object ob;
43 mixed *it;
44
45 if (!path || !nm) return;
46 if (ob=clone_object(path)) {
47 ob->move(this_object(),M_NOCHECK);
48 command("zieh "+nm+" an");
49 }
50 it=QueryProp(P_ITEMS);
51 if (!pointerp(it) || !sizeof(it)) it=({0});
52 it+=({ob,path,nm});
53 SetProp(P_ITEMS,it);
54}
55
56void reset() {
57 mixed *it,x;
58 int i;
59 object ob;
60
61 if (!pointerp(it=QueryProp(P_ITEMS))) return;
62 for (i=sizeof(it)-1;i>=0;i--) {
63 x=it[i];
64 if (!pointerp(x) || sizeof(x)<3) continue;
65 if (!objectp(x[0])) {
66 if (ob=clone_object(x[1]))
67 ob->move(this_object(),M_NOCHECK);
68 x[0]=ob;
69 }
70 if (objectp(x[0])) {
71 if (i)
72 command("zieh "+x[2]+" an");
73 else
74 command("zuecke "+x[2]);
75 }
76 }
77}