blob: 6c897fa1baeab1d6c584b94c3790809095ee8fad [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
MG Mud User88f12472016-06-24 23:31:02 +020010
11inherit "/std/container/inventory";
12
13#define NEED_PROTOTYPES
14
15#include <properties.h>
16#include <sensitive.h>
17#include <attributes.h>
18
19#define ME this_object()
20
21public void RemoveSensitiveObject(object ob) {
22 ::RemoveSensitiveObject(ob);
23 RemoveSensitiveObjectFromList(ob,SENSITIVE_ATTACK);
24 if (objectp(ob) && (ob->QueryProp(P_X_ATTR_MOD) ||
25 ob->QueryProp(P_X_HEALTH_MOD) ))
26 {
27 deregister_modifier(ob);
28 // Erst wenn das Objekt den Spieler verlassen konnte, die Attribute
29 // neu berechnen.
30 if (find_call_out("UpdateAttributes")==-1)
31 call_out("UpdateAttributes",0);
32 }
33}
34
35public void InsertSensitiveObject(object ob, mixed arg) {
36 ::InsertSensitiveObject(ob,arg);
37 if (objectp(ob) && (ob->QueryProp(P_X_ATTR_MOD) ||
38 ob->QueryProp(P_X_HEALTH_MOD) ))
39 {
40 register_modifier(ob);
41 UpdateAttributes();
42 }
43}
44
45public void CheckSensitiveAttack(int dam, mixed dam_type, mixed spell,
46 object enemy) {
47 mixed a,x;
48 int i;
49
50 if (!pointerp(a=QueryProp(P_SENSITIVE_ATTACK)))
51 return;
52 if (!pointerp(dam_type))
53 dam_type=({dam_type});
54 for (i=sizeof(a)-1;i>=0;i--)
55 if (pointerp(x=a[i]) &&
56 dam>x[SENS_THRESHOLD] &&
57 member(dam_type,x[SENS_KEY])>=0 &&
58 objectp(x[SENS_OBJECT]) &&
59 environment(x[SENS_OBJECT])==ME &&
60 closurep(x[SENS_CLOSURE]))
61 funcall(x[SENS_CLOSURE],
62 enemy,x[SENS_KEY],dam,
63 spell,x[SENS_OPT]);
64}
65