blob: dc00415a45cc4e9fb9a3770ea4defb88b007ea9f [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
MG Mud User88f12472016-06-24 23:31:02 +020027
28inherit "/std/container/restrictions";
29
30#define NEED_PROTOTYPES
31#include <thing/properties.h>
32#include <hook.h>
33#include <living/skills.h>
34#include <attributes.h>
35#undef NEED_PROTOTYPES
36#include <properties.h>
37#include <wizlevels.h>
38#include <container.h>
39#include <defines.h>
40#include <new_skills.h>
41
MG Mud User88f12472016-06-24 23:31:02 +020042// local properties prototypes
43static int _query_max_weight();
44static mixed _set_frog(mixed arg);
45
Zesstra98d32002019-10-17 23:50:21 +020046protected void create()
MG Mud User88f12472016-06-24 23:31:02 +020047{
48 ::create();
49
50 Set(P_MAX_WEIGHT, NOSETMETHOD, F_SET_METHOD);
51 Set(P_MAX_WEIGHT, SECURED, F_MODE);
52 offerHook(H_HOOK_INSERT, 1);
53}
54
55// **** local property methods
56static int _query_max_weight() {
57 int str,val;
58 mixed ski;
59
60 if (QueryProp(P_GHOST) && !IS_WIZARD(ME))
61 return 0;
62 str=QueryAttribute(A_STR);
63 ski = UseSkill(SK_CARRY, ([SI_SKILLARG : str ]));
64
65 if (!intp(ski))
66 ski = 0;
67
68 if (str<0) {
69 val=9200+str*160+(int)ski;
70 if (val<3000) val=3000;
71 return val;
72 }
73 val = 9200+str*800+(int)ski;
74 if (val<3000)
75 val = 3000;
76 return val;
77}
78
79static mixed _set_frog(mixed arg) {
80 mixed res;
81
82 res=Set(P_FROG,arg);
83 if (res)
84 SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",([A_STR:-30])}));
85 else
86 SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",0 }));
87 return res;
88}
89
90public void NotifyInsert(object ob, object oldenv)
91{
92 ::NotifyInsert(ob, oldenv);
Zesstra98d32002019-10-17 23:50:21 +020093 // Alle Listener vom InsertHook informieren
MG Mud User88f12472016-06-24 23:31:02 +020094 HookFlow(H_HOOK_INSERT, ob);
MG Mud User88f12472016-06-24 23:31:02 +020095}
96
97void AddInsertHook(object ob)
98{
Zesstra98d32002019-10-17 23:50:21 +020099 raise_error("Diese Funktion gibt es nicht mehr. Bitte das neue "
100 "Hooksystem nutzen!\n");
MG Mud User88f12472016-06-24 23:31:02 +0200101}
102