StoneAge/gmsv/map/map_deal.c

319 lines
9.1 KiB
C
Raw Normal View History

2018-08-07 15:51:35 +08:00
#include "version.h"
#include "common.h"
#include "readmap.h"
#include "char.h"
#include "map_util.h"
#include "lssproto_serv.h"
#include "net.h"
#include "anim_tbl.h"
/*#define MAPEDITORTROUBLE*/
#define SPR_kmydamY CG_HIT_MARK_10 // anim_tbl.h <20><><EFBFBD><EFBFBD> <20><>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD>ƥ <20><><EFBFBD>ް<EFBFBD><DEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/*------------------------------------------------------------
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ӭ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>ƽ<EFBFBD>ҷ»<EFBFBD> <EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¦<EFBFBD>ѻ<EFBFBD>ؤ<EFBFBD>£<EFBFBD>
* ¦<EFBFBD><EFBFBD>
* ff int floor
* fx int x<EFBFBD><EFBFBD>
* fy int y<EFBFBD><EFBFBD>
* isfly int <EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE(1)
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD> FALSE(0)
------------------------------------------------------------*/
BOOL MAP_walkAbleFromPoint( int ff, int fx, int fy, BOOL isfly )
{
int map[2];
if( !MAP_getTileAndObjData( ff,fx,fy, &map[0], &map[1] ) ){
return FALSE;
}
if( isfly ){
int i;
for( i = 0 ; i < 2 ; i ++ )
if( MAP_getImageInt( map[i], MAP_HAVEHEIGHT ) == TRUE ){
return FALSE;
}
return TRUE;
}else{
switch( MAP_getImageInt( map[1], MAP_WALKABLE ) ){
case 0:
return FALSE;
break;
case 1:
if( MAP_getImageInt( map[0], MAP_WALKABLE ) == 1 ){
return TRUE;
}else{
return FALSE;
}
break;
case 2:
return TRUE;
break;
default:
return FALSE;
break;
}
}
return FALSE;
}
/*------------------------------------------------------------
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ӭ<EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
* ¦<EFBFBD><EFBFBD>
* index int Char ƥ<EFBFBD><EFBFBD> Index
* ff int floor id
* fx int x<EFBFBD><EFBFBD>
* fy int y<EFBFBD><EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE(1)
* <EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD> FALSE(0)
------------------------------------------------------------*/
BOOL MAP_walkAble( int index,int ff, int fx, int fy)
{
/* ƽ<>ҷ<EFBFBD>ئ<EFBFBD><D8A6>OK */
if( CHAR_getFlg( index, CHAR_ISTRANSPARENT ) ) return TRUE;
// Arminius 7.9 Airplane ok
if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE;
if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) {
int oyaindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1);
if( CHAR_CHECKINDEX( oyaindex)) {
if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE;
}
}
return MAP_walkAbleFromPoint( ff,fx,fy,CHAR_getFlg(index,CHAR_ISFLYING)|CHAR_getWorkInt(index,CHAR_WORKSKYWALKER) );
}
/*------------------------------------------------------------
* <EFBFBD><EFBFBD> ë϶<EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ؤ<EFBFBD>¾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ¦<EFBFBD><EFBFBD>
* fl int <EFBFBD>׷<EFBFBD>ʧ
* x int x <EFBFBD><EFBFBD>
* y int y <EFBFBD><EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ؤ<EFBFBD><EFBFBD> TRUE
* <EFBFBD>ν<EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD> FALSE
------------------------------------------------------------*/
BOOL MAP_haveHeight( int fl, int x, int y )
{
int map[2];
/* Ѩ<><D1A8><EFBFBD>󷸡<EFBFBD><F3B7B8A1><EFBFBD>ë <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
if( !MAP_getTileAndObjData( fl,x,y, &map[0], &map[1] ) )
return FALSE;
return MAP_getImageInt( map[1], MAP_HAVEHEIGHT );
}
/*----------------------------------------
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD> <EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ¦<EFBFBD><EFBFBD>
* index int ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* map int Ѩ<EFBFBD><EFBFBD><EFBFBD>󷸡<EFBFBD><EFBFBD><EFBFBD>
* outof BOOL <EFBFBD>׸<EFBFBD><EFBFBD>ݣ<EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>ݾ<EFBFBD> TRUE ئ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>׸<EFBFBD><EFBFBD><EFBFBD>ƥؤ<EFBFBD>£<EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE
* <EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FALSE
----------------------------------------*/
static BOOL MAP_changeCharStatusFromMapDataAndTime( int index,
int map, BOOL outof)
{
#if 0
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6>
int i;
int offset;
BOOL change=FALSE;
static struct tagStatusInteractionOfBitAndDefine{
int mapdataindex;
int charadataindex;
}statusInteraction[]={
{MAP_INTOPOISON, CHAR_POISON},
{MAP_INTOPARALYSIS, CHAR_PARALYSIS},
{MAP_INTOSILENCE, CHAR_SLEEP},
{MAP_INTOSTONE, CHAR_STONE},
{MAP_INTODARKNESS, CHAR_DRUNK},
{MAP_INTOCONFUSION, CHAR_CONFUSION},
{MAP_OUTOFPOISON, CHAR_POISON},
{MAP_OUTOFPARALYSIS, CHAR_PARALYSIS},
{MAP_OUTOFSILENCE, CHAR_SLEEP},
{MAP_OUTOFSTONE, CHAR_STONE},
{MAP_OUTOFDARKNESS, CHAR_DRUNK},
{MAP_OUTOFCONFUSION, CHAR_CONFUSION},
};
if( outof == FALSE )offset = 6;
else offset= 0;
for( i = 0 ; i < 6 ; i ++ ){
int newdata;
newdata = MAP_getImageInt(map,statusInteraction[i+offset].
mapdataindex);
if( newdata > 0 ){
change=TRUE;
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɬ<EFBFBD><C9AC> */
CHAR_setInt( index,
statusInteraction[i+offset].charadataindex,
CHAR_getInt(index,
statusInteraction[i+offset].
charadataindex ) + newdata );
}
}
return change;
#else
return FALSE;
#endif
}
/*------------------------------------------------------------
* Map <EFBFBD><EFBFBD>ì<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pre postë<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ¦<EFBFBD><EFBFBD>
* index int <EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* mode BOOL TRUE<EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><EFBFBD><EFBFBD>in FALSE<EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD> out <EFBFBD>ɱ
* ߯Ի<EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD>
------------------------------------------------------------*/
static void MAP_dealprepostevent( int index, BOOL mode )
{
int map[2];
int i;
int damaged=FALSE,statuschange=FALSE;
if( CHAR_getFlg(index,CHAR_ISFLYING) )
/* <20><>ƥ<EFBFBD><C6A5>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><E5B7B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6> */
return;
if( !MAP_getMapDataFromCharIndex( index , map ) ) return;
for( i = 0 ; i < 2 ; i ++ ){
/* damage */
int damage;
damage = MAP_getImageInt(map[i],
mode ? MAP_INTODAMAGE : MAP_OUTOFDAMAGE);
if( damage != 0 ){
/* ĸ<><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB>ƥ <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>ƥ į ľ׸<C4BE><D7B8> */
int opt[2]={SPR_kmydamY,-damage};
damaged=TRUE;
CHAR_setInt(index, CHAR_HP,
CHAR_getInt(index,CHAR_HP) + damage );
CHAR_complianceParameter(index);
/* ĸ<><C4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B0BE><EFBFBD>׾ް<D7BE><DEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
CHAR_sendWatchEvent(CHAR_getWorkInt(index,CHAR_WORKOBJINDEX),
CHAR_ACTDAMAGE,opt,2,TRUE);
}
if( MAP_changeCharStatusFromMapDataAndTime(
index,map[i], mode ? TRUE : FALSE ) )
statuschange=TRUE;
}
if( damaged ) CHAR_sendStatusString(index,"M");
if( statuschange ){
CHAR_sendCToArroundCharacter(index);
CHAR_sendStatusString(index,"P");
}
}
/*----------------------------------------
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>£۳<EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>xxx<EFBFBD>̼<EFBFBD>
* <EFBFBD><EFBFBD>ë <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>
* ¦<EFBFBD><EFBFBD>
* index int <EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* flooor int <EFBFBD>׷<EFBFBD>ʧID
* fx int x<EFBFBD><EFBFBD>
* fy int y<EFBFBD><EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* ئ<EFBFBD><EFBFBD>
----------------------------------------*/
void MAP_preovered( int index )
{
MAP_dealprepostevent( index, FALSE );
}
/*----------------------------------------
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>£<EFBFBD>
* ¦<EFBFBD><EFBFBD>
* index int <EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* ئ<EFBFBD><EFBFBD>
----------------------------------------*/
void MAP_postovered( int index )
{
MAP_dealprepostevent( index, TRUE );
}
/*----------------------------------------
* ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><EFBFBD>Ѩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>˪<EFBFBD><EFBFBD>
* ¦<EFBFBD><EFBFBD>
* fd int
* charaindex int ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> TRUE(1)
* <EFBFBD><EFBFBD> FALSE(0)
----------------------------------------*/
BOOL MAP_sendArroundCharNeedFD( int fd,int charaindex )
{
char* stringdata;
int x=CHAR_getInt(charaindex,CHAR_X);
int y=CHAR_getInt(charaindex,CHAR_Y);
int fl=CHAR_getInt(charaindex,CHAR_FLOOR);
int size=MAP_CHAR_DEFAULTSEESIZ;
RECT seekr,retr;
seekr.x = x - (int)(size/2);
seekr.y = y - (int)(size/2);
seekr.width = size;
seekr.height = size;
#if 1
{
int tilesum, objsum, eventsum;
stringdata = MAP_getChecksumFromRECT(fl,&seekr,&retr, &tilesum,&objsum,&eventsum);
if( stringdata == NULL )
return FALSE;
lssproto_MC_send(fd,fl,
retr.x, retr.y,
retr.x + retr.width, retr.y + retr.height,
tilesum,
objsum,
eventsum,
stringdata );
}
#else
stringdata = MAP_getdataFromRECT(fl,&seekr,&retr);
if( stringdata == NULL )
return FALSE;
lssproto_M_send(fd,fl,
retr.x, retr.y,
retr.x + retr.width, retr.y + retr.height,
stringdata );
#endif
return TRUE;
}
/*----------------------------------------
* Ѩ<EFBFBD><EFBFBD><EFBFBD>󷸡<EFBFBD><EFBFBD><EFBFBD>ë <EFBFBD>£<EFBFBD>
* ¦<EFBFBD><EFBFBD>
* charaindex int ƽ<EFBFBD>ҷ¼<EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>
* ߯Ի<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD> TRUE(1)
* <EFBFBD><EFBFBD> FALSE(0)
----------------------------------------*/
BOOL MAP_sendArroundChar(int charaindex)
{
int fd;
fd = getfdFromCharaIndex( charaindex );
if( fd == -1 )return FALSE;
return MAP_sendArroundCharNeedFD(fd, charaindex);
}