OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Thaatu on 09 Oct 2005, 16:54:40

Title: How to check if AI is disabled?
Post by: Thaatu on 09 Oct 2005, 16:54:40
I tried searching for an answer, but couldn't find one so...

I'm trying to make an "exhibition" of how WWI air combat would work in OFP, so I made a TDM mission of an allied squadron vs. an axis jasta. The problem is, as they both start in air, that if one of the pilots is disabled, his plane will start in air and crash.

What I want to do is check if a pilot is disabled and if is, then deletevehicle his plane.

I tried the following:

Created a trigger checking if the pilot is present, on activation "pilotpresent = 1".

Created another trigger checking if pilot is NOT present, condition "this AND Not (pilotpresent == 1)", on activation "deletevehicle plane".

So what the first trigger would do is check if the pilot has been present at the beginning of the game, and the second trig. would check if the pilot isn't present and basically ask the first trig. if the pilot has died or dropped, in that case the sec.trig. won't activate.

But that doesn't work! Help me...
Title: Re:How to check if AI is disabled?
Post by: Planck on 09 Oct 2005, 17:01:04
Hmmmmm............try:

this AND (NOT pilotpresent)

Maybe........ ::)

Ohh.......and welcome to OFPEC.   ;D


Planck
Title: Re:How to check if AI is disabled?
Post by: Thaatu on 09 Oct 2005, 17:17:21
The trigger thingy works in mission editor when I just manually delete the pilot then preview. Then the deletevehicle kicks in and deletes the plane.

But in MP the disabled pilot, I quess, sort of blinks in the beginning of the mission, activating the "pilotpresent = 1" trigger and it all goes to hell...


I need some alternative route here.

                   Ohh... and thanks  :)
Title: Re:How to check if AI is disabled?
Post by: Platoon Patton on 09 Oct 2005, 18:30:30
First I assume U know about DisabledAI = 1 in Description.ext?
That means that the empty slots in MP are not AI.

Then U could do an engine  check on the vehicles with "IsEngineOn" a  second after the mission started.The Players will have engine On,the empty planes not and can be deleted.

In Your Planes initfields:
Code: [Select]
[this] exec "Checkvehicle.sqs"
Checkvehicle.sqs:

Code: [Select]
~1  
?(!Isengineon (_this select 0)) :DeleteVehicle (_this select 0)
exit




Title: Re:How to check if AI is disabled?
Post by: Thaatu on 09 Oct 2005, 19:31:55
----! I just tried it and it seems that empty planes have their engines on, so that doesn't work...
I also tried a simple "NOT (pilot in plane)", but if "pilot" is disabled then it doesn't exist and for ----- sake...  :P
I also tried something else, but my brain melt and I can't remember what... whatever it was, it didn't work.

About disabledAI, I do want to make AI wingmen available.


Oh by the way, that "isengineon" script's a very nice idea. It does work with land vehicles...
Title: Re:How to check if AI is disabled?
Post by: Platoon Patton on 09 Oct 2005, 19:55:23
OMG I tried it with choppers,all went well...

Even Empty  Planes indeed return "IsEngineOn" true, :o ???


Quote
About disabledAI, I do want to make AI wingmen available.

With DisabledAI = 0 U have Human Players and AI players together,so when exactly do U have an empty Plane then?Or whats the condition that a AI pilot/plane should be disabled?

Title: Re:How to check if AI is disabled?
Post by: Thaatu on 09 Oct 2005, 20:09:29
I want to give players the choise to play a squadron encounter, or just a 1vs1 dogfight, or 3vs3 with AI wingmen etc. So they could adjust that by disabling AI players in multiplayer setup.

Now if you want to play 1vs1 and disable all AI, there'll be 19 empty planes crashing down at the same time, causing muchos lag and very muchos laughter...
Title: Re:How to check if AI is disabled?
Post by: Platoon Patton on 09 Oct 2005, 20:24:19
Ok,because IsengineOn return true,we do a count crew check first and then turn the engine off :)

Code: [Select]
~1  
?(count crew (_this select 0)<=0): (_this select 0) EngineOn false
?(!Isengineon (_this select 0)):  DeleteVehicle (_this select 0)
exit


Or skip the engine part:
Code: [Select]
?(count crew (_this select 0)<=0) :DeleteVehicle (_this select 0)

Hope this works
Title: Re:How to check if AI is disabled?
Post by: Thaatu on 10 Oct 2005, 19:54:43
Yes! It works!  :D

Thanks PP... a lot!