Tipologie server:
*Resursă folosită:
*ServerFiles utilizat:Martysama 5.8
*Syserr:
Poză:
*Detalii suplimentare:
Cod: Selectaţi tot
int game_mob_attack_mob(lua_State *L)
{
if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
{
lua_pushboolean(L, 0);
lua_pushstring(L, "Invalid argument. Usage: mob_attack_mob(attacker_vid, target_vid, map_index)");
return 2;
}
int attacker_vid = (int)lua_tonumber(L, 1);
int target_vid = (int)lua_tonumber(L, 2);
int map_index = (int)lua_tonumber(L, 3); // Expected map index
LPCHARACTER attacker = CHARACTER_MANAGER::instance().Find(attacker_vid);
LPCHARACTER target = CHARACTER_MANAGER::instance().Find(target_vid);
if (!attacker || !attacker->IsMonster())
{
lua_pushboolean(L, 0);
lua_pushstring(L, "Attacker not found or is not a monster.");
return 2;
}
if (!target || !target->IsMonster())
{
lua_pushboolean(L, 0);
lua_pushstring(L, "Target not found or is not a monster.");
return 2;
}
if (attacker->GetMapIndex() != map_index || target->GetMapIndex() != map_index)
{
lua_pushboolean(L, 0);
lua_pushstring(L, "Either attacker or target is not in the specified map.");
return 2;
}
// All checks passed, proceed to set victim
attacker->SetVictim(target);
attacker->BeginFight(target);
lua_pushboolean(L, 1);
lua_pushstring(L, "Attack set successfully.");
return 2;
}



