OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Terox on 02 Jan 2003, 14:59:53

Title: Disabling AI (ingame after start)
Post by: Terox on 02 Jan 2003, 14:59:53
If you use the

"disabledAI = 1" in the description.ext file
As we know it disables ai during the soldier selection screen.
However, if an mplayer disconnects from the server, he creates an ai

So my question is

If a looping script was to be made, using disableAI or something similar, would this stop the AI from occuring ingame

If anybody has any work arounds for this I would appreciate it
Title: Re:Disabling AI (ingame after start)
Post by: Ranger on 02 Jan 2003, 19:24:24
If I understand correctly, you want to remove (delete) the unit when a player disconnects.  Your literal wording makes it sound like you want to disable the AI (i.e., the unit exists but does nothing).

So, assuming that you really want to remove the unit, you can check if a unit is player-controlled by using the player value.  For example, in a script, you can use something similar to the following code:

? (unitName != player) : deleteVehicle unitName

Where unitName is the name of a unit.  This checks if the specified unit is a player.  If not, then it deletes the unit.  So, you can put this in a script and have the script loop, or something similar.  With some modification, you can have it check multiple units with a single line, or do whatever else you need.

Good luck!  8)
Title: Re:Disabling AI (ingame after start)
Post by: Tactician on 04 Jan 2003, 01:32:02
unit disableAI section

Operand types:
    unit: Object
    section: String
Type of returned value:
    Nothing
Description:
    Disable parts of AI behaviour to get fine control over unit. Section is one of "TARGET" (disable watching assinged target), "AUTOTARGET" (disable independed target assigning and watching unknown targets), "MOVE" (disable movement).

Example:
    soldierOne disableAI "Move"

Try running this kind of thing:

{_x disableAI "move"; _x disableAI "target"; _x disableAI "autotarget"} forEach listOfAllPlayers

listOfAllPlayers would be an array in which you list all soldiers, i.e. listOfAllPlayers = [wa1,wa2,wa3,ea1,ea2,ea3,etc]

Alternately you could add all three disableAI lines in the init field of each soldier.

If you do this to all players at the beginning of the game, I wonder if it still applies when they disconnect?  I wonder if it even works at all?  If it does, the AI will still be present, but they won't move or find their own targets.  Experiment.

Remember that AI is handled exclusively by the server, so you probably don't need to run it on all clients.
Title: Re:Disabling AI (ingame after start)
Post by: Terox on 04 Jan 2003, 14:37:03
Thanks, I will