NPC99 said:Wendepoz said:Hello, I'm trying to make it so that when the player falls in battle he controls another agent and this is what I have so far (I'm using lua) :
function ChangePlayerAgent()
local player = game.get_player_agent_no(0)
local deadAgent = game.store_trigger_param(0, 1)
if deadAgent == player then
local newPlayerAgent
for agent in game.agentsI() do
if game.agent_is_ally(agent) and game.agent_is_human(agent) and game.agent_is_alive(agent) then
newPlayerAgent = agent
break
end
end
if newPlayerAgent ~= nil then
local playerID = game.agent_get_player_id(0, player)
game.player_control_agent(playerID, newPlayerAgent)
game.display_message("Set new player agent")
else
game.display_message("Couldn't find agent for player")
end
end
end
game.addTrigger("mst_lead_charge", game.const.ti_on_agent_killed_or_wounded, 0, 0, returnTrue, ChangePlayerAgent)
I'm almost certain that the cause of the problem is that I'm using "player_control_agent" which is for multiplayer but I can't find an equivalent for singleplayer. Does anybody know how to make this work?
I can’t help with lua, but the Twilight of the Sun King mod’s source code is OSP & includes body sliding for singleplayer - look at their auxilliary triggers in mission_templates.py.
Thanks, I'll check it out