blob: e3027e4bdb0ec9f26bdd7b608eb1a4bf2da079a7 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// container/inventory.c -- Umgang mit besonderen Objekten im Inventory
4//
5// $Id: inventory.c 6554 2007-10-17 22:45:53Z Zesstra $
6#pragma strong_types
7#pragma save_types
8#pragma range_check
9#pragma no_clone
10#pragma pedantic
11
12inherit "/std/container/inventory";
13
14#define NEED_PROTOTYPES
15
16#include <properties.h>
17#include <sensitive.h>
18#include <attributes.h>
19
20#define ME this_object()
21
22public void RemoveSensitiveObject(object ob) {
23 ::RemoveSensitiveObject(ob);
24 RemoveSensitiveObjectFromList(ob,SENSITIVE_ATTACK);
25 if (objectp(ob) && (ob->QueryProp(P_X_ATTR_MOD) ||
26 ob->QueryProp(P_X_HEALTH_MOD) ))
27 {
28 deregister_modifier(ob);
29 // Erst wenn das Objekt den Spieler verlassen konnte, die Attribute
30 // neu berechnen.
31 if (find_call_out("UpdateAttributes")==-1)
32 call_out("UpdateAttributes",0);
33 }
34}
35
36public void InsertSensitiveObject(object ob, mixed arg) {
37 ::InsertSensitiveObject(ob,arg);
38 if (objectp(ob) && (ob->QueryProp(P_X_ATTR_MOD) ||
39 ob->QueryProp(P_X_HEALTH_MOD) ))
40 {
41 register_modifier(ob);
42 UpdateAttributes();
43 }
44}
45
46public void CheckSensitiveAttack(int dam, mixed dam_type, mixed spell,
47 object enemy) {
48 mixed a,x;
49 int i;
50
51 if (!pointerp(a=QueryProp(P_SENSITIVE_ATTACK)))
52 return;
53 if (!pointerp(dam_type))
54 dam_type=({dam_type});
55 for (i=sizeof(a)-1;i>=0;i--)
56 if (pointerp(x=a[i]) &&
57 dam>x[SENS_THRESHOLD] &&
58 member(dam_type,x[SENS_KEY])>=0 &&
59 objectp(x[SENS_OBJECT]) &&
60 environment(x[SENS_OBJECT])==ME &&
61 closurep(x[SENS_CLOSURE]))
62 funcall(x[SENS_CLOSURE],
63 enemy,x[SENS_KEY],dam,
64 spell,x[SENS_OPT]);
65}
66