1 | |
|
|
2 | /* |
1 | /* |
3 | * static char *rcsid_pets_c = |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
4 | * "$Id: pets.C,v 1.6 2006/09/12 20:55:18 root Exp $"; |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
|
|
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
|
|
7 | * |
|
|
8 | * Deliantra is free software: you can redistribute it and/or modify |
|
|
9 | * it under the terms of the GNU General Public License as published by |
|
|
10 | * the Free Software Foundation, either version 3 of the License, or |
|
|
11 | * (at your option) any later version. |
|
|
12 | * |
|
|
13 | * 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 | * |
|
|
18 | * You should have received a copy of the GNU General Public License |
|
|
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
20 | * |
|
|
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
5 | */ |
22 | */ |
6 | |
23 | |
7 | /* |
|
|
8 | CrossFire, A Multiplayer game for X-windows |
|
|
9 | |
|
|
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
|
|
11 | Copyright (C) 1992 Frank Tore Johansen |
|
|
12 | |
|
|
13 | This program is free software; you can redistribute it and/or modify |
|
|
14 | it under the terms of the GNU General Public License as published by |
|
|
15 | the Free Software Foundation; either version 2 of the License, or |
|
|
16 | (at your option) any later version. |
|
|
17 | |
|
|
18 | This program is distributed in the hope that it will be useful, |
|
|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
21 | GNU General Public License for more details. |
|
|
22 | |
|
|
23 | You should have received a copy of the GNU General Public License |
|
|
24 | along with this program; if not, write to the Free Software |
|
|
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
26 | |
|
|
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
|
|
28 | */ |
|
|
29 | |
|
|
30 | #include <global.h> |
24 | #include <global.h> |
31 | #ifndef __CEXTRACT__ |
|
|
32 | # include <sproto.h> |
25 | #include <sproto.h> |
33 | #endif |
|
|
34 | |
26 | |
35 | /* given that 'pet' is a friendly object, this function returns a |
27 | /* given that 'pet' is a friendly object, this function returns a |
36 | * monster the pet should attack, NULL if nothing appropriate is |
28 | * monster the pet should attack, NULL if nothing appropriate is |
37 | * found. it basically looks for nasty things around the owner |
29 | * found. it basically looks for nasty things around the owner |
38 | * of the pet to attack. |
30 | * of the pet to attack. |
39 | * this is now tilemap aware. |
31 | * this is now tilemap aware. |
40 | */ |
32 | */ |
41 | |
|
|
42 | object * |
33 | object * |
43 | get_pet_enemy (object *pet, rv_vector * rv) |
34 | get_pet_enemy (object *pet, rv_vector * rv) |
44 | { |
35 | { |
45 | object *owner, *tmp, *attacker, *tmp3; |
36 | object *tmp, *attacker, *tmp3; |
46 | int i; |
37 | int i; |
47 | sint16 x, y; |
38 | sint16 x, y; |
48 | mapstruct *nm; |
39 | maptile *nm; |
49 | int search_arr[SIZEOFFREE]; |
40 | int search_arr[SIZEOFFREE]; |
50 | int mflags; |
41 | int mflags; |
51 | |
42 | |
52 | attacker = pet->attacked_by; /*pointer to attacking enemy */ |
43 | attacker = pet->attacked_by; /*pointer to attacking enemy */ |
53 | pet->attacked_by = NULL; /*clear this, since we are dealing with it */ |
44 | pet->attacked_by = NULL; /*clear this, since we are dealing with it */ |
54 | |
45 | |
55 | if ((owner = get_owner (pet)) != NULL) |
46 | object *owner = pet->owner; |
56 | { |
47 | |
57 | /* If the owner has turned on the pet, make the pet |
48 | if (!owner) |
58 | * unfriendly. |
|
|
59 | */ |
|
|
60 | if ((check_enemy (owner, rv)) == pet) |
|
|
61 | { |
|
|
62 | CLEAR_FLAG (pet, FLAG_FRIENDLY); |
|
|
63 | remove_friendly_object (pet); |
|
|
64 | pet->attack_movement &= ~PETMOVE; |
|
|
65 | return owner; |
|
|
66 | } |
|
|
67 | } |
49 | { |
68 | else |
|
|
69 | { |
|
|
70 | /* else the owner is no longer around, so the |
50 | /* the owner is no longer around, so the |
71 | * pet no longer needs to be friendly. |
51 | * pet no longer needs to be friendly. |
72 | */ |
52 | */ |
73 | CLEAR_FLAG (pet, FLAG_FRIENDLY); |
|
|
74 | remove_friendly_object (pet); |
53 | remove_friendly_object (pet); |
75 | pet->attack_movement &= ~PETMOVE; |
54 | pet->attack_movement &= ~PETMOVE; |
76 | return NULL; |
55 | return 0; |
|
|
56 | } |
|
|
57 | |
|
|
58 | /* If the owner has turned on the pet, make the pet |
|
|
59 | * unfriendly. |
|
|
60 | */ |
|
|
61 | if (check_enemy (owner, rv) == pet) |
77 | } |
62 | { |
|
|
63 | remove_friendly_object (pet); |
|
|
64 | pet->attack_movement &= ~PETMOVE; |
|
|
65 | return owner; |
|
|
66 | } |
|
|
67 | |
78 | /* If they are not on the same map, the pet won't be agressive */ |
68 | /* If they are not on the same map, the pet won't be agressive */ |
79 | if (!on_same_map (pet, owner)) |
69 | //if (!on_same_map (pet, owner)) |
80 | return NULL; |
70 | // return 0; |
81 | |
71 | |
82 | /* See if the pet has an existing enemy. If so, don't start a new one */ |
72 | /* See if the pet has an existing enemy. If so, don't start a new one */ |
83 | if ((tmp = check_enemy (pet, rv)) != NULL) |
73 | if (tmp = check_enemy (pet, rv)) |
84 | { |
74 | { |
85 | if (tmp == owner && !QUERY_FLAG (pet, FLAG_CONFUSED) && QUERY_FLAG (pet, FLAG_FRIENDLY)) |
75 | if (tmp == owner && !QUERY_FLAG (pet, FLAG_CONFUSED) && QUERY_FLAG (pet, FLAG_FRIENDLY)) |
86 | /* without this check, you can actually get pets with |
76 | /* without this check, you can actually get pets with |
87 | * enemy set to owner! |
77 | * enemy set to owner! |
88 | */ |
78 | */ |
89 | pet->enemy = NULL; |
79 | pet->enemy = 0; |
90 | else |
80 | else |
91 | return tmp; |
81 | return tmp; |
92 | } |
82 | } |
|
|
83 | |
93 | get_search_arr (search_arr); |
84 | get_search_arr (search_arr); |
94 | |
85 | |
95 | if (owner->type == PLAYER && owner->contr->petmode > pet_normal) |
86 | if (owner->type == PLAYER && owner->contr->petmode > pet_normal) |
96 | { |
87 | { |
97 | if (owner->contr->petmode == pet_sad) |
88 | if (owner->contr->petmode == pet_sad) |
98 | { |
89 | { |
99 | tmp = find_nearest_living_creature (pet); |
90 | tmp = find_nearest_living_creature (pet); |
100 | if (tmp != NULL) |
91 | if (tmp != 0) |
101 | { |
92 | { |
102 | get_rangevector (pet, tmp, rv, 0); |
93 | get_rangevector (pet, tmp, rv, 0); |
103 | if (check_enemy (pet, rv) != NULL) |
94 | if (check_enemy (pet, rv) != 0) |
104 | return tmp; |
95 | return tmp; |
105 | else |
96 | else |
106 | pet->enemy = NULL; |
97 | pet->enemy = 0; |
107 | } |
98 | } |
108 | /* if we got here we have no enemy */ |
99 | /* if we got here we have no enemy */ |
109 | /* we return NULL to avoid heading back to the owner */ |
100 | /* we return 0 to avoid heading back to the owner */ |
110 | pet->enemy = NULL; |
101 | pet->enemy = 0; |
111 | return NULL; |
102 | return 0; |
112 | } |
103 | } |
113 | } |
104 | } |
114 | |
105 | |
115 | /* Since the pet has no existing enemy, look for anything nasty |
106 | /* Since the pet has no existing enemy, look for anything nasty |
116 | * around the owner that it should go and attack. |
107 | * around the owner that it should go and attack. (if the owner is |
|
|
108 | * still on a map) |
117 | */ |
109 | */ |
118 | tmp3 = NULL; |
110 | // owners sometimes are not on a map but in the inventory of somehting else |
|
|
111 | if (!owner->flag [FLAG_REMOVED] && owner->map) |
|
|
112 | { |
|
|
113 | tmp3 = 0; |
|
|
114 | |
119 | for (i = 0; i < SIZEOFFREE; i++) |
115 | for (i = 0; i < SIZEOFFREE; i++) |
120 | { |
116 | { |
121 | x = owner->x + freearr_x[search_arr[i]]; |
117 | x = owner->x + freearr_x[search_arr[i]]; |
122 | y = owner->y + freearr_y[search_arr[i]]; |
118 | y = owner->y + freearr_y[search_arr[i]]; |
123 | nm = owner->map; |
119 | nm = owner->map; |
124 | /* Only look on the space if there is something alive there. */ |
120 | /* Only look on the space if there is something alive there. */ |
125 | mflags = get_map_flags (nm, &nm, x, y, &x, &y); |
121 | mflags = get_map_flags (nm, &nm, x, y, &x, &y); |
|
|
122 | |
126 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
123 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
127 | { |
124 | { |
128 | for (tmp = get_map_ob (nm, x, y); tmp != NULL; tmp = tmp->above) |
125 | for (tmp = GET_MAP_OB (nm, x, y); tmp != 0; tmp = tmp->above) |
129 | { |
|
|
130 | object *tmp2 = tmp->head == NULL ? tmp : tmp->head; |
|
|
131 | |
|
|
132 | if (QUERY_FLAG (tmp2, FLAG_ALIVE) && ((!QUERY_FLAG (tmp2, FLAG_FRIENDLY) && |
|
|
133 | (tmp2->type != PLAYER)) || |
|
|
134 | should_arena_attack (pet, owner, tmp2)) |
|
|
135 | && !QUERY_FLAG (tmp2, FLAG_UNAGGRESSIVE) && tmp2 != pet && tmp2 != owner && can_detect_enemy (pet, tmp2, rv)) |
|
|
136 | { |
126 | { |
|
|
127 | object *tmp2 = tmp->head == 0 ? tmp : tmp->head; |
137 | |
128 | |
138 | if (!can_see_enemy (pet, tmp2)) |
129 | if (QUERY_FLAG (tmp2, FLAG_ALIVE) && ((!QUERY_FLAG (tmp2, FLAG_FRIENDLY) && |
|
|
130 | (tmp2->type != PLAYER)) || |
|
|
131 | should_arena_attack (pet, owner, tmp2)) |
|
|
132 | && !QUERY_FLAG (tmp2, FLAG_UNAGGRESSIVE) && tmp2 != pet && tmp2 != owner && can_detect_enemy (pet, tmp2, rv)) |
139 | { |
133 | { |
|
|
134 | |
|
|
135 | if (!can_see_enemy (pet, tmp2)) |
|
|
136 | { |
140 | if (tmp3 != NULL) |
137 | if (tmp3 != 0) |
141 | tmp3 = tmp2; |
138 | tmp3 = tmp2; |
142 | } |
139 | } |
143 | else |
|
|
144 | { |
|
|
145 | pet->enemy = tmp2; |
|
|
146 | if (check_enemy (pet, rv) != NULL) |
|
|
147 | return tmp2; |
|
|
148 | else |
140 | else |
|
|
141 | { |
|
|
142 | pet->enemy = tmp2; |
|
|
143 | if (check_enemy (pet, rv) != 0) |
|
|
144 | return tmp2; |
|
|
145 | else |
149 | pet->enemy = NULL; |
146 | pet->enemy = 0; |
150 | } |
147 | } |
151 | } /* if this is a valid enemy */ |
148 | } /* if this is a valid enemy */ |
152 | } /* for objects on this space */ |
149 | } /* for objects on this space */ |
153 | } /* if there is something living on this space */ |
150 | } /* if there is something living on this space */ |
154 | } /* for loop of spaces around the owner */ |
151 | } /* for loop of spaces around the owner */ |
155 | |
152 | |
156 | /* fine, we went through the whole loop and didn't find one we could |
153 | /* fine, we went through the whole loop and didn't find one we could |
157 | see, take what we have */ |
154 | see, take what we have */ |
158 | if (tmp3 != NULL) |
155 | if (tmp3 != 0) |
159 | { |
156 | { |
160 | pet->enemy = tmp3; |
157 | pet->enemy = tmp3; |
161 | if (check_enemy (pet, rv) != NULL) |
158 | if (check_enemy (pet, rv) != 0) |
162 | return tmp3; |
159 | return tmp3; |
163 | else |
160 | else |
164 | pet->enemy = NULL; |
161 | pet->enemy = 0; |
|
|
162 | } |
165 | } |
163 | } |
166 | |
164 | |
167 | /* No threat to owner, check to see if the pet has an attacker */ |
165 | /* No threat to owner, check to see if the pet has an attacker */ |
168 | if (attacker) |
166 | if (attacker) |
169 | { |
167 | { |
170 | /* need to be sure this is the right one! */ |
|
|
171 | if (attacker->count == pet->attacked_by_count) |
|
|
172 | { |
|
|
173 | /* also need to check to make sure it is not freindly */ |
168 | /* also need to check to make sure it is not freindly */ |
174 | /* or otherwise non-hostile, and is an appropriate target */ |
169 | /* or otherwise non-hostile, and is an appropriate target */ |
175 | if (!QUERY_FLAG (attacker, FLAG_FRIENDLY) && on_same_map (pet, attacker)) |
170 | if (!QUERY_FLAG (attacker, FLAG_FRIENDLY) && on_same_map (pet, attacker)) |
176 | { |
171 | { |
177 | pet->enemy = attacker; |
172 | pet->enemy = attacker; |
|
|
173 | |
178 | if (check_enemy (pet, rv) != NULL) |
174 | if (check_enemy (pet, rv) != 0) |
179 | return attacker; |
175 | return attacker; |
180 | else |
176 | else |
181 | pet->enemy = NULL; |
177 | pet->enemy = 0; |
182 | } |
|
|
183 | } |
178 | } |
184 | } |
179 | } |
185 | |
180 | |
186 | /* Don't have an attacker or legal enemy, so look for a new one!. |
181 | /* Don't have an attacker or legal enemy, so look for a new one!. |
187 | * This looks for one around where the pet is. Thus, you could lead |
182 | * This looks for one around where the pet is. Thus, you could lead |
188 | * a pet to danger, then take a few steps back. This code is basically |
183 | * a pet to danger, then take a few steps back. This code is basically |
189 | * the same as the code that looks around the owner. |
184 | * the same as the code that looks around the owner. |
190 | */ |
185 | */ |
191 | if (owner->type == PLAYER && owner->contr->petmode != pet_defend) |
186 | if (owner->type == PLAYER && owner->contr->petmode != pet_defend) |
192 | { |
187 | { |
193 | tmp3 = NULL; |
188 | tmp3 = 0; |
194 | for (i = 0; i < SIZEOFFREE; i++) |
189 | for (i = 0; i < SIZEOFFREE; i++) |
195 | { |
190 | { |
196 | x = pet->x + freearr_x[search_arr[i]]; |
191 | x = pet->x + freearr_x[search_arr[i]]; |
197 | y = pet->y + freearr_y[search_arr[i]]; |
192 | y = pet->y + freearr_y[search_arr[i]]; |
198 | nm = pet->map; |
193 | nm = pet->map; |
199 | /* Only look on the space if there is something alive there. */ |
194 | /* Only look on the space if there is something alive there. */ |
200 | mflags = get_map_flags (nm, &nm, x, y, &x, &y); |
195 | mflags = get_map_flags (nm, &nm, x, y, &x, &y); |
201 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
196 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) |
202 | { |
197 | { |
203 | for (tmp = get_map_ob (nm, x, y); tmp != NULL; tmp = tmp->above) |
198 | for (tmp = GET_MAP_OB (nm, x, y); tmp != 0; tmp = tmp->above) |
204 | { |
199 | { |
205 | object *tmp2 = tmp->head == NULL ? tmp : tmp->head; |
200 | object *tmp2 = tmp->head == 0 ? tmp : tmp->head; |
206 | |
201 | |
207 | if (QUERY_FLAG (tmp2, FLAG_ALIVE) && ((!QUERY_FLAG (tmp2, FLAG_FRIENDLY) && |
202 | if (QUERY_FLAG (tmp2, FLAG_ALIVE) && ((!QUERY_FLAG (tmp2, FLAG_FRIENDLY) && |
208 | (tmp2->type != PLAYER)) || |
203 | (tmp2->type != PLAYER)) || |
209 | should_arena_attack (pet, owner, tmp2)) |
204 | should_arena_attack (pet, owner, tmp2)) |
210 | && !QUERY_FLAG (tmp2, FLAG_UNAGGRESSIVE) && tmp2 != pet && tmp2 != owner && can_detect_enemy (pet, tmp2, rv)) |
205 | && !QUERY_FLAG (tmp2, FLAG_UNAGGRESSIVE) && tmp2 != pet && tmp2 != owner && can_detect_enemy (pet, tmp2, rv)) |
211 | { |
206 | { |
212 | |
207 | |
213 | if (!can_see_enemy (pet, tmp2)) |
208 | if (!can_see_enemy (pet, tmp2)) |
214 | { |
209 | { |
215 | if (tmp3 != NULL) |
210 | if (tmp3 != 0) |
216 | tmp3 = tmp2; |
211 | tmp3 = tmp2; |
217 | } |
212 | } |
218 | else |
213 | else |
219 | { |
214 | { |
220 | pet->enemy = tmp2; |
215 | pet->enemy = tmp2; |
221 | if (check_enemy (pet, rv) != NULL) |
216 | if (check_enemy (pet, rv) != 0) |
222 | return tmp2; |
217 | return tmp2; |
223 | else |
218 | else |
224 | pet->enemy = NULL; |
219 | pet->enemy = 0; |
225 | } |
220 | } |
226 | } /* make sure we can get to the bugger */ |
221 | } /* make sure we can get to the bugger */ |
227 | } /* for objects on this space */ |
222 | } /* for objects on this space */ |
228 | } /* if there is something living on this space */ |
223 | } /* if there is something living on this space */ |
229 | } /* for loop of spaces around the pet */ |
224 | } /* for loop of spaces around the pet */ |
|
|
225 | |
|
|
226 | /* fine, we went through the whole loop and didn't find one we could |
|
|
227 | see, take what we have */ |
|
|
228 | if (tmp3 != 0) |
|
|
229 | { |
|
|
230 | pet->enemy = tmp3; |
|
|
231 | if (check_enemy (pet, rv) != 0) |
|
|
232 | return tmp3; |
|
|
233 | else |
|
|
234 | pet->enemy = 0; |
|
|
235 | } |
230 | } /* pet in defence mode */ |
236 | } /* pet in defence mode */ |
231 | |
237 | |
232 | /* fine, we went through the whole loop and didn't find one we could |
238 | object *enemy = check_enemy (pet, rv); |
233 | see, take what we have */ |
239 | // we have a summoned pet here and the owners enemy isn't set or can't |
234 | if (tmp3 != NULL) |
240 | // be reached => search for a player around us and set it as our new enemy!! |
235 | { |
241 | if (!enemy && pet->owner && pet->owner->type != PLAYER) |
236 | pet->enemy = tmp3; |
242 | enemy = get_nearest_player (pet); |
237 | if (check_enemy (pet, rv) != NULL) |
|
|
238 | return tmp3; |
|
|
239 | else |
|
|
240 | pet->enemy = NULL; |
|
|
241 | } |
|
|
242 | |
243 | |
243 | /* Didn't find anything - return the owner's enemy or NULL */ |
244 | /* Didn't find anything - return the owner's enemy or 0 */ |
244 | return check_enemy (pet, rv); |
245 | return enemy; |
245 | } |
246 | } |
246 | |
247 | |
247 | void |
248 | void |
248 | terminate_all_pets (object *owner) |
249 | terminate_all_pets (object *owner) |
249 | { |
250 | { |
250 | objectlink *obl, *next; |
251 | objectlink *obl, *next; |
251 | |
252 | |
252 | for (obl = first_friendly_object; obl != NULL; obl = next) |
253 | for (obl = first_friendly_object; obl; obl = next) |
253 | { |
254 | { |
254 | object *ob = obl->ob; |
255 | object *ob = obl->ob; |
255 | |
|
|
256 | next = obl->next; |
256 | next = obl->next; |
|
|
257 | |
257 | if (get_owner (ob) == owner) |
258 | if (ob->owner == owner) |
258 | { |
259 | ob->drop_and_destroy (); |
259 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
260 | remove_ob (ob); |
|
|
261 | remove_friendly_object (ob); |
|
|
262 | free_object (ob); |
|
|
263 | } |
|
|
264 | } |
260 | } |
265 | } |
261 | } |
266 | |
262 | |
267 | /* |
263 | /* |
268 | * Unfortunately, sometimes, the owner of a pet is in the |
264 | * Unfortunately, sometimes, the owner of a pet is in the |
… | |
… | |
270 | * Thus the map isn't loaded yet, and we have to remove |
266 | * Thus the map isn't loaded yet, and we have to remove |
271 | * the pet... |
267 | * the pet... |
272 | * Interesting enough, we don't use the passed map structure in |
268 | * Interesting enough, we don't use the passed map structure in |
273 | * this function. |
269 | * this function. |
274 | */ |
270 | */ |
275 | |
|
|
276 | void |
271 | void |
277 | remove_all_pets (mapstruct *map) |
272 | remove_all_pets (maptile *map) |
278 | { |
273 | { |
279 | objectlink *obl, *next; |
274 | objectlink *obl, *next; |
280 | object *owner; |
275 | object *owner; |
281 | |
276 | |
282 | for (obl = first_friendly_object; obl != NULL; obl = next) |
277 | for (obl = first_friendly_object; obl; obl = next) |
283 | { |
278 | { |
284 | next = obl->next; |
279 | next = obl->next; |
285 | if (obl->ob->type != PLAYER && QUERY_FLAG (obl->ob, FLAG_FRIENDLY) && |
280 | |
286 | (owner = get_owner (obl->ob)) != NULL && !on_same_map (owner, obl->ob)) |
281 | if (obl->ob->type != PLAYER |
|
|
282 | && QUERY_FLAG (obl->ob, FLAG_FRIENDLY) |
|
|
283 | && (owner = obl->ob->owner) != 0 |
|
|
284 | && !on_same_map (owner, obl->ob)) |
287 | { |
285 | { |
288 | /* follow owner checks map status for us */ |
286 | /* follow owner checks map status for us */ |
289 | follow_owner (obl->ob, owner); |
287 | follow_owner (obl->ob, owner); |
290 | } |
288 | } |
291 | } |
289 | } |
292 | } |
290 | } |
293 | |
291 | |
294 | int |
292 | int |
295 | follow_owner (object *ob, object *owner) |
293 | follow_owner (object *ob, object *owner) |
296 | { |
294 | { |
297 | object *tmp; |
295 | if (owner->flag [FLAG_REMOVED]) |
298 | int dir; |
296 | return 0; // do nothing if the owner is removed |
299 | |
297 | else if (!owner->map || owner->map->in_memory != MAP_ACTIVE) |
300 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
298 | LOG (llevError, "owner '%s' of the pet '%s' not on a map in memory!?\n", &owner->name, &ob->name); |
301 | remove_ob (ob); |
299 | else |
302 | |
|
|
303 | if (owner->map == NULL) |
|
|
304 | { |
|
|
305 | LOG (llevError, "Can't follow owner (%d): no map.\n", &owner->name); |
|
|
306 | goto fail; |
|
|
307 | } |
300 | { |
308 | if (owner->map->in_memory != MAP_IN_MEMORY) |
|
|
309 | { |
|
|
310 | LOG (llevError, "Owner of the pet not on a map in memory!?\n"); |
|
|
311 | goto fail; |
|
|
312 | } |
|
|
313 | |
|
|
314 | dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); |
301 | int dir = find_free_spot (ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); |
315 | |
302 | |
316 | if (dir == -1) |
303 | if (dir >= 0) |
317 | { |
|
|
318 | LOG (llevMonster, "No space for pet to follow, freeing %s.\n", &ob->name); |
|
|
319 | goto fail; |
|
|
320 | } |
|
|
321 | for (tmp = ob; tmp != NULL; tmp = tmp->more) |
|
|
322 | { |
|
|
323 | tmp->x = owner->x + freearr_x[dir] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); |
|
|
324 | tmp->y = owner->y + freearr_y[dir] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
|
|
325 | tmp->map = owner->map; |
|
|
326 | if (OUT_OF_REAL_MAP (tmp->map, tmp->x, tmp->y)) |
|
|
327 | { |
|
|
328 | tmp->map = get_map_from_coord (tmp->map, &tmp->x, &tmp->y); |
|
|
329 | } |
304 | { |
330 | } |
305 | owner->map->insert (ob, owner->x + freearr_x[dir], owner->y + freearr_y[dir]); |
331 | insert_ob_in_map (ob, ob->map, NULL, 0); |
306 | |
332 | if (owner->type == PLAYER) /* Uh, I hope this is always true... */ |
307 | if (owner->type == PLAYER) /* Uh, I hope this is always true... */ |
333 | new_draw_info (NDI_UNIQUE, 0, owner, "Your pet magically appears next to you"); |
308 | new_draw_info (NDI_UNIQUE, 0, owner, "Your pet magically appears next to you"); |
334 | |
309 | |
335 | return 0; |
310 | return 0; |
|
|
311 | } |
|
|
312 | } |
336 | |
313 | |
337 | fail: |
314 | ob->drop_and_destroy (); |
338 | remove_friendly_object (ob); |
|
|
339 | free_object (ob); |
|
|
340 | |
315 | |
341 | return 1; |
316 | return 1; |
342 | } |
317 | } |
343 | |
318 | |
344 | void |
319 | void |
345 | pet_move (object *ob) |
320 | pet_move (object *ob) |
346 | { |
321 | { |
347 | int dir, tag, i; |
322 | int dir = 0, i; |
348 | sint16 dx, dy; |
323 | sint16 dx, dy; |
349 | object *ob2, *owner; |
324 | object *ob2, *owner; |
350 | mapstruct *m; |
325 | maptile *m; |
351 | |
326 | |
352 | /* Check to see if player pulled out */ |
327 | /* Check to see if player pulled out */ |
353 | if ((owner = get_owner (ob)) == NULL) |
328 | if ((owner = ob->owner) == NULL) |
354 | { |
329 | { |
355 | remove_ob (ob); /* Will be freed when returning */ |
330 | ob->drop_and_destroy (); |
356 | remove_friendly_object (ob); |
|
|
357 | free_object (ob); |
|
|
358 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
331 | LOG (llevMonster, "Pet: no owner, leaving.\n"); |
359 | return; |
332 | return; |
360 | } |
333 | } |
361 | |
334 | |
362 | /* move monster into the owners map if not in the same map */ |
335 | /* move monster into the owners map if not in the same map |
363 | if (!on_same_map (ob, owner)) |
336 | * except when the owner is removed. |
|
|
337 | */ |
|
|
338 | if (!on_same_map (ob, owner) && !owner->flag [FLAG_REMOVED]) |
364 | { |
339 | { |
365 | follow_owner (ob, owner); |
340 | follow_owner (ob, owner); |
366 | return; |
341 | return; |
367 | } |
342 | } |
368 | /* Calculate Direction */ |
343 | /* Calculate Direction */ |
… | |
… | |
381 | continue; |
356 | continue; |
382 | else |
357 | else |
383 | break; |
358 | break; |
384 | } |
359 | } |
385 | } |
360 | } |
386 | else |
361 | else if (!owner->flag [FLAG_REMOVED]) // only get vector to owner when owner not removed |
387 | { |
362 | { |
388 | struct rv_vector rv; |
363 | struct rv_vector rv; |
389 | |
364 | |
390 | get_rangevector (ob, ob->owner, &rv, 0); |
365 | get_rangevector (ob, ob->owner, &rv, 0); |
391 | dir = rv.direction; |
366 | dir = rv.direction; |
392 | } |
367 | } |
393 | ob->direction = dir; |
368 | ob->direction = dir; |
394 | |
369 | |
395 | tag = ob->count; |
|
|
396 | /* move_ob returns 0 if the object couldn't move. If that is the |
370 | /* move_ob returns 0 if the object couldn't move. If that is the |
397 | * case, lets do some other work. |
371 | * case, lets do some other work. |
398 | */ |
372 | */ |
399 | if (!(move_ob (ob, dir, ob))) |
373 | if (!(move_ob (ob, dir, ob))) |
400 | { |
374 | { |
401 | object *part; |
375 | object *part; |
402 | |
376 | |
403 | /* the failed move_ob above may destroy the pet, so check here */ |
377 | /* the failed move_ob above may destroy the pet, so check here */ |
404 | if (was_destroyed (ob, tag)) |
378 | if (ob->destroyed ()) |
405 | return; |
379 | return; |
406 | |
380 | |
407 | for (part = ob; part != NULL; part = part->more) |
381 | for (part = ob; part != NULL; part = part->more) |
408 | { |
382 | { |
409 | dx = part->x + freearr_x[dir]; |
383 | dx = part->x + freearr_x[dir]; |
410 | dy = part->y + freearr_y[dir]; |
384 | dy = part->y + freearr_y[dir]; |
411 | m = get_map_from_coord (part->map, &dx, &dy); |
385 | m = get_map_from_coord (part->map, &dx, &dy); |
412 | if (!m) |
386 | if (!m) |
413 | continue; |
387 | continue; |
414 | |
388 | |
415 | for (ob2 = get_map_ob (m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
389 | for (ob2 = GET_MAP_OB (m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
416 | { |
390 | { |
417 | object *new_ob; |
391 | object *new_ob; |
418 | |
392 | |
419 | new_ob = ob2->head ? ob2->head : ob2; |
393 | new_ob = ob2->head ? ob2->head : ob2; |
420 | if (new_ob == ob) |
394 | if (new_ob == ob) |
421 | break; |
395 | break; |
422 | if (new_ob == ob->owner) |
396 | if (new_ob == ob->owner) |
423 | return; |
397 | return; |
424 | if (get_owner (new_ob) == ob->owner) |
398 | if (new_ob->owner == ob->owner) |
425 | break; |
399 | break; |
426 | |
400 | |
427 | /* Hmm. Did we try to move into an enemy monster? If so, |
401 | /* Hmm. Did we try to move into an enemy monster? If so, |
428 | * make it our enemy. |
402 | * make it our enemy. |
429 | */ |
403 | */ |
… | |
… | |
442 | return; |
416 | return; |
443 | } |
417 | } |
444 | } |
418 | } |
445 | } |
419 | } |
446 | /* Try a different course */ |
420 | /* Try a different course */ |
447 | dir = absdir (dir + 4 - (RANDOM () % 5) - (RANDOM () % 5)); |
421 | dir = absdir (dir + 4 - (rndm (5)) - (rndm (5))); |
448 | (void) move_ob (ob, dir, ob); |
422 | (void) move_ob (ob, dir, ob); |
449 | } |
423 | } |
450 | return; |
424 | return; |
451 | } |
425 | } |
452 | |
426 | |
… | |
… | |
463 | * is_golem is to note that this is a golem spell. |
437 | * is_golem is to note that this is a golem spell. |
464 | */ |
438 | */ |
465 | object * |
439 | object * |
466 | fix_summon_pet (archetype *at, object *op, int dir, int is_golem) |
440 | fix_summon_pet (archetype *at, object *op, int dir, int is_golem) |
467 | { |
441 | { |
468 | archetype *atmp; |
|
|
469 | object *tmp = NULL, *prev = NULL, *head = NULL; |
442 | object *tmp = NULL, *prev = NULL, *head = NULL; |
470 | |
443 | |
471 | for (atmp = at; atmp != NULL; atmp = atmp->more) |
444 | for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more) |
472 | { |
445 | { |
473 | tmp = arch_to_object (atmp); |
446 | tmp = arch_to_object (atmp); |
|
|
447 | |
474 | if (atmp == at) |
448 | if (atmp == at) |
475 | { |
449 | { |
476 | if (!is_golem) |
450 | if (!is_golem) |
477 | SET_FLAG (tmp, FLAG_MONSTER); |
451 | SET_FLAG (tmp, FLAG_MONSTER); |
|
|
452 | |
478 | set_owner (tmp, op); |
453 | tmp->set_owner (op); |
|
|
454 | |
479 | if (op->type == PLAYER) |
455 | if (op->type == PLAYER) |
480 | { |
456 | { |
481 | tmp->stats.exp = 0; |
457 | tmp->stats.exp = 0; |
482 | add_friendly_object (tmp); |
458 | add_friendly_object (tmp); |
483 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
484 | if (is_golem) |
459 | if (is_golem) |
485 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
460 | CLEAR_FLAG (tmp, FLAG_MONSTER); |
486 | } |
461 | } |
487 | else |
462 | else |
488 | { |
463 | { |
489 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
464 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
490 | { |
465 | { |
491 | object *owner = get_owner (op); |
466 | object *owner = op->owner; |
492 | |
467 | |
493 | if (owner != NULL) |
468 | if (owner) |
494 | { /* For now, we transfer ownership */ |
469 | { /* For now, we transfer ownership */ |
495 | set_owner (tmp, owner); |
470 | tmp->set_owner (owner); |
496 | tmp->attack_movement = PETMOVE; |
471 | tmp->attack_movement = PETMOVE; |
497 | add_friendly_object (tmp); |
472 | add_friendly_object (tmp); |
498 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
499 | } |
473 | } |
500 | } |
474 | } |
501 | } |
475 | } |
|
|
476 | |
502 | if (op->type != PLAYER || !is_golem) |
477 | if (op->type != PLAYER || !is_golem) |
503 | { |
478 | { |
504 | tmp->attack_movement = PETMOVE; |
479 | tmp->attack_movement = PETMOVE; |
505 | tmp->speed_left = -1; |
480 | tmp->speed_left = -1; |
506 | tmp->type = 0; |
481 | tmp->type = 0; |
… | |
… | |
508 | } |
483 | } |
509 | else |
484 | else |
510 | tmp->type = GOLEM; |
485 | tmp->type = GOLEM; |
511 | |
486 | |
512 | } |
487 | } |
|
|
488 | |
513 | if (head == NULL) |
489 | if (!head) |
514 | head = tmp; |
490 | head = tmp; |
|
|
491 | |
515 | tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x; |
492 | tmp->x = op->x + freearr_x[dir] + tmp->arch->x; |
516 | tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y; |
493 | tmp->y = op->y + freearr_y[dir] + tmp->arch->y; |
517 | tmp->map = op->map; |
494 | tmp->map = op->map; |
|
|
495 | |
518 | if (tmp->invisible) |
496 | if (tmp->invisible) |
519 | tmp->invisible = 0; |
497 | tmp->invisible = 0; |
|
|
498 | |
520 | if (head != tmp) |
499 | if (head != tmp) |
521 | tmp->head = head, prev->more = tmp; |
500 | tmp->head = head, prev->more = tmp; |
|
|
501 | |
522 | prev = tmp; |
502 | prev = tmp; |
523 | } |
503 | } |
|
|
504 | |
524 | head->direction = dir; |
505 | head->direction = dir; |
525 | |
506 | |
526 | /* need to change some monster attr to prevent problems/crashing */ |
507 | /* need to change some monster attr to prevent problems/crashing */ |
527 | head->last_heal = 0; |
508 | head->last_heal = 0; |
528 | head->last_eat = 0; |
509 | head->last_eat = 0; |
… | |
… | |
539 | |
520 | |
540 | return head; |
521 | return head; |
541 | } |
522 | } |
542 | |
523 | |
543 | /* updated this to allow more than the golem 'head' to attack */ |
524 | /* updated this to allow more than the golem 'head' to attack */ |
544 | |
|
|
545 | /* op is the golem to be moved. */ |
525 | /* op is the golem to be moved. */ |
546 | |
|
|
547 | void |
526 | void |
548 | move_golem (object *op) |
527 | move_golem (object *op) |
549 | { |
528 | { |
550 | int made_attack = 0; |
529 | int made_attack = 0; |
551 | object *tmp; |
530 | object *tmp; |
552 | tag_t tag; |
|
|
553 | |
531 | |
554 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
532 | if (QUERY_FLAG (op, FLAG_MONSTER)) |
555 | return; /* Has already been moved */ |
533 | return; /* Has already been moved */ |
556 | |
534 | |
557 | if (get_owner (op) == NULL) |
535 | if (!op->owner) |
558 | { |
536 | { |
559 | LOG (llevDebug, "Golem without owner destructed.\n"); |
537 | LOG (llevDebug, "Golem without owner destructed.\n"); |
560 | remove_ob (op); |
538 | op->drop_and_destroy (); |
561 | free_object (op); |
|
|
562 | return; |
539 | return; |
563 | } |
540 | } |
|
|
541 | |
564 | /* It would be nice to have a cleaner way of what message to print |
542 | /* It would be nice to have a cleaner way of what message to print |
565 | * when the golem expires than these hard coded entries. |
543 | * when the golem expires than these hard coded entries. |
566 | * Note it is intentional that a golems duration is based on its |
544 | * Note it is intentional that a golems duration is based on its |
567 | * hp, and not duration |
545 | * hp, and not duration |
568 | */ |
546 | */ |
569 | if (--op->stats.hp < 0) |
547 | if (--op->stats.hp < 0) |
570 | { |
548 | { |
571 | if (op->msg) |
549 | if (op->msg) |
572 | new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); |
550 | new_draw_info (NDI_UNIQUE, 0, op->owner, op->msg); |
573 | op->owner->contr->ranges[range_golem] = NULL; |
551 | |
574 | op->owner->contr->golem_count = 0; |
552 | op->drop_and_destroy (); |
575 | remove_friendly_object (op); |
|
|
576 | remove_ob (op); |
|
|
577 | free_object (op); |
|
|
578 | return; |
553 | return; |
579 | } |
554 | } |
580 | |
555 | |
581 | /* Do golem attacks/movement for single & multisq golems. |
556 | /* Do golem attacks/movement for single & multisq golems. |
582 | * Assuming here that op is the 'head' object. Pass only op to |
557 | * Assuming here that op is the 'head' object. Pass only op to |
583 | * move_ob (makes recursive calls to other parts) |
558 | * move_ob (makes recursive calls to other parts) |
584 | * move_ob returns 0 if the creature was not able to move. |
559 | * move_ob returns 0 if the creature was not able to move. |
585 | */ |
560 | */ |
586 | tag = op->count; |
|
|
587 | if (move_ob (op, op->direction, op)) |
561 | if (move_ob (op, op->direction, op)) |
588 | return; |
562 | return; |
589 | if (was_destroyed (op, tag)) |
563 | |
|
|
564 | if (op->destroyed ()) |
590 | return; |
565 | return; |
591 | |
566 | |
592 | for (tmp = op; tmp; tmp = tmp->more) |
567 | for (tmp = op; tmp; tmp = tmp->more) |
593 | { |
568 | { |
594 | sint16 x = tmp->x + freearr_x[op->direction], y = tmp->y + freearr_y[op->direction]; |
569 | sint16 x = tmp->x + freearr_x[op->direction], y = tmp->y + freearr_y[op->direction]; |
595 | object *victim; |
570 | object *victim; |
596 | mapstruct *m; |
571 | maptile *m; |
597 | int mflags; |
572 | int mflags; |
598 | |
573 | |
599 | m = op->map; |
574 | m = op->map; |
600 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
575 | mflags = get_map_flags (m, &m, x, y, &x, &y); |
601 | |
576 | |
602 | if (mflags & P_OUT_OF_MAP) |
577 | if (mflags & P_OUT_OF_MAP) |
603 | continue; |
578 | continue; |
604 | |
579 | |
605 | for (victim = get_map_ob (op->map, x, y); victim; victim = victim->above) |
580 | for (victim = GET_MAP_OB (m, x, y); victim; victim = victim->above) |
606 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
581 | if (QUERY_FLAG (victim, FLAG_ALIVE)) |
607 | break; |
582 | break; |
608 | |
583 | |
609 | /* We used to call will_hit_self to make sure we don't |
584 | /* We used to call will_hit_self to make sure we don't |
610 | * hit ourselves, but that didn't work, and I don't really |
585 | * hit ourselves, but that didn't work, and I don't really |
… | |
… | |
613 | * but since we are not trying to dereferance that pointer, |
588 | * but since we are not trying to dereferance that pointer, |
614 | * that isn't a problem. |
589 | * that isn't a problem. |
615 | */ |
590 | */ |
616 | if (victim && victim != op && victim->head != op) |
591 | if (victim && victim != op && victim->head != op) |
617 | { |
592 | { |
618 | |
|
|
619 | /* for golems with race fields, we don't attack |
593 | /* for golems with race fields, we don't attack |
620 | * aligned races |
594 | * aligned races |
621 | */ |
595 | */ |
622 | |
596 | |
623 | if (victim->race && op->race && strstr (op->race, victim->race)) |
597 | if (victim->race && op->race && op->race.contains (victim->race)) |
624 | { |
598 | { |
625 | if (op->owner) |
599 | if (op->owner) |
626 | new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name); |
600 | new_draw_info_format (NDI_UNIQUE, 0, op->owner, "%s avoids damaging %s.", &op->name, &victim->name); |
627 | } |
601 | } |
628 | else if (victim == op->owner) |
602 | else if (victim == op->owner) |
… | |
… | |
635 | attack_ob (victim, op); |
609 | attack_ob (victim, op); |
636 | made_attack = 1; |
610 | made_attack = 1; |
637 | } |
611 | } |
638 | } /* If victim */ |
612 | } /* If victim */ |
639 | } |
613 | } |
|
|
614 | |
640 | if (made_attack) |
615 | if (made_attack) |
641 | update_object (op, UP_OBJ_FACE); |
616 | update_object (op, UP_OBJ_FACE); |
642 | } |
617 | } |
643 | |
618 | |
644 | /* this is a really stupid function when you get down and |
619 | /* this is a really stupid function when you get down and |
… | |
… | |
650 | control_golem (object *op, int dir) |
625 | control_golem (object *op, int dir) |
651 | { |
626 | { |
652 | op->direction = dir; |
627 | op->direction = dir; |
653 | } |
628 | } |
654 | |
629 | |
655 | /* summon golem: summons a monster for 'op'. caster is the object |
630 | /* summon golem: summons a monster for 'op'. caster is the object |
656 | * casting the spell, dir is the direction to place the monster, |
631 | * casting the spell, dir is the direction to place the monster, |
657 | * at is the archetype of the monster, and spob is the spell |
632 | * at is the archetype of the monster, and spob is the spell |
658 | * object. At this stage, all spob is really used for is to |
633 | * object. At this stage, all spob is really used for is to |
659 | * adjust some values in the monster. |
634 | * adjust some values in the monster. |
660 | */ |
635 | */ |
… | |
… | |
666 | char buf[MAX_BUF]; |
641 | char buf[MAX_BUF]; |
667 | |
642 | |
668 | /* Because there can be different golem spells, player may want to |
643 | /* Because there can be different golem spells, player may want to |
669 | * 'lose' their old golem. |
644 | * 'lose' their old golem. |
670 | */ |
645 | */ |
671 | if (op->type == PLAYER && op->contr->ranges[range_golem] != NULL && op->contr->golem_count == op->contr->ranges[range_golem]->count) |
646 | if (op->type == PLAYER && op->contr->golem) |
672 | { |
647 | { |
673 | new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem."); |
648 | new_draw_info (NDI_UNIQUE, 0, op, "You dismiss your existing golem."); |
674 | remove_ob (op->contr->ranges[range_golem]); |
649 | op->contr->golem->drop_and_destroy (); |
675 | free_object (op->contr->ranges[range_golem]); |
650 | op->contr->golem = 0; |
676 | op->contr->ranges[range_golem] = NULL; |
|
|
677 | op->contr->golem_count = (uint32) - 1; |
|
|
678 | } |
651 | } |
679 | |
652 | |
680 | if (spob->other_arch) |
653 | if (spob->other_arch) |
681 | at = spob->other_arch; |
654 | at = spob->other_arch; |
682 | else if (spob->race) |
655 | else if (spob->race) |
… | |
… | |
702 | LOG (llevError, "Spell %s lacks other_arch\n", &spob->name); |
675 | LOG (llevError, "Spell %s lacks other_arch\n", &spob->name); |
703 | return 0; |
676 | return 0; |
704 | } |
677 | } |
705 | |
678 | |
706 | if (!dir) |
679 | if (!dir) |
707 | dir = find_free_spot (NULL, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); |
680 | dir = find_free_spot (at, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); |
708 | |
681 | |
709 | if (dir == -1 || ob_blocked (&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) |
682 | if (dir < 0 || at->blocked (op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) |
710 | { |
683 | { |
711 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
684 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
712 | return 0; |
685 | return 0; |
713 | } |
686 | } |
|
|
687 | |
714 | /* basically want to get proper map/coordinates for this object */ |
688 | /* basically want to get proper map/coordinates for this object */ |
715 | |
689 | |
716 | if (!(tmp = fix_summon_pet (at, op, dir, GOLEM))) |
690 | if (!(tmp = fix_summon_pet (at, op, dir, GOLEM))) |
717 | { |
691 | { |
718 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell fails."); |
692 | new_draw_info (NDI_UNIQUE, 0, op, "Your spell fails."); |
… | |
… | |
720 | } |
694 | } |
721 | |
695 | |
722 | if (op->type == PLAYER) |
696 | if (op->type == PLAYER) |
723 | { |
697 | { |
724 | tmp->type = GOLEM; |
698 | tmp->type = GOLEM; |
725 | set_owner (tmp, op); |
699 | op->contr->golem = tmp; |
|
|
700 | /* give the player control of the golem */ |
726 | set_spell_skill (op, caster, spob, tmp); |
701 | set_spell_skill (op, caster, spob, tmp); |
727 | op->contr->ranges[range_golem] = tmp; |
|
|
728 | op->contr->golem_count = tmp->count; |
|
|
729 | /* give the player control of the golem */ |
|
|
730 | op->contr->shoottype = range_golem; |
|
|
731 | } |
|
|
732 | else |
|
|
733 | { |
|
|
734 | if (QUERY_FLAG (op, FLAG_FRIENDLY)) |
|
|
735 | { |
|
|
736 | object *owner = get_owner (op); |
|
|
737 | |
|
|
738 | if (owner != NULL) |
|
|
739 | { /* For now, we transfer ownership */ |
|
|
740 | set_owner (tmp, owner); |
|
|
741 | tmp->attack_movement = PETMOVE; |
|
|
742 | add_friendly_object (tmp); |
|
|
743 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
744 | } |
|
|
745 | } |
|
|
746 | |
|
|
747 | SET_FLAG (tmp, FLAG_MONSTER); |
|
|
748 | } |
702 | } |
749 | |
703 | |
750 | /* make the speed positive. */ |
704 | /* make the speed positive. */ |
751 | tmp->speed = FABS (tmp->speed); |
705 | tmp->speed = fabs (tmp->speed); |
752 | |
706 | |
753 | /* This sets the level dependencies on dam and hp for monsters */ |
707 | /* This sets the level dependencies on dam and hp for monsters */ |
754 | /* players can't cope with too strong summonings. */ |
708 | /* players can't cope with too strong summonings. */ |
755 | /* but monsters can. reserve these for players. */ |
709 | /* but monsters can. reserve these for players. */ |
756 | if (op->type == PLAYER) |
710 | if (op->type == PLAYER) |
… | |
… | |
761 | tmp->stats.dam += SP_level_dam_adjust (caster, spob); |
715 | tmp->stats.dam += SP_level_dam_adjust (caster, spob); |
762 | else |
716 | else |
763 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
717 | tmp->stats.dam = spob->stats.dam + SP_level_dam_adjust (caster, spob); |
764 | |
718 | |
765 | tmp->speed += .02 * SP_level_range_adjust (caster, spob); |
719 | tmp->speed += .02 * SP_level_range_adjust (caster, spob); |
766 | tmp->speed = MIN (tmp->speed, 1.0); |
720 | tmp->speed = min (tmp->speed, 1.0); |
767 | |
721 | |
768 | if (spob->attacktype) |
722 | if (spob->attacktype) |
769 | tmp->attacktype = spob->attacktype; |
723 | tmp->attacktype = spob->attacktype; |
770 | } |
724 | } |
771 | |
725 | |
… | |
… | |
775 | |
729 | |
776 | /* make experience increase in proportion to the strength. |
730 | /* make experience increase in proportion to the strength. |
777 | * this is a bit simplistic - we are basically just looking at how |
731 | * this is a bit simplistic - we are basically just looking at how |
778 | * often the sp doubles and use that as the ratio. |
732 | * often the sp doubles and use that as the ratio. |
779 | */ |
733 | */ |
780 | tmp->stats.exp *= 1 + (MAX (spob->stats.maxgrace, spob->stats.sp) / caster_level (caster, spob)); |
734 | tmp->stats.exp *= 1 + max (spob->stats.maxgrace, spob->stats.sp) / casting_level (caster, spob); |
781 | tmp->speed_left = 0; |
735 | tmp->speed_left = 0; |
782 | tmp->direction = dir; |
736 | tmp->direction = dir; |
783 | |
737 | |
784 | /* Holy spell - some additional tailoring */ |
738 | /* Holy spell - some additional tailoring */ |
785 | if (god) |
739 | if (god) |
… | |
… | |
801 | if (!(tmp->attacktype & AT_PHYSICAL)) |
755 | if (!(tmp->attacktype & AT_PHYSICAL)) |
802 | tmp->attacktype |= AT_PHYSICAL; |
756 | tmp->attacktype |= AT_PHYSICAL; |
803 | } |
757 | } |
804 | |
758 | |
805 | insert_ob_in_map (tmp, tmp->map, op, 0); |
759 | insert_ob_in_map (tmp, tmp->map, op, 0); |
|
|
760 | |
806 | return 1; |
761 | return 1; |
807 | } |
762 | } |
808 | |
763 | |
809 | |
764 | |
810 | /*************************************************************************** |
765 | /*************************************************************************** |
… | |
… | |
816 | /* Returns a monster (chosen at random) that this particular player (and his |
771 | /* Returns a monster (chosen at random) that this particular player (and his |
817 | * god) find acceptable. This checks level, races allowed by god, etc |
772 | * god) find acceptable. This checks level, races allowed by god, etc |
818 | * to determine what is acceptable. |
773 | * to determine what is acceptable. |
819 | * This returns NULL if no match was found. |
774 | * This returns NULL if no match was found. |
820 | */ |
775 | */ |
821 | |
|
|
822 | object * |
776 | object * |
823 | choose_cult_monster (object *pl, object *god, int summon_level) |
777 | choose_cult_monster (object *pl, object *god, int summon_level) |
824 | { |
778 | { |
825 | char buf[MAX_BUF]; |
779 | char buf[MAX_BUF]; |
826 | const char *race; |
780 | const char *race; |
… | |
… | |
881 | * a valid entry, assuming nothing is available and quit. |
835 | * a valid entry, assuming nothing is available and quit. |
882 | */ |
836 | */ |
883 | if (!mon_nr) |
837 | if (!mon_nr) |
884 | return NULL; |
838 | return NULL; |
885 | |
839 | |
886 | mon_nr = rndm (0, mon_nr - 1); |
840 | mon_nr = rndm (mon_nr - 1); |
887 | for (tobl = list->member; tobl; tobl = tobl->next) |
841 | for (tobl = list->member; tobl; tobl = tobl->next) |
888 | { |
842 | { |
889 | otmp = tobl->ob; |
843 | otmp = tobl->ob; |
890 | if (!otmp || !QUERY_FLAG (otmp, FLAG_MONSTER)) |
844 | if (!otmp || !QUERY_FLAG (otmp, FLAG_MONSTER)) |
891 | continue; |
845 | continue; |
|
|
846 | |
892 | if (otmp->level <= summon_level && !mon_nr--) |
847 | if (otmp->level <= summon_level && !mon_nr--) |
893 | return otmp; |
848 | return otmp; |
894 | } |
849 | } |
|
|
850 | |
895 | /* This should not happen */ |
851 | /* This should not happen */ |
896 | LOG (llevDebug, "choose_cult_monster() mon_nr was set, but did not find a monster\n"); |
852 | LOG (llevDebug, "choose_cult_monster() mon_nr was set, but did not find a monster\n"); |
897 | return NULL; |
853 | return NULL; |
898 | } |
854 | } |
899 | |
855 | |
… | |
… | |
906 | |
862 | |
907 | if (spell_ob->other_arch) |
863 | if (spell_ob->other_arch) |
908 | summon_arch = spell_ob->other_arch; |
864 | summon_arch = spell_ob->other_arch; |
909 | else if (spell_ob->randomitems) |
865 | else if (spell_ob->randomitems) |
910 | { |
866 | { |
911 | int level = caster_level (caster, spell_ob); |
867 | int level = casting_level (caster, spell_ob); |
912 | treasure *tr, *lasttr = NULL; |
868 | treasure *tr, *lasttr = NULL; |
913 | |
869 | |
914 | shstr_cmp sparam (stringarg); |
870 | shstr_cmp sparam (stringarg); |
915 | |
871 | |
916 | /* In old code, this was a very convoluted for statement, |
872 | /* In old code, this was a very convoluted for statement, |
917 | * with all the checks in the 'for' portion itself. Much |
873 | * with all the checks in the 'for' portion itself. Much |
918 | * more readable to break some of the conditions out. |
874 | * more readable to break some of the conditions out. |
919 | */ |
875 | */ |
920 | for (tr = spell_ob->randomitems->items; tr; tr = tr->next) |
876 | for (tr = spell_ob->randomitems->items; tr; tr = tr->next) |
921 | { |
877 | { |
|
|
878 | if (!tr->item) |
|
|
879 | continue; |
|
|
880 | |
922 | if (level < tr->magic) |
881 | if (level < tr->magic) |
923 | break; |
882 | break; |
924 | |
883 | |
925 | lasttr = tr; |
884 | lasttr = tr; |
926 | |
885 | |
927 | if (stringarg && tr->item->name == sparam) |
886 | if (tr->item->archname == sparam) |
928 | break; |
|
|
929 | |
|
|
930 | if (!tr->next || !tr->next->item) |
|
|
931 | break; |
887 | break; |
932 | } |
888 | } |
933 | |
889 | |
934 | if (!lasttr) |
890 | if (!lasttr) |
935 | { |
891 | { |
… | |
… | |
937 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); |
893 | new_draw_info (NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); |
938 | return 0; |
894 | return 0; |
939 | } |
895 | } |
940 | |
896 | |
941 | summon_arch = lasttr->item; |
897 | summon_arch = lasttr->item; |
942 | nrof = lasttr->nrof; |
898 | nrof = lasttr->nrof; |
943 | } |
899 | } |
944 | else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) |
900 | else if (spell_ob->race && !strcmp (spell_ob->race, "GODCULTMON")) |
945 | { |
901 | { |
946 | object *god = find_god (determine_god (op)), *mon, *owner; |
902 | object *god = find_god (determine_god (op)), *mon, *owner; |
947 | int summon_level, tries; |
903 | int summon_level, tries; |
948 | |
904 | |
949 | if (!god && ((owner = get_owner (op)) != NULL)) |
905 | if (!god && ((owner = op->owner) != NULL)) |
950 | god = find_god (determine_god (owner)); |
906 | god = find_god (determine_god (owner)); |
951 | |
907 | |
952 | /* If we can't find a god, can't get what monster to summon */ |
908 | /* If we can't find a god, can't get what monster to summon */ |
953 | if (!god) |
909 | if (!god) |
954 | return 0; |
910 | return 0; |
… | |
… | |
958 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s has no creatures that you may summon!", &god->name); |
914 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s has no creatures that you may summon!", &god->name); |
959 | return 0; |
915 | return 0; |
960 | } |
916 | } |
961 | |
917 | |
962 | /* the summon level */ |
918 | /* the summon level */ |
963 | summon_level = caster_level (caster, spell_ob); |
919 | summon_level = casting_level (caster, spell_ob); |
964 | if (summon_level == 0) |
920 | if (summon_level == 0) |
965 | summon_level = 1; |
921 | summon_level = 1; |
966 | |
922 | |
967 | tries = 0; |
923 | tries = 0; |
968 | do |
924 | do |
… | |
… | |
977 | ndir = dir; |
933 | ndir = dir; |
978 | |
934 | |
979 | if (!ndir) |
935 | if (!ndir) |
980 | ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE); |
936 | ndir = find_free_spot (mon, op->map, op->x, op->y, 1, SIZEOFFREE); |
981 | |
937 | |
982 | if (ndir == -1 || ob_blocked (mon, op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir])) |
938 | if (ndir < 0 || mon->blocked (op->map, op->x + freearr_x[ndir], op->y + freearr_y[ndir])) |
983 | { |
939 | { |
984 | ndir = -1; |
940 | ndir = -1; |
985 | if (++tries == 5) |
941 | if (++tries == 5) |
986 | { |
942 | { |
987 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
943 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
… | |
… | |
1010 | return 0; |
966 | return 0; |
1011 | } |
967 | } |
1012 | |
968 | |
1013 | for (i = 1; i <= nrof; i++) |
969 | for (i = 1; i <= nrof; i++) |
1014 | { |
970 | { |
1015 | archetype *atmp; |
|
|
1016 | object *prev = NULL, *head = NULL, *tmp; |
971 | object *prev = NULL, *head = NULL, *tmp; |
1017 | |
972 | |
1018 | if (dir) |
973 | if (dir) |
1019 | { |
974 | { |
1020 | ndir = dir; |
975 | ndir = dir; |
1021 | dir = absdir (dir + 1); |
976 | dir = absdir (dir + 1); |
1022 | } |
977 | } |
1023 | else |
978 | else |
1024 | ndir = find_free_spot (&summon_arch->clone, op->map, op->x, op->y, 1, SIZEOFFREE); |
979 | ndir = find_free_spot (summon_arch, op->map, op->x, op->y, 1, SIZEOFFREE); |
1025 | |
980 | |
1026 | if (ndir > 0) |
981 | if (ndir > 0) |
1027 | { |
982 | { |
1028 | x = freearr_x[ndir]; |
983 | x = freearr_x[ndir]; |
1029 | y = freearr_y[ndir]; |
984 | y = freearr_y[ndir]; |
1030 | } |
985 | } |
1031 | |
986 | |
1032 | if (ndir == -1 || ob_blocked (&summon_arch->clone, op->map, op->x + x, op->y + y)) |
987 | if (ndir < 0 || summon_arch->blocked (op->map, op->x + x, op->y + y)) |
1033 | { |
988 | { |
1034 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
989 | new_draw_info (NDI_UNIQUE, 0, op, "There is something in the way."); |
1035 | if (nrof > 1) |
990 | if (nrof > 1) |
1036 | new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting."); |
991 | new_draw_info (NDI_UNIQUE, 0, op, "No more pets for this casting."); |
1037 | |
992 | |
1038 | return nrof > 1; |
993 | return nrof > 1; |
1039 | } |
994 | } |
1040 | |
995 | |
1041 | for (atmp = summon_arch; atmp != NULL; atmp = atmp->more) |
996 | for (archetype *atmp = summon_arch; atmp != NULL; atmp = (archetype *)atmp->more) |
1042 | { |
997 | { |
1043 | tmp = arch_to_object (atmp); |
998 | tmp = arch_to_object (atmp); |
1044 | if (atmp == summon_arch) |
999 | if (atmp == summon_arch) |
1045 | { |
1000 | { |
1046 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1001 | if (QUERY_FLAG (tmp, FLAG_MONSTER)) |
1047 | { |
1002 | { |
1048 | set_owner (tmp, op); |
1003 | tmp->set_owner (op); |
1049 | set_spell_skill (op, caster, spell_ob, tmp); |
1004 | set_spell_skill (op, caster, spell_ob, tmp); |
1050 | tmp->enemy = op->enemy; |
1005 | tmp->enemy = op->enemy; |
1051 | tmp->type = 0; |
1006 | tmp->type = 0; |
1052 | CLEAR_FLAG (tmp, FLAG_SLEEP); |
1007 | CLEAR_FLAG (tmp, FLAG_SLEEP); |
1053 | |
1008 | |
1054 | if (op->type == PLAYER || QUERY_FLAG (op, FLAG_FRIENDLY)) |
1009 | if (op->type == PLAYER || QUERY_FLAG (op, FLAG_FRIENDLY)) |
1055 | { |
1010 | { |
1056 | /* If this is not set, we make it friendly */ |
1011 | /* If this is not set, we make it friendly */ |
1057 | if (!QUERY_FLAG (spell_ob, FLAG_MONSTER)) |
1012 | if (!QUERY_FLAG (spell_ob, FLAG_MONSTER)) |
1058 | { |
1013 | { |
1059 | SET_FLAG (tmp, FLAG_FRIENDLY); |
|
|
1060 | add_friendly_object (tmp); |
1014 | add_friendly_object (tmp); |
1061 | tmp->stats.exp = 0; |
1015 | tmp->stats.exp = 0; |
1062 | |
1016 | |
1063 | if (spell_ob->attack_movement) |
1017 | if (spell_ob->attack_movement) |
1064 | tmp->attack_movement = spell_ob->attack_movement; |
1018 | tmp->attack_movement = spell_ob->attack_movement; |
1065 | |
1019 | |
1066 | if (get_owner (op)) |
1020 | if (op->owner) |
1067 | set_owner (tmp, get_owner (op)); |
1021 | tmp->set_owner (op->owner); |
1068 | } |
1022 | } |
1069 | } |
1023 | } |
1070 | } |
1024 | } |
1071 | |
1025 | |
1072 | if (tmp->speed > MIN_ACTIVE_SPEED) |
1026 | if (tmp->speed > MIN_ACTIVE_SPEED) |
… | |
… | |
1080 | tmp->head = head; |
1034 | tmp->head = head; |
1081 | prev->more = tmp; |
1035 | prev->more = tmp; |
1082 | } |
1036 | } |
1083 | |
1037 | |
1084 | prev = tmp; |
1038 | prev = tmp; |
1085 | tmp->x = op->x + x + tmp->arch->clone.x; |
1039 | tmp->x = op->x + x + tmp->arch->x; |
1086 | tmp->y = op->y + y + tmp->arch->clone.y; |
1040 | tmp->y = op->y + y + tmp->arch->y; |
1087 | tmp->map = op->map; |
1041 | tmp->map = op->map; |
1088 | } |
1042 | } |
1089 | |
1043 | |
1090 | head->direction = freedir[ndir]; |
1044 | head->direction = freedir[ndir]; |
1091 | head->stats.exp = 0; |
1045 | head->stats.exp = 0; |
1092 | head = insert_ob_in_map (head, head->map, op, 0); |
1046 | head = insert_ob_in_map (head, head->map, op, 0); |
1093 | |
1047 | |
1094 | if (head && head->randomitems) |
1048 | if (head && head->randomitems) |
1095 | { |
1049 | { |
1096 | object *tmp; |
|
|
1097 | |
|
|
1098 | create_treasure (head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0); |
1050 | create_treasure (head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0); |
|
|
1051 | |
1099 | for (tmp = head->inv; tmp; tmp = tmp->below) |
1052 | for (object *tmp = head->inv; tmp; tmp = tmp->below) |
1100 | if (!tmp->nrof) |
|
|
1101 | SET_FLAG (tmp, FLAG_NO_DROP); |
1053 | SET_FLAG (tmp, FLAG_DESTROY_ON_DEATH); |
1102 | } |
1054 | } |
1103 | } /* for i < nrof */ |
1055 | } /* for i < nrof */ |
1104 | |
1056 | |
1105 | return 1; |
1057 | return 1; |
1106 | } |
|
|
1107 | |
|
|
1108 | /* recursively look through the owner property of objects until the real owner |
|
|
1109 | is found */ |
|
|
1110 | object * |
|
|
1111 | get_real_owner (object *ob) |
|
|
1112 | { |
|
|
1113 | object *realowner = ob; |
|
|
1114 | |
|
|
1115 | if (realowner == NULL) |
|
|
1116 | return NULL; |
|
|
1117 | |
|
|
1118 | while (get_owner (realowner) != NULL) |
|
|
1119 | { |
|
|
1120 | realowner = get_owner (realowner); |
|
|
1121 | } |
|
|
1122 | return realowner; |
|
|
1123 | } |
1058 | } |
1124 | |
1059 | |
1125 | /* determines if checks so pets don't attack players or other pets should be |
1060 | /* determines if checks so pets don't attack players or other pets should be |
1126 | overruled by the arena petmode */ |
1061 | overruled by the arena petmode */ |
1127 | int |
1062 | int |
… | |
… | |
1133 | if ((target == NULL) || (pet == NULL) || (owner == NULL)) |
1068 | if ((target == NULL) || (pet == NULL) || (owner == NULL)) |
1134 | return 0; |
1069 | return 0; |
1135 | |
1070 | |
1136 | /* get the owners of itself and the target, this is to deal with pets of |
1071 | /* get the owners of itself and the target, this is to deal with pets of |
1137 | pets */ |
1072 | pets */ |
1138 | rowner = get_real_owner (owner); |
1073 | rowner = owner->outer_owner (); |
1139 | if (target->type != PLAYER) |
1074 | towner = target->is_player () ? 0 : target->outer_owner (); |
1140 | { |
|
|
1141 | towner = get_real_owner (target); |
|
|
1142 | } |
|
|
1143 | else |
|
|
1144 | { |
|
|
1145 | towner = 0; |
|
|
1146 | } |
|
|
1147 | |
1075 | |
1148 | /* if the pet has now owner, exit with error */ |
1076 | /* if the pet has now owner, exit with error */ |
1149 | if (rowner == NULL) |
1077 | if (!rowner) |
1150 | { |
1078 | { |
1151 | LOG (llevError, "Pet has no owner.\n"); |
1079 | LOG (llevError, "Pet has no owner.\n"); |
1152 | return 0; |
1080 | return 0; |
1153 | } |
1081 | } |
1154 | |
1082 | |
1155 | /* if the target is not a player, and has no owner, we shouldn't be here |
1083 | /* if the target is not a player, and has no owner, we shouldn't be here |
1156 | */ |
1084 | */ |
1157 | if ((towner == NULL) && (target->type != PLAYER)) |
1085 | if (!towner && !target->is_player ()) |
1158 | { |
1086 | { |
1159 | LOG (llevError, "Target is not a player but has no owner. We should not be here.\n"); |
1087 | LOG (llevError, "Target is not a player but has no owner. We should not be here.\n"); |
1160 | return 0; |
1088 | return 0; |
1161 | } |
1089 | } |
1162 | |
1090 | |
1163 | /* make sure that the owner is a player */ |
1091 | /* make sure that the owner is a player */ |
1164 | if (rowner->type != PLAYER) |
1092 | if (!rowner->is_player ()) |
1165 | return 0; |
1093 | return 0; |
1166 | |
1094 | |
1167 | /* abort if the petmode is not arena */ |
1095 | /* abort if the petmode is not arena */ |
1168 | if (rowner->contr->petmode != pet_arena) |
1096 | if (rowner->contr->petmode != pet_arena) |
1169 | return 0; |
1097 | return 0; |
… | |
… | |
1171 | /* abort if the pet, it's owner, or the target is not on battleground */ |
1099 | /* abort if the pet, it's owner, or the target is not on battleground */ |
1172 | if (!(op_on_battleground (pet, NULL, NULL) && op_on_battleground (owner, NULL, NULL) && op_on_battleground (target, NULL, NULL))) |
1100 | if (!(op_on_battleground (pet, NULL, NULL) && op_on_battleground (owner, NULL, NULL) && op_on_battleground (target, NULL, NULL))) |
1173 | return 0; |
1101 | return 0; |
1174 | |
1102 | |
1175 | /* if the target is a monster, make sure it's owner is not the same */ |
1103 | /* if the target is a monster, make sure it's owner is not the same */ |
1176 | if ((target->type != PLAYER) && (rowner == towner)) |
1104 | if (!target->is_player () && rowner == towner) |
1177 | return 0; |
1105 | return 0; |
1178 | |
1106 | |
1179 | /* check if the target is a player which affects how it will handle |
1107 | /* check if the target is a player which affects how it will handle |
1180 | parties */ |
1108 | parties */ |
1181 | if (target->type != PLAYER) |
1109 | if (!target->is_player ()) |
1182 | { |
1110 | { |
1183 | /* if the target is owned by a player make sure than make sure |
1111 | /* if the target is owned by a player make sure than make sure |
1184 | it's not in the same party */ |
1112 | it's not in the same party */ |
1185 | if ((towner->type == PLAYER) && (rowner->contr->party != NULL)) |
1113 | if (towner->is_player () && rowner->contr->party) |
1186 | { |
|
|
1187 | if (rowner->contr->party == towner->contr->party) |
1114 | if (rowner->contr->party == towner->contr->party) |
1188 | return 0; |
1115 | return 0; |
1189 | } |
|
|
1190 | } |
1116 | } |
1191 | else |
1117 | else |
1192 | { |
1118 | { |
1193 | /* if the target is a player make sure than make sure it's not |
1119 | /* if the target is a player make sure than make sure it's not |
1194 | in the same party */ |
1120 | in the same party */ |
1195 | if (rowner->contr->party != NULL) |
1121 | if (rowner->contr->party) |
1196 | { |
|
|
1197 | if (rowner->contr->party == target->contr->party) |
1122 | if (rowner->contr->party == target->contr->party) |
1198 | return 0; |
1123 | return 0; |
1199 | } |
|
|
1200 | } |
1124 | } |
1201 | |
1125 | |
1202 | return 1; |
1126 | return 1; |
1203 | } |
1127 | } |
|
|
1128 | |