BOOL NPC_UtilObj_isFaceToFace( int npcobjindex, int objindex, int distance ) { int i; int npc_floor, npc_x, npc_y, npc_dir; npc_floor = OBJECT_getFloor( npcobjindex); npc_x = OBJECT_getX( npcobjindex); npc_y = OBJECT_getY( npcobjindex); npc_dir = OBJECT_getNpcdir( npcobjindex); if( OBJECT_getFloor( objindex) != npc_floor ) return FALSE; if( OBJECT_getX( objindex) == npc_x && OBJECT_getY( objindex) == npc_y ) return FALSE; for( i=1; i<=distance; i++ ){ int walked_x, walked_y; CHAR_getCoordinationDir( OBJECT_getNpcdir( objindex) , OBJECT_getX( objindex), OBJECT_getY( objindex) , i, &walked_x, &walked_y ); if( npc_x == walked_x && npc_y == walked_y ){ return TRUE; }else{ return FALSE; } } return FALSE; }
BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, BOOL net ) { int oind,cind; if( !ITEM_CHECKINDEX( itemindex ) ) return FALSE; oind = ITEM_getWorkInt( itemindex , ITEM_WORKOBJINDEX ); cind = ITEM_getWorkInt( itemindex , ITEM_WORKCHARAINDEX ); if( oind >= 0 ){ return MAP_objmove( oind , OBJECT_getFloor(oind), OBJECT_getX(oind), OBJECT_getY(oind), fl,x,y); } else if( cind >= 0 ){ int itemindexinchara = NPC_Util_SearchItemInChar(cind,itemindex); if( itemindexinchara == -1 ) return FALSE; CHAR_setItemIndex( cind , itemindexinchara , -1 ); CHAR_complianceParameter(cind); if( net ) CHAR_sendItemDataOne( cind, itemindexinchara); if( CHAR_DropItemAbsolute( itemindex, fl,x,y,TRUE) < 0 ){ return FALSE; } else { return TRUE; } } return FALSE; }
BOOL CHAR_makeCAOPT1String( int objindex,char* buf, int buflen, int act,int opt1 ) { char objindexbuf[64]; if( CHECKOBJECT(objindex) == FALSE ) return FALSE; if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; snprintf( buf,buflen,"%s|%d|%d|%d|%d|%d", cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), OBJECT_getX(objindex), OBJECT_getY(objindex), act, CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR), opt1); return TRUE; }
/* * 地形におかれているもしくはキャラがもっているアイテム * を強制的に地形のある地点に置く。 * * int itemindex : アイテム表への index * int fl,x,y : 位置。 * BOOL net: ネットワークの処理をするかどうか * 返り値は FALSE : 失敗 TRUE : 成功 */ BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, BOOL net ) { int oind,cind; if( !ITEM_CHECKINDEX( itemindex ) ) return FALSE; oind = ITEM_getWorkInt( itemindex , ITEM_WORKOBJINDEX ); cind = ITEM_getWorkInt( itemindex , ITEM_WORKCHARAINDEX ); if( oind >= 0 ){ /* 地形におかれている場合は単に位置を変更 */ return MAP_objmove( oind , OBJECT_getFloor(oind), OBJECT_getX(oind), OBJECT_getY(oind), fl,x,y); } else if( cind >= 0 ){ /* キャラがもっている */ int itemindexinchara = NPC_Util_SearchItemInChar(cind,itemindex); if( itemindexinchara == -1 ) return FALSE; /* キャラがもっていないようにする */ CHAR_setItemIndex( cind , itemindexinchara , -1 ); if( itemindexinchara == CHAR_ARM1 && CHAR_getItemIndex( cind,CHAR_ARM2 )== -2){ CHAR_setItemIndex(cind,CHAR_ARM2,-1); } CHAR_complianceParameter(cind); if( net ) CHAR_sendStatusString( cind,"I"); /* アイテムindexから直接起く */ if( CHAR_DropItemAbsolute( itemindex, fl,x,y,TRUE) < 0 ){ return FALSE; } else { return TRUE; } } return FALSE; }
int NPC_Lua_NLG_UpChar(lua_State *_NLL) { CheckEx(_NLL, 1); CheckIndexNull(_NLL, 1); int TM_Index = (int)lua_tointeger(_NLL, 1); if(!CHAR_CHECKINDEX(TM_Index)) { LRetErrInt(_NLL, -1, "传入的索引是无效的。"); } CHAR_complianceParameter( TM_Index ); if(CHAR_getInt(TM_Index,CHAR_WHICHTYPE)==CHAR_TYPEPET){ int playindex = CHAR_getWorkInt(TM_Index,CHAR_WORKPLAYERINDEX); if(!CHAR_CHECKINDEX(playindex)){ LRetErrInt(_NLL, -1, "传入的索引是无效的。"); }else{ int i; for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { int workindex = CHAR_getCharPet( playindex, i ); if( workindex == TM_Index ){ CHAR_send_K_StatusString( playindex, i, CHAR_K_STRING_BASEIMAGENUMBER| CHAR_K_STRING_HP| CHAR_K_STRING_MAXHP| CHAR_K_STRING_MP| CHAR_K_STRING_MAXMP| CHAR_K_STRING_EXP| CHAR_K_STRING_NEXTEXP| CHAR_K_STRING_LV| CHAR_K_STRING_ATK| CHAR_K_STRING_DEF| CHAR_K_STRING_QUICK| CHAR_K_STRING_AI| CHAR_K_STRING_EARTH| CHAR_K_STRING_WATER| CHAR_K_STRING_FIRE| CHAR_K_STRING_WIND| CHAR_K_STRING_SLOT| CHAR_K_STRING_CHANGENAMEFLG| CHAR_K_STRING_NAME| CHAR_K_STRING_USERPETNAME); char msgbuf[128]; snprintf( msgbuf, sizeof( msgbuf ), "W%d",i); CHAR_sendStatusString( playindex, msgbuf ); CHAR_sendStatusString( playindex, "P"); break; } } } }else if(CHAR_getInt(TM_Index,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ CHAR_send_P_StatusString( TM_Index, CHAR_P_STRING_GOLD ); } if(CHAR_getFlg(TM_Index, CHAR_ISVISIBLE) == FALSE) { int TM_objindex = CHAR_getWorkInt(TM_Index,CHAR_WORKOBJINDEX); CHAR_sendCDArroundChar ( OBJECT_getFloor(TM_objindex), OBJECT_getX(TM_objindex), OBJECT_getY(TM_objindex), TM_objindex ); }else { CHAR_sendCToArroundCharacter( CHAR_getWorkInt( TM_Index , CHAR_WORKOBJINDEX )); } LRetNull(_NLL); }