Exemplo n.º 1
0
int NPC_Lua_NLG_DelHaveIndexPet(lua_State *_NLL)
{
	CheckEx(_NLL, 2);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	int TM_PetHaveIndex = (int)lua_tointeger(_NLL, 2);
	int TM_Num = 1;
	int TM_PetIndex = -1;
	int TM_Ret = 0;
	
	if(TM_PetHaveIndex<0 || TM_PetHaveIndex>4){
		LRetErrInt(_NLL, -1, "传入的索引是无效的。");
	}
		TM_PetIndex = CHAR_getCharPet( TM_Index, TM_PetHaveIndex);
		
		if(!CHAR_CHECKINDEX(TM_PetIndex))
		{
			LRetErrInt(_NLL, -1, "传入的索引是无效的。");
		}

		TM_Ret = NPC_DelPet( TM_Index, TM_PetHaveIndex);
		if(TM_Ret < 0)
		{
			char TM_MsgBuff[128];
			snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "删除宠物时产生错误 错误号: %d。", TM_Ret);
			LRetErrInt(_NLL , -1, TM_MsgBuff);
		}

	LRetInt(_NLL, 1);
}
Exemplo n.º 2
0
int NPC_Lua_NLG_SearchWatchBattleRandIndex(lua_State *_NLL)
{
	CheckEx(_NLL, 2);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	int TM_Floor = (int)lua_tointeger(_NLL, 2);
	int TM_Ret = -1;

	if( (CHAR_getInt( TM_Index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) ){
		LRetErrInt(_NLL, -1, "对象类型不是玩家");
	}
	if( (CHAR_getWorkInt( TM_Index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) )
	{
		LRetErrInt(_NLL, -2, "对象正在对战中");
	}
	if( CHAR_getWorkInt( TM_Index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT )
	{
		int TM_Index2 = CHAR_getWorkInt( TM_Index, CHAR_WORKPARTYINDEX1 );

		if( TM_Index2 < 0 )
		{
			LRetErrInt(_NLL, -3, "对象的队伍异常");
		}
	}
	TM_Ret = SearchFmWarRandIndex(TM_Index, TM_Floor);
	if(TM_Ret != 0)
	{
		char TM_Buff[64];
		snprintf(TM_Buff, sizeof(TM_Buff), "无战斗可看!错误号:%d", TM_Floor);
		LRetErrInt(_NLL, -4, TM_Buff);
	}
	LRetInt(_NLL, TM_Ret);
}
Exemplo n.º 3
0
int NPC_Lua_NLG_TalkToFloor(lua_State *_NLL)
{
	CheckEx2(_NLL, 2, 5);
	
	int TM_Top = lua_gettop(_NLL);
	int TM_floor = (int)lua_tointeger(_NLL, 1);
	char *TM_Msg = lua_tostring(_NLL, 2);
	if(TM_Msg == NULL)
	{
		LRetErrInt(_NLL , -1, "说话内容不能为nil。");
	}

	int TM_color = CHAR_COLORWHITE;
	int TM_fontsize = 0;
	int TM_Talkindex = -1;

	if(TM_Top >= 3)
	{
		TM_color = (int)lua_tointeger(_NLL, 3);
	}
	if(TM_Top >= 4)
	{
		TM_fontsize = (int)lua_tointeger(_NLL, 4);
	}
	if(TM_Top == 5)
	{
		CheckIndexNull(_NLL, 5);
		TM_Talkindex = (int)lua_tointeger(_NLL, 5);
	}
	//指定地图说话
	BOOL TM_Ret = FALSE;
	int TM_playernum = CHAR_getPlayerMaxNum();
	int i = 0;

	for( i = 0 ; i < TM_playernum ; i++)
	{
		if( CHAR_getCharUse(i) != FALSE )
		{
			if (CHAR_getInt(i, CHAR_FLOOR) == TM_floor)
			{
			#ifdef _FONT_SIZE
				TM_Ret |= CHAR_talkToCliExt( i, TM_Talkindex, TM_Msg, TM_color, TM_fontsize);
			#else
				TM_Ret |= CHAR_talkToCli( i, TM_Talkindex, TM_Msg, TM_color);
			#endif
				
			}
		}
	}

	if(TM_Ret == TRUE)
	{
		LRetInt(_NLL, 0);
	}else
	{
		LRetErrInt(_NLL , -2, "未知原因导致发送说话失败。");
	}
}
Exemplo n.º 4
0
int NPC_Lua_NLG_ShowWindowTalked(lua_State *_NLL)
{
	CheckEx2(_NLL, 5, 6);
	CheckIndexNull(_NLL, 1);
	int TM_Top = lua_gettop(_NLL);
	int TM_index = (int)lua_tointeger(_NLL, 1);
	int TM_windowtype = (int)lua_tointeger(_NLL, 2);
	int TM_buttontype = (int)lua_tointeger(_NLL, 3);
	int TM_seqno = (int)lua_tointeger(_NLL, 4);
	char *TM_data = lua_tostring(_NLL, 5);

	if(TM_data == NULL)
	{
		LRetErrInt(_NLL , -1, "对话框内容不能为nil");
	}

	int TM_MeIndex = -1;
	int TM_fd = getfdFromCharaIndex(TM_index);

	if(TM_Top == 6)
	{
		CheckIndexNull(_NLL, 6);
		TM_MeIndex = (int)lua_tointeger(_NLL, 6);
	}

	lssproto_WN_send(TM_fd, TM_windowtype, TM_buttontype, TM_seqno, CHAR_getWorkInt( TM_MeIndex, CHAR_WORKOBJINDEX), TM_data);
	LRetInt(_NLL, 0);
}
Exemplo n.º 5
0
int NPC_Lua_NLG_CreateBattlePvP(lua_State *_NLL)
{
	CheckEx(_NLL, 2);
	CheckIndexNull(_NLL, 1);
	CheckIndexNull(_NLL, 2);
	int TM_Index1 = (int)lua_tointeger(_NLL, 1);
	int TM_Index2 = (int)lua_tointeger(_NLL, 2);
	int TM_Ret = -1;
	int TM_BattleIndex = -1;

	if( (CHAR_getInt( TM_Index2, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) || (CHAR_getInt( TM_Index1, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER)){
		LRetErrInt(_NLL, -1, "对象类型不是玩家");
	}
	if( (CHAR_getWorkInt( TM_Index2, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) || (CHAR_getWorkInt( TM_Index1, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE))
	{
		LRetErrInt(_NLL, -2, "对象正在对战中");
	}
	if( CHAR_getWorkInt( TM_Index2, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT )
	{
		int TM_Index = CHAR_getWorkInt( TM_Index2, CHAR_WORKPARTYINDEX1 );

		if( TM_Index < 0 )
		{
			LRetErrInt(_NLL, -3, "对象的队伍异常");
		}
	}
	if( CHAR_getWorkInt( TM_Index1, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT )
	{
		int TM_Index = CHAR_getWorkInt( TM_Index1, CHAR_WORKPARTYINDEX1 );

		if( TM_Index < 0 )
		{
			LRetErrInt(_NLL, -3, "对象的队伍异常");
		}
	}
	TM_Ret = NPC_Lua_CreateVsPlayer(&TM_BattleIndex, TM_Index1, TM_Index2);
	if(TM_Ret != 0)
	{
		char TM_Buff[64];
		snprintf(TM_Buff, sizeof(TM_Buff), "遭遇失败!错误号:%d", TM_Ret);
		LRetErrInt(_NLL, -4, TM_Buff);
	}
	LRetInt(_NLL, TM_BattleIndex);
}
Exemplo n.º 6
0
int NPC_Lua_NLG_CheckPlayIndex(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, "传入的索引是无效的。");
	}
	LRetInt(_NLL, TM_Index);
}
Exemplo n.º 7
0
int NPC_Lua_NLG_Save(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_charSaveFromConnect(TM_Index, FALSE);
	LRetInt(_NLL, TM_Index);
}
Exemplo n.º 8
0
//更新道具數據的接口
int NPC_Lua_Item_UpItem(lua_State *_NLL)
{
	CheckEx(_NLL, 2);
	CheckItemIndexNull(_NLL, 1);
	int TM_CharaIndex = (int)lua_tointeger(_NLL, 1);
	int TM_CharaPtr = API_GetCharaPtrFromCharaIndex(TM_CharaIndex);
	int TM_Pos = (int)lua_tointeger(_NLL, 2);

	if(!API_CHAR_CheckCharPointer(TM_CharaPtr))
	{
		LRetErrInt(_NLL, -1, "傳入的對象索引是無效的。");
	}
	
	if(TM_Pos >= 0 && TM_Pos<=27)
	{
		API_CHAR_sendItemDataOne(TM_CharaPtr, TM_Pos);
		LRetInt(_NLL, 0);
	}
	
	LRetErrInt(_NLL, -2, "傳入的道具位置是錯誤的。");
}
Exemplo n.º 9
0
int NPC_Lua_NLG_SetAction(lua_State *_NLL)
{
	CheckEx(_NLL, 2);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	int TM_Action = (int)lua_tointeger(_NLL, 2);

	if(!CHAR_CHECKINDEX(TM_Index))
	{
		LRetErrInt(_NLL, -1, "传入的索引是无效的。");
	}

	CHAR_sendWatchEvent( CHAR_getWorkInt( TM_Index, CHAR_WORKOBJINDEX),	TM_Action, NULL, 0,TRUE);
	CHAR_setWorkInt( TM_Index, CHAR_WORKACTION, TM_Action);

	LRetInt(_NLL, 0);
}
Exemplo n.º 10
0
int NPC_Lua_NLG_DelPet(lua_State *_NLL)
{
	CheckEx2(_NLL, 2, 3);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	int TM_PetID = (int)lua_tointeger(_NLL, 2);
	int TM_Num = 1;
	int TM_PetIndex = -1;
	int TM_Ret = 0;
	int TM_Count = 0;

	if(lua_gettop(_NLL) == 3)
	{
		TM_Num = (int)lua_tointeger(_NLL, 3);
	}
	int i = 0;
	for(i = 0; i < CHAR_MAXPETHAVE ; i++)
	{
		TM_PetIndex = CHAR_getCharPet( TM_Index, i);
		
		if(!CHAR_CHECKINDEX(TM_PetIndex))
		{
			continue;
		}
		if(CHAR_getInt( TM_PetIndex, CHAR_PETID) != TM_PetID)
		{
			continue;
		}

		TM_Ret = NPC_DelPet( TM_Index, i);
		if(TM_Ret < 0)
		{
			char TM_MsgBuff[128];
			snprintf(TM_MsgBuff, sizeof(TM_MsgBuff), "删除宠物时产生错误 错误号: %d。", TM_Ret);
			LRetErrInt(_NLL , -1, TM_MsgBuff);
		}

		TM_Count++;
		if(TM_Count == TM_Num)
		{
			break;
		}
	}
	LRetInt(_NLL, TM_Count);
}
Exemplo n.º 11
0
int NPC_Lua_NLG_GivePet(lua_State *_NLL)
{
	CheckEx2(_NLL, 2, 4);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	int TM_EnemyId = (int)lua_tointeger(_NLL, 2);
	int TM_Level = -1;
	int TM_Num = 1;
	int TM_Count = 0;
	int TM_PetIndex = -1;
	int TM_Int = -1;

	if(lua_gettop(_NLL) >= 3)
	{
		TM_Level = (int)lua_tointeger(_NLL, 3);
	}
	
	if(lua_gettop(_NLL) == 4)
	{
		TM_Num = (int)lua_tointeger(_NLL, 4);
	}
	if(TM_Num <= 0)
	{
		LRetErrInt(_NLL, -1, "给予数量不能少于等于0。");
	}
	int i = 0;
	for(i = 0; i < TM_Num; i++)
	{
		TM_Int = NPC_GivePet(TM_Index, TM_Level, TM_EnemyId);
		if(TM_Int < 0)
		{
			break;
		}
		TM_PetIndex = TM_Int;
		TM_Count++;
	}
	if(TM_Count > 0)
	{
		char TM_Buff[128];
		snprintf(TM_Buff, sizeof(TM_Buff), "获得 %d 只 %s。", TM_Count, CHAR_getChar( TM_PetIndex, CHAR_NAME));
		CHAR_talkToCli( TM_Index, -1, TM_Buff, CHAR_COLORYELLOW);
	}
	LRetInt(_NLL, TM_Count);
}
Exemplo n.º 12
0
int NPC_Lua_NLG_UpStateBySecond(lua_State *_NLL)
{
	CheckEx2(_NLL, 1, 3);
	CheckIndexNull(_NLL, 1);
	int TM_Index = (int)lua_tointeger(_NLL, 1);
	
	if(!CHAR_CHECKINDEX(TM_Index))
	{
		LRetErrInt(_NLL, -1, "传入的索引是无效的。");
	}

	char TM_Buff[128];
	int TM_fd = getfdFromCharaIndex(TM_Index);
#ifdef _SAF_MAKE
	snprintf(TM_Buff, sizeof(TM_Buff), "FAME|%d|%d|%d", CHAR_getInt(TM_Index,CHAR_FAME)/100, (int)lua_tointeger(_NLL, 2), (int)lua_tointeger(_NLL, 3));
#else
	snprintf(TM_Buff, sizeof(TM_Buff), "FAME|%d", CHAR_getInt(TM_Index,CHAR_FAME)/100);
#endif
	lssproto_S2_send(TM_fd,TM_Buff);
	LRetInt(_NLL, 0);
}
Exemplo n.º 13
0
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);
}