ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.161 by root, Thu Aug 23 15:20:33 2007 UTC vs.
Revision 1.162 by root, Thu Aug 23 17:13:04 2007 UTC

3166 * object op. This function works fine for monsters, 3166 * object op. This function works fine for monsters,
3167 * but we dont worry if the object isnt the top one in 3167 * but we dont worry if the object isnt the top one in
3168 * a pile (say a coin under a table would return "viewable" 3168 * a pile (say a coin under a table would return "viewable"
3169 * by this routine). Another question, should we be 3169 * by this routine). Another question, should we be
3170 * concerned with the direction the player is looking 3170 * concerned with the direction the player is looking
3171 * in? Realistically, most of use cant see stuff behind 3171 * in? Realistically, most of us can't see stuff behind
3172 * our backs...on the other hand, does the "facing" direction 3172 * our backs...on the other hand, does the "facing" direction
3173 * imply the way your head, or body is facing? Its possible 3173 * imply the way your head, or body is facing? It's possible
3174 * for them to differ. Sigh, this fctn could get a bit more complex. 3174 * for them to differ. Sigh, this fctn could get a bit more complex.
3175 * -b.t. 3175 * -b.t.
3176 * This function is now map tiling safe. 3176 * This function is now map tiling safe.
3177 */ 3177 */
3178
3179int 3178int
3180player_can_view (object *pl, object *op) 3179player_can_view (object *pl, object *op)
3181{ 3180{
3182 rv_vector rv; 3181 rv_vector rv;
3183 int dx, dy; 3182 int dx, dy;
3195 3194
3196 get_rangevector (pl, op, &rv, 0x1); 3195 get_rangevector (pl, op, &rv, 0x1);
3197 3196
3198 /* starting with the 'head' part, lets loop 3197 /* starting with the 'head' part, lets loop
3199 * through the object and find if it has any 3198 * through the object and find if it has any
3200 * part that is in the los array but isnt on 3199 * part that is in the los array but isn't on
3201 * a blocked los square. 3200 * a blocked los square.
3202 * we use the archetype to figure out offsets. 3201 * we use the archetype to figure out offsets.
3203 */ 3202 */
3204 while (op) 3203 while (op)
3205 { 3204 {
3208 3207
3209 /* only the viewable area the player sees is updated by LOS 3208 /* only the viewable area the player sees is updated by LOS
3210 * code, so we need to restrict ourselves to that range of values 3209 * code, so we need to restrict ourselves to that range of values
3211 * for any meaningful values. 3210 * for any meaningful values.
3212 */ 3211 */
3213 if (FABS (dx) <= (pl->contr->ns->mapx / 2) && 3212 if (abs (dx) <= (pl->contr->ns->mapx / 2) &&
3214 FABS (dy) <= (pl->contr->ns->mapy / 2) && 3213 abs (dy) <= (pl->contr->ns->mapy / 2) &&
3215 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)]) 3214 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3216 return 1; 3215 return 1;
3216
3217 op = op->more; 3217 op = op->more;
3218 } 3218 }
3219
3219 return 0; 3220 return 0;
3220} 3221}
3221 3222
3222/* routine for both players and monsters. We call this when 3223/* routine for both players and monsters. We call this when
3223 * there is a possibility for our action distrubing our hiding 3224 * there is a possibility for our action distrubing our hiding
3226 * return 0. 3227 * return 0.
3227 */ 3228 */
3228int 3229int
3229action_makes_visible (object *op) 3230action_makes_visible (object *op)
3230{ 3231{
3231
3232 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE)) 3232 if (op->invisible && QUERY_FLAG (op, FLAG_ALIVE))
3233 { 3233 {
3234 if (QUERY_FLAG (op, FLAG_MAKE_INVIS)) 3234 if (QUERY_FLAG (op, FLAG_MAKE_INVIS))
3235 return 0; 3235 return 0;
3236 3236
3242 { 3242 {
3243 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible"); 3243 new_draw_info_format (NDI_UNIQUE, 0, op, "You become %s!", op->hide ? "unhidden" : "visible");
3244 return 1; 3244 return 1;
3245 } 3245 }
3246 } 3246 }
3247
3247 return 0; 3248 return 0;
3248} 3249}
3249 3250
3250/* op_on_battleground - checks if the given object op (usually 3251/* op_on_battleground - checks if the given object op (usually
3251 * a player) is standing on a valid battleground-tile, 3252 * a player) is standing on a valid battleground-tile,
3256 * Default is to do the same as before, so only people wanting to have different points need worry about this 3257 * Default is to do the same as before, so only people wanting to have different points need worry about this
3257 */ 3258 */
3258int 3259int
3259op_on_battleground (object *op, int *x, int *y) 3260op_on_battleground (object *op, int *x, int *y)
3260{ 3261{
3261 object *tmp;
3262
3263 /* A battleground-tile needs the following attributes to be valid: 3262 /* A battleground-tile needs the following attributes to be valid:
3264 * is_floor 1 (has to be the FIRST floor beneath the player's feet), 3263 * is_floor 1 (has to be the FIRST floor beneath the player's feet),
3265 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND) 3264 * name="battleground", no_pick 1, type=58 (type BATTLEGROUND)
3266 * and the exit-coordinates sp/hp must both be > 0. 3265 * and the exit-coordinates sp/hp must both be > 0.
3267 * => The intention here is to prevent abuse of the battleground- 3266 * => The intention here is to prevent abuse of the battleground-
3268 * feature (like pickable or hidden battleground tiles). */ 3267 * feature (like pickable or hidden battleground tiles). */
3269 for (tmp = op->below; tmp != NULL; tmp = tmp->below) 3268 for (object *tmp = op->below; tmp; tmp = tmp->below)
3270 { 3269 {
3271 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 3270 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
3272 { 3271 {
3273 if (QUERY_FLAG (tmp, FLAG_NO_PICK) && 3272 if (QUERY_FLAG (tmp, FLAG_NO_PICK)
3274 strcmp (tmp->name, "battleground") == 0 && tmp->type == BATTLEGROUND && EXIT_X (tmp) && EXIT_Y (tmp)) 3273 && tmp->type == BATTLEGROUND
3274 && tmp->name == shstr_battleground
3275 && EXIT_X (tmp) && EXIT_Y (tmp))
3275 { 3276 {
3276 /*before we assign the exit, check if this is a teambattle */ 3277 /* before we assign the exit, check if this is a teambattle */
3277 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp)) 3278 if (EXIT_ALT_X (tmp) && EXIT_ALT_Y (tmp) && EXIT_PATH (tmp))
3278 { 3279 {
3279 object *invtmp;
3280
3281 for (invtmp = op->inv; invtmp != NULL; invtmp = invtmp->below) 3280 for (object *invtmp = op->inv; invtmp; invtmp = invtmp->below)
3282 { 3281 {
3283 if (invtmp->type == FORCE && invtmp->slaying && !strcmp (EXIT_PATH (tmp), invtmp->slaying)) 3282 if (invtmp->type == FORCE && invtmp->slaying && tmp->slaying == invtmp->slaying)
3284 { 3283 {
3285 if (x != NULL && y != NULL) 3284 if (x && y)
3286 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp); 3285 *x = EXIT_ALT_X (tmp), *y = EXIT_ALT_Y (tmp);
3286
3287 return 1; 3287 return 1;
3288 } 3288 }
3289 } 3289 }
3290 } 3290 }
3291
3291 if (x != NULL && y != NULL) 3292 if (x && y)
3292 *x = EXIT_X (tmp), *y = EXIT_Y (tmp); 3293 *x = EXIT_X (tmp), *y = EXIT_Y (tmp);
3294
3293 return 1; 3295 return 1;
3294 } 3296 }
3295 } 3297 }
3296 } 3298 }
3299
3297 /* If we got here, did not find a battleground */ 3300 /* If we got here, did not find a battleground */
3298 return 0; 3301 return 0;
3299} 3302}
3300 3303
3301/* 3304/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines