Can a spectator take over for an ai player?

Can a spectator take over for an ai player?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Can a spectator take over for an ai player?

Post by smoth »

Say I am playing vs a Lua ai like Craig, can a spectator take over that ai player?
Super Mario
Posts: 823
Joined: 21 Oct 2008, 02:54

Re: Can a spectator take over for an ai player?

Post by Super Mario »

Correct me if I'm wrong, but isn't Ai, just consider to be another player in the game?
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Can a spectator take over for an ai player?

Post by Anarchid »

An AI is not just another player, but a Lua AI team should be possible to overtake. You can also "partially overtake" the AI with cheats as-is, e.g. via /team N or /godmode.
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Can a spectator take over for an ai player?

Post by Silentwings »

Spring.AssignPlayerToTeam should do it.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Can a spectator take over for an ai player?

Post by smoth »

ah, so will the ai try control things once a player has taken over?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Can a spectator take over for an ai player?

Post by Silentwings »

Yes, you'll have to remove the AI somehow as well.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Can a spectator take over for an ai player?

Post by smoth »

Is there a way for this or does it have to be part of the AI to step down?
User avatar
Silentwings
Posts: 3720
Joined: 25 Oct 2008, 00:23

Re: Can a spectator take over for an ai player?

Post by Silentwings »

I'm not sure, AIs are something I never got into.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Can a spectator take over for an ai player?

Post by Google_Frog »

The luaAI would have to be told to stop controlling the units. I doubt any luaAIs come with this feature but it sounds easy to add in. The simplest way (which allows the AI to be restarted) would be to replace Spring.GiveOrderToUnit with a function which checks whether the AI is active and blocks the order if it is not.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Can a spectator take over for an ai player?

Post by Jools »

Sounds a bit like a hack. Wouldn't it just be possible to add a shutdown button into the AI?
sprunk
Posts: 101
Joined: 29 Jun 2015, 07:36

Re: Can a spectator take over for an ai player?

Post by sprunk »

LuaAI can use the PlayerChanged call-in to check if someone joined the AI team to disable itself.
The gadget that calls AssignPlayerToTeam can also notify the LuaAIs itself through GG.
Post Reply

Return to “Lua Scripts”