version 1.142 | | version 1.143 |
---|
| | |
/* | | /* |
* static char *rcsid_apply_c = | | * static char *rcsid_apply_c = |
* "$Id: apply.c,v 1.142 2005/10/07 19:38:49 akirschbaum Exp $"; | | * "$Id: apply.c,v 1.143 2005/10/08 09:56:43 ryo_saeba Exp $"; |
*/ | | */ |
/* | | /* |
CrossFire, A Multiplayer game for X-windows | | CrossFire, A Multiplayer game for X-windows |
| | |
return 0; | | return 0; |
} | | } |
| | |
case GPS: | | |
apply_positioning_system( op, tmp ); | | |
return 1; | | |
| | |
case ITEM_TRANSFORMER: | | case ITEM_TRANSFORMER: |
apply_item_transformer( op, tmp ); | | apply_item_transformer( op, tmp ); |
return 1; | | return 1; |
| | |
} | | } |
| | |
/** | | /** |
* This handles the positioning system. | | |
* Useful to know a player's position. | | |
* If item is also marked, then will reset the origin. | | |
* If gps's food is 0, not yet reset -> can't use. | | |
* Origin's x & y are stored in hp/sp. | | |
* Can only be used on 'world_xxx_xxx' maps. | | |
*/ | | |
void apply_positioning_system( object* pl, object* gps ) | | |
{ | | |
int x, y; | | |
int reset; | | |
int map_x, map_y; | | |
| | |
if ( !pl->type == PLAYER ) | | |
/* Non players have no need for that */ | | |
return; | | |
| | |
reset = 0; | | |
if ( find_marked_object( pl ) == gps ) | | |
reset = 1; | | |
| | |
if ( gps->stats.food == 0 && !reset ) | | |
{ | | |
new_draw_info( NDI_UNIQUE, 0, pl, "You must fix the origin of the positioning system first!" ); | | |
return; | | |
} | | |
| | |
if ( !pl->map || !pl->map->name ) | | |
{ | | |
new_draw_info( NDI_UNIQUE, 0, pl, "This is a too weird place to try to position yourself." ); | | |
return; | | |
} | | |
| | |
/* Check map is a world one */ | | |
if ( sscanf( pl->map->name, "world_%d_%d", &map_x, &map_y ) != 2 ) | | |
{ | | |
new_draw_info( NDI_UNIQUE, 0, pl, "You must be in the world to position yourself." ); | | |
return; | | |
} | | |
| | |
/* Now compute actual position */ | | |
map_x -= 99; | | |
map_y -= 99; | | |
x = map_x * settings.worldmaptilesizex + pl->x; | | |
y = map_y * settings.worldmaptilesizey + pl->y; | | |
| | |
if ( reset ) | | |
{ | | |
gps->stats.hp = x; | | |
gps->stats.sp = y; | | |
gps->stats.food = 1; | | |
new_draw_info( NDI_UNIQUE, 0, pl, "You reset the origin of the system." ); | | |
return; | | |
} | | |
| | |
x -= gps->stats.hp; | | |
y -= gps->stats.sp; | | |
| | |
/* Display location */ | | |
new_draw_info_format( NDI_UNIQUE, 0, pl, "You are at %d:%d.", x, y ); | | |
} | | |
| | |
/** | | |
* This handles items of type 'transformer'. | | * This handles items of type 'transformer'. |
* Basically those items, used with a marked item, transform both items into something | | * Basically those items, used with a marked item, transform both items into something |
* else. | | * else. |