1 | /* |
1 | /* |
2 | * static char *rcsid_pets_c = |
2 | * static char *rcsid_pets_c = |
3 | * "$Id: pets.C,v 1.1 2006/08/13 17:16:04 elmex Exp $"; |
3 | * "$Id: pets.C,v 1.2 2006/08/29 08:01:37 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
48 | |
48 | |
49 | attacker = pet->attacked_by; /*pointer to attacking enemy*/ |
49 | attacker = pet->attacked_by; /*pointer to attacking enemy*/ |
50 | pet->attacked_by = NULL; /*clear this, since we are dealing with it*/ |
50 | pet->attacked_by = NULL; /*clear this, since we are dealing with it*/ |
51 | |
51 | |
52 | if ((owner = get_owner(pet)) != NULL) { |
52 | if ((owner = get_owner(pet)) != NULL) { |
53 | /* If the owner has turned on the pet, make the pet |
53 | /* If the owner has turned on the pet, make the pet |
54 | * unfriendly. |
54 | * unfriendly. |
55 | */ |
55 | */ |
56 | if ((check_enemy(owner,rv)) == pet) { |
56 | if ((check_enemy(owner,rv)) == pet) { |
57 | CLEAR_FLAG(pet, FLAG_FRIENDLY); |
57 | CLEAR_FLAG(pet, FLAG_FRIENDLY); |
58 | remove_friendly_object(pet); |
58 | remove_friendly_object(pet); |
59 | pet->attack_movement &=~PETMOVE; |
59 | pet->attack_movement &=~PETMOVE; |
60 | return owner; |
60 | return owner; |
61 | } |
61 | } |
62 | } else { |
62 | } else { |
63 | /* else the owner is no longer around, so the |
63 | /* else the owner is no longer around, so the |
64 | * pet no longer needs to be friendly. |
64 | * pet no longer needs to be friendly. |
65 | */ |
65 | */ |
66 | CLEAR_FLAG(pet, FLAG_FRIENDLY); |
66 | CLEAR_FLAG(pet, FLAG_FRIENDLY); |
67 | remove_friendly_object(pet); |
67 | remove_friendly_object(pet); |
68 | pet->attack_movement &=~PETMOVE; |
68 | pet->attack_movement &=~PETMOVE; |
69 | return NULL; |
69 | return NULL; |
70 | } |
70 | } |
71 | /* If they are not on the same map, the pet won't be agressive */ |
71 | /* If they are not on the same map, the pet won't be agressive */ |
72 | if (!on_same_map(pet,owner)) |
72 | if (!on_same_map(pet,owner)) |
73 | return NULL; |
73 | return NULL; |
74 | |
74 | |
75 | /* See if the pet has an existing enemy. If so, don't start a new one*/ |
75 | /* See if the pet has an existing enemy. If so, don't start a new one*/ |
76 | if((tmp=check_enemy(pet, rv))!=NULL) |
76 | if((tmp=check_enemy(pet, rv))!=NULL) |
77 | { |
77 | { |
78 | if(tmp == owner && !QUERY_FLAG(pet,FLAG_CONFUSED) |
78 | if(tmp == owner && !QUERY_FLAG(pet,FLAG_CONFUSED) |
79 | && QUERY_FLAG(pet,FLAG_FRIENDLY)) |
79 | && QUERY_FLAG(pet,FLAG_FRIENDLY)) |
80 | /* without this check, you can actually get pets with |
80 | /* without this check, you can actually get pets with |
81 | * enemy set to owner! |
81 | * enemy set to owner! |
82 | */ |
82 | */ |
83 | pet->enemy = NULL; |
83 | pet->enemy = NULL; |
84 | else |
84 | else |
85 | return tmp; |
85 | return tmp; |
86 | } |
86 | } |
87 | get_search_arr(search_arr); |
87 | get_search_arr(search_arr); |
88 | |
88 | |
89 | if (owner->type == PLAYER && owner->contr->petmode > pet_normal) { |
89 | if (owner->type == PLAYER && owner->contr->petmode > pet_normal) { |
90 | if (owner->contr->petmode == pet_sad) { |
90 | if (owner->contr->petmode == pet_sad) { |
91 | tmp = find_nearest_living_creature(pet); |
91 | tmp = find_nearest_living_creature(pet); |
92 | if (tmp != NULL) { |
92 | if (tmp != NULL) { |
93 | get_rangevector(pet, tmp, rv, 0); |
93 | get_rangevector(pet, tmp, rv, 0); |
94 | if(check_enemy(pet, rv) != NULL) |
94 | if(check_enemy(pet, rv) != NULL) |
95 | return tmp; |
95 | return tmp; |
96 | else |
96 | else |
97 | pet->enemy = NULL; |
97 | pet->enemy = NULL; |
98 | } |
98 | } |
99 | /* if we got here we have no enemy */ |
99 | /* if we got here we have no enemy */ |
100 | /* we return NULL to avoid heading back to the owner */ |
100 | /* we return NULL to avoid heading back to the owner */ |
101 | pet->enemy = NULL; |
101 | pet->enemy = NULL; |
102 | return NULL; |
102 | return NULL; |
103 | } |
103 | } |
104 | } |
104 | } |
105 | |
105 | |
106 | /* Since the pet has no existing enemy, look for anything nasty |
106 | /* Since the pet has no existing enemy, look for anything nasty |
107 | * around the owner that it should go and attack. |
107 | * around the owner that it should go and attack. |
108 | */ |
108 | */ |
109 | tmp3 = NULL; |
109 | tmp3 = NULL; |
110 | for (i = 0; i < SIZEOFFREE; i++) { |
110 | for (i = 0; i < SIZEOFFREE; i++) { |
111 | x = owner->x + freearr_x[search_arr[i]]; |
111 | x = owner->x + freearr_x[search_arr[i]]; |
112 | y = owner->y + freearr_y[search_arr[i]]; |
112 | y = owner->y + freearr_y[search_arr[i]]; |
113 | nm = owner->map; |
113 | nm = owner->map; |
114 | /* Only look on the space if there is something alive there. */ |
114 | /* Only look on the space if there is something alive there. */ |
115 | mflags = get_map_flags(nm, &nm, x, y, &x, &y); |
115 | mflags = get_map_flags(nm, &nm, x, y, &x, &y); |
116 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) { |
116 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) { |
117 | for (tmp = get_map_ob(nm, x, y); tmp != NULL; tmp = tmp->above) { |
117 | for (tmp = get_map_ob(nm, x, y); tmp != NULL; tmp = tmp->above) { |
118 | object *tmp2 = tmp->head == NULL?tmp:tmp->head; |
118 | object *tmp2 = tmp->head == NULL?tmp:tmp->head; |
119 | |
119 | |
120 | if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (( |
120 | if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (( |
121 | !QUERY_FLAG(tmp2, FLAG_FRIENDLY) && |
121 | !QUERY_FLAG(tmp2, FLAG_FRIENDLY) && |
122 | (tmp2->type != PLAYER)) || |
122 | (tmp2->type != PLAYER)) || |
123 | should_arena_attack(pet, owner, tmp2)) |
123 | should_arena_attack(pet, owner, tmp2)) |
124 | && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) && |
124 | && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) && |
125 | tmp2 != pet && tmp2 != owner && |
125 | tmp2 != pet && tmp2 != owner && |
126 | can_detect_enemy(pet, tmp2, rv)) { |
126 | can_detect_enemy(pet, tmp2, rv)) { |
127 | |
127 | |
128 | if (!can_see_enemy(pet, tmp2)) { |
128 | if (!can_see_enemy(pet, tmp2)) { |
129 | if (tmp3 != NULL) |
129 | if (tmp3 != NULL) |
130 | tmp3 = tmp2; |
130 | tmp3 = tmp2; |
131 | } else { |
131 | } else { |
132 | pet->enemy = tmp2; |
132 | pet->enemy = tmp2; |
133 | if(check_enemy(pet, rv)!=NULL) |
133 | if(check_enemy(pet, rv)!=NULL) |
134 | return tmp2; |
134 | return tmp2; |
135 | else |
135 | else |
136 | pet->enemy = NULL; |
136 | pet->enemy = NULL; |
137 | } |
137 | } |
138 | }/* if this is a valid enemy */ |
138 | }/* if this is a valid enemy */ |
139 | }/* for objects on this space */ |
139 | }/* for objects on this space */ |
140 | }/* if there is something living on this space */ |
140 | }/* if there is something living on this space */ |
141 | } /* for loop of spaces around the owner */ |
141 | } /* for loop of spaces around the owner */ |
142 | |
142 | |
143 | /* fine, we went through the whole loop and didn't find one we could |
143 | /* fine, we went through the whole loop and didn't find one we could |
144 | see, take what we have */ |
144 | see, take what we have */ |
145 | if (tmp3 != NULL) { |
145 | if (tmp3 != NULL) { |
146 | pet->enemy = tmp3; |
146 | pet->enemy = tmp3; |
147 | if (check_enemy(pet, rv) != NULL) |
147 | if (check_enemy(pet, rv) != NULL) |
148 | return tmp3; |
148 | return tmp3; |
149 | else |
149 | else |
150 | pet->enemy = NULL; |
150 | pet->enemy = NULL; |
151 | } |
151 | } |
152 | |
152 | |
153 | /* No threat to owner, check to see if the pet has an attacker*/ |
153 | /* No threat to owner, check to see if the pet has an attacker*/ |
154 | if (attacker) |
154 | if (attacker) |
155 | { |
155 | { |
… | |
… | |
157 | if (attacker->count == pet->attacked_by_count) |
157 | if (attacker->count == pet->attacked_by_count) |
158 | { |
158 | { |
159 | /* also need to check to make sure it is not freindly */ |
159 | /* also need to check to make sure it is not freindly */ |
160 | /* or otherwise non-hostile, and is an appropriate target */ |
160 | /* or otherwise non-hostile, and is an appropriate target */ |
161 | if (!QUERY_FLAG(attacker, FLAG_FRIENDLY) && on_same_map(pet, attacker)) |
161 | if (!QUERY_FLAG(attacker, FLAG_FRIENDLY) && on_same_map(pet, attacker)) |
162 | { |
162 | { |
163 | pet->enemy = attacker; |
163 | pet->enemy = attacker; |
164 | if (check_enemy(pet, rv) != NULL) |
164 | if (check_enemy(pet, rv) != NULL) |
165 | return attacker; |
165 | return attacker; |
166 | else |
166 | else |
167 | pet->enemy = NULL; |
167 | pet->enemy = NULL; |
168 | } |
168 | } |
169 | } |
169 | } |
170 | } |
170 | } |
171 | |
171 | |
172 | /* Don't have an attacker or legal enemy, so look for a new one!. |
172 | /* Don't have an attacker or legal enemy, so look for a new one!. |
173 | * This looks for one around where the pet is. Thus, you could lead |
173 | * This looks for one around where the pet is. Thus, you could lead |
174 | * a pet to danger, then take a few steps back. This code is basically |
174 | * a pet to danger, then take a few steps back. This code is basically |
175 | * the same as the code that looks around the owner. |
175 | * the same as the code that looks around the owner. |
176 | */ |
176 | */ |
177 | if (owner->type == PLAYER && owner->contr->petmode != pet_defend) { |
177 | if (owner->type == PLAYER && owner->contr->petmode != pet_defend) { |
178 | tmp3 = NULL; |
178 | tmp3 = NULL; |
179 | for (i = 0; i < SIZEOFFREE; i++) { |
179 | for (i = 0; i < SIZEOFFREE; i++) { |
180 | x = pet->x + freearr_x[search_arr[i]]; |
180 | x = pet->x + freearr_x[search_arr[i]]; |
181 | y = pet->y + freearr_y[search_arr[i]]; |
181 | y = pet->y + freearr_y[search_arr[i]]; |
182 | nm = pet->map; |
182 | nm = pet->map; |
183 | /* Only look on the space if there is something alive there. */ |
183 | /* Only look on the space if there is something alive there. */ |
184 | mflags = get_map_flags(nm, &nm, x,y, &x, &y); |
184 | mflags = get_map_flags(nm, &nm, x,y, &x, &y); |
185 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) { |
185 | if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) { |
186 | for (tmp = get_map_ob(nm, x, y); tmp != NULL; tmp = tmp->above) { |
186 | for (tmp = get_map_ob(nm, x, y); tmp != NULL; tmp = tmp->above) { |
187 | object *tmp2 = tmp->head == NULL?tmp:tmp->head; |
187 | object *tmp2 = tmp->head == NULL?tmp:tmp->head; |
188 | if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (( |
188 | if (QUERY_FLAG(tmp2,FLAG_ALIVE) && (( |
189 | !QUERY_FLAG(tmp2, FLAG_FRIENDLY) && |
189 | !QUERY_FLAG(tmp2, FLAG_FRIENDLY) && |
190 | (tmp2->type != PLAYER)) || |
190 | (tmp2->type != PLAYER)) || |
191 | should_arena_attack(pet, owner, tmp2)) |
191 | should_arena_attack(pet, owner, tmp2)) |
192 | && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) && |
192 | && !QUERY_FLAG(tmp2,FLAG_UNAGGRESSIVE) && |
193 | tmp2 != pet && tmp2 != owner && |
193 | tmp2 != pet && tmp2 != owner && |
194 | can_detect_enemy(pet, tmp2, rv)) { |
194 | can_detect_enemy(pet, tmp2, rv)) { |
195 | |
195 | |
196 | if (!can_see_enemy(pet, tmp2)) { |
196 | if (!can_see_enemy(pet, tmp2)) { |
197 | if (tmp3 != NULL) |
197 | if (tmp3 != NULL) |
198 | tmp3 = tmp2; |
198 | tmp3 = tmp2; |
199 | } else { |
199 | } else { |
200 | pet->enemy = tmp2; |
200 | pet->enemy = tmp2; |
201 | if(check_enemy(pet, rv)!=NULL) |
201 | if(check_enemy(pet, rv)!=NULL) |
202 | return tmp2; |
202 | return tmp2; |
203 | else |
203 | else |
204 | pet->enemy = NULL; |
204 | pet->enemy = NULL; |
205 | } |
205 | } |
206 | } /* make sure we can get to the bugger */ |
206 | } /* make sure we can get to the bugger */ |
207 | }/* for objects on this space */ |
207 | }/* for objects on this space */ |
208 | } /* if there is something living on this space */ |
208 | } /* if there is something living on this space */ |
209 | } /* for loop of spaces around the pet */ |
209 | } /* for loop of spaces around the pet */ |
210 | } /* pet in defence mode */ |
210 | } /* pet in defence mode */ |
211 | |
211 | |
212 | /* fine, we went through the whole loop and didn't find one we could |
212 | /* fine, we went through the whole loop and didn't find one we could |
213 | see, take what we have */ |
213 | see, take what we have */ |
214 | if (tmp3 != NULL) { |
214 | if (tmp3 != NULL) { |
215 | pet->enemy = tmp3; |
215 | pet->enemy = tmp3; |
216 | if (check_enemy(pet, rv) != NULL) |
216 | if (check_enemy(pet, rv) != NULL) |
217 | return tmp3; |
217 | return tmp3; |
218 | else |
218 | else |
219 | pet->enemy = NULL; |
219 | pet->enemy = NULL; |
220 | } |
220 | } |
221 | |
221 | |
222 | /* Didn't find anything - return the owner's enemy or NULL */ |
222 | /* Didn't find anything - return the owner's enemy or NULL */ |
223 | return check_enemy(pet, rv); |
223 | return check_enemy(pet, rv); |
224 | } |
224 | } |
… | |
… | |
253 | for(obl = first_friendly_object; obl != NULL; obl = next) { |
253 | for(obl = first_friendly_object; obl != NULL; obl = next) { |
254 | next = obl->next; |
254 | next = obl->next; |
255 | if(obl->ob->type != PLAYER && QUERY_FLAG(obl->ob,FLAG_FRIENDLY) && |
255 | if(obl->ob->type != PLAYER && QUERY_FLAG(obl->ob,FLAG_FRIENDLY) && |
256 | (owner = get_owner(obl->ob)) != NULL && !on_same_map(owner, obl->ob)) |
256 | (owner = get_owner(obl->ob)) != NULL && !on_same_map(owner, obl->ob)) |
257 | { |
257 | { |
258 | /* follow owner checks map status for us */ |
258 | /* follow owner checks map status for us */ |
259 | follow_owner(obl->ob,owner); |
259 | follow_owner(obl->ob,owner); |
260 | } |
260 | } |
261 | } |
261 | } |
262 | } |
262 | } |
263 | |
263 | |
264 | int follow_owner(object *ob, object *owner) { |
264 | int follow_owner(object *ob, object *owner) { |
265 | object *tmp; |
265 | object *tmp; |
266 | int dir; |
266 | int dir; |
267 | |
267 | |
268 | if (!QUERY_FLAG(ob,FLAG_REMOVED)) |
268 | if (!QUERY_FLAG(ob,FLAG_REMOVED)) |
269 | remove_ob(ob); |
269 | remove_ob(ob); |
270 | |
270 | |
271 | if(owner->map == NULL) { |
271 | if(owner->map == NULL) { |
272 | LOG(llevError,"Can't follow owner (%d): no map.\n", owner->name); |
272 | LOG(llevError,"Can't follow owner (%d): no map.\n", owner->name); |
273 | goto fail; |
273 | goto fail; |
274 | } |
274 | } |
275 | if(owner->map->in_memory != MAP_IN_MEMORY) { |
275 | if(owner->map->in_memory != MAP_IN_MEMORY) { |
276 | LOG(llevError,"Owner of the pet not on a map in memory!?\n"); |
276 | LOG(llevError,"Owner of the pet not on a map in memory!?\n"); |
277 | goto fail; |
277 | goto fail; |
278 | } |
278 | } |
279 | |
279 | |
280 | dir = find_free_spot(ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); |
280 | dir = find_free_spot(ob, owner->map, owner->x, owner->y, 1, SIZEOFFREE); |
281 | |
281 | |
282 | if (dir==-1) { |
282 | if (dir==-1) { |
283 | LOG(llevMonster,"No space for pet to follow, freeing %s.\n",ob->name); |
283 | LOG(llevMonster,"No space for pet to follow, freeing %s.\n",ob->name); |
284 | goto fail; |
284 | goto fail; |
285 | } |
285 | } |
286 | for(tmp=ob;tmp!=NULL;tmp=tmp->more) { |
286 | for(tmp=ob;tmp!=NULL;tmp=tmp->more) { |
287 | tmp->x = owner->x + freearr_x[dir]+(tmp->arch==NULL?0:tmp->arch->clone.x); |
287 | tmp->x = owner->x + freearr_x[dir]+(tmp->arch==NULL?0:tmp->arch->clone.x); |
288 | tmp->y = owner->y + freearr_y[dir]+(tmp->arch==NULL?0:tmp->arch->clone.y); |
288 | tmp->y = owner->y + freearr_y[dir]+(tmp->arch==NULL?0:tmp->arch->clone.y); |
289 | tmp->map = owner->map; |
289 | tmp->map = owner->map; |
290 | if (OUT_OF_REAL_MAP(tmp->map, tmp->x, tmp->y)) { |
290 | if (OUT_OF_REAL_MAP(tmp->map, tmp->x, tmp->y)) { |
291 | tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y); |
291 | tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y); |
292 | } |
292 | } |
293 | } |
293 | } |
294 | insert_ob_in_map(ob, ob->map, NULL,0); |
294 | insert_ob_in_map(ob, ob->map, NULL,0); |
295 | if (owner->type == PLAYER) /* Uh, I hope this is always true... */ |
295 | if (owner->type == PLAYER) /* Uh, I hope this is always true... */ |
296 | new_draw_info(NDI_UNIQUE, 0,owner, "Your pet magically appears next to you"); |
296 | new_draw_info(NDI_UNIQUE, 0,owner, "Your pet magically appears next to you"); |
297 | |
297 | |
298 | return 0; |
298 | return 0; |
299 | |
299 | |
300 | fail: |
300 | fail: |
301 | remove_friendly_object (ob); |
301 | remove_friendly_object (ob); |
… | |
… | |
311 | object *ob2, *owner; |
311 | object *ob2, *owner; |
312 | mapstruct *m; |
312 | mapstruct *m; |
313 | |
313 | |
314 | /* Check to see if player pulled out */ |
314 | /* Check to see if player pulled out */ |
315 | if ((owner = get_owner(ob)) == NULL) { |
315 | if ((owner = get_owner(ob)) == NULL) { |
316 | remove_ob(ob); /* Will be freed when returning */ |
316 | remove_ob(ob); /* Will be freed when returning */ |
317 | remove_friendly_object(ob); |
317 | remove_friendly_object(ob); |
318 | free_object(ob); |
318 | free_object(ob); |
319 | LOG(llevMonster, "Pet: no owner, leaving.\n"); |
319 | LOG(llevMonster, "Pet: no owner, leaving.\n"); |
320 | return; |
320 | return; |
321 | } |
321 | } |
322 | |
322 | |
323 | /* move monster into the owners map if not in the same map */ |
323 | /* move monster into the owners map if not in the same map */ |
324 | if (!on_same_map(ob, owner)) { |
324 | if (!on_same_map(ob, owner)) { |
325 | follow_owner(ob, owner); |
325 | follow_owner(ob, owner); |
326 | return; |
326 | return; |
327 | } |
327 | } |
328 | /* Calculate Direction */ |
328 | /* Calculate Direction */ |
329 | if (owner->type == PLAYER && owner->contr->petmode == pet_sad) { |
329 | if (owner->type == PLAYER && owner->contr->petmode == pet_sad) { |
330 | /* in S&D mode, if we have no enemy, run randomly about. */ |
330 | /* in S&D mode, if we have no enemy, run randomly about. */ |
331 | for (i=0; i < 15; i++) { |
331 | for (i=0; i < 15; i++) { |
332 | dir = rndm(1, 8); |
332 | dir = rndm(1, 8); |
333 | dx = ob->x + freearr_x[dir]; |
333 | dx = ob->x + freearr_x[dir]; |
334 | dy = ob->y + freearr_y[dir]; |
334 | dy = ob->y + freearr_y[dir]; |
335 | m = ob->map; |
335 | m = ob->map; |
336 | if (get_map_flags(ob->map, &m, dx, dy, &dx, &dy) & P_OUT_OF_MAP) |
336 | if (get_map_flags(ob->map, &m, dx, dy, &dx, &dy) & P_OUT_OF_MAP) |
337 | continue; |
337 | continue; |
338 | else if (OB_TYPE_MOVE_BLOCK(ob, GET_MAP_MOVE_BLOCK(m, dx, dy))) |
338 | else if (OB_TYPE_MOVE_BLOCK(ob, GET_MAP_MOVE_BLOCK(m, dx, dy))) |
339 | continue; |
339 | continue; |
340 | else |
340 | else |
341 | break; |
341 | break; |
342 | } |
342 | } |
343 | } else { |
343 | } else { |
344 | struct rv_vector rv; |
344 | struct rv_vector rv; |
345 | get_rangevector (ob, ob->owner, &rv, 0); |
345 | get_rangevector (ob, ob->owner, &rv, 0); |
346 | dir = rv.direction; |
346 | dir = rv.direction; |
347 | } |
347 | } |
… | |
… | |
350 | tag = ob->count; |
350 | tag = ob->count; |
351 | /* move_ob returns 0 if the object couldn't move. If that is the |
351 | /* move_ob returns 0 if the object couldn't move. If that is the |
352 | * case, lets do some other work. |
352 | * case, lets do some other work. |
353 | */ |
353 | */ |
354 | if (!(move_ob(ob, dir, ob))) { |
354 | if (!(move_ob(ob, dir, ob))) { |
355 | object *part; |
355 | object *part; |
356 | |
356 | |
357 | /* the failed move_ob above may destroy the pet, so check here */ |
357 | /* the failed move_ob above may destroy the pet, so check here */ |
358 | if (was_destroyed(ob, tag)) return; |
358 | if (was_destroyed(ob, tag)) return; |
359 | |
359 | |
360 | for(part = ob; part != NULL; part = part->more) |
360 | for(part = ob; part != NULL; part = part->more) |
361 | { |
361 | { |
362 | dx = part->x + freearr_x[dir]; |
362 | dx = part->x + freearr_x[dir]; |
363 | dy = part->y + freearr_y[dir]; |
363 | dy = part->y + freearr_y[dir]; |
364 | m = get_map_from_coord(part->map, &dx, &dy); |
364 | m = get_map_from_coord(part->map, &dx, &dy); |
365 | if (!m) continue; |
365 | if (!m) continue; |
366 | |
366 | |
367 | for (ob2 = get_map_ob(m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
367 | for (ob2 = get_map_ob(m, dx, dy); ob2 != NULL; ob2 = ob2->above) |
368 | { |
368 | { |
369 | object *new_ob; |
369 | object *new_ob; |
370 | new_ob = ob2->head?ob2->head:ob2; |
370 | new_ob = ob2->head?ob2->head:ob2; |
371 | if(new_ob == ob) |
371 | if(new_ob == ob) |
372 | break; |
372 | break; |
373 | if (new_ob == ob->owner) |
373 | if (new_ob == ob->owner) |
374 | return; |
374 | return; |
375 | if (get_owner(new_ob) == ob->owner) |
375 | if (get_owner(new_ob) == ob->owner) |
376 | break; |
376 | break; |
377 | |
377 | |
378 | /* Hmm. Did we try to move into an enemy monster? If so, |
378 | /* Hmm. Did we try to move into an enemy monster? If so, |
379 | * make it our enemy. |
379 | * make it our enemy. |
380 | */ |
380 | */ |
381 | if (QUERY_FLAG(new_ob,FLAG_ALIVE) && !QUERY_FLAG(ob,FLAG_UNAGGRESSIVE) |
381 | if (QUERY_FLAG(new_ob,FLAG_ALIVE) && !QUERY_FLAG(ob,FLAG_UNAGGRESSIVE) |
382 | && !QUERY_FLAG(new_ob,FLAG_UNAGGRESSIVE) && |
382 | && !QUERY_FLAG(new_ob,FLAG_UNAGGRESSIVE) && |
383 | !QUERY_FLAG(new_ob,FLAG_FRIENDLY)) { |
383 | !QUERY_FLAG(new_ob,FLAG_FRIENDLY)) { |
384 | |
384 | |
385 | ob->enemy = new_ob; |
385 | ob->enemy = new_ob; |
386 | if(new_ob->enemy == NULL) |
386 | if(new_ob->enemy == NULL) |
387 | new_ob->enemy = ob; |
387 | new_ob->enemy = ob; |
388 | return; |
388 | return; |
389 | } else if (new_ob->type == PLAYER) { |
389 | } else if (new_ob->type == PLAYER) { |
390 | new_draw_info(NDI_UNIQUE, 0,new_ob, "You stand in the way of someones pet."); |
390 | new_draw_info(NDI_UNIQUE, 0,new_ob, "You stand in the way of someones pet."); |
391 | return; |
391 | return; |
392 | } |
392 | } |
393 | } |
393 | } |
394 | } |
394 | } |
395 | /* Try a different course */ |
395 | /* Try a different course */ |
396 | dir = absdir(dir + 4 - (RANDOM() %5) - (RANDOM()%5)); |
396 | dir = absdir(dir + 4 - (RANDOM() %5) - (RANDOM()%5)); |
397 | (void) move_ob(ob, dir, ob); |
397 | (void) move_ob(ob, dir, ob); |
398 | } |
398 | } |
399 | return; |
399 | return; |
400 | } |
400 | } |
401 | |
401 | |
402 | /**************************************************************************** |
402 | /**************************************************************************** |
… | |
… | |
414 | object *fix_summon_pet(archetype *at, object *op, int dir, int is_golem ) { |
414 | object *fix_summon_pet(archetype *at, object *op, int dir, int is_golem ) { |
415 | archetype *atmp; |
415 | archetype *atmp; |
416 | object *tmp=NULL, *prev=NULL, *head=NULL; |
416 | object *tmp=NULL, *prev=NULL, *head=NULL; |
417 | |
417 | |
418 | for(atmp = at; atmp!=NULL; atmp = atmp->more) { |
418 | for(atmp = at; atmp!=NULL; atmp = atmp->more) { |
419 | tmp = arch_to_object(atmp); |
419 | tmp = arch_to_object(atmp); |
420 | if (atmp == at) { |
420 | if (atmp == at) { |
421 | if(!is_golem) |
421 | if(!is_golem) |
422 | SET_FLAG(tmp, FLAG_MONSTER); |
422 | SET_FLAG(tmp, FLAG_MONSTER); |
423 | set_owner(tmp, op); |
423 | set_owner(tmp, op); |
424 | if (op->type == PLAYER) { |
424 | if (op->type == PLAYER) { |
425 | tmp->stats.exp = 0; |
425 | tmp->stats.exp = 0; |
426 | add_friendly_object(tmp); |
426 | add_friendly_object(tmp); |
427 | SET_FLAG(tmp, FLAG_FRIENDLY); |
427 | SET_FLAG(tmp, FLAG_FRIENDLY); |
428 | if(is_golem) CLEAR_FLAG(tmp, FLAG_MONSTER); |
428 | if(is_golem) CLEAR_FLAG(tmp, FLAG_MONSTER); |
429 | } else { |
429 | } else { |
430 | if(QUERY_FLAG(op, FLAG_FRIENDLY)) { |
430 | if(QUERY_FLAG(op, FLAG_FRIENDLY)) { |
431 | object *owner = get_owner(op); |
431 | object *owner = get_owner(op); |
432 | if(owner != NULL) {/* For now, we transfer ownership */ |
432 | if(owner != NULL) {/* For now, we transfer ownership */ |
433 | set_owner(tmp,owner); |
433 | set_owner(tmp,owner); |
434 | tmp->attack_movement = PETMOVE; |
434 | tmp->attack_movement = PETMOVE; |
435 | add_friendly_object(tmp); |
435 | add_friendly_object(tmp); |
436 | SET_FLAG(tmp, FLAG_FRIENDLY); |
436 | SET_FLAG(tmp, FLAG_FRIENDLY); |
437 | } |
437 | } |
438 | } |
438 | } |
439 | } |
439 | } |
440 | if(op->type!=PLAYER || !is_golem) { |
440 | if(op->type!=PLAYER || !is_golem) { |
441 | tmp->attack_movement = PETMOVE; |
441 | tmp->attack_movement = PETMOVE; |
442 | tmp->speed_left = -1; |
442 | tmp->speed_left = -1; |
443 | tmp->type = 0; |
443 | tmp->type = 0; |
444 | tmp->enemy = op->enemy; |
444 | tmp->enemy = op->enemy; |
445 | } else |
445 | } else |
446 | tmp->type = GOLEM; |
446 | tmp->type = GOLEM; |
447 | |
447 | |
448 | } |
448 | } |
449 | if(head == NULL) |
449 | if(head == NULL) |
450 | head = tmp; |
450 | head = tmp; |
451 | tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x; |
451 | tmp->x = op->x + freearr_x[dir] + tmp->arch->clone.x; |
452 | tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y; |
452 | tmp->y = op->y + freearr_y[dir] + tmp->arch->clone.y; |
453 | tmp->map = op->map; |
453 | tmp->map = op->map; |
454 | if(tmp->invisible) tmp->invisible=0; |
454 | if(tmp->invisible) tmp->invisible=0; |
455 | if(head != tmp) |
455 | if(head != tmp) |
456 | tmp->head = head, prev->more = tmp; |
456 | tmp->head = head, prev->more = tmp; |
457 | prev = tmp; |
457 | prev = tmp; |
458 | } |
458 | } |
459 | head->direction = dir; |
459 | head->direction = dir; |
460 | |
460 | |
461 | /* need to change some monster attr to prevent problems/crashing */ |
461 | /* need to change some monster attr to prevent problems/crashing */ |
462 | head->last_heal=0; |
462 | head->last_heal=0; |
… | |
… | |
481 | int made_attack=0; |
481 | int made_attack=0; |
482 | object *tmp; |
482 | object *tmp; |
483 | tag_t tag; |
483 | tag_t tag; |
484 | |
484 | |
485 | if(QUERY_FLAG(op, FLAG_MONSTER)) |
485 | if(QUERY_FLAG(op, FLAG_MONSTER)) |
486 | return; /* Has already been moved */ |
486 | return; /* Has already been moved */ |
487 | |
487 | |
488 | if(get_owner(op)==NULL) { |
488 | if(get_owner(op)==NULL) { |
489 | LOG(llevDebug,"Golem without owner destructed.\n"); |
489 | LOG(llevDebug,"Golem without owner destructed.\n"); |
490 | remove_ob(op); |
490 | remove_ob(op); |
491 | free_object(op); |
491 | free_object(op); |
492 | return; |
492 | return; |
493 | } |
493 | } |
494 | /* It would be nice to have a cleaner way of what message to print |
494 | /* It would be nice to have a cleaner way of what message to print |
495 | * when the golem expires than these hard coded entries. |
495 | * when the golem expires than these hard coded entries. |
496 | * Note it is intentional that a golems duration is based on its |
496 | * Note it is intentional that a golems duration is based on its |
497 | * hp, and not duration |
497 | * hp, and not duration |
498 | */ |
498 | */ |
499 | if(--op->stats.hp<0) { |
499 | if(--op->stats.hp<0) { |
500 | if (op->msg) |
500 | if (op->msg) |
501 | new_draw_info(NDI_UNIQUE, 0,op->owner,op->msg); |
501 | new_draw_info(NDI_UNIQUE, 0,op->owner,op->msg); |
502 | op->owner->contr->ranges[range_golem]=NULL; |
502 | op->owner->contr->ranges[range_golem]=NULL; |
503 | op->owner->contr->golem_count = 0; |
503 | op->owner->contr->golem_count = 0; |
504 | remove_friendly_object(op); |
504 | remove_friendly_object(op); |
505 | remove_ob(op); |
505 | remove_ob(op); |
506 | free_object(op); |
506 | free_object(op); |
507 | return; |
507 | return; |
508 | } |
508 | } |
509 | |
509 | |
510 | /* Do golem attacks/movement for single & multisq golems. |
510 | /* Do golem attacks/movement for single & multisq golems. |
511 | * Assuming here that op is the 'head' object. Pass only op to |
511 | * Assuming here that op is the 'head' object. Pass only op to |
512 | * move_ob (makes recursive calls to other parts) |
512 | * move_ob (makes recursive calls to other parts) |
… | |
… | |
516 | if(move_ob(op,op->direction,op)) return; |
516 | if(move_ob(op,op->direction,op)) return; |
517 | if (was_destroyed (op, tag)) |
517 | if (was_destroyed (op, tag)) |
518 | return; |
518 | return; |
519 | |
519 | |
520 | for(tmp=op;tmp;tmp=tmp->more) { |
520 | for(tmp=op;tmp;tmp=tmp->more) { |
521 | sint16 x=tmp->x+freearr_x[op->direction],y=tmp->y+freearr_y[op->direction]; |
521 | sint16 x=tmp->x+freearr_x[op->direction],y=tmp->y+freearr_y[op->direction]; |
522 | object *victim; |
522 | object *victim; |
523 | mapstruct *m; |
523 | mapstruct *m; |
524 | int mflags; |
524 | int mflags; |
525 | |
525 | |
526 | m = op->map; |
526 | m = op->map; |
527 | mflags = get_map_flags(m, &m, x, y, &x, &y); |
527 | mflags = get_map_flags(m, &m, x, y, &x, &y); |
528 | |
528 | |
529 | if (mflags & P_OUT_OF_MAP) continue; |
529 | if (mflags & P_OUT_OF_MAP) continue; |
530 | |
530 | |
531 | for(victim=get_map_ob(op->map,x,y);victim;victim=victim->above) |
531 | for(victim=get_map_ob(op->map,x,y);victim;victim=victim->above) |
532 | if(QUERY_FLAG(victim,FLAG_ALIVE)) break; |
532 | if(QUERY_FLAG(victim,FLAG_ALIVE)) break; |
533 | |
533 | |
534 | /* We used to call will_hit_self to make sure we don't |
534 | /* We used to call will_hit_self to make sure we don't |
535 | * hit ourselves, but that didn't work, and I don't really |
535 | * hit ourselves, but that didn't work, and I don't really |
536 | * know if that was more efficient anyways than this. |
536 | * know if that was more efficient anyways than this. |
537 | * This at least works. Note that victim->head can be NULL, |
537 | * This at least works. Note that victim->head can be NULL, |
538 | * but since we are not trying to dereferance that pointer, |
538 | * but since we are not trying to dereferance that pointer, |
539 | * that isn't a problem. |
539 | * that isn't a problem. |
540 | */ |
540 | */ |
541 | if(victim && victim!=op && victim->head!=op) { |
541 | if(victim && victim!=op && victim->head!=op) { |
542 | |
542 | |
543 | /* for golems with race fields, we don't attack |
543 | /* for golems with race fields, we don't attack |
544 | * aligned races |
544 | * aligned races |
545 | */ |
545 | */ |
546 | |
546 | |
547 | if(victim->race && op->race && strstr(op->race,victim->race)) { |
547 | if(victim->race && op->race && strstr(op->race,victim->race)) { |
548 | if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, |
548 | if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, |
549 | "%s avoids damaging %s.",op->name,victim->name); |
549 | "%s avoids damaging %s.",op->name,victim->name); |
550 | } else if (victim == op->owner) { |
550 | } else if (victim == op->owner) { |
551 | if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, |
551 | if(op->owner) new_draw_info_format(NDI_UNIQUE, 0,op->owner, |
552 | "%s avoids damaging you.",op->name); |
552 | "%s avoids damaging you.",op->name); |
553 | } else { |
553 | } else { |
554 | attack_ob(victim,op); |
554 | attack_ob(victim,op); |
555 | made_attack=1; |
555 | made_attack=1; |
556 | } |
556 | } |
557 | } /* If victim */ |
557 | } /* If victim */ |
558 | } |
558 | } |
559 | if(made_attack) update_object(op,UP_OBJ_FACE); |
559 | if(made_attack) update_object(op,UP_OBJ_FACE); |
560 | } |
560 | } |
561 | |
561 | |
562 | /* this is a really stupid function when you get down and |
562 | /* this is a really stupid function when you get down and |
… | |
… | |
583 | * 'lose' their old golem. |
583 | * 'lose' their old golem. |
584 | */ |
584 | */ |
585 | if(op->type==PLAYER && |
585 | if(op->type==PLAYER && |
586 | op->contr->ranges[range_golem]!=NULL && |
586 | op->contr->ranges[range_golem]!=NULL && |
587 | op->contr->golem_count == op->contr->ranges[range_golem]->count) { |
587 | op->contr->golem_count == op->contr->ranges[range_golem]->count) { |
588 | new_draw_info(NDI_UNIQUE, 0, op, "You dismiss your existing golem."); |
588 | new_draw_info(NDI_UNIQUE, 0, op, "You dismiss your existing golem."); |
589 | remove_ob(op->contr->ranges[range_golem]); |
589 | remove_ob(op->contr->ranges[range_golem]); |
590 | free_object(op->contr->ranges[range_golem]); |
590 | free_object(op->contr->ranges[range_golem]); |
591 | op->contr->ranges[range_golem]=NULL; |
591 | op->contr->ranges[range_golem]=NULL; |
592 | op->contr->golem_count=(uint32)-1; |
592 | op->contr->golem_count=(uint32)-1; |
593 | } |
593 | } |
594 | |
594 | |
595 | if (spob->other_arch) |
595 | if (spob->other_arch) |
596 | at = spob->other_arch; |
596 | at = spob->other_arch; |
597 | else if (spob->race) { |
597 | else if (spob->race) { |
598 | god = find_god(determine_god(caster)); |
598 | god = find_god(determine_god(caster)); |
599 | |
599 | |
600 | if (!god) { |
600 | if (!god) { |
601 | new_draw_info_format(NDI_UNIQUE, 0,op,"You must worship a god to cast %s.", spob->name); |
601 | new_draw_info_format(NDI_UNIQUE, 0,op,"You must worship a god to cast %s.", spob->name); |
602 | return 0; |
602 | return 0; |
603 | } |
603 | } |
604 | at = determine_holy_arch (god, spob->race); |
604 | at = determine_holy_arch (god, spob->race); |
605 | if (!at) { |
605 | if (!at) { |
606 | new_draw_info_format(NDI_UNIQUE, 0,op,"%s has no %s for you to call.", |
606 | new_draw_info_format(NDI_UNIQUE, 0,op,"%s has no %s for you to call.", |
607 | god->name,spob->race); |
607 | god->name,spob->race); |
608 | return 0; |
608 | return 0; |
609 | } |
609 | } |
610 | } else { |
610 | } else { |
611 | LOG(llevError,"Spell %s lacks other_arch\n", spob->name); |
611 | LOG(llevError,"Spell %s lacks other_arch\n", spob->name); |
612 | return 0; |
612 | return 0; |
613 | } |
613 | } |
614 | |
614 | |
615 | if(!dir) |
615 | if(!dir) |
616 | dir=find_free_spot(NULL,op->map,op->x,op->y,1,SIZEOFFREE1+1); |
616 | dir=find_free_spot(NULL,op->map,op->x,op->y,1,SIZEOFFREE1+1); |
617 | |
617 | |
618 | if ((dir==-1) || ob_blocked(&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) { |
618 | if ((dir==-1) || ob_blocked(&at->clone, op->map, op->x + freearr_x[dir], op->y + freearr_y[dir])) { |
619 | new_draw_info(NDI_UNIQUE, 0,op,"There is something in the way."); |
619 | new_draw_info(NDI_UNIQUE, 0,op,"There is something in the way."); |
620 | return 0; |
620 | return 0; |
621 | } |
621 | } |
622 | /* basically want to get proper map/coordinates for this object */ |
622 | /* basically want to get proper map/coordinates for this object */ |
623 | |
623 | |
624 | if(!(tmp=fix_summon_pet(at,op,dir,GOLEM))) { |
624 | if(!(tmp=fix_summon_pet(at,op,dir,GOLEM))) { |
625 | new_draw_info(NDI_UNIQUE, 0,op,"Your spell fails."); |
625 | new_draw_info(NDI_UNIQUE, 0,op,"Your spell fails."); |
626 | return 0; |
626 | return 0; |
627 | } |
627 | } |
628 | |
628 | |
629 | if(op->type==PLAYER) { |
629 | if(op->type==PLAYER) { |
630 | tmp->type=GOLEM; |
630 | tmp->type=GOLEM; |
631 | set_owner(tmp,op); |
631 | set_owner(tmp,op); |
632 | set_spell_skill(op, caster, spob, tmp); |
632 | set_spell_skill(op, caster, spob, tmp); |
633 | op->contr->ranges[range_golem]=tmp; |
633 | op->contr->ranges[range_golem]=tmp; |
634 | op->contr->golem_count = tmp->count; |
634 | op->contr->golem_count = tmp->count; |
635 | /* give the player control of the golem */ |
635 | /* give the player control of the golem */ |
636 | op->contr->shoottype=range_golem; |
636 | op->contr->shoottype=range_golem; |
637 | } else { |
637 | } else { |
638 | if(QUERY_FLAG(op, FLAG_FRIENDLY)) { |
638 | if(QUERY_FLAG(op, FLAG_FRIENDLY)) { |
639 | object *owner = get_owner(op); |
639 | object *owner = get_owner(op); |
640 | if (owner != NULL) { /* For now, we transfer ownership */ |
640 | if (owner != NULL) { /* For now, we transfer ownership */ |
641 | set_owner (tmp, owner); |
641 | set_owner (tmp, owner); |
642 | tmp->attack_movement = PETMOVE; |
642 | tmp->attack_movement = PETMOVE; |
643 | add_friendly_object (tmp); |
643 | add_friendly_object (tmp); |
644 | SET_FLAG (tmp, FLAG_FRIENDLY); |
644 | SET_FLAG (tmp, FLAG_FRIENDLY); |
645 | } |
645 | } |
646 | } |
646 | } |
647 | SET_FLAG(tmp, FLAG_MONSTER); |
647 | SET_FLAG(tmp, FLAG_MONSTER); |
648 | } |
648 | } |
649 | |
649 | |
650 | /* make the speed positive.*/ |
650 | /* make the speed positive.*/ |
651 | tmp->speed = FABS(tmp->speed); |
651 | tmp->speed = FABS(tmp->speed); |
652 | |
652 | |
653 | /* This sets the level dependencies on dam and hp for monsters */ |
653 | /* This sets the level dependencies on dam and hp for monsters */ |
654 | /* players can't cope with too strong summonings. */ |
654 | /* players can't cope with too strong summonings. */ |
655 | /* but monsters can. reserve these for players. */ |
655 | /* but monsters can. reserve these for players. */ |
656 | if(op->type==PLAYER) { |
656 | if(op->type==PLAYER) { |
657 | tmp->stats.hp += spob->duration + |
657 | tmp->stats.hp += spob->duration + |
658 | SP_level_duration_adjust(caster,spob); |
658 | SP_level_duration_adjust(caster,spob); |
659 | if (!spob->stats.dam) |
659 | if (!spob->stats.dam) |
660 | tmp->stats.dam += SP_level_dam_adjust(caster,spob); |
660 | tmp->stats.dam += SP_level_dam_adjust(caster,spob); |
661 | else |
661 | else |
662 | tmp->stats.dam= spob->stats.dam + |
662 | tmp->stats.dam= spob->stats.dam + |
663 | SP_level_dam_adjust(caster,spob); |
663 | SP_level_dam_adjust(caster,spob); |
664 | tmp->speed += .02 * SP_level_range_adjust(caster,spob); |
664 | tmp->speed += .02 * SP_level_range_adjust(caster,spob); |
665 | tmp->speed = MIN(tmp->speed, 1.0); |
665 | tmp->speed = MIN(tmp->speed, 1.0); |
666 | if (spob->attacktype) tmp->attacktype = spob->attacktype; |
666 | if (spob->attacktype) tmp->attacktype = spob->attacktype; |
667 | } |
667 | } |
668 | tmp->stats.wc -= SP_level_range_adjust(caster,spob); |
668 | tmp->stats.wc -= SP_level_range_adjust(caster,spob); |
669 | |
669 | |
670 | /* limit the speed to 0.3 for non-players, 1 for players. */ |
670 | /* limit the speed to 0.3 for non-players, 1 for players. */ |
671 | |
671 | |
672 | /* make experience increase in proportion to the strength. |
672 | /* make experience increase in proportion to the strength. |
673 | * this is a bit simplistic - we are basically just looking at how |
673 | * this is a bit simplistic - we are basically just looking at how |
674 | * often the sp doubles and use that as the ratio. |
674 | * often the sp doubles and use that as the ratio. |
675 | */ |
675 | */ |
676 | tmp->stats.exp *= 1 + (MAX(spob->stats.maxgrace, spob->stats.sp) / |
676 | tmp->stats.exp *= 1 + (MAX(spob->stats.maxgrace, spob->stats.sp) / |
677 | caster_level(caster, spob)); |
677 | caster_level(caster, spob)); |
678 | tmp->speed_left= 0; |
678 | tmp->speed_left= 0; |
679 | tmp->direction=dir; |
679 | tmp->direction=dir; |
680 | |
680 | |
681 | /* Holy spell - some additional tailoring */ |
681 | /* Holy spell - some additional tailoring */ |
682 | if (god) { |
682 | if (god) { |
683 | object *tmp2; |
683 | object *tmp2; |
684 | |
684 | |
685 | sprintf(buf,"%s of %s",spob->name,god->name); |
685 | sprintf(buf,"%s of %s",spob->name,god->name); |
686 | buf[0] = toupper(buf[0]); |
686 | buf[0] = toupper(buf[0]); |
687 | for (tmp2=tmp; tmp2; tmp2=tmp2->more) { |
687 | for (tmp2=tmp; tmp2; tmp2=tmp2->more) { |
688 | if (tmp2->name) free_string(tmp2->name); |
688 | if (tmp2->name) free_string(tmp2->name); |
689 | tmp2->name = add_string(buf); |
689 | tmp2->name = add_string(buf); |
690 | } |
690 | } |
691 | tmp->attacktype |= god->attacktype; |
691 | tmp->attacktype |= god->attacktype; |
692 | memcpy(tmp->resist, god->resist, sizeof(tmp->resist)); |
692 | memcpy(tmp->resist, god->resist, sizeof(tmp->resist)); |
693 | if (tmp->race) FREE_AND_CLEAR_STR(tmp->race); |
693 | if (tmp->race) FREE_AND_CLEAR_STR(tmp->race); |
694 | if (god->race) tmp->race = add_string(god->race); |
694 | if (god->race) tmp->race = add_string(god->race); |
695 | if (tmp->slaying) FREE_AND_CLEAR_STR(tmp->slaying); |
695 | if (tmp->slaying) FREE_AND_CLEAR_STR(tmp->slaying); |
696 | if (god->slaying) tmp->slaying = add_string(god->slaying); |
696 | if (god->slaying) tmp->slaying = add_string(god->slaying); |
697 | /* safety, we must allow a god's servants some reasonable attack */ |
697 | /* safety, we must allow a god's servants some reasonable attack */ |
698 | if(!(tmp->attacktype&AT_PHYSICAL)) tmp->attacktype|=AT_PHYSICAL; |
698 | if(!(tmp->attacktype&AT_PHYSICAL)) tmp->attacktype|=AT_PHYSICAL; |
699 | } |
699 | } |
700 | |
700 | |
701 | insert_ob_in_map(tmp,tmp->map,op,0); |
701 | insert_ob_in_map(tmp,tmp->map,op,0); |
702 | return 1; |
702 | return 1; |
703 | } |
703 | } |
… | |
… | |
726 | /* Determine the number of races available */ |
726 | /* Determine the number of races available */ |
727 | racenr=0; |
727 | racenr=0; |
728 | strcpy(buf,god->race); |
728 | strcpy(buf,god->race); |
729 | race = strtok(buf,","); |
729 | race = strtok(buf,","); |
730 | while(race) { |
730 | while(race) { |
731 | racenr++; |
731 | racenr++; |
732 | race = strtok(NULL,","); |
732 | race = strtok(NULL,","); |
733 | } |
733 | } |
734 | |
734 | |
735 | /* next, randomly select a race from the aligned_races string */ |
735 | /* next, randomly select a race from the aligned_races string */ |
736 | if(racenr>1) { |
736 | if(racenr>1) { |
737 | racenr = rndm(0, racenr-1); |
737 | racenr = rndm(0, racenr-1); |
738 | strcpy(buf,god->race); |
738 | strcpy(buf,god->race); |
739 | race = strtok(buf,","); |
739 | race = strtok(buf,","); |
740 | for(i=0;i<racenr;i++) |
740 | for(i=0;i<racenr;i++) |
741 | race = strtok(NULL,","); |
741 | race = strtok(NULL,","); |
742 | } else |
742 | } else |
743 | race = god->race; |
743 | race = god->race; |
744 | |
744 | |
745 | |
745 | |
746 | /* see if a we can match a race list of monsters. This should not |
746 | /* see if a we can match a race list of monsters. This should not |
747 | * happen, so graceful recovery isn't really needed, but this sanity |
747 | * happen, so graceful recovery isn't really needed, but this sanity |
748 | * checking is good for cases where the god archetypes mismatch the |
748 | * checking is good for cases where the god archetypes mismatch the |
749 | * race file |
749 | * race file |
750 | */ |
750 | */ |
751 | if((list=find_racelink(race))==NULL) { |
751 | if((list=find_racelink(race))==NULL) { |
752 | new_draw_info_format(NDI_UNIQUE, 0,pl, |
752 | new_draw_info_format(NDI_UNIQUE, 0,pl, |
753 | "The spell fails! %s's creatures are beyond the range of your summons", |
753 | "The spell fails! %s's creatures are beyond the range of your summons", |
754 | god->name); |
754 | god->name); |
755 | LOG(llevDebug,"choose_cult_monster() requested non-existent aligned race!\n"); |
755 | LOG(llevDebug,"choose_cult_monster() requested non-existent aligned race!\n"); |
756 | return 0; |
756 | return 0; |
757 | } |
757 | } |
758 | |
758 | |
759 | /* search for an apprplritate monster on this race list */ |
759 | /* search for an apprplritate monster on this race list */ |
760 | mon_nr=0; |
760 | mon_nr=0; |
761 | for(tobl=list->member;tobl;tobl=tobl->next) { |
761 | for(tobl=list->member;tobl;tobl=tobl->next) { |
762 | otmp=tobl->ob; |
762 | otmp=tobl->ob; |
763 | if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; |
763 | if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; |
764 | if(otmp->level<=summon_level) mon_nr++; |
764 | if(otmp->level<=summon_level) mon_nr++; |
765 | } |
765 | } |
766 | |
766 | |
767 | /* If this god has multiple race entries, we should really choose another. |
767 | /* If this god has multiple race entries, we should really choose another. |
768 | * But then we either need to track which ones we have tried, or just |
768 | * But then we either need to track which ones we have tried, or just |
769 | * make so many calls to this function, and if we get so many without |
769 | * make so many calls to this function, and if we get so many without |
… | |
… | |
771 | */ |
771 | */ |
772 | if (!mon_nr) return NULL; |
772 | if (!mon_nr) return NULL; |
773 | |
773 | |
774 | mon_nr = rndm(0, mon_nr-1); |
774 | mon_nr = rndm(0, mon_nr-1); |
775 | for(tobl=list->member;tobl;tobl=tobl->next) { |
775 | for(tobl=list->member;tobl;tobl=tobl->next) { |
776 | otmp=tobl->ob; |
776 | otmp=tobl->ob; |
777 | if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; |
777 | if(!otmp||!QUERY_FLAG(otmp,FLAG_MONSTER)) continue; |
778 | if(otmp->level<=summon_level && !mon_nr--) return otmp; |
778 | if(otmp->level<=summon_level && !mon_nr--) return otmp; |
779 | } |
779 | } |
780 | /* This should not happen */ |
780 | /* This should not happen */ |
781 | LOG(llevDebug,"choose_cult_monster() mon_nr was set, but did not find a monster\n"); |
781 | LOG(llevDebug,"choose_cult_monster() mon_nr was set, but did not find a monster\n"); |
782 | return NULL; |
782 | return NULL; |
783 | } |
783 | } |
… | |
… | |
789 | sint16 x,y, nrof=1, i; |
789 | sint16 x,y, nrof=1, i; |
790 | archetype *summon_arch; |
790 | archetype *summon_arch; |
791 | int ndir; |
791 | int ndir; |
792 | |
792 | |
793 | if (spell_ob->other_arch) { |
793 | if (spell_ob->other_arch) { |
794 | summon_arch = spell_ob->other_arch; |
794 | summon_arch = spell_ob->other_arch; |
795 | } else if (spell_ob->randomitems) { |
795 | } else if (spell_ob->randomitems) { |
796 | int level = caster_level(caster, spell_ob); |
796 | int level = caster_level(caster, spell_ob); |
797 | treasure *tr, *lasttr=NULL;; |
797 | treasure *tr, *lasttr=NULL;; |
798 | |
798 | |
799 | /* In old code, this was a very convuluted for statement, |
799 | /* In old code, this was a very convuluted for statement, |
800 | * with all the checks in the 'for' portion itself. Much |
800 | * with all the checks in the 'for' portion itself. Much |
801 | * more readable to break some of the conditions out. |
801 | * more readable to break some of the conditions out. |
802 | */ |
802 | */ |
803 | for (tr=spell_ob->randomitems->items; tr; tr=tr->next) { |
803 | for (tr=spell_ob->randomitems->items; tr; tr=tr->next) { |
804 | if (level < tr->magic) break; |
804 | if (level < tr->magic) break; |
805 | lasttr = tr; |
805 | lasttr = tr; |
806 | if(stringarg && !strcmp(tr->item->name,stringarg)) break; |
806 | if(stringarg && !strcmp(tr->item->name,stringarg)) break; |
807 | if (tr->next == NULL || tr->next->item == NULL) break; |
807 | if (tr->next == NULL || tr->next->item == NULL) break; |
808 | } |
808 | } |
809 | if (!lasttr) { |
809 | if (!lasttr) { |
810 | LOG(llevError,"Treasurelist %s did not generate a valid entry in summon_object\n", |
810 | LOG(llevError,"Treasurelist %s did not generate a valid entry in summon_object\n", |
811 | spell_ob->randomitems->name); |
811 | spell_ob->randomitems->name); |
812 | new_draw_info(NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); |
812 | new_draw_info(NDI_UNIQUE, 0, op, "The spell fails to summon any monsters."); |
813 | return 0; |
813 | return 0; |
814 | } |
814 | } |
815 | summon_arch = lasttr->item; |
815 | summon_arch = lasttr->item; |
816 | nrof = lasttr->nrof; |
816 | nrof = lasttr->nrof; |
817 | |
817 | |
818 | } else if (spell_ob->race && !strcmp(spell_ob->race,"GODCULTMON")) { |
818 | } else if (spell_ob->race && !strcmp(spell_ob->race,"GODCULTMON")) { |
819 | object *god=find_god(determine_god(op)), *mon, *owner; |
819 | object *god=find_god(determine_god(op)), *mon, *owner; |
820 | int summon_level, tries; |
820 | int summon_level, tries; |
821 | |
821 | |
822 | if (!god && ((owner=get_owner(op))!=NULL)) { |
822 | if (!god && ((owner=get_owner(op))!=NULL)) { |
823 | god = find_god(determine_god(owner)); |
823 | god = find_god(determine_god(owner)); |
824 | } |
824 | } |
825 | /* If we can't find a god, can't get what monster to summon */ |
825 | /* If we can't find a god, can't get what monster to summon */ |
826 | if (!god) return 0; |
826 | if (!god) return 0; |
827 | |
827 | |
828 | if (!god->race) { |
828 | if (!god->race) { |
829 | new_draw_info_format(NDI_UNIQUE, 0,op, |
829 | new_draw_info_format(NDI_UNIQUE, 0,op, |
830 | "%s has no creatures that you may summon!",god->name); |
830 | "%s has no creatures that you may summon!",god->name); |
831 | return 0; |
831 | return 0; |
832 | } |
832 | } |
833 | /* the summon level */ |
833 | /* the summon level */ |
834 | summon_level=caster_level(caster, spell_ob); |
834 | summon_level=caster_level(caster, spell_ob); |
835 | if (summon_level==0) summon_level=1; |
835 | if (summon_level==0) summon_level=1; |
836 | tries = 0; |
836 | tries = 0; |
837 | do { |
837 | do { |
838 | mon = choose_cult_monster(op, god,summon_level); |
838 | mon = choose_cult_monster(op, god,summon_level); |
839 | if (!mon) { |
839 | if (!mon) { |
840 | new_draw_info_format(NDI_UNIQUE, 0,op, |
840 | new_draw_info_format(NDI_UNIQUE, 0,op, |
841 | "%s fails to send anything.",god->name); |
841 | "%s fails to send anything.",god->name); |
842 | return 0; |
842 | return 0; |
843 | } |
843 | } |
844 | ndir = dir; |
844 | ndir = dir; |
845 | if (!ndir) |
845 | if (!ndir) |
846 | ndir = find_free_spot(mon, op->map, op->x, op->y, 1, SIZEOFFREE); |
846 | ndir = find_free_spot(mon, op->map, op->x, op->y, 1, SIZEOFFREE); |
847 | if (ndir == -1 || ob_blocked(mon,op->map, op->x + freearr_x[ndir], op->y+freearr_y[ndir])) { |
847 | if (ndir == -1 || ob_blocked(mon,op->map, op->x + freearr_x[ndir], op->y+freearr_y[ndir])) { |
848 | ndir=-1; |
848 | ndir=-1; |
849 | if (++tries == 5) { |
849 | if (++tries == 5) { |
850 | new_draw_info(NDI_UNIQUE, 0,op, "There is something in the way."); |
850 | new_draw_info(NDI_UNIQUE, 0,op, "There is something in the way."); |
851 | return 0; |
851 | return 0; |
852 | } |
852 | } |
853 | } |
853 | } |
854 | } while (ndir == -1); |
854 | } while (ndir == -1); |
855 | if (mon->level > (summon_level/2)) |
855 | if (mon->level > (summon_level/2)) |
856 | nrof = random_roll(1, 2, op, PREFER_HIGH); |
856 | nrof = random_roll(1, 2, op, PREFER_HIGH); |
857 | else |
857 | else |
858 | nrof = die_roll(2, 2, op, PREFER_HIGH); |
858 | nrof = die_roll(2, 2, op, PREFER_HIGH); |
859 | summon_arch = mon->arch; |
859 | summon_arch = mon->arch; |
860 | } else { |
860 | } else { |
861 | summon_arch = NULL; |
861 | summon_arch = NULL; |
862 | } |
862 | } |
863 | |
863 | |
864 | if (spell_ob->stats.dam) |
864 | if (spell_ob->stats.dam) |
865 | nrof += spell_ob->stats.dam + SP_level_dam_adjust(caster, spell_ob); |
865 | nrof += spell_ob->stats.dam + SP_level_dam_adjust(caster, spell_ob); |
866 | |
866 | |
867 | if (!summon_arch) { |
867 | if (!summon_arch) { |
868 | new_draw_info(NDI_UNIQUE, 0, op, "There is no monsters available for summoning."); |
868 | new_draw_info(NDI_UNIQUE, 0, op, "There is no monsters available for summoning."); |
869 | return 0; |
869 | return 0; |
870 | } |
870 | } |
871 | |
871 | |
872 | for (i=1; i <= nrof; i++) { |
872 | for (i=1; i <= nrof; i++) { |
873 | archetype *atmp; |
873 | archetype *atmp; |
874 | object *prev=NULL, *head=NULL, *tmp; |
874 | object *prev=NULL, *head=NULL, *tmp; |
875 | |
875 | |
876 | if (dir) { |
876 | if (dir) { |
877 | ndir = dir; |
877 | ndir = dir; |
878 | dir = absdir (dir+1); |
878 | dir = absdir (dir+1); |
879 | } else |
879 | } else |
… | |
… | |
885 | } |
885 | } |
886 | |
886 | |
887 | if (ndir == -1 || ob_blocked(&summon_arch->clone, op->map, op->x + x, op->y + y)){ |
887 | if (ndir == -1 || ob_blocked(&summon_arch->clone, op->map, op->x + x, op->y + y)){ |
888 | new_draw_info(NDI_UNIQUE, 0, op, "There is something in the way."); |
888 | new_draw_info(NDI_UNIQUE, 0, op, "There is something in the way."); |
889 | if (nrof > 1) |
889 | if (nrof > 1) |
890 | new_draw_info(NDI_UNIQUE, 0,op, "No more pets for this casting."); |
890 | new_draw_info(NDI_UNIQUE, 0,op, "No more pets for this casting."); |
891 | |
891 | |
892 | return nrof > 1; |
892 | return nrof > 1; |
893 | } |
893 | } |
894 | |
894 | |
895 | for (atmp = summon_arch; atmp!=NULL; atmp=atmp->more) { |
895 | for (atmp = summon_arch; atmp!=NULL; atmp=atmp->more) { |
896 | tmp = arch_to_object(atmp); |
896 | tmp = arch_to_object(atmp); |
897 | if (atmp == summon_arch) { |
897 | if (atmp == summon_arch) { |
898 | if (QUERY_FLAG(tmp, FLAG_MONSTER)) { |
898 | if (QUERY_FLAG(tmp, FLAG_MONSTER)) { |
899 | set_owner(tmp, op); |
899 | set_owner(tmp, op); |
900 | set_spell_skill(op, caster, spell_ob, tmp); |
900 | set_spell_skill(op, caster, spell_ob, tmp); |
901 | tmp->enemy = op->enemy; |
901 | tmp->enemy = op->enemy; |
902 | tmp->type = 0; |
902 | tmp->type = 0; |
903 | CLEAR_FLAG(tmp, FLAG_SLEEP); |
903 | CLEAR_FLAG(tmp, FLAG_SLEEP); |
904 | if (op->type == PLAYER || QUERY_FLAG(op, FLAG_FRIENDLY)) { |
904 | if (op->type == PLAYER || QUERY_FLAG(op, FLAG_FRIENDLY)) { |
905 | /* If this is not set, we make it friendly */ |
905 | /* If this is not set, we make it friendly */ |
906 | if (!QUERY_FLAG(spell_ob, FLAG_MONSTER)) { |
906 | if (!QUERY_FLAG(spell_ob, FLAG_MONSTER)) { |
907 | SET_FLAG(tmp, FLAG_FRIENDLY); |
907 | SET_FLAG(tmp, FLAG_FRIENDLY); |
908 | add_friendly_object(tmp); |
908 | add_friendly_object(tmp); |
909 | tmp->stats.exp = 0; |
909 | tmp->stats.exp = 0; |
910 | if (spell_ob->attack_movement) |
910 | if (spell_ob->attack_movement) |
911 | tmp->attack_movement = spell_ob->attack_movement; |
911 | tmp->attack_movement = spell_ob->attack_movement; |
912 | if (get_owner(op)) |
912 | if (get_owner(op)) |
913 | set_owner(tmp, get_owner(op)); |
913 | set_owner(tmp, get_owner(op)); |
914 | } |
914 | } |
915 | } |
915 | } |
916 | } |
916 | } |
917 | if (tmp->speed > MIN_ACTIVE_SPEED) tmp->speed_left = -1; |
917 | if (tmp->speed > MIN_ACTIVE_SPEED) tmp->speed_left = -1; |
918 | } |
918 | } |
919 | if (head == NULL) head = tmp; |
919 | if (head == NULL) head = tmp; |
920 | else { |
920 | else { |
921 | tmp->head = head; |
921 | tmp->head = head; |
922 | prev->more = tmp; |
922 | prev->more = tmp; |
923 | } |
923 | } |
924 | prev = tmp; |
924 | prev = tmp; |
925 | tmp->x = op->x + x + tmp->arch->clone.x; |
925 | tmp->x = op->x + x + tmp->arch->clone.x; |
926 | tmp->y = op->y + y + tmp->arch->clone.y; |
926 | tmp->y = op->y + y + tmp->arch->clone.y; |
927 | tmp->map = op->map; |
927 | tmp->map = op->map; |
928 | } |
928 | } |
929 | head->direction = freedir[ndir]; |
929 | head->direction = freedir[ndir]; |
930 | head->stats.exp = 0; |
930 | head->stats.exp = 0; |
931 | head = insert_ob_in_map(head, head->map, op, 0); |
931 | head = insert_ob_in_map(head, head->map, op, 0); |
932 | if (head && head->randomitems) { |
932 | if (head && head->randomitems) { |
933 | object *tmp; |
933 | object *tmp; |
934 | create_treasure(head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0); |
934 | create_treasure(head->randomitems, head, GT_APPLY | GT_STARTEQUIP, 6, 0); |
935 | for (tmp=head->inv; tmp; tmp=tmp->below) |
935 | for (tmp=head->inv; tmp; tmp=tmp->below) |
936 | if (!tmp->nrof) SET_FLAG(tmp, FLAG_NO_DROP); |
936 | if (!tmp->nrof) SET_FLAG(tmp, FLAG_NO_DROP); |
937 | } |
937 | } |
938 | } /* for i < nrof */ |
938 | } /* for i < nrof */ |
939 | return 1; |
939 | return 1; |
940 | } |
940 | } |
941 | |
941 | |
942 | /* recursively look through the owner property of objects until the real owner |
942 | /* recursively look through the owner property of objects until the real owner |
943 | is found */ |
943 | is found */ |
944 | object *get_real_owner(object *ob) { |
944 | object *get_real_owner(object *ob) { |
945 | object *realowner = ob; |
945 | object *realowner = ob; |
946 | |
946 | |
947 | if (realowner == NULL) return NULL; |
947 | if (realowner == NULL) return NULL; |
948 | |
948 | |
949 | while(get_owner(realowner) != NULL) |
949 | while(get_owner(realowner) != NULL) |
950 | { |
950 | { |
951 | realowner = get_owner(realowner); |
951 | realowner = get_owner(realowner); |
952 | } |
952 | } |
953 | return realowner; |
953 | return realowner; |
954 | } |
954 | } |
955 | |
955 | |
956 | /* determines if checks so pets don't attack players or other pets should be |
956 | /* determines if checks so pets don't attack players or other pets should be |
957 | overruled by the arena petmode */ |
957 | overruled by the arena petmode */ |
958 | int should_arena_attack(object *pet,object *owner,object *target) { |
958 | int should_arena_attack(object *pet,object *owner,object *target) { |
959 | object *rowner, *towner; |
959 | object *rowner, *towner; |
960 | |
960 | |
961 | /* exit if the target, pet, or owner is null. */ |
961 | /* exit if the target, pet, or owner is null. */ |
962 | if ((target == NULL) || (pet == NULL) || (owner == NULL)) return 0; |
962 | if ((target == NULL) || (pet == NULL) || (owner == NULL)) return 0; |
963 | |
963 | |
964 | /* get the owners of itself and the target, this is to deal with pets of |
964 | /* get the owners of itself and the target, this is to deal with pets of |
965 | pets */ |
965 | pets */ |
966 | rowner = get_real_owner(owner); |
966 | rowner = get_real_owner(owner); |
967 | if (target->type != PLAYER) { |
967 | if (target->type != PLAYER) { |
968 | towner = get_real_owner(target); |
968 | towner = get_real_owner(target); |
969 | } else { |
969 | } else { |
970 | towner = 0; |
970 | towner = 0; |
971 | } |
971 | } |
972 | |
972 | |
973 | /* if the pet has now owner, exit with error */ |
973 | /* if the pet has now owner, exit with error */ |
974 | if (rowner == NULL) { |
974 | if (rowner == NULL) { |
975 | LOG(llevError,"Pet has no owner.\n"); |
975 | LOG(llevError,"Pet has no owner.\n"); |
976 | return 0; |
976 | return 0; |
977 | } |
977 | } |
978 | |
978 | |
979 | /* if the target is not a player, and has no owner, we shouldn't be here |
979 | /* if the target is not a player, and has no owner, we shouldn't be here |
980 | */ |
980 | */ |
981 | if ((towner == NULL) && (target->type != PLAYER)) { |
981 | if ((towner == NULL) && (target->type != PLAYER)) { |
982 | LOG(llevError,"Target is not a player but has no owner. We should not be here.\n"); |
982 | LOG(llevError,"Target is not a player but has no owner. We should not be here.\n"); |
983 | return 0; |
983 | return 0; |
984 | } |
984 | } |
985 | |
985 | |
986 | /* make sure that the owner is a player */ |
986 | /* make sure that the owner is a player */ |
987 | if (rowner->type != PLAYER) return 0; |
987 | if (rowner->type != PLAYER) return 0; |
988 | |
988 | |
989 | /* abort if the petmode is not arena */ |
989 | /* abort if the petmode is not arena */ |
990 | if (rowner->contr->petmode != pet_arena) return 0; |
990 | if (rowner->contr->petmode != pet_arena) return 0; |
991 | |
991 | |
992 | /* abort if the pet, it's owner, or the target is not on battleground*/ |
992 | /* abort if the pet, it's owner, or the target is not on battleground*/ |
993 | if (!(op_on_battleground(pet, NULL, NULL) && |
993 | if (!(op_on_battleground(pet, NULL, NULL) && |
994 | op_on_battleground(owner, NULL, NULL) && |
994 | op_on_battleground(owner, NULL, NULL) && |
995 | op_on_battleground(target, NULL, NULL))) |
995 | op_on_battleground(target, NULL, NULL))) |
996 | return 0; |
996 | return 0; |
997 | |
997 | |
998 | /* if the target is a monster, make sure it's owner is not the same */ |
998 | /* if the target is a monster, make sure it's owner is not the same */ |
999 | if ((target->type != PLAYER) && (rowner == towner)) return 0; |
999 | if ((target->type != PLAYER) && (rowner == towner)) return 0; |
1000 | |
1000 | |
1001 | /* check if the target is a player which affects how it will handle |
1001 | /* check if the target is a player which affects how it will handle |
1002 | parties */ |
1002 | parties */ |
1003 | if (target->type != PLAYER) { |
1003 | if (target->type != PLAYER) { |
1004 | /* if the target is owned by a player make sure than make sure |
1004 | /* if the target is owned by a player make sure than make sure |
1005 | it's not in the same party */ |
1005 | it's not in the same party */ |
1006 | if ((towner->type == PLAYER) && (rowner->contr->party != NULL)) { |
1006 | if ((towner->type == PLAYER) && (rowner->contr->party != NULL)) { |
1007 | if (rowner->contr->party == towner->contr->party) return 0; |
1007 | if (rowner->contr->party == towner->contr->party) return 0; |
1008 | } |
1008 | } |
1009 | } else { |
1009 | } else { |
1010 | /* if the target is a player make sure than make sure it's not |
1010 | /* if the target is a player make sure than make sure it's not |
1011 | in the same party */ |
1011 | in the same party */ |
1012 | if (rowner->contr->party != NULL){ |
1012 | if (rowner->contr->party != NULL){ |
1013 | if (rowner->contr->party == target->contr->party) return 0; |
1013 | if (rowner->contr->party == target->contr->party) return 0; |
1014 | } |
1014 | } |
1015 | } |
1015 | } |
1016 | |
1016 | |
1017 | return 1; |
1017 | return 1; |
1018 | } |
1018 | } |