1 |
elmex |
1.1 |
/* |
2 |
root |
1.40 |
* This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 |
pippijn |
1.27 |
* |
4 |
root |
1.65 |
* Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 |
root |
1.64 |
* Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 |
|
|
* Copyright (©) 1992 Frank Tore Johansen |
7 |
pippijn |
1.27 |
* |
8 |
root |
1.56 |
* Deliantra is free software: you can redistribute it and/or modify it under |
9 |
|
|
* the terms of the Affero GNU General Public License as published by the |
10 |
|
|
* Free Software Foundation, either version 3 of the License, or (at your |
11 |
|
|
* option) any later version. |
12 |
pippijn |
1.27 |
* |
13 |
root |
1.36 |
* This program is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
|
* GNU General Public License for more details. |
17 |
pippijn |
1.27 |
* |
18 |
root |
1.56 |
* You should have received a copy of the Affero GNU General Public License |
19 |
|
|
* and the GNU General Public License along with this program. If not, see |
20 |
|
|
* <http://www.gnu.org/licenses/>. |
21 |
root |
1.33 |
* |
22 |
root |
1.40 |
* The authors can be reached via e-mail to <support@deliantra.net> |
23 |
pippijn |
1.27 |
*/ |
24 |
elmex |
1.1 |
|
25 |
|
|
#include <global.h> |
26 |
|
|
|
27 |
|
|
/* |
28 |
|
|
* This code is no longer highly inefficient 8) |
29 |
|
|
*/ |
30 |
|
|
|
31 |
|
|
/* |
32 |
elmex |
1.3 |
* elmex: |
33 |
|
|
* This function takes a objectlink list with all the objects are going to be activated. |
34 |
|
|
* state is a true/false flag that will actiavte objects that have FLAG_ACTIVATE_ON_PUSH/RELEASE set. |
35 |
root |
1.52 |
* The activator argument can be 0 or the source object for this activation. |
36 |
|
|
* the originator is the player or monster who did something. |
37 |
elmex |
1.1 |
*/ |
38 |
root |
1.52 |
static void |
39 |
root |
1.53 |
activate_connection_link (objectlink *ol, int state, object *activator, object *originator) |
40 |
elmex |
1.3 |
{ |
41 |
|
|
for (; ol; ol = ol->next) |
42 |
|
|
{ |
43 |
root |
1.12 |
if (!ol->ob) |
44 |
elmex |
1.3 |
{ |
45 |
root |
1.12 |
LOG (llevError, "Internal error in activate_connection_link.\n"); |
46 |
elmex |
1.3 |
continue; |
47 |
|
|
} |
48 |
root |
1.12 |
|
49 |
elmex |
1.3 |
/* a button link object can become freed when the map is saving. As |
50 |
|
|
* a map is saved, objects are removed and freed, and if an object is |
51 |
|
|
* on top of a button, this function is eventually called. If a map |
52 |
|
|
* is getting moved out of memory, the status of buttons and levers |
53 |
|
|
* probably isn't important - it will get sorted out when the map is |
54 |
|
|
* re-loaded. As such, just exit this function if that is the case. |
55 |
|
|
*/ |
56 |
elmex |
1.1 |
|
57 |
root |
1.66 |
if (ol->ob->flag [FLAG_FREED]) |
58 |
elmex |
1.3 |
return; |
59 |
root |
1.19 |
|
60 |
|
|
object *tmp = ol->ob; |
61 |
root |
1.2 |
|
62 |
elmex |
1.3 |
/* if the criteria isn't appropriate, don't do anything */ |
63 |
root |
1.66 |
if (state && !tmp->flag [FLAG_ACTIVATE_ON_PUSH]) |
64 |
elmex |
1.3 |
continue; |
65 |
root |
1.37 |
|
66 |
root |
1.66 |
if (!state && !tmp->flag [FLAG_ACTIVATE_ON_RELEASE]) |
67 |
elmex |
1.3 |
continue; |
68 |
root |
1.2 |
|
69 |
elmex |
1.3 |
switch (tmp->type) |
70 |
|
|
{ |
71 |
root |
1.19 |
case GATE: |
72 |
|
|
case HOLE: |
73 |
root |
1.39 |
if (!tmp->active) |
74 |
|
|
tmp->play_sound (tmp->sound |
75 |
|
|
? tmp->sound |
76 |
|
|
: sound_find (tmp->type == GATE ? "trigger_gate" : "trigger_hole")); |
77 |
root |
1.19 |
tmp->value = tmp->stats.maxsp ? !state : state; |
78 |
root |
1.20 |
tmp->set_speed (0.5); |
79 |
root |
1.19 |
break; |
80 |
|
|
|
81 |
root |
1.57 |
case T_HANDLE: |
82 |
root |
1.19 |
SET_ANIMATION (tmp, (tmp->value = tmp->stats.maxsp ? !state : state)); |
83 |
|
|
update_object (tmp, UP_OBJ_FACE); |
84 |
|
|
break; |
85 |
|
|
|
86 |
|
|
case SIGN: |
87 |
|
|
if (!tmp->stats.food || tmp->last_eat < tmp->stats.food) |
88 |
|
|
{ |
89 |
root |
1.60 |
tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("msg_voice")); |
90 |
|
|
|
91 |
|
|
if (originator && originator->contr) |
92 |
|
|
originator->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n%s", &tmp->name, &tmp->msg)); |
93 |
|
|
|
94 |
|
|
new_info_map_except (NDI_UNIQUE | NDI_NAVY, tmp->map, originator, tmp->msg); |
95 |
|
|
|
96 |
root |
1.19 |
if (tmp->stats.food) |
97 |
|
|
tmp->last_eat++; |
98 |
|
|
} |
99 |
|
|
break; |
100 |
|
|
|
101 |
|
|
case ALTAR: |
102 |
root |
1.39 |
tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("trigger_altar")); |
103 |
root |
1.19 |
tmp->value = 1; |
104 |
|
|
SET_ANIMATION (tmp, tmp->value); |
105 |
|
|
update_object (tmp, UP_OBJ_FACE); |
106 |
|
|
break; |
107 |
|
|
|
108 |
|
|
case BUTTON: |
109 |
|
|
case PEDESTAL: |
110 |
root |
1.39 |
tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("trigger_button")); |
111 |
root |
1.19 |
tmp->value = state; |
112 |
|
|
SET_ANIMATION (tmp, tmp->value); |
113 |
|
|
update_object (tmp, UP_OBJ_FACE); |
114 |
|
|
break; |
115 |
|
|
|
116 |
|
|
case MOOD_FLOOR: |
117 |
root |
1.52 |
do_mood_floor (tmp, activator); |
118 |
root |
1.19 |
break; |
119 |
|
|
|
120 |
|
|
case TIMED_GATE: |
121 |
root |
1.39 |
if (!tmp->active) |
122 |
|
|
tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("trigger_gate")); |
123 |
root |
1.51 |
|
124 |
root |
1.35 |
tmp->set_speed (tmp->arch->speed); |
125 |
|
|
tmp->value = tmp->arch->value; |
126 |
root |
1.19 |
tmp->stats.sp = 1; |
127 |
|
|
tmp->stats.hp = tmp->stats.maxhp; |
128 |
|
|
/* Handle multipart gates. We copy the value for the other parts |
129 |
|
|
* from the head - this ensures that the data will consistent |
130 |
|
|
*/ |
131 |
root |
1.32 |
for (object *part = tmp->more; part; part = part->more) |
132 |
root |
1.19 |
{ |
133 |
root |
1.32 |
part->value = tmp->value; |
134 |
|
|
part->stats.sp = tmp->stats.sp; |
135 |
|
|
part->stats.hp = tmp->stats.hp; |
136 |
|
|
part->set_speed (tmp->speed); |
137 |
root |
1.19 |
} |
138 |
|
|
break; |
139 |
root |
1.7 |
|
140 |
root |
1.19 |
case DIRECTOR: |
141 |
|
|
case FIREWALL: |
142 |
root |
1.66 |
if (!tmp->flag [FLAG_ANIMATE] && tmp->type == FIREWALL) |
143 |
root |
1.19 |
move_firewall (tmp); |
144 |
|
|
else |
145 |
|
|
{ |
146 |
root |
1.53 |
tmp->stats.sp = absdir (tmp->stats.sp + tmp->stats.maxsp); /* next direction */ |
147 |
root |
1.19 |
animate_turning (tmp); |
148 |
|
|
} |
149 |
|
|
break; |
150 |
|
|
|
151 |
|
|
case TELEPORTER: |
152 |
|
|
move_teleporter (tmp); |
153 |
|
|
break; |
154 |
root |
1.2 |
|
155 |
root |
1.19 |
case CREATOR: |
156 |
|
|
move_creator (tmp); |
157 |
|
|
break; |
158 |
elmex |
1.3 |
|
159 |
root |
1.19 |
case TRIGGER_MARKER: |
160 |
root |
1.39 |
//tmp->play_sound (tmp->sound ? tmp->sound : sound_find ("trigger_marker")); |
161 |
root |
1.19 |
move_marker (tmp); |
162 |
|
|
break; |
163 |
elmex |
1.3 |
|
164 |
root |
1.19 |
case DUPLICATOR: |
165 |
|
|
move_duplicator (tmp); |
166 |
|
|
break; |
167 |
root |
1.51 |
|
168 |
|
|
case MAPSCRIPT: |
169 |
root |
1.52 |
cfperl_mapscript_activate (tmp, state, activator, originator); |
170 |
root |
1.51 |
break; |
171 |
elmex |
1.3 |
} |
172 |
|
|
} |
173 |
|
|
} |
174 |
root |
1.2 |
|
175 |
elmex |
1.3 |
/* |
176 |
|
|
* elmex: |
177 |
|
|
* This is the new push_button function, it got split up so that |
178 |
|
|
* you can activate connections without a button now! |
179 |
|
|
* old but still valid comment: |
180 |
|
|
* |
181 |
|
|
* Push the specified object. This can affect other buttons/gates/handles |
182 |
|
|
* altars/pedestals/holes in the whole map. |
183 |
|
|
* Changed the routine to loop through _all_ objects. |
184 |
|
|
* Better hurry with that linked list... |
185 |
|
|
* |
186 |
|
|
*/ |
187 |
root |
1.7 |
void |
188 |
root |
1.52 |
push_button (object *op, object *originator) |
189 |
elmex |
1.3 |
{ |
190 |
root |
1.51 |
if (oblinkpt *obp = op->find_link ()) |
191 |
|
|
{ |
192 |
root |
1.52 |
if (INVOKE_MAP (TRIGGER, op->map, ARG_STRING (&obp->id), ARG_INT (op->value), ARG_OBJECT (op), ARG_OBJECT (originator))) |
193 |
root |
1.51 |
return; |
194 |
root |
1.2 |
|
195 |
root |
1.52 |
activate_connection_link (obp->link, op->value, op, originator); |
196 |
root |
1.51 |
} |
197 |
elmex |
1.3 |
} |
198 |
root |
1.2 |
|
199 |
elmex |
1.3 |
/* |
200 |
|
|
* elmex: |
201 |
|
|
* This activates a connection, similar to push_button (object *op) but it takes |
202 |
|
|
* only a map, a connection value and a true or false flag that indicated whether |
203 |
|
|
* the connection was 'state' or 'released'. So that you can activate objects |
204 |
|
|
* who have FLAG_ACTIVATE_ON_PUSH/RELEASE set properly. |
205 |
|
|
* |
206 |
|
|
*/ |
207 |
root |
1.7 |
void |
208 |
root |
1.53 |
maptile::trigger (shstr_tmp id, int state, object *activator, object *originator) |
209 |
elmex |
1.3 |
{ |
210 |
root |
1.51 |
if (INVOKE_MAP (TRIGGER, this, ARG_STRING (&id), ARG_INT (state), ARG_OBJECT (originator))) |
211 |
elmex |
1.3 |
return; |
212 |
root |
1.2 |
|
213 |
root |
1.51 |
if (oblinkpt *obp = find_link (id)) |
214 |
root |
1.52 |
activate_connection_link (obp->link, state, activator, originator); |
215 |
elmex |
1.1 |
} |
216 |
|
|
|
217 |
|
|
/* |
218 |
|
|
* Updates everything connected with the button op. |
219 |
|
|
* After changing the state of a button, this function must be called |
220 |
|
|
* to make sure that all gates and other buttons connected to the |
221 |
|
|
* button reacts to the (eventual) change of state. |
222 |
|
|
*/ |
223 |
root |
1.7 |
void |
224 |
root |
1.52 |
update_button (object *op, object *originator) |
225 |
root |
1.7 |
{ |
226 |
root |
1.45 |
int any_down = 0, old_value = op->value; |
227 |
root |
1.7 |
|
228 |
root |
1.51 |
if (oblinkpt *obp = op->find_link ()) |
229 |
|
|
for (objectlink *ol = obp->link; ol; ol = ol->next) |
230 |
root |
1.7 |
{ |
231 |
root |
1.12 |
if (!ol->ob) |
232 |
root |
1.7 |
{ |
233 |
|
|
LOG (llevDebug, "Internal error in update_button (%s).\n", &op->name); |
234 |
|
|
continue; |
235 |
|
|
} |
236 |
root |
1.12 |
|
237 |
root |
1.45 |
object *tmp = ol->ob; |
238 |
|
|
|
239 |
root |
1.7 |
if (tmp->type == BUTTON) |
240 |
|
|
{ |
241 |
root |
1.45 |
sint32 total = 0; |
242 |
|
|
|
243 |
|
|
for (object *ab = tmp->above; ab; ab = ab->above) |
244 |
|
|
/* Basically, if the move_type matches that on what the |
245 |
|
|
* button wants, we count it. The second check is so that |
246 |
|
|
* objects who don't move (swords, etc) will count. Note that |
247 |
|
|
* this means that more work is needed to make buttons |
248 |
|
|
* that are only triggered by flying objects. |
249 |
|
|
*/ |
250 |
|
|
if ((ab->move_type & tmp->move_on) || ab->move_type == 0) |
251 |
|
|
total += ab->head_ ()->total_weight (); |
252 |
root |
1.7 |
|
253 |
root |
1.45 |
tmp->value = total >= tmp->weight; |
254 |
root |
1.7 |
|
255 |
root |
1.45 |
any_down = any_down || tmp->value; |
256 |
elmex |
1.3 |
} |
257 |
root |
1.7 |
else if (tmp->type == PEDESTAL) |
258 |
|
|
{ |
259 |
root |
1.55 |
bool is_match = is_match_expr (tmp->slaying); |
260 |
root |
1.7 |
tmp->value = 0; |
261 |
root |
1.42 |
|
262 |
root |
1.45 |
for (object *ab = tmp->above; ab; ab = ab->above) |
263 |
root |
1.7 |
{ |
264 |
root |
1.45 |
object *head = ab->head_ (); |
265 |
root |
1.42 |
|
266 |
root |
1.7 |
/* Same note regarding move_type for buttons above apply here. */ |
267 |
root |
1.55 |
if (((ab->move_type & tmp->move_on) || ab->move_type == 0)) |
268 |
|
|
if (is_match |
269 |
|
|
? match (tmp->slaying, head, tmp, originator) |
270 |
|
|
: (head->race == tmp->slaying |
271 |
|
|
|| (head->type == SPECIAL_KEY && head->slaying == tmp->slaying) |
272 |
|
|
|| (tmp->slaying == shstr_player && head->type == PLAYER))) |
273 |
|
|
{ |
274 |
|
|
tmp->value = 1; |
275 |
|
|
break; |
276 |
|
|
} |
277 |
elmex |
1.3 |
} |
278 |
root |
1.45 |
|
279 |
|
|
any_down = any_down || tmp->value; |
280 |
root |
1.42 |
} |
281 |
root |
1.59 |
else if (tmp->type == T_MATCH) |
282 |
|
|
{ |
283 |
|
|
tmp->value = 0; |
284 |
|
|
|
285 |
|
|
for (object *ab = tmp->above; ab; ab = ab->above) |
286 |
|
|
{ |
287 |
|
|
object *head = ab->head_ (); |
288 |
|
|
|
289 |
|
|
/* Same note regarding move_type for buttons above apply here. */ |
290 |
|
|
if (((ab->move_type & tmp->move_on) || ab->move_type == 0)) |
291 |
|
|
if (match (tmp->slaying, head, tmp, originator)) |
292 |
|
|
{ |
293 |
|
|
tmp->value = 1; |
294 |
|
|
break; |
295 |
|
|
} |
296 |
|
|
} |
297 |
|
|
|
298 |
|
|
any_down = any_down || tmp->value; |
299 |
|
|
} |
300 |
elmex |
1.3 |
} |
301 |
root |
1.42 |
|
302 |
root |
1.7 |
if (any_down) /* If any other buttons were down, force this to remain down */ |
303 |
|
|
op->value = 1; |
304 |
elmex |
1.1 |
|
305 |
root |
1.45 |
//LOG(llevDebug, "update_button: %s (%d, %d=%d)\n", &op->name, op->count, op->value, old_value); |
306 |
|
|
|
307 |
root |
1.7 |
/* If this button hasn't changed, don't do anything */ |
308 |
|
|
if (op->value != old_value) |
309 |
|
|
{ |
310 |
|
|
SET_ANIMATION (op, op->value); |
311 |
|
|
update_object (op, UP_OBJ_FACE); |
312 |
root |
1.52 |
push_button (op, originator); /* Make all other buttons the same */ |
313 |
elmex |
1.1 |
} |
314 |
|
|
} |
315 |
|
|
|
316 |
root |
1.7 |
void |
317 |
root |
1.52 |
use_trigger (object *op, object *originator) |
318 |
elmex |
1.1 |
{ |
319 |
root |
1.7 |
/* Toggle value */ |
320 |
|
|
op->value = !op->value; |
321 |
root |
1.52 |
|
322 |
|
|
push_button (op, originator); |
323 |
elmex |
1.1 |
} |
324 |
|
|
|
325 |
|
|
/* |
326 |
|
|
* Note: animate_object should be used instead of this, |
327 |
|
|
* but it can't handle animations in the 8 directions |
328 |
|
|
*/ |
329 |
root |
1.7 |
void |
330 |
|
|
animate_turning (object *op) /* only one part objects */ |
331 |
elmex |
1.1 |
{ |
332 |
root |
1.7 |
if (++op->state >= NUM_ANIMATIONS (op) / 8) |
333 |
|
|
op->state = 0; |
334 |
|
|
SET_ANIMATION (op, (op->stats.sp - 1) * NUM_ANIMATIONS (op) / 8 + op->state); |
335 |
|
|
update_object (op, UP_OBJ_FACE); |
336 |
elmex |
1.1 |
} |
337 |
|
|
|
338 |
|
|
#define ARCH_SACRIFICE(xyz) ((xyz)->slaying) |
339 |
|
|
#define NROF_SACRIFICE(xyz) ((uint32)(xyz)->stats.food) |
340 |
|
|
|
341 |
|
|
/* Returns true if the sacrifice meets the needs of the altar. |
342 |
|
|
* |
343 |
|
|
* Function put in (0.92.1) so that identify altars won't grab money |
344 |
|
|
* unnecessarily - we can see if there is sufficient money, see if something |
345 |
|
|
* needs to be identified, and then remove money if needed. |
346 |
|
|
* |
347 |
|
|
* 0.93.4: Linked objects (ie, objects that are connected) can not be |
348 |
|
|
* sacrificed. This fixes a bug of trying to put multiple altars/related |
349 |
|
|
* objects on the same space that take the same sacrifice. |
350 |
|
|
*/ |
351 |
root |
1.7 |
int |
352 |
root |
1.54 |
check_altar_sacrifice (object *altar, object *sacrifice, object *originator) |
353 |
elmex |
1.1 |
{ |
354 |
root |
1.54 |
if (sacrifice->flag [FLAG_UNPAID]) |
355 |
|
|
return 0; |
356 |
|
|
|
357 |
|
|
if (is_match_expr (ARCH_SACRIFICE (altar))) |
358 |
|
|
return match (ARCH_SACRIFICE (altar), altar, originator); |
359 |
|
|
|
360 |
root |
1.66 |
if (!sacrifice->flag [FLAG_ALIVE] |
361 |
|
|
&& !sacrifice->flag [FLAG_IS_LINKED] |
362 |
elmex |
1.38 |
&& sacrifice->type != PLAYER) |
363 |
root |
1.7 |
{ |
364 |
root |
1.41 |
if (ARCH_SACRIFICE (altar) == shstr_money |
365 |
elmex |
1.38 |
&& sacrifice->type == MONEY |
366 |
|
|
&& sacrifice->nrof * sacrifice->value >= NROF_SACRIFICE (altar)) |
367 |
|
|
return 1; |
368 |
|
|
|
369 |
root |
1.34 |
if ((ARCH_SACRIFICE (altar) == sacrifice->arch->archname |
370 |
|
|
|| ARCH_SACRIFICE (altar) == sacrifice->name |
371 |
|
|
|| ARCH_SACRIFICE (altar) == sacrifice->slaying |
372 |
elmex |
1.38 |
|| strstr (query_base_name (sacrifice, 0), ARCH_SACRIFICE (altar))) |
373 |
root |
1.42 |
&& NROF_SACRIFICE (altar) <= sacrifice->number_of ()) |
374 |
root |
1.7 |
return 1; |
375 |
|
|
} |
376 |
root |
1.17 |
|
377 |
elmex |
1.1 |
return 0; |
378 |
|
|
} |
379 |
|
|
|
380 |
|
|
/* |
381 |
|
|
* operate_altar checks if sacrifice was accepted and removes sacrificed |
382 |
|
|
* objects. If sacrifice was succeed return 1 else 0. Might be better to |
383 |
|
|
* call check_altar_sacrifice (above) than depend on the return value, |
384 |
|
|
* since operate_altar will remove the sacrifice also. |
385 |
|
|
* |
386 |
|
|
* If this function returns 1, '*sacrifice' is modified to point to the |
387 |
|
|
* remaining sacrifice, or is set to NULL if the sacrifice was used up. |
388 |
|
|
*/ |
389 |
root |
1.7 |
int |
390 |
root |
1.54 |
operate_altar (object *altar, object **sacrifice, object *originator) |
391 |
elmex |
1.1 |
{ |
392 |
root |
1.7 |
if (!altar->map) |
393 |
|
|
{ |
394 |
|
|
LOG (llevError, "BUG: operate_altar(): altar has no map\n"); |
395 |
|
|
return 0; |
396 |
|
|
} |
397 |
elmex |
1.1 |
|
398 |
|
|
if (!altar->slaying || altar->value) |
399 |
|
|
return 0; |
400 |
|
|
|
401 |
root |
1.54 |
if (!check_altar_sacrifice (altar, *sacrifice, originator)) |
402 |
elmex |
1.1 |
return 0; |
403 |
|
|
|
404 |
|
|
/* check_altar_sacrifice should have already verified that enough money |
405 |
|
|
* has been dropped. |
406 |
|
|
*/ |
407 |
root |
1.41 |
if (ARCH_SACRIFICE (altar) == shstr_money) |
408 |
root |
1.7 |
{ |
409 |
|
|
int number = NROF_SACRIFICE (altar) / (*sacrifice)->value; |
410 |
elmex |
1.1 |
|
411 |
root |
1.7 |
/* Round up any sacrifices. Altars don't make change either */ |
412 |
|
|
if (NROF_SACRIFICE (altar) % (*sacrifice)->value) |
413 |
|
|
number++; |
414 |
root |
1.9 |
|
415 |
root |
1.43 |
if (!(*sacrifice)->decrease (number)) |
416 |
|
|
*sacrifice = 0; |
417 |
root |
1.7 |
} |
418 |
elmex |
1.1 |
else |
419 |
root |
1.43 |
if (!(*sacrifice)->decrease (NROF_SACRIFICE (altar))) |
420 |
|
|
*sacrifice = 0; |
421 |
root |
1.7 |
|
422 |
elmex |
1.1 |
if (altar->msg) |
423 |
root |
1.7 |
new_info_map (NDI_BLACK, altar->map, altar->msg); |
424 |
root |
1.9 |
|
425 |
elmex |
1.1 |
return 1; |
426 |
|
|
} |
427 |
|
|
|
428 |
root |
1.61 |
static void |
429 |
root |
1.52 |
trigger_move (object *op, int state, object *originator) /* 1 down and 0 up */ |
430 |
elmex |
1.1 |
{ |
431 |
root |
1.7 |
op->stats.wc = state; |
432 |
root |
1.52 |
|
433 |
root |
1.7 |
if (state) |
434 |
|
|
{ |
435 |
root |
1.52 |
use_trigger (op, originator); |
436 |
root |
1.20 |
op->set_speed (op->stats.exp > 0 ? 1. / op->stats.exp : 1.); |
437 |
root |
1.7 |
op->speed_left = -1; |
438 |
|
|
} |
439 |
|
|
else |
440 |
|
|
{ |
441 |
root |
1.52 |
use_trigger (op, originator); |
442 |
root |
1.20 |
op->set_speed (0); |
443 |
elmex |
1.1 |
} |
444 |
|
|
} |
445 |
|
|
|
446 |
|
|
|
447 |
|
|
/* |
448 |
|
|
* cause != NULL: something has moved on top of op |
449 |
|
|
* |
450 |
|
|
* cause == NULL: nothing has moved, we have been called from |
451 |
|
|
* animate_trigger(). |
452 |
|
|
* |
453 |
|
|
* TRIGGER_ALTAR: Returns 1 if 'cause' was destroyed, 0 if not. |
454 |
|
|
* |
455 |
|
|
* TRIGGER: Returns 1 if handle could be moved, 0 if not. |
456 |
|
|
* |
457 |
|
|
* TRIGGER_BUTTON, TRIGGER_PEDESTAL: Returns 0. |
458 |
|
|
*/ |
459 |
root |
1.7 |
int |
460 |
root |
1.54 |
check_trigger (object *op, object *cause, object *originator) |
461 |
elmex |
1.1 |
{ |
462 |
root |
1.7 |
object *tmp; |
463 |
|
|
int push = 0, tot = 0; |
464 |
root |
1.62 |
int in_movement = op->stats.wc || op->has_active_speed (); |
465 |
elmex |
1.1 |
|
466 |
root |
1.7 |
switch (op->type) |
467 |
|
|
{ |
468 |
root |
1.45 |
case TRIGGER_BUTTON: |
469 |
|
|
if (op->weight > 0) |
470 |
|
|
{ |
471 |
|
|
if (cause) |
472 |
|
|
{ |
473 |
|
|
for (tmp = op->above; tmp; tmp = tmp->above) |
474 |
|
|
/* Comment reproduced from update_buttons(): */ |
475 |
|
|
/* Basically, if the move_type matches that on what the |
476 |
|
|
* button wants, we count it. The second check is so that |
477 |
|
|
* objects that don't move (swords, etc) will count. Note that |
478 |
|
|
* this means that more work is needed to make buttons |
479 |
|
|
* that are only triggered by flying objects. |
480 |
|
|
*/ |
481 |
|
|
if ((tmp->move_type & op->move_on) || tmp->move_type == 0) |
482 |
|
|
tot += tmp->head_ ()->total_weight (); |
483 |
|
|
|
484 |
|
|
if (tot >= op->weight) |
485 |
|
|
push = 1; |
486 |
|
|
|
487 |
|
|
if (op->stats.ac == push) |
488 |
|
|
return 0; |
489 |
|
|
|
490 |
|
|
op->stats.ac = push; |
491 |
|
|
if (NUM_ANIMATIONS (op) > 1) |
492 |
|
|
{ |
493 |
|
|
SET_ANIMATION (op, push); |
494 |
|
|
update_object (op, UP_OBJ_FACE); |
495 |
|
|
} |
496 |
|
|
|
497 |
|
|
if (in_movement || !push) |
498 |
|
|
return 0; |
499 |
|
|
} |
500 |
root |
1.52 |
|
501 |
|
|
trigger_move (op, push, cause); |
502 |
root |
1.45 |
} |
503 |
|
|
|
504 |
|
|
return 0; |
505 |
|
|
|
506 |
|
|
case TRIGGER_PEDESTAL: |
507 |
|
|
if (cause) |
508 |
|
|
{ |
509 |
|
|
for (tmp = op->above; tmp; tmp = tmp->above) |
510 |
|
|
{ |
511 |
|
|
object *head = tmp->head_ (); |
512 |
root |
1.7 |
|
513 |
root |
1.45 |
/* See comment in TRIGGER_BUTTON about move_types */ |
514 |
|
|
if (((head->move_type & op->move_on) || head->move_type == 0) |
515 |
root |
1.50 |
&& (head->race == op->slaying || (op->slaying == shstr_player && head->type == PLAYER))) |
516 |
root |
1.45 |
{ |
517 |
root |
1.2 |
push = 1; |
518 |
root |
1.45 |
break; |
519 |
|
|
} |
520 |
|
|
} |
521 |
|
|
|
522 |
|
|
if (op->stats.ac == push) |
523 |
|
|
return 0; |
524 |
|
|
|
525 |
|
|
op->stats.ac = push; |
526 |
|
|
|
527 |
|
|
if (NUM_ANIMATIONS (op) > 1) |
528 |
|
|
{ |
529 |
|
|
SET_ANIMATION (op, push); |
530 |
|
|
update_object (op, UP_OBJ_FACE); |
531 |
|
|
} |
532 |
|
|
|
533 |
|
|
update_object (op, UP_OBJ_FACE); |
534 |
|
|
|
535 |
|
|
if (in_movement || !push) |
536 |
|
|
return 0; |
537 |
|
|
} |
538 |
root |
1.42 |
|
539 |
root |
1.52 |
trigger_move (op, push, cause); |
540 |
root |
1.45 |
return 0; |
541 |
root |
1.42 |
|
542 |
root |
1.45 |
case TRIGGER_ALTAR: |
543 |
|
|
if (cause) |
544 |
|
|
{ |
545 |
|
|
if (in_movement) |
546 |
|
|
return 0; |
547 |
|
|
|
548 |
root |
1.54 |
if (operate_altar (op, &cause)) /* TODO: originator? */ |
549 |
root |
1.45 |
{ |
550 |
|
|
if (NUM_ANIMATIONS (op) > 1) |
551 |
|
|
{ |
552 |
|
|
SET_ANIMATION (op, 1); |
553 |
|
|
update_object (op, UP_OBJ_FACE); |
554 |
|
|
} |
555 |
|
|
|
556 |
|
|
if (op->last_sp >= 0) |
557 |
|
|
{ |
558 |
root |
1.52 |
trigger_move (op, 1, cause); |
559 |
|
|
|
560 |
root |
1.45 |
if (op->last_sp > 0) |
561 |
root |
1.7 |
op->last_sp = -op->last_sp; |
562 |
root |
1.45 |
} |
563 |
|
|
else |
564 |
|
|
{ |
565 |
|
|
/* for trigger altar with last_sp, the ON/OFF |
566 |
|
|
* status (-> +/- value) is "simulated": |
567 |
|
|
*/ |
568 |
|
|
op->value = !op->value; |
569 |
root |
1.52 |
trigger_move (op, 1, cause); |
570 |
root |
1.45 |
op->last_sp = -op->last_sp; |
571 |
|
|
op->value = !op->value; |
572 |
|
|
} |
573 |
|
|
|
574 |
|
|
return cause == NULL; |
575 |
|
|
} |
576 |
|
|
else |
577 |
|
|
return 0; |
578 |
|
|
} |
579 |
|
|
else |
580 |
|
|
{ |
581 |
|
|
if (NUM_ANIMATIONS (op) > 1) |
582 |
|
|
{ |
583 |
|
|
SET_ANIMATION (op, 0); |
584 |
|
|
update_object (op, UP_OBJ_FACE); |
585 |
|
|
} |
586 |
|
|
|
587 |
|
|
/* If trigger_altar has "last_sp > 0" set on the map, |
588 |
|
|
* it will push the connected value only once per sacrifice. |
589 |
|
|
* Otherwise (default), the connected value will be |
590 |
|
|
* pushed twice: First by sacrifice, second by reset! -AV |
591 |
|
|
*/ |
592 |
|
|
if (!op->last_sp) |
593 |
root |
1.52 |
trigger_move (op, 0, cause); |
594 |
root |
1.45 |
else |
595 |
|
|
{ |
596 |
|
|
op->stats.wc = 0; |
597 |
|
|
op->value = !op->value; |
598 |
|
|
op->set_speed (0); |
599 |
|
|
} |
600 |
|
|
} |
601 |
|
|
return 0; |
602 |
|
|
|
603 |
|
|
case TRIGGER: |
604 |
|
|
if (cause) |
605 |
|
|
{ |
606 |
|
|
if (in_movement) |
607 |
|
|
return 0; |
608 |
root |
1.32 |
|
609 |
root |
1.45 |
push = 1; |
610 |
|
|
} |
611 |
|
|
|
612 |
|
|
if (NUM_ANIMATIONS (op) > 1) |
613 |
|
|
{ |
614 |
|
|
SET_ANIMATION (op, push); |
615 |
|
|
update_object (op, UP_OBJ_FACE); |
616 |
|
|
} |
617 |
|
|
|
618 |
root |
1.52 |
trigger_move (op, push, cause); |
619 |
root |
1.45 |
return 1; |
620 |
|
|
|
621 |
|
|
default: |
622 |
|
|
LOG (llevDebug, "Unknown trigger type: %s (%d)\n", &op->name, op->type); |
623 |
|
|
return 0; |
624 |
elmex |
1.1 |
} |
625 |
|
|
} |
626 |
|
|
|
627 |
root |
1.7 |
void |
628 |
root |
1.51 |
object::add_link (maptile *map, shstr_tmp id) |
629 |
root |
1.7 |
{ |
630 |
|
|
if (!map) |
631 |
|
|
{ |
632 |
|
|
LOG (llevError, "Tried to add button-link without map.\n"); |
633 |
|
|
return; |
634 |
|
|
} |
635 |
elmex |
1.1 |
|
636 |
root |
1.51 |
flag [FLAG_IS_LINKED] = true; |
637 |
elmex |
1.1 |
|
638 |
root |
1.51 |
objectlink *ol = get_objectlink (); |
639 |
|
|
ol->ob = this; |
640 |
elmex |
1.1 |
|
641 |
root |
1.51 |
for (oblinkpt *obp = map->buttons; obp; obp = obp->next) |
642 |
|
|
if (obp->id == id) |
643 |
|
|
{ |
644 |
|
|
ol->next = obp->link; |
645 |
|
|
obp->link = ol; |
646 |
|
|
return; |
647 |
|
|
} |
648 |
elmex |
1.1 |
|
649 |
root |
1.51 |
oblinkpt *obp = get_objectlinkpt (); |
650 |
|
|
obp->id = id; |
651 |
root |
1.7 |
|
652 |
root |
1.51 |
obp->next = map->buttons; |
653 |
|
|
map->buttons = obp; |
654 |
|
|
obp->link = ol; |
655 |
elmex |
1.1 |
} |
656 |
|
|
|
657 |
|
|
/* |
658 |
|
|
* Remove the object from the linked lists of buttons in the map. |
659 |
|
|
* This is only needed by editors. |
660 |
|
|
*/ |
661 |
root |
1.7 |
void |
662 |
root |
1.51 |
object::remove_link () |
663 |
root |
1.7 |
{ |
664 |
root |
1.51 |
if (!map) |
665 |
root |
1.7 |
{ |
666 |
|
|
LOG (llevError, "remove_button_link() in object without map.\n"); |
667 |
|
|
return; |
668 |
|
|
} |
669 |
root |
1.12 |
|
670 |
root |
1.51 |
if (!flag [FLAG_IS_LINKED]) |
671 |
root |
1.7 |
{ |
672 |
|
|
LOG (llevError, "remove_button_linked() in unlinked object.\n"); |
673 |
|
|
return; |
674 |
|
|
} |
675 |
root |
1.12 |
|
676 |
root |
1.51 |
flag [FLAG_IS_LINKED] = false; |
677 |
|
|
|
678 |
|
|
for (oblinkpt *obp = map->buttons; obp; obp = obp->next) |
679 |
|
|
for (objectlink **olp = &obp->link; *olp; olp = &(*olp)->next) |
680 |
|
|
if ((*olp)->ob == this) |
681 |
root |
1.7 |
{ |
682 |
root |
1.51 |
objectlink *ol = *olp; |
683 |
root |
1.7 |
*olp = ol->next; |
684 |
root |
1.12 |
delete ol; |
685 |
root |
1.7 |
return; |
686 |
|
|
} |
687 |
root |
1.12 |
|
688 |
root |
1.7 |
LOG (llevError, "remove_button_linked(): couldn't find object.\n"); |
689 |
elmex |
1.1 |
} |
690 |
elmex |
1.3 |
|
691 |
|
|
/* |
692 |
root |
1.51 |
* Updates every button on the map (by calling update_button() for them). |
693 |
elmex |
1.3 |
*/ |
694 |
root |
1.51 |
void |
695 |
|
|
maptile::update_buttons () |
696 |
elmex |
1.3 |
{ |
697 |
root |
1.51 |
for (oblinkpt *obp = buttons; obp; obp = obp->next) |
698 |
|
|
for (objectlink *ol = obp->link; ol; ol = ol->next) |
699 |
|
|
{ |
700 |
|
|
if (!ol->ob) |
701 |
|
|
{ |
702 |
|
|
LOG (llevError, "Internal error in update_button (%s (%dx%d), connected %ld).\n", |
703 |
|
|
ol->ob ? (const char *) ol->ob->name : "null", ol->ob ? ol->ob->x : -1, ol->ob ? ol->ob->y : -1, &obp->id); |
704 |
|
|
continue; |
705 |
|
|
} |
706 |
root |
1.12 |
|
707 |
root |
1.51 |
if (ol->ob->type == BUTTON || ol->ob->type == PEDESTAL) |
708 |
|
|
{ |
709 |
root |
1.52 |
update_button (ol->ob, 0); |
710 |
root |
1.51 |
break; |
711 |
|
|
} |
712 |
|
|
} |
713 |
elmex |
1.3 |
} |
714 |
|
|
|
715 |
elmex |
1.1 |
/* |
716 |
root |
1.51 |
* Gets the objectlink for this connection from the map. |
717 |
elmex |
1.1 |
*/ |
718 |
root |
1.7 |
oblinkpt * |
719 |
root |
1.51 |
maptile::find_link (shstr_tmp id) |
720 |
root |
1.7 |
{ |
721 |
root |
1.51 |
for (oblinkpt *obp = buttons; obp; obp = obp->next) |
722 |
|
|
if (obp->id == id) |
723 |
|
|
return obp; |
724 |
elmex |
1.1 |
|
725 |
root |
1.51 |
return 0; |
726 |
elmex |
1.1 |
} |
727 |
|
|
|
728 |
|
|
/* |
729 |
root |
1.51 |
* Return the first objectlink in the objects linked to this one |
730 |
elmex |
1.1 |
*/ |
731 |
root |
1.51 |
oblinkpt * |
732 |
|
|
object::find_link () const |
733 |
root |
1.7 |
{ |
734 |
root |
1.51 |
if (map) |
735 |
|
|
for (oblinkpt *obp = map->buttons; obp; obp = obp->next) |
736 |
|
|
for (objectlink *ol = obp->link; ol; ol = ol->next) |
737 |
|
|
if (ol->ob == this) |
738 |
|
|
return obp; |
739 |
elmex |
1.1 |
|
740 |
|
|
return 0; |
741 |
|
|
} |
742 |
|
|
|
743 |
|
|
/* This routine makes monsters who are |
744 |
|
|
* standing on the 'mood floor' change their |
745 |
|
|
* disposition if it is different. |
746 |
|
|
* If floor is to be triggered must have |
747 |
|
|
* a speed of zero (default is 1 for all |
748 |
|
|
* but the charm floor type). |
749 |
|
|
* by b.t. thomas@nomad.astro.psu.edu |
750 |
|
|
*/ |
751 |
root |
1.7 |
void |
752 |
|
|
do_mood_floor (object *op, object *source) |
753 |
|
|
{ |
754 |
|
|
if (!source) |
755 |
|
|
source = op; |
756 |
|
|
|
757 |
root |
1.28 |
mapspace &ms = op->ms (); |
758 |
|
|
|
759 |
|
|
if (!(ms.flags () & P_IS_ALIVE)) |
760 |
|
|
return; |
761 |
|
|
|
762 |
|
|
object *tmp; |
763 |
|
|
|
764 |
|
|
for (tmp = ms.top; tmp; tmp = tmp->below) |
765 |
root |
1.66 |
if (tmp->flag [FLAG_MONSTER]) |
766 |
root |
1.7 |
break; |
767 |
|
|
|
768 |
|
|
/* doesn't effect players, and if there is a player on this space, won't also |
769 |
|
|
* be a monster here. |
770 |
|
|
*/ |
771 |
root |
1.28 |
//TODO: have players really FLAG_MONSTER? kept it for safety |
772 |
root |
1.7 |
if (!tmp || tmp->type == PLAYER) |
773 |
|
|
return; |
774 |
|
|
|
775 |
|
|
switch (op->last_sp) |
776 |
|
|
{ |
777 |
root |
1.8 |
case 0: /* furious--make all monsters mad */ |
778 |
root |
1.66 |
if (tmp->flag [FLAG_UNAGGRESSIVE]) |
779 |
|
|
tmp->clr_flag (FLAG_UNAGGRESSIVE); |
780 |
root |
1.28 |
|
781 |
root |
1.66 |
if (tmp->flag [FLAG_FRIENDLY]) |
782 |
root |
1.8 |
{ |
783 |
|
|
tmp->attack_movement = 0; |
784 |
|
|
/* lots of checks here, but want to make sure we don't |
785 |
|
|
* dereference a null value |
786 |
|
|
*/ |
787 |
root |
1.29 |
if (tmp->type == GOLEM |
788 |
|
|
&& tmp->owner |
789 |
|
|
&& tmp->owner->type == PLAYER |
790 |
root |
1.31 |
&& tmp->owner->contr->golem == tmp) |
791 |
|
|
tmp->owner->contr->golem = 0; |
792 |
root |
1.13 |
|
793 |
root |
1.8 |
tmp->owner = 0; |
794 |
root |
1.29 |
|
795 |
|
|
remove_friendly_object (tmp); |
796 |
root |
1.8 |
} |
797 |
|
|
break; |
798 |
root |
1.28 |
|
799 |
root |
1.8 |
case 1: /* angry -- get neutral monsters mad */ |
800 |
root |
1.66 |
if (tmp->flag [FLAG_UNAGGRESSIVE] && !tmp->flag [FLAG_FRIENDLY]) |
801 |
|
|
tmp->clr_flag (FLAG_UNAGGRESSIVE); |
802 |
root |
1.8 |
break; |
803 |
root |
1.28 |
|
804 |
root |
1.8 |
case 2: /* calm -- pacify unfriendly monsters */ |
805 |
root |
1.66 |
tmp->set_flag (FLAG_UNAGGRESSIVE); |
806 |
root |
1.8 |
break; |
807 |
root |
1.28 |
|
808 |
root |
1.8 |
case 3: /* make all monsters fall asleep */ |
809 |
root |
1.66 |
tmp->set_flag (FLAG_SLEEP); |
810 |
root |
1.8 |
break; |
811 |
root |
1.28 |
|
812 |
root |
1.8 |
case 4: /* charm all monsters */ |
813 |
|
|
if (op == source) |
814 |
|
|
break; /* only if 'connected' */ |
815 |
|
|
|
816 |
root |
1.28 |
if (object *pl = source->ms ().player ()) |
817 |
|
|
{ |
818 |
|
|
tmp->set_owner (pl); |
819 |
root |
1.66 |
tmp->set_flag (FLAG_MONSTER); |
820 |
root |
1.7 |
|
821 |
root |
1.28 |
tmp->stats.exp = 0; |
822 |
root |
1.17 |
|
823 |
root |
1.28 |
add_friendly_object (tmp); |
824 |
|
|
tmp->attack_movement = PETMOVE; |
825 |
|
|
} |
826 |
|
|
break; |
827 |
root |
1.17 |
|
828 |
root |
1.30 |
case 6: // kill monsters |
829 |
root |
1.66 |
if (!tmp->flag [FLAG_FRIENDLY]) |
830 |
root |
1.28 |
break; |
831 |
root |
1.17 |
|
832 |
root |
1.28 |
// FALL THROUGH |
833 |
root |
1.30 |
case 5: // kill all alives |
834 |
|
|
if (!tmp->flag [FLAG_PRECIOUS]) |
835 |
|
|
{ |
836 |
root |
1.46 |
archetype::get (shstr_burnout)->insert_at (tmp, source); |
837 |
root |
1.49 |
tmp->destroy (); |
838 |
root |
1.30 |
} |
839 |
root |
1.8 |
break; |
840 |
elmex |
1.1 |
|
841 |
root |
1.8 |
default: |
842 |
|
|
break; |
843 |
elmex |
1.1 |
} |
844 |
|
|
} |
845 |
|
|
|
846 |
|
|
/* this function returns the object it matches, or NULL if non. |
847 |
|
|
* It will descend through containers to find the object. |
848 |
|
|
* slaying = match object slaying flag |
849 |
|
|
* race = match object archetype name flag |
850 |
|
|
* hp = match object type (excpt type '0'== PLAYER) |
851 |
|
|
*/ |
852 |
root |
1.7 |
object * |
853 |
|
|
check_inv_recursive (object *op, const object *trig) |
854 |
elmex |
1.1 |
{ |
855 |
root |
1.7 |
object *tmp, *ret = NULL; |
856 |
|
|
|
857 |
|
|
/* First check the object itself. */ |
858 |
|
|
if ((trig->stats.hp && (op->type == trig->stats.hp)) |
859 |
elmex |
1.16 |
|| (trig->slaying && (op->slaying == trig->slaying)) |
860 |
root |
1.34 |
|| (trig->race && (op->arch->archname == trig->race))) |
861 |
root |
1.7 |
return op; |
862 |
elmex |
1.1 |
|
863 |
root |
1.7 |
for (tmp = op->inv; tmp; tmp = tmp->below) |
864 |
|
|
{ |
865 |
|
|
if (tmp->inv) |
866 |
|
|
{ |
867 |
|
|
ret = check_inv_recursive (tmp, trig); |
868 |
|
|
if (ret) |
869 |
|
|
return ret; |
870 |
root |
1.2 |
} |
871 |
root |
1.7 |
else if ((trig->stats.hp && (tmp->type == trig->stats.hp)) |
872 |
elmex |
1.16 |
|| (trig->slaying && (tmp->slaying == trig->slaying)) |
873 |
root |
1.34 |
|| (trig->race && (tmp->arch->archname == trig->race))) |
874 |
root |
1.7 |
return tmp; |
875 |
elmex |
1.1 |
} |
876 |
root |
1.7 |
return NULL; |
877 |
elmex |
1.1 |
} |
878 |
|
|
|
879 |
|
|
/* check_inv(), a function to search the inventory, |
880 |
|
|
* of a player and then based on a set of conditions, |
881 |
|
|
* the square will activate connected items. |
882 |
|
|
* Monsters can't trigger this square (for now) |
883 |
|
|
* Values are: last_sp = 1/0 obj/no obj triggers |
884 |
|
|
* last_heal = 1/0 remove/dont remove obj if triggered |
885 |
|
|
* -b.t. (thomas@nomad.astro.psu.edu |
886 |
elmex |
1.16 |
* |
887 |
|
|
* Tue Dec 19 15:34:00 CET 2006 elmex: changed the function to ignore op |
888 |
|
|
* because the check-inventory semantic essentially only applies when |
889 |
|
|
* something is above the inventory checker. |
890 |
|
|
* The semantic prior this change was: trigger if something has moved on or off |
891 |
|
|
* and has a matching item. Imagine what happens if someone steps on the inventory |
892 |
|
|
* checker with a matching item, has it, activates the connection, throws the item |
893 |
|
|
* away, and then leaves the inventory checker. That would've caused an always-enabled |
894 |
|
|
* state in the inventory checker. This won't happen anymore now. |
895 |
|
|
* |
896 |
elmex |
1.26 |
* Wed Jan 10 11:34:26 CET 2007 elmex: fixed this function, we now check |
897 |
|
|
* whether op is on this mapspace or not, because the value (1|0) depends |
898 |
|
|
* on this information. also make sure to only push_button if op has |
899 |
|
|
* a matching item (because when we do a push_button with value=0 timed gates |
900 |
|
|
* will still open)! (i hope i got the semantics right this time) |
901 |
|
|
* |
902 |
elmex |
1.1 |
*/ |
903 |
root |
1.7 |
void |
904 |
elmex |
1.16 |
check_inv (object *op, object *trig) |
905 |
root |
1.7 |
{ |
906 |
elmex |
1.16 |
trig->value = 0; // deactivate if none of the following conditions apply |
907 |
|
|
|
908 |
elmex |
1.26 |
object *pl = trig->ms ().player (); |
909 |
|
|
object *match = check_inv_recursive (op, trig); |
910 |
|
|
|
911 |
|
|
// elmex: a note about (pl == op): |
912 |
|
|
// if pl == 0 then the player has left this space |
913 |
|
|
// if pl != 0 then a player is on this mapspace, but then |
914 |
|
|
// we still have to check whether it's the player that triggered |
915 |
|
|
// this inv-checker, because if not, then the op left this inv-checker |
916 |
|
|
// and we have to set the value to 0 |
917 |
|
|
|
918 |
|
|
if (match && trig->last_sp) // match == having |
919 |
root |
1.18 |
{ |
920 |
elmex |
1.26 |
if (trig->last_heal) |
921 |
root |
1.43 |
match->decrease (); |
922 |
root |
1.18 |
|
923 |
elmex |
1.26 |
trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left |
924 |
root |
1.52 |
push_button (trig, op); |
925 |
elmex |
1.26 |
} |
926 |
|
|
else if (!match && !trig->last_sp) // match == not having |
927 |
|
|
{ |
928 |
|
|
trig->value = (pl == op ? 1 : 0); // 1 if matching player entered, and 0 if he left |
929 |
root |
1.52 |
push_button (trig, op); |
930 |
root |
1.18 |
} |
931 |
elmex |
1.1 |
} |
932 |
|
|
|