easy method for having AI take over when a player quits? in Developer Help
|
|
I'd like to have AI take over when a player quits in the middle of a game. I tried creating a new mob, then setting it's key to that of the player who is quitting, in hopes his mob will then be a clientless mob (with all variables, possessions, etc. intact) that will now be AI, while the new mob that the person took over can gracefully leave.
I got a ton of run-time errors/glitches when I tried this approach though. The code is shown below. Is there a demo/tutorial that would help with this, or does anyone have any advice on the matter? Thanks.
mob/player/proc/leave_game()
if(!game_over)
var/mob/player/spectator = new(src.loc,0)
spectator.key = src.key // make the switch!
src.name = "[src.name]_AI"
spectator.name = spectator.key
world << "[src.name] takes over."
|
The only real advice I can offer is to consider using a datum to hold all key info about your player, and attach it to different mobs as needed.
Lummox JR