MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 1 | // 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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 27 | |
| 28 | inherit "/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 User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 42 | // local properties prototypes |
| 43 | static int _query_max_weight(); |
| 44 | static mixed _set_frog(mixed arg); |
| 45 | |
Zesstra | 98d3200 | 2019-10-17 23:50:21 +0200 | [diff] [blame] | 46 | protected void create() |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 47 | { |
| 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 |
| 56 | static int _query_max_weight() { |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 57 | if (QueryProp(P_GHOST) && !IS_WIZARD(ME)) |
| 58 | return 0; |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 59 | int str=QueryAttribute(A_STR); |
| 60 | int ski = UseSkill(SK_CARRY, ([SI_SKILLARG : str ])); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 61 | |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 62 | int val; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 63 | if (str<0) { |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 64 | val=9200+str*160+ski; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 65 | if (val<3000) val=3000; |
| 66 | return val; |
| 67 | } |
Vanion | 5065232 | 2020-03-10 21:13:25 +0100 | [diff] [blame] | 68 | val = 9200+str*800+ski; |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 69 | if (val<3000) |
| 70 | val = 3000; |
| 71 | return val; |
| 72 | } |
| 73 | |
| 74 | static mixed _set_frog(mixed arg) { |
| 75 | mixed res; |
| 76 | |
| 77 | res=Set(P_FROG,arg); |
| 78 | if (res) |
| 79 | SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",([A_STR:-30])})); |
| 80 | else |
| 81 | SetProp(P_ATTRIBUTES_MODIFIER,({"#frosch",0 })); |
| 82 | return res; |
| 83 | } |
| 84 | |
| 85 | public void NotifyInsert(object ob, object oldenv) |
| 86 | { |
| 87 | ::NotifyInsert(ob, oldenv); |
Zesstra | 98d3200 | 2019-10-17 23:50:21 +0200 | [diff] [blame] | 88 | // Alle Listener vom InsertHook informieren |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 89 | HookFlow(H_HOOK_INSERT, ob); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void AddInsertHook(object ob) |
| 93 | { |
Zesstra | 98d3200 | 2019-10-17 23:50:21 +0200 | [diff] [blame] | 94 | raise_error("Diese Funktion gibt es nicht mehr. Bitte das neue " |
| 95 | "Hooksystem nutzen!\n"); |
MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame] | 96 | } |
| 97 | |