1 | /* |
1 | /* |
2 | * static char *rcsid_button_c = |
2 | * static char *rcsid_button_c = |
3 | * "$Id: button.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; |
3 | * "$Id: button.C,v 1.6 2006/09/03 00:18:39 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
32 | /* |
32 | /* |
33 | * This code is no longer highly inefficient 8) |
33 | * This code is no longer highly inefficient 8) |
34 | */ |
34 | */ |
35 | |
35 | |
36 | /* |
36 | /* |
|
|
37 | * elmex: |
|
|
38 | * This function takes a objectlink list with all the objects are going to be activated. |
|
|
39 | * state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. |
|
|
40 | * The source argument can be 0 or the source object for this activation. |
|
|
41 | */ |
|
|
42 | void activate_connection_link (objectlink *ol, bool state, object *source = 0) |
|
|
43 | { |
|
|
44 | object *tmp = 0; |
|
|
45 | |
|
|
46 | for (; ol; ol = ol->next) |
|
|
47 | { |
|
|
48 | if (!ol->ob || ol->ob->count != ol->id) |
|
|
49 | { |
|
|
50 | LOG (llevError, "Internal error in activate_connection_link (%ld).\n", ol->id); |
|
|
51 | continue; |
|
|
52 | } |
|
|
53 | /* a button link object can become freed when the map is saving. As |
|
|
54 | * a map is saved, objects are removed and freed, and if an object is |
|
|
55 | * on top of a button, this function is eventually called. If a map |
|
|
56 | * is getting moved out of memory, the status of buttons and levers |
|
|
57 | * probably isn't important - it will get sorted out when the map is |
|
|
58 | * re-loaded. As such, just exit this function if that is the case. |
|
|
59 | */ |
|
|
60 | |
|
|
61 | if (QUERY_FLAG (ol->ob, FLAG_FREED)) |
|
|
62 | return; |
|
|
63 | tmp = ol->ob; |
|
|
64 | |
|
|
65 | /* if the criteria isn't appropriate, don't do anything */ |
|
|
66 | if (state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_PUSH)) |
|
|
67 | continue; |
|
|
68 | if (!state && !QUERY_FLAG (tmp, FLAG_ACTIVATE_ON_RELEASE)) |
|
|
69 | continue; |
|
|
70 | |
|
|
71 | switch (tmp->type) |
|
|
72 | { |
|
|
73 | case GATE: |
|
|
74 | case HOLE: |
|
|
75 | tmp->value = tmp->stats.maxsp ? !state : state; |
|
|
76 | tmp->speed = 0.5; |
|
|
77 | update_ob_speed (tmp); |
|
|
78 | break; |
|
|
79 | |
|
|
80 | case CF_HANDLE: |
|
|
81 | SET_ANIMATION (tmp, |
|
|
82 | (tmp->value = |
|
|
83 | tmp->stats.maxsp ? !state : state)); |
|
|
84 | update_object (tmp, UP_OBJ_FACE); |
|
|
85 | break; |
|
|
86 | |
|
|
87 | case SIGN: |
|
|
88 | if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) |
|
|
89 | { |
|
|
90 | new_info_map (NDI_UNIQUE | NDI_NAVY, tmp->map, tmp->msg); |
|
|
91 | if (tmp->stats.food) |
|
|
92 | tmp->last_eat++; |
|
|
93 | } |
|
|
94 | break; |
|
|
95 | |
|
|
96 | case ALTAR: |
|
|
97 | tmp->value = 1; |
|
|
98 | SET_ANIMATION (tmp, tmp->value); |
|
|
99 | update_object (tmp, UP_OBJ_FACE); |
|
|
100 | break; |
|
|
101 | |
|
|
102 | case BUTTON: |
|
|
103 | case PEDESTAL: |
|
|
104 | tmp->value = state; |
|
|
105 | SET_ANIMATION (tmp, tmp->value); |
|
|
106 | update_object (tmp, UP_OBJ_FACE); |
|
|
107 | break; |
|
|
108 | |
|
|
109 | case MOOD_FLOOR: |
|
|
110 | do_mood_floor (tmp, source); |
|
|
111 | break; |
|
|
112 | |
|
|
113 | case TIMED_GATE: |
|
|
114 | tmp->speed = tmp->arch->clone.speed; |
|
|
115 | update_ob_speed (tmp); /* original values */ |
|
|
116 | tmp->value = tmp->arch->clone.value; |
|
|
117 | tmp->stats.sp = 1; |
|
|
118 | tmp->stats.hp = tmp->stats.maxhp; |
|
|
119 | /* Handle multipart gates. We copy the value for the other parts |
|
|
120 | * from the head - this ensures that the data will consistent |
|
|
121 | */ |
|
|
122 | for (tmp = tmp->more; tmp != NULL; tmp = tmp->more) |
|
|
123 | { |
|
|
124 | tmp->speed = tmp->head->speed; |
|
|
125 | tmp->value = tmp->head->value; |
|
|
126 | tmp->stats.sp = tmp->head->stats.sp; |
|
|
127 | tmp->stats.hp = tmp->head->stats.hp; |
|
|
128 | update_ob_speed (tmp); |
|
|
129 | } |
|
|
130 | break; |
|
|
131 | |
|
|
132 | case DIRECTOR: |
|
|
133 | case FIREWALL: |
|
|
134 | if (!QUERY_FLAG (tmp, FLAG_ANIMATE) && tmp->type == FIREWALL) |
|
|
135 | move_firewall (tmp); |
|
|
136 | else |
|
|
137 | { |
|
|
138 | if ((tmp->stats.sp += tmp->stats.maxsp) > 8) /* next direction */ |
|
|
139 | tmp->stats.sp = ((tmp->stats.sp - 1) % 8) + 1; |
|
|
140 | animate_turning (tmp); |
|
|
141 | } |
|
|
142 | break; |
|
|
143 | |
|
|
144 | case TELEPORTER: |
|
|
145 | move_teleporter (tmp); |
|
|
146 | break; |
|
|
147 | |
|
|
148 | case CREATOR: |
|
|
149 | move_creator (tmp); |
|
|
150 | break; |
|
|
151 | |
|
|
152 | case TRIGGER_MARKER: |
|
|
153 | move_marker (tmp); |
|
|
154 | break; |
|
|
155 | |
|
|
156 | case DUPLICATOR: |
|
|
157 | move_duplicator (tmp); |
|
|
158 | break; |
|
|
159 | } |
|
|
160 | } |
|
|
161 | } |
|
|
162 | |
|
|
163 | /* |
|
|
164 | * elmex: |
|
|
165 | * This is the new push_button function, it got split up so that |
|
|
166 | * you can activate connections without a button now! |
|
|
167 | * old but still valid comment: |
|
|
168 | * |
37 | * Push the specified object. This can affect other buttons/gates/handles |
169 | * Push the specified object. This can affect other buttons/gates/handles |
38 | * altars/pedestals/holes in the whole map. |
170 | * altars/pedestals/holes in the whole map. |
39 | * Changed the routine to loop through _all_ objects. |
171 | * Changed the routine to loop through _all_ objects. |
40 | * Better hurry with that linked list... |
172 | * Better hurry with that linked list... |
41 | */ |
173 | * |
42 | |
174 | */ |
43 | void push_button(object *op) { |
175 | void push_button (object *op) |
44 | object *tmp; |
176 | { |
45 | objectlink *ol; |
177 | oblinkpt *obp = get_button_links (op); |
46 | |
178 | |
47 | /* LOG(llevDebug, "push_button: %s (%d)\n", op->name, op->count); */ |
179 | if (!obp) |
48 | for (ol = get_button_links(op); ol; ol = ol->next) { |
180 | return; |
49 | if (!ol->ob || ol->ob->count != ol->id) { |
181 | |
50 | LOG(llevError, "Internal error in push_button (%s).\n", op->name); |
182 | if (INVOKE_MAP (TRIGGER, op->map, ARG_INT64(obp->value), ARG_INT(op->value))) |
51 | continue; |
183 | return; |
52 | } |
184 | |
53 | /* a button link object can become freed when the map is saving. As |
185 | activate_connection_link (obp->link, op->value, op); |
54 | * a map is saved, objects are removed and freed, and if an object is |
186 | } |
55 | * on top of a button, this function is eventually called. If a map |
187 | |
56 | * is getting moved out of memory, the status of buttons and levers |
188 | /* |
57 | * probably isn't important - it will get sorted out when the map is |
189 | * elmex: |
58 | * re-loaded. As such, just exit this function if that is the case. |
190 | * This activates a connection, similar to push_button (object *op) but it takes |
|
|
191 | * only a map, a connection value and a true or false flag that indicated whether |
|
|
192 | * the connection was 'state' or 'released'. So that you can activate objects |
|
|
193 | * who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
|
|
194 | * |
59 | */ |
195 | */ |
60 | |
196 | void activate_connection (mapstruct *map, long connection, bool state) |
61 | if (QUERY_FLAG(ol->ob, FLAG_FREED)) return; |
197 | { |
62 | tmp = ol->ob; |
198 | if (INVOKE_MAP (TRIGGER, map, ARG_INT64(connection), ARG_INT(state))) |
|
|
199 | return; |
63 | |
200 | |
64 | /* if the criteria isn't appropriate, don't do anything */ |
201 | oblinkpt *obp = get_connection_links (map, connection); |
65 | if (op->value && !QUERY_FLAG(tmp, FLAG_ACTIVATE_ON_PUSH)) continue; |
202 | if (obp) |
66 | if (!op->value && !QUERY_FLAG(tmp, FLAG_ACTIVATE_ON_RELEASE)) continue; |
203 | activate_connection_link (obp->link, state); |
67 | |
|
|
68 | switch(tmp->type) { |
|
|
69 | |
|
|
70 | case GATE: |
|
|
71 | case HOLE: |
|
|
72 | tmp->value=tmp->stats.maxsp?!op->value:op->value; |
|
|
73 | tmp->speed=0.5; |
|
|
74 | update_ob_speed(tmp); |
|
|
75 | break; |
|
|
76 | |
|
|
77 | case CF_HANDLE: |
|
|
78 | SET_ANIMATION(tmp, (tmp->value=tmp->stats.maxsp?!op->value:op->value)); |
|
|
79 | update_object(tmp,UP_OBJ_FACE); |
|
|
80 | break; |
|
|
81 | |
|
|
82 | case SIGN: |
|
|
83 | if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) { |
|
|
84 | new_info_map(NDI_UNIQUE | NDI_NAVY,tmp->map,tmp->msg); |
|
|
85 | if (tmp->stats.food) tmp->last_eat++; |
|
|
86 | } |
|
|
87 | break; |
|
|
88 | |
|
|
89 | case ALTAR: |
|
|
90 | tmp->value = 1; |
|
|
91 | SET_ANIMATION(tmp, tmp->value); |
|
|
92 | update_object(tmp,UP_OBJ_FACE); |
|
|
93 | break; |
|
|
94 | |
|
|
95 | case BUTTON: |
|
|
96 | case PEDESTAL: |
|
|
97 | tmp->value=op->value; |
|
|
98 | SET_ANIMATION(tmp, tmp->value); |
|
|
99 | update_object(tmp,UP_OBJ_FACE); |
|
|
100 | break; |
|
|
101 | |
|
|
102 | case MOOD_FLOOR: |
|
|
103 | do_mood_floor(tmp, op); |
|
|
104 | break; |
|
|
105 | |
|
|
106 | case TIMED_GATE: |
|
|
107 | tmp->speed = tmp->arch->clone.speed; |
|
|
108 | update_ob_speed(tmp); /* original values */ |
|
|
109 | tmp->value = tmp->arch->clone.value; |
|
|
110 | tmp->stats.sp = 1; |
|
|
111 | tmp->stats.hp = tmp->stats.maxhp; |
|
|
112 | /* Handle multipart gates. We copy the value for the other parts |
|
|
113 | * from the head - this ensures that the data will consistent |
|
|
114 | */ |
|
|
115 | for (tmp=tmp->more; tmp!=NULL; tmp=tmp->more) { |
|
|
116 | tmp->speed = tmp->head->speed; |
|
|
117 | tmp->value = tmp->head->value; |
|
|
118 | tmp->stats.sp = tmp->head->stats.sp; |
|
|
119 | tmp->stats.hp = tmp->head->stats.hp; |
|
|
120 | update_ob_speed(tmp); |
|
|
121 | } |
|
|
122 | break; |
|
|
123 | |
|
|
124 | case DIRECTOR: |
|
|
125 | case FIREWALL: |
|
|
126 | if(!QUERY_FLAG(tmp,FLAG_ANIMATE)&&tmp->type==FIREWALL) move_firewall(tmp); |
|
|
127 | else { |
|
|
128 | if ((tmp->stats.sp += tmp->stats.maxsp) > 8) /* next direction */ |
|
|
129 | tmp->stats.sp = ((tmp->stats.sp-1)%8)+1; |
|
|
130 | animate_turning(tmp); |
|
|
131 | } |
|
|
132 | break; |
|
|
133 | |
|
|
134 | case TELEPORTER: |
|
|
135 | move_teleporter(tmp); |
|
|
136 | break; |
|
|
137 | |
|
|
138 | case CREATOR: |
|
|
139 | move_creator(tmp); |
|
|
140 | break; |
|
|
141 | |
|
|
142 | case TRIGGER_MARKER: |
|
|
143 | move_marker(tmp); |
|
|
144 | break; |
|
|
145 | |
|
|
146 | case DUPLICATOR: |
|
|
147 | move_duplicator(tmp); |
|
|
148 | break; |
|
|
149 | } |
|
|
150 | } |
|
|
151 | } |
204 | } |
152 | |
205 | |
153 | /* |
206 | /* |
154 | * Updates everything connected with the button op. |
207 | * Updates everything connected with the button op. |
155 | * After changing the state of a button, this function must be called |
208 | * After changing the state of a button, this function must be called |
… | |
… | |
158 | */ |
211 | */ |
159 | |
212 | |
160 | void update_button(object *op) { |
213 | void update_button(object *op) { |
161 | object *ab,*tmp,*head; |
214 | object *ab,*tmp,*head; |
162 | int tot,any_down=0, old_value=op->value; |
215 | int tot,any_down=0, old_value=op->value; |
|
|
216 | oblinkpt *obp = 0; |
163 | objectlink *ol; |
217 | objectlink *ol; |
164 | |
218 | |
|
|
219 | obp = get_button_links (op); |
165 | /* LOG(llevDebug, "update_button: %s (%d)\n", op->name, op->count); */ |
220 | /* LOG(llevDebug, "update_button: %s (%d)\n", op->name, op->count); */ |
|
|
221 | if (obp) |
166 | for (ol = get_button_links(op); ol; ol = ol->next) { |
222 | for (ol = obp->link; ol; ol = ol->next) { |
167 | if (!ol->ob || ol->ob->count != ol->id) { |
223 | if (!ol->ob || ol->ob->count != ol->id) { |
168 | LOG(llevDebug, "Internal error in update_button (%s).\n", op->name); |
224 | LOG(llevDebug, "Internal error in update_button (%s).\n", &op->name); |
169 | continue; |
225 | continue; |
170 | } |
226 | } |
171 | tmp = ol->ob; |
227 | tmp = ol->ob; |
172 | if (tmp->type==BUTTON) { |
228 | if (tmp->type==BUTTON) { |
173 | for(ab=tmp->above,tot=0;ab!=NULL;ab=ab->above) |
229 | for(ab=tmp->above,tot=0;ab!=NULL;ab=ab->above) |
174 | /* Bug? The pedestal code below looks for the head of |
230 | /* Bug? The pedestal code below looks for the head of |
175 | * the object, this bit doesn't. I'd think we should check |
231 | * the object, this bit doesn't. I'd think we should check |
176 | * for head here also. Maybe it also makese sense to |
232 | * for head here also. Maybe it also makese sense to |
177 | * make the for ab=tmp->above loop common, and alter |
233 | * make the for ab=tmp->above loop common, and alter |
178 | * behaviour based on object within that loop? |
234 | * behaviour based on object within that loop? |
179 | */ |
235 | */ |
180 | |
236 | |
181 | /* Basically, if the move_type matches that on what the |
237 | /* Basically, if the move_type matches that on what the |
182 | * button wants, we count it. The second check is so that |
238 | * button wants, we count it. The second check is so that |
183 | * objects don't move (swords, etc) will count. Note that |
239 | * objects don't move (swords, etc) will count. Note that |
184 | * this means that more work is needed to make buttons |
240 | * this means that more work is needed to make buttons |
185 | * that are only triggered by flying objects. |
241 | * that are only triggered by flying objects. |
186 | */ |
242 | */ |
187 | if ((ab->move_type & tmp->move_on) || ab->move_type==0 ) |
243 | if ((ab->move_type & tmp->move_on) || ab->move_type==0 ) |
188 | tot+=ab->weight*(ab->nrof?ab->nrof:1)+ab->carrying; |
244 | tot+=ab->weight*(ab->nrof?ab->nrof:1)+ab->carrying; |
189 | |
245 | |
190 | tmp->value=(tot>=tmp->weight)?1:0; |
246 | tmp->value=(tot>=tmp->weight)?1:0; |
191 | if(tmp->value) |
247 | if(tmp->value) |
192 | any_down=1; |
248 | any_down=1; |
193 | } else if (tmp->type == PEDESTAL) { |
249 | } else if (tmp->type == PEDESTAL) { |
194 | tmp->value = 0; |
250 | tmp->value = 0; |
195 | for(ab=tmp->above; ab!=NULL; ab=ab->above) { |
251 | for(ab=tmp->above; ab!=NULL; ab=ab->above) { |
196 | head = ab->head ? ab->head : ab; |
252 | head = ab->head ? ab->head : ab; |
197 | /* Same note regarding move_type for buttons above apply here. */ |
253 | /* Same note regarding move_type for buttons above apply here. */ |
198 | if ( ((head->move_type & tmp->move_on) || ab->move_type==0) && |
254 | if ( ((head->move_type & tmp->move_on) || ab->move_type==0) && |
199 | (head->race==tmp->slaying || |
255 | (head->race==tmp->slaying || |
200 | ((head->type==SPECIAL_KEY) && (head->slaying==tmp->slaying)) || |
256 | ((head->type==SPECIAL_KEY) && (head->slaying==tmp->slaying)) || |
201 | (!strcmp (tmp->slaying, "player") && |
257 | (!strcmp (tmp->slaying, "player") && |
202 | head->type == PLAYER))) |
258 | head->type == PLAYER))) |
203 | tmp->value = 1; |
259 | tmp->value = 1; |
204 | } |
260 | } |
205 | if(tmp->value) |
261 | if(tmp->value) |
206 | any_down=1; |
262 | any_down=1; |
207 | } |
263 | } |
208 | } |
264 | } |
209 | if(any_down) /* If any other buttons were down, force this to remain down */ |
265 | if(any_down) /* If any other buttons were down, force this to remain down */ |
210 | op->value=1; |
266 | op->value=1; |
211 | |
267 | |
212 | /* If this button hasn't changed, don't do anything */ |
268 | /* If this button hasn't changed, don't do anything */ |
213 | if (op->value != old_value) { |
269 | if (op->value != old_value) { |
214 | SET_ANIMATION(op, op->value); |
270 | SET_ANIMATION(op, op->value); |
215 | update_object(op, UP_OBJ_FACE); |
271 | update_object(op, UP_OBJ_FACE); |
216 | push_button(op); /* Make all other buttons the same */ |
272 | push_button(op); /* Make all other buttons the same */ |
217 | } |
273 | } |
218 | } |
274 | } |
219 | |
275 | |
220 | /* |
276 | /* |
221 | * Updates every button on the map (by calling update_button() for them). |
277 | * Updates every button on the map (by calling update_button() for them). |
… | |
… | |
226 | oblinkpt *obp; |
282 | oblinkpt *obp; |
227 | for (obp = m->buttons; obp; obp = obp->next) |
283 | for (obp = m->buttons; obp; obp = obp->next) |
228 | for (ol = obp->link; ol; ol = ol->next) { |
284 | for (ol = obp->link; ol; ol = ol->next) { |
229 | if (!ol->ob || ol->ob->count != ol->id) { |
285 | if (!ol->ob || ol->ob->count != ol->id) { |
230 | LOG(llevError, "Internal error in update_button (%s (%dx%d):%d, connected %ld).\n", |
286 | LOG(llevError, "Internal error in update_button (%s (%dx%d):%d, connected %ld).\n", |
231 | ol->ob?ol->ob->name:"null", |
287 | ol->ob?(const char *)ol->ob->name:"null", |
232 | ol->ob?ol->ob->x:-1, |
288 | ol->ob?ol->ob->x:-1, |
233 | ol->ob?ol->ob->y:-1, |
289 | ol->ob?ol->ob->y:-1, |
234 | ol->id, |
290 | ol->id, |
235 | obp->value); |
291 | obp->value); |
236 | continue; |
292 | continue; |
237 | } |
293 | } |
238 | if (ol->ob->type==BUTTON || ol->ob->type==PEDESTAL) |
294 | if (ol->ob->type==BUTTON || ol->ob->type==PEDESTAL) |
239 | { |
295 | { |
240 | update_button(ol->ob); |
296 | update_button(ol->ob); |
… | |
… | |
259 | void animate_turning(object *op) /* only one part objects */ |
315 | void animate_turning(object *op) /* only one part objects */ |
260 | { |
316 | { |
261 | if (++op->state >= NUM_ANIMATIONS(op)/8) |
317 | if (++op->state >= NUM_ANIMATIONS(op)/8) |
262 | op->state=0; |
318 | op->state=0; |
263 | SET_ANIMATION(op, (op->stats.sp-1) * NUM_ANIMATIONS(op) / 8 + |
319 | SET_ANIMATION(op, (op->stats.sp-1) * NUM_ANIMATIONS(op) / 8 + |
264 | op->state); |
320 | op->state); |
265 | update_object(op,UP_OBJ_FACE); |
321 | update_object(op,UP_OBJ_FACE); |
266 | } |
322 | } |
267 | |
323 | |
268 | #define ARCH_SACRIFICE(xyz) ((xyz)->slaying) |
324 | #define ARCH_SACRIFICE(xyz) ((xyz)->slaying) |
269 | #define NROF_SACRIFICE(xyz) ((uint32)(xyz)->stats.food) |
325 | #define NROF_SACRIFICE(xyz) ((uint32)(xyz)->stats.food) |
… | |
… | |
284 | if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE) |
340 | if ( ! QUERY_FLAG (sacrifice, FLAG_ALIVE) |
285 | && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED) |
341 | && ! QUERY_FLAG (sacrifice, FLAG_IS_LINKED) |
286 | && sacrifice->type != PLAYER) |
342 | && sacrifice->type != PLAYER) |
287 | { |
343 | { |
288 | if ((ARCH_SACRIFICE(altar) == sacrifice->arch->name || |
344 | if ((ARCH_SACRIFICE(altar) == sacrifice->arch->name || |
289 | ARCH_SACRIFICE(altar) == sacrifice->name || |
345 | ARCH_SACRIFICE(altar) == sacrifice->name || |
290 | ARCH_SACRIFICE(altar) == sacrifice->slaying || |
346 | ARCH_SACRIFICE(altar) == sacrifice->slaying || |
291 | (!strcmp(ARCH_SACRIFICE(altar),query_base_name(sacrifice,0)))) |
347 | (!strcmp(ARCH_SACRIFICE(altar),query_base_name(sacrifice,0)))) |
292 | && NROF_SACRIFICE(altar) <= (sacrifice->nrof?sacrifice->nrof:1)) |
348 | && NROF_SACRIFICE(altar) <= (sacrifice->nrof?sacrifice->nrof:1)) |
293 | return 1; |
349 | return 1; |
294 | if (strcmp (ARCH_SACRIFICE(altar), "money") == 0 |
350 | if (strcmp (ARCH_SACRIFICE(altar), "money") == 0 |
295 | && sacrifice->type == MONEY |
351 | && sacrifice->type == MONEY |
296 | && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE(altar)) |
352 | && sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE(altar)) |
297 | return 1; |
353 | return 1; |
298 | } |
354 | } |
299 | return 0; |
355 | return 0; |
300 | } |
356 | } |
301 | |
357 | |
302 | |
358 | |
… | |
… | |
326 | |
382 | |
327 | /* check_altar_sacrifice should have already verified that enough money |
383 | /* check_altar_sacrifice should have already verified that enough money |
328 | * has been dropped. |
384 | * has been dropped. |
329 | */ |
385 | */ |
330 | if (!strcmp(ARCH_SACRIFICE(altar), "money")) { |
386 | if (!strcmp(ARCH_SACRIFICE(altar), "money")) { |
331 | int number=NROF_SACRIFICE(altar) / (*sacrifice)->value; |
387 | int number=NROF_SACRIFICE(altar) / (*sacrifice)->value; |
332 | |
388 | |
333 | /* Round up any sacrifices. Altars don't make change either */ |
389 | /* Round up any sacrifices. Altars don't make change either */ |
334 | if (NROF_SACRIFICE(altar) % (*sacrifice)->value) number++; |
390 | if (NROF_SACRIFICE(altar) % (*sacrifice)->value) number++; |
335 | *sacrifice = decrease_ob_nr (*sacrifice, number); |
391 | *sacrifice = decrease_ob_nr (*sacrifice, number); |
336 | } |
392 | } |
337 | else |
393 | else |
338 | *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE(altar)); |
394 | *sacrifice = decrease_ob_nr (*sacrifice, NROF_SACRIFICE(altar)); |
339 | |
395 | |
340 | if (altar->msg) |
396 | if (altar->msg) |
… | |
… | |
344 | |
400 | |
345 | void trigger_move (object *op, int state) /* 1 down and 0 up */ |
401 | void trigger_move (object *op, int state) /* 1 down and 0 up */ |
346 | { |
402 | { |
347 | op->stats.wc = state; |
403 | op->stats.wc = state; |
348 | if (state) { |
404 | if (state) { |
349 | use_trigger(op); |
405 | use_trigger(op); |
350 | if (op->stats.exp > 0) /* check sanity */ |
406 | if (op->stats.exp > 0) /* check sanity */ |
351 | op->speed = 1.0 / op->stats.exp; |
407 | op->speed = 1.0 / op->stats.exp; |
352 | else |
408 | else |
353 | op->speed = 1.0; |
409 | op->speed = 1.0; |
354 | update_ob_speed(op); |
410 | update_ob_speed(op); |
355 | op->speed_left = -1; |
411 | op->speed_left = -1; |
356 | } else { |
412 | } else { |
357 | use_trigger(op); |
413 | use_trigger(op); |
358 | op->speed = 0; |
414 | op->speed = 0; |
359 | update_ob_speed(op); |
415 | update_ob_speed(op); |
360 | } |
416 | } |
361 | } |
417 | } |
362 | |
418 | |
363 | |
419 | |
364 | /* |
420 | /* |
… | |
… | |
378 | object *tmp; |
434 | object *tmp; |
379 | int push = 0, tot = 0; |
435 | int push = 0, tot = 0; |
380 | int in_movement = op->stats.wc || op->speed; |
436 | int in_movement = op->stats.wc || op->speed; |
381 | |
437 | |
382 | switch (op->type) { |
438 | switch (op->type) { |
383 | case TRIGGER_BUTTON: |
439 | case TRIGGER_BUTTON: |
384 | if (op->weight > 0) { |
440 | if (op->weight > 0) { |
385 | if (cause) { |
441 | if (cause) { |
386 | for (tmp = op->above; tmp; tmp = tmp->above) |
442 | for (tmp = op->above; tmp; tmp = tmp->above) |
387 | /* Comment reproduced from update_buttons(): */ |
443 | /* Comment reproduced from update_buttons(): */ |
388 | /* Basically, if the move_type matches that on what the |
444 | /* Basically, if the move_type matches that on what the |
389 | * button wants, we count it. The second check is so that |
445 | * button wants, we count it. The second check is so that |
390 | * objects that don't move (swords, etc) will count. Note that |
446 | * objects that don't move (swords, etc) will count. Note that |
391 | * this means that more work is needed to make buttons |
447 | * this means that more work is needed to make buttons |
392 | * that are only triggered by flying objects. |
448 | * that are only triggered by flying objects. |
393 | */ |
449 | */ |
394 | |
450 | |
395 | if ((tmp->move_type & op->move_on) || tmp->move_type==0) { |
451 | if ((tmp->move_type & op->move_on) || tmp->move_type==0) { |
396 | tot += tmp->weight * (tmp->nrof ? tmp->nrof : 1) |
452 | tot += tmp->weight * (tmp->nrof ? tmp->nrof : 1) |
397 | + tmp->carrying; |
453 | + tmp->carrying; |
398 | } |
454 | } |
399 | if (tot >= op->weight) |
455 | if (tot >= op->weight) |
400 | push = 1; |
456 | push = 1; |
401 | if (op->stats.ac == push) |
457 | if (op->stats.ac == push) |
402 | return 0; |
458 | return 0; |
403 | op->stats.ac = push; |
459 | op->stats.ac = push; |
404 | if (NUM_ANIMATIONS(op) > 1) { |
460 | if (NUM_ANIMATIONS(op) > 1) { |
405 | SET_ANIMATION (op, push); |
461 | SET_ANIMATION (op, push); |
406 | update_object (op, UP_OBJ_FACE); |
462 | update_object (op, UP_OBJ_FACE); |
407 | } |
463 | } |
408 | if (in_movement || ! push) |
464 | if (in_movement || ! push) |
409 | return 0; |
465 | return 0; |
410 | } |
466 | } |
411 | trigger_move (op, push); |
467 | trigger_move (op, push); |
412 | } |
468 | } |
413 | return 0; |
469 | return 0; |
414 | |
470 | |
415 | case TRIGGER_PEDESTAL: |
471 | case TRIGGER_PEDESTAL: |
416 | if (cause) { |
472 | if (cause) { |
417 | for (tmp = op->above; tmp; tmp = tmp->above) { |
473 | for (tmp = op->above; tmp; tmp = tmp->above) { |
418 | object *head = tmp->head ? tmp->head : tmp; |
474 | object *head = tmp->head ? tmp->head : tmp; |
419 | |
475 | |
420 | /* See comment in TRIGGER_BUTTON about move_types */ |
476 | /* See comment in TRIGGER_BUTTON about move_types */ |
421 | if (((head->move_type & op->move_on) || head->move_type==0) |
477 | if (((head->move_type & op->move_on) || head->move_type==0) |
422 | && (head->race==op->slaying || |
478 | && (head->race==op->slaying || |
423 | (!strcmp (op->slaying, "player") && head->type == PLAYER))) { |
479 | (!strcmp (op->slaying, "player") && head->type == PLAYER))) { |
424 | push = 1; |
480 | push = 1; |
425 | break; |
481 | break; |
426 | } |
482 | } |
427 | } |
483 | } |
428 | if (op->stats.ac == push) |
484 | if (op->stats.ac == push) |
429 | return 0; |
485 | return 0; |
430 | op->stats.ac = push; |
486 | op->stats.ac = push; |
431 | if (NUM_ANIMATIONS(op) > 1) { |
487 | if (NUM_ANIMATIONS(op) > 1) { |
432 | SET_ANIMATION (op, push); |
488 | SET_ANIMATION (op, push); |
433 | update_object (op, UP_OBJ_FACE); |
489 | update_object (op, UP_OBJ_FACE); |
434 | } |
490 | } |
435 | update_object(op,UP_OBJ_FACE); |
491 | update_object(op,UP_OBJ_FACE); |
436 | if (in_movement || ! push) |
492 | if (in_movement || ! push) |
437 | return 0; |
493 | return 0; |
438 | } |
494 | } |
439 | trigger_move (op, push); |
495 | trigger_move (op, push); |
440 | return 0; |
496 | return 0; |
441 | |
497 | |
442 | case TRIGGER_ALTAR: |
498 | case TRIGGER_ALTAR: |
443 | if (cause) { |
499 | if (cause) { |
444 | if (in_movement) |
500 | if (in_movement) |
445 | return 0; |
501 | return 0; |
446 | if (operate_altar (op, &cause)) { |
502 | if (operate_altar (op, &cause)) { |
447 | if (NUM_ANIMATIONS(op) > 1) { |
503 | if (NUM_ANIMATIONS(op) > 1) { |
448 | SET_ANIMATION (op, 1); |
504 | SET_ANIMATION (op, 1); |
449 | update_object(op, UP_OBJ_FACE); |
505 | update_object(op, UP_OBJ_FACE); |
450 | } |
506 | } |
451 | if (op->last_sp >= 0) { |
507 | if (op->last_sp >= 0) { |
452 | trigger_move (op, 1); |
508 | trigger_move (op, 1); |
453 | if (op->last_sp > 0) |
509 | if (op->last_sp > 0) |
454 | op->last_sp = -op->last_sp; |
510 | op->last_sp = -op->last_sp; |
455 | } |
511 | } |
456 | else { |
512 | else { |
457 | /* for trigger altar with last_sp, the ON/OFF |
513 | /* for trigger altar with last_sp, the ON/OFF |
458 | * status (-> +/- value) is "simulated": |
514 | * status (-> +/- value) is "simulated": |
459 | */ |
515 | */ |
460 | op->value = !op->value; |
516 | op->value = !op->value; |
461 | trigger_move (op, 1); |
517 | trigger_move (op, 1); |
462 | op->last_sp = -op->last_sp; |
518 | op->last_sp = -op->last_sp; |
463 | op->value = !op->value; |
519 | op->value = !op->value; |
464 | } |
520 | } |
465 | return cause == NULL; |
521 | return cause == NULL; |
466 | } else { |
522 | } else { |
467 | return 0; |
523 | return 0; |
468 | } |
524 | } |
469 | } else { |
525 | } else { |
470 | if (NUM_ANIMATIONS(op) > 1) { |
526 | if (NUM_ANIMATIONS(op) > 1) { |
471 | SET_ANIMATION (op, 0); |
527 | SET_ANIMATION (op, 0); |
472 | update_object(op, UP_OBJ_FACE); |
528 | update_object(op, UP_OBJ_FACE); |
473 | } |
529 | } |
474 | |
530 | |
475 | /* If trigger_altar has "last_sp > 0" set on the map, |
531 | /* If trigger_altar has "last_sp > 0" set on the map, |
476 | * it will push the connected value only once per sacrifice. |
532 | * it will push the connected value only once per sacrifice. |
477 | * Otherwise (default), the connected value will be |
533 | * Otherwise (default), the connected value will be |
478 | * pushed twice: First by sacrifice, second by reset! -AV |
534 | * pushed twice: First by sacrifice, second by reset! -AV |
479 | */ |
535 | */ |
480 | if (!op->last_sp) |
536 | if (!op->last_sp) |
481 | trigger_move (op, 0); |
537 | trigger_move (op, 0); |
482 | else { |
538 | else { |
483 | op->stats.wc = 0; |
539 | op->stats.wc = 0; |
484 | op->value = !op->value; |
540 | op->value = !op->value; |
485 | op->speed = 0; |
541 | op->speed = 0; |
486 | update_ob_speed(op); |
542 | update_ob_speed(op); |
487 | } |
543 | } |
488 | } |
544 | } |
489 | return 0; |
545 | return 0; |
490 | |
546 | |
491 | case TRIGGER: |
547 | case TRIGGER: |
492 | if (cause) { |
548 | if (cause) { |
493 | if (in_movement) |
549 | if (in_movement) |
494 | return 0; |
550 | return 0; |
495 | push = 1; |
551 | push = 1; |
496 | } |
552 | } |
497 | if (NUM_ANIMATIONS(op) > 1) { |
553 | if (NUM_ANIMATIONS(op) > 1) { |
498 | SET_ANIMATION (op, push); |
554 | SET_ANIMATION (op, push); |
499 | update_object(op, UP_OBJ_FACE); |
555 | update_object(op, UP_OBJ_FACE); |
500 | } |
556 | } |
501 | trigger_move (op, push); |
557 | trigger_move (op, push); |
502 | return 1; |
558 | return 1; |
503 | |
559 | |
504 | default: |
560 | default: |
505 | LOG(llevDebug, "Unknown trigger type: %s (%d)\n", op->name, op->type); |
561 | LOG(llevDebug, "Unknown trigger type: %s (%d)\n", &op->name, op->type); |
506 | return 0; |
562 | return 0; |
507 | } |
563 | } |
508 | } |
564 | } |
509 | |
565 | |
510 | void add_button_link(object *button, mapstruct *map, int connected) { |
566 | void add_button_link(object *button, mapstruct *map, int connected) { |
511 | oblinkpt *obp; |
567 | oblinkpt *obp; |
… | |
… | |
514 | if (!map) { |
570 | if (!map) { |
515 | LOG(llevError, "Tried to add button-link without map.\n"); |
571 | LOG(llevError, "Tried to add button-link without map.\n"); |
516 | return; |
572 | return; |
517 | } |
573 | } |
518 | if (!editor) button->path_attuned = connected; /* peterm: I need this so I can rebuild |
574 | if (!editor) button->path_attuned = connected; /* peterm: I need this so I can rebuild |
519 | a connected map from a template map. */ |
575 | a connected map from a template map. */ |
520 | /* LOG(llevDebug,"adding button %s (%d)\n", button->name, connected);*/ |
576 | /* LOG(llevDebug,"adding button %s (%d)\n", button->name, connected);*/ |
521 | |
577 | |
522 | SET_FLAG(button,FLAG_IS_LINKED); |
578 | SET_FLAG(button,FLAG_IS_LINKED); |
523 | |
579 | |
524 | ol->ob = button; |
580 | ol->ob = button; |
… | |
… | |
567 | return; |
623 | return; |
568 | } |
624 | } |
569 | LOG(llevError, "remove_button_linked(): couldn't find object.\n"); |
625 | LOG(llevError, "remove_button_linked(): couldn't find object.\n"); |
570 | CLEAR_FLAG(op,FLAG_IS_LINKED); |
626 | CLEAR_FLAG(op,FLAG_IS_LINKED); |
571 | } |
627 | } |
572 | |
628 | |
|
|
629 | /* |
|
|
630 | * Gets the objectlink for this connection from the map. |
|
|
631 | */ |
|
|
632 | oblinkpt *get_connection_links (mapstruct *map, long connection) |
|
|
633 | { |
|
|
634 | for (oblinkpt *obp = map->buttons; obp; obp = obp->next) |
|
|
635 | if (obp->value == connection) |
|
|
636 | return obp; |
|
|
637 | return 0; |
|
|
638 | } |
|
|
639 | |
573 | /* |
640 | /* |
574 | * Return the first objectlink in the objects linked to this one |
641 | * Return the first objectlink in the objects linked to this one |
575 | */ |
642 | */ |
576 | |
643 | |
577 | objectlink *get_button_links(const object *button) { |
644 | oblinkpt *get_button_links(const object *button) { |
578 | oblinkpt *obp; |
645 | oblinkpt *obp; |
579 | objectlink *ol; |
646 | objectlink *ol; |
580 | |
647 | |
581 | if (!button->map) |
648 | if (!button->map) |
582 | return NULL; |
649 | return NULL; |
583 | for (obp = button->map->buttons; obp; obp = obp->next) |
650 | for (obp = button->map->buttons; obp; obp = obp->next) |
584 | for (ol = obp->link; ol; ol = ol->next) |
651 | for (ol = obp->link; ol; ol = ol->next) |
585 | if (ol->ob == button && ol->id == button->count) |
652 | if (ol->ob == button && ol->id == button->count) |
586 | return obp->link; |
653 | return obp; |
587 | return NULL; |
654 | return NULL; |
588 | } |
655 | } |
589 | |
656 | |
590 | /* |
657 | /* |
591 | * Made as a separate function to increase efficiency |
658 | * Made as a separate function to increase efficiency |
… | |
… | |
611 | * a speed of zero (default is 1 for all |
678 | * a speed of zero (default is 1 for all |
612 | * but the charm floor type). |
679 | * but the charm floor type). |
613 | * by b.t. thomas@nomad.astro.psu.edu |
680 | * by b.t. thomas@nomad.astro.psu.edu |
614 | */ |
681 | */ |
615 | |
682 | |
616 | void do_mood_floor(object *op, object *op2) { |
683 | void do_mood_floor(object *op, object *source) { |
617 | object *tmp; |
684 | object *tmp; |
618 | object *tmp2; |
685 | object *tmp2; |
619 | |
686 | |
|
|
687 | if (!source) |
|
|
688 | source = op; |
|
|
689 | |
620 | for (tmp = GET_MAP_OB(op->map, op->x, op->y); tmp; tmp=tmp->above) |
690 | for (tmp = GET_MAP_OB(op->map, op->x, op->y); tmp; tmp=tmp->above) |
621 | if (QUERY_FLAG(tmp, FLAG_MONSTER)) break; |
691 | if (QUERY_FLAG(tmp, FLAG_MONSTER)) break; |
622 | |
692 | |
623 | /* doesn't effect players, and if there is a player on this space, won't also |
693 | /* doesn't effect players, and if there is a player on this space, won't also |
624 | * be a monster here. |
694 | * be a monster here. |
625 | */ |
695 | */ |
626 | if (!tmp || tmp->type == PLAYER) return; |
696 | if (!tmp || tmp->type == PLAYER) return; |
627 | |
697 | |
628 | switch(op->last_sp) { |
698 | switch(op->last_sp) { |
629 | case 0: /* furious--make all monsters mad */ |
699 | case 0: /* furious--make all monsters mad */ |
630 | if(QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)) |
700 | if(QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)) |
631 | CLEAR_FLAG(tmp, FLAG_UNAGGRESSIVE); |
701 | CLEAR_FLAG(tmp, FLAG_UNAGGRESSIVE); |
632 | if(QUERY_FLAG(tmp, FLAG_FRIENDLY)) { |
702 | if(QUERY_FLAG(tmp, FLAG_FRIENDLY)) { |
633 | CLEAR_FLAG(tmp, FLAG_FRIENDLY); |
703 | CLEAR_FLAG(tmp, FLAG_FRIENDLY); |
634 | remove_friendly_object(tmp); |
704 | remove_friendly_object(tmp); |
635 | tmp->attack_movement = 0; |
705 | tmp->attack_movement = 0; |
636 | /* lots of checks here, but want to make sure we don't |
706 | /* lots of checks here, but want to make sure we don't |
637 | * dereference a null value |
707 | * dereference a null value |
638 | */ |
708 | */ |
639 | if (tmp->type == GOLEM && tmp->owner && tmp->owner->type==PLAYER && |
709 | if (tmp->type == GOLEM && tmp->owner && tmp->owner->type==PLAYER && |
640 | tmp->owner->contr->ranges[range_golem]==tmp) { |
710 | tmp->owner->contr->ranges[range_golem]==tmp) { |
641 | tmp->owner->contr->ranges[range_golem]=NULL; |
711 | tmp->owner->contr->ranges[range_golem]=NULL; |
642 | tmp->owner->contr->golem_count = 0; |
712 | tmp->owner->contr->golem_count = 0; |
643 | } |
713 | } |
644 | tmp->owner = 0; |
714 | tmp->owner = 0; |
645 | } |
715 | } |
646 | break; |
716 | break; |
647 | case 1: /* angry -- get neutral monsters mad */ |
717 | case 1: /* angry -- get neutral monsters mad */ |
648 | if(QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)&& |
718 | if(QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)&& |
649 | !QUERY_FLAG(tmp, FLAG_FRIENDLY)) |
719 | !QUERY_FLAG(tmp, FLAG_FRIENDLY)) |
650 | CLEAR_FLAG(tmp, FLAG_UNAGGRESSIVE); |
720 | CLEAR_FLAG(tmp, FLAG_UNAGGRESSIVE); |
651 | break; |
721 | break; |
652 | case 2: /* calm -- pacify unfriendly monsters */ |
722 | case 2: /* calm -- pacify unfriendly monsters */ |
653 | if(!QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)) |
723 | if(!QUERY_FLAG(tmp, FLAG_UNAGGRESSIVE)) |
654 | SET_FLAG(tmp, FLAG_UNAGGRESSIVE); |
724 | SET_FLAG(tmp, FLAG_UNAGGRESSIVE); |
655 | break; |
725 | break; |
656 | case 3: /* make all monsters fall asleep */ |
726 | case 3: /* make all monsters fall asleep */ |
657 | if(!QUERY_FLAG(tmp, FLAG_SLEEP)) |
727 | if(!QUERY_FLAG(tmp, FLAG_SLEEP)) |
658 | SET_FLAG(tmp, FLAG_SLEEP); |
728 | SET_FLAG(tmp, FLAG_SLEEP); |
659 | break; |
729 | break; |
660 | case 4: /* charm all monsters */ |
730 | case 4: /* charm all monsters */ |
661 | |
|
|
662 | if(op == op2) break; /* only if 'connected' */ |
731 | if (op == source) break; /* only if 'connected' */ |
663 | |
732 | |
664 | for(tmp2=get_map_ob(op2->map,op2->x,op2->y); /* finding an owner */ |
733 | for(tmp2=get_map_ob(source->map,source->x,source->y); /* finding an owner */ |
665 | tmp2->type!=PLAYER;tmp2=tmp2->above) |
734 | tmp2->type!=PLAYER;tmp2=tmp2->above) |
666 | if(tmp2->above==NULL) break; |
735 | if(tmp2->above==NULL) break; |
667 | |
736 | |
668 | if (tmp2->type != PLAYER) |
737 | if (tmp2->type != PLAYER) |
669 | break; |
738 | break; |
670 | set_owner(tmp,tmp2); |
739 | set_owner(tmp,tmp2); |
671 | SET_FLAG(tmp,FLAG_MONSTER); |
740 | SET_FLAG(tmp,FLAG_MONSTER); |
672 | tmp->stats.exp = 0; |
741 | tmp->stats.exp = 0; |
673 | SET_FLAG(tmp, FLAG_FRIENDLY); |
742 | SET_FLAG(tmp, FLAG_FRIENDLY); |
674 | add_friendly_object (tmp); |
743 | add_friendly_object (tmp); |
675 | tmp->attack_movement = PETMOVE; |
744 | tmp->attack_movement = PETMOVE; |
676 | break; |
745 | break; |
677 | |
746 | |
678 | default: |
747 | default: |
679 | break; |
748 | break; |
680 | |
749 | |
681 | } |
750 | } |
682 | } |
751 | } |
683 | |
752 | |
684 | /* this function returns the object it matches, or NULL if non. |
753 | /* this function returns the object it matches, or NULL if non. |
… | |
… | |
692 | { |
761 | { |
693 | object *tmp,*ret=NULL; |
762 | object *tmp,*ret=NULL; |
694 | |
763 | |
695 | /* First check the object itself. */ |
764 | /* First check the object itself. */ |
696 | if((trig->stats.hp && (op->type == trig->stats.hp)) |
765 | if((trig->stats.hp && (op->type == trig->stats.hp)) |
697 | || (trig->slaying && (op->slaying == trig->slaying)) |
766 | || (trig->slaying && (op->slaying == trig->slaying)) |
698 | || (trig->race && (op->arch->name == trig->race))) |
767 | || (trig->race && (op->arch->name == trig->race))) |
699 | return op; |
768 | return op; |
700 | |
769 | |
701 | for(tmp=op->inv; tmp; tmp=tmp->below) { |
770 | for(tmp=op->inv; tmp; tmp=tmp->below) { |
702 | if (tmp->inv) { |
771 | if (tmp->inv) { |
703 | ret=check_inv_recursive(tmp, trig); |
772 | ret=check_inv_recursive(tmp, trig); |
704 | if (ret) return ret; |
773 | if (ret) return ret; |
705 | } |
774 | } |
706 | else if((trig->stats.hp && (tmp->type == trig->stats.hp)) |
775 | else if((trig->stats.hp && (tmp->type == trig->stats.hp)) |
707 | || (trig->slaying && (tmp->slaying == trig->slaying)) |
776 | || (trig->slaying && (tmp->slaying == trig->slaying)) |
708 | || (trig->race && (tmp->arch->name == trig->race))) |
777 | || (trig->race && (tmp->arch->name == trig->race))) |
709 | return tmp; |
778 | return tmp; |
710 | } |
779 | } |
711 | return NULL; |
780 | return NULL; |
712 | } |
781 | } |
713 | |
782 | |
714 | /* check_inv(), a function to search the inventory, |
783 | /* check_inv(), a function to search the inventory, |
… | |
… | |
724 | object *match; |
793 | object *match; |
725 | |
794 | |
726 | if(op->type != PLAYER) return; |
795 | if(op->type != PLAYER) return; |
727 | match = check_inv_recursive(op,trig); |
796 | match = check_inv_recursive(op,trig); |
728 | if (match && trig->last_sp) { |
797 | if (match && trig->last_sp) { |
729 | if(trig->last_heal) |
798 | if(trig->last_heal) |
730 | decrease_ob(match); |
799 | decrease_ob(match); |
731 | use_trigger(trig); |
800 | use_trigger(trig); |
732 | } |
801 | } |
733 | else if (!match && !trig->last_sp) |
802 | else if (!match && !trig->last_sp) |
734 | use_trigger(trig); |
803 | use_trigger(trig); |
735 | } |
804 | } |
736 | |
805 | |
737 | |
806 | |
738 | /* This does a minimal check of the button link consistency for object |
807 | /* This does a minimal check of the button link consistency for object |
739 | * map. All it really does it much sure the object id link that is set |
808 | * map. All it really does it much sure the object id link that is set |
… | |
… | |
744 | objectlink *ol; |
813 | objectlink *ol; |
745 | |
814 | |
746 | if (!map) return; |
815 | if (!map) return; |
747 | |
816 | |
748 | for (obp = map->buttons; obp; obp = obp->next) { |
817 | for (obp = map->buttons; obp; obp = obp->next) { |
749 | for (ol=obp->link; ol; ol=ol->next) { |
818 | for (ol=obp->link; ol; ol=ol->next) { |
750 | if (ol->id!=ol->ob->count) |
819 | if (ol->id!=ol->ob->count) |
751 | LOG(llevError,"verify_button_links: object %s on list is corrupt (%d!=%d)\n",ol->ob->name, ol->id, ol->ob->count); |
820 | LOG(llevError,"verify_button_links: object %s on list is corrupt (%d!=%d)\n", &ol->ob->name, ol->id, ol->ob->count); |
752 | } |
821 | } |
753 | } |
822 | } |
754 | } |
823 | } |