Page 1 of 1

FaceTarget()

Posted: Sat Mar 21, 2020 11:54 am
by Cynnar
Found that a spawn will not fact target after the spawn faced another npc. Here is part of the lua so hopefully it will make more sense.

Code: Select all

function TalkToCaptainVarlos(NPC, Spawn)
	
	local Ingrid = GetSpawn(NPC, 270001)
	
	FaceTarget(NPC, Ingrid)
	
	PlayFlavor(NPC, "voiceover/english/captain_varlos/boat_06p_tutorial02_fvo_007.mp3", "Don't want the ship to come apart in these high winds, do ya'?!", "scold", 517097409, 4194681002, Spawn)
	
	AddTimer(Ingrid, 4000, "SaluteCaptainVarlos", 1, Spawn)
	
	
end

function IngridLeaveCaptain(NPC, Spawn)
	FaceTarget(NPC, Spawn)
	
	PlayFlavor(NPC, "voiceover/english/captain_varlos/boat_06p_tutorial02_fvo_008.mp3", "Ya think she'd never seen a gnome afore.", "", 2447879193, 4289147535, Spawn)
	
	AddTimer(NPC, 3000, "ShakeCamera_1", 1, Spawn)
	
	AddTimer(NPC, 4000, "TheQuestOffer")
	
end
In the Function TalkToCaptainVarlos(NPC, Spawn) I have to have the Captain face Ingrid and using the FaceTarget(NPC, Ingrid) does in fact work. The issue is after their interaction the Captain turns and faces the player. Which I would think that the FaceTarget(NPC, Spawn) in the function IngridLeaveCaptain(NPC, Spawn) would work, but it is not working.

Here is the function SaluteCaptainVarlos(NPC, Spawn) in Ingrids spawn script

Code: Select all

function SaluteCaptainVarlos(NPC, Spawn)
	
	local Varlos = GetSpawn(NPC, 270000)
	
	PlayFlavor(NPC, "voiceover/english/ingrid/boat_06p_tutorial02/020_deckhand_ingrid_010_1637e047.mp3", "Aye, aye, Captain!", "salute", 1250282628, 237171958, Spawn)
	
	AddTimer(Varlos, 3000, "IngridLeaveCaptain", 1, Spawn)
	AddTimer(NPC, 2000, "ReturnToSpawnPoint", 1, Spawn)
	
end

Re: FaceTarget()

Posted: Sat Mar 21, 2020 4:29 pm
by Cynnar
We have a fix for the crash, not the facetarget issue this is script related, from smash.

In the LuaFunctions.cpp around line 156 replace the current EQ2Emu_lua_PerformCameraShake() function with the one below.

Code: Select all

int    EQ2Emu_lua_PerformCameraShake(lua_State* state) {

    if (!lua_interface)
        return 0;
    Client* client = 0;
    Spawn* player = lua_interface->GetSpawn(state);
    if (!player) {
        lua_interface->LogError("LUA PerformCameraShake command error: spawn is not valid");
        return 0;
    }

    if (!player->IsPlayer()) {
        lua_interface->LogError("LUA PerformCameraShake command error: spawn is not a player");
        return 0;
    }

    if (player->GetZone())
        client = player->GetZone()->GetClientBySpawn(player);

    if (!client) {
        lua_interface->LogError("LUA PerformCameraShake command error: could not find client");
        return 0;
    }
    int16 value1 = lua_interface->GetInt16Value(state, 2);
    int16 value2 = lua_interface->GetInt16Value(state, 3);
    PacketStruct* packet = configReader.getStruct("WS_PerformCameraShakeMsg", client->GetVersion());
    if (packet) {
        packet->setDataByName("unknown1", value1);
        packet->setDataByName("unknown2", value2);
        client->QueuePacket(packet->serialize());
        safe_delete(packet);
    }
    return 0;
}
This will throw an error in the lua debug that can be see from the chat window/command line, when lua debug is started, instead if the server crashing.

Thanks Smash for the code.