blob: 9f6c0957e41d6a112b3a6781825f31fd6bb8b7e9 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// player/restrictions.c -- container aspect of players
4//
5// $Id: restrictions.c 9020 2015-01-10 21:49:41Z Zesstra $
6
7// This is a simple container to put objects in. It defines all functions
8// which are necessary to describe an object which can be filled with
9// other things.
10//
11// It will support restrictions for volume, weight etc.
12//
13// The following properties are defined:
14// P_MAX_WEIGHT - maximum weight which container can carry
15// P_WEIGHT_CONTENTS - current contents
16// P_WEIGHT - builtin property: read->total weight, write->own weight
17//
18// Functions for manipulation of weight
19// MayAddWeight(weight) - Can <weight> be inserted?
20// AddWeight(weight) - Add an amount of <weight>
21//
22// IMPORTANT: unit should be interpreted as grams (g).
23#pragma strong_types
24#pragma save_types
25#pragma range_check
26#pragma no_clone
27#pragma pedantic
28
29inherit "/std/container/restrictions";
30
31#define NEED_PROTOTYPES
32#include <thing/properties.h>
33#include <hook.h>
34#include <living/skills.h>
35#include <attributes.h>
36#undef NEED_PROTOTYPES
37#include <properties.h>
38#include <wizlevels.h>
39#include <container.h>
40#include <defines.h>
41#include <new_skills.h>
42
MG Mud User88f12472016-06-24 23:31:02 +020043// local properties prototypes
44static int _query_max_weight();
45static mixed _set_frog(mixed arg);
46
Zesstra98d32002019-10-17 23:50:21 +020047protected void create()
MG Mud User88f12472016-06-24 23:31:02 +020048{
49 ::create();
50
51 Set(P_MAX_WEIGHT, NOSETMETHOD, F_SET_METHOD);
52 Set(P_MAX_WEIGHT, SECURED, F_MODE);
53 offerHook(H_HOOK_INSERT, 1);
54}
55
56// **** local property methods
57static int _query_max_weight() {
58 int str,val;
59 mixed ski;
60
61 if (QueryProp(P_GHOST) && !IS_WIZARD(ME))
62 return 0;
63 str=QueryAttribute(A_STR);
64 ski = UseSkill(SK_CARRY, ([SI_SKILLARG : str ]));
65
66 if (!intp(ski))
67 ski = 0;
68
69 if (str<0) {
70 val=9200+str*160+(int)ski;
71 if (val<3000) val=3000;
72 return val;
73 }
74 val = 9200+str*800+(int)ski;
75 if (val<3000)
76 val = 3000;
77 return val;
78}
79
80static mixed _set_frog(mixed arg) {
81 mixed res;
82
83 res=Set(P_FROG,arg);
84 if (res)
85 SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",([A_STR:-30])}));
86 else
87 SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",0 }));
88 return res;
89}
90
91public void NotifyInsert(object ob, object oldenv)
92{
93 ::NotifyInsert(ob, oldenv);
Zesstra98d32002019-10-17 23:50:21 +020094 // Alle Listener vom InsertHook informieren
MG Mud User88f12472016-06-24 23:31:02 +020095 HookFlow(H_HOOK_INSERT, ob);
MG Mud User88f12472016-06-24 23:31:02 +020096}
97
98void AddInsertHook(object ob)
99{
Zesstra98d32002019-10-17 23:50:21 +0200100 raise_error("Diese Funktion gibt es nicht mehr. Bitte das neue "
101 "Hooksystem nutzen!\n");
MG Mud User88f12472016-06-24 23:31:02 +0200102}
103