OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Ale on 11 Apr 2007, 17:42:06

Title: WW2 Tank Firing
Post by: Ale on 11 Apr 2007, 17:42:06
Hello all,

I'm a great fan of OFP and of all the mods, but specially of WW2 mods. In these mods there are many tanks, but they are similar to modern tanks, in fact they do not stop when firing. While a Tiger tank is moving it fires a shot to a vehicle or another tank. Here is my question: do you know a way to make the behaviour of ww2 tanks more real and less similar to that of a T72 or a M1 Abrams?

Thank you
Title: Re: WW2 Tank Firing
Post by: The-Architect on 13 Apr 2007, 00:42:55
You'd have to script it so that they did things you'd want.

Take stopping before firing for instance. I'm not sure how it would be done, but you could write a script that would temporarily give the tank a stop command and then remove it after it has fired.

The reason for it to stop is the hard part.
Title: Re: WW2 Tank Firing
Post by: h- on 13 Apr 2007, 18:10:56
The thing is that there is absolutely no way to tell whether a unit is about to fire..
Title: Re: WW2 Tank Firing
Post by: The-Architect on 14 Apr 2007, 02:09:23
That's what I meant. Could there possibly be a workaround of some sort. Only allowing ammo for a certain amount of time or something. The player wouldn't ever have to know.

I dunno, summit along those lines. :confused:
Title: Re: WW2 Tank Firing
Post by: Ale on 20 Apr 2007, 17:15:00
Well I confess that I have problem with the scripts, I have read hundreds of posts but with no result.

Probably I have found a way to stop the tank with the command "SetFuel 0" and the command "KnowsAbout";

I have made a simple mission with one Tiger (panzer1) and one Sherman (ustank), with SetCombatMode "Green" to prevent shooting while they are moving. I have set a trigger with this condition "panzer1 KnowsAbout ustank> 2" and on activation "panzer1 SetFuel 0"; so the Tiger stops and open fire on the Sherman. Another trigger set the fuel to 1 if "panzer1 KnowsAbout ustank < 2", and the Tiger continue his patrol.

Now I need some help if you can:

I must check all enemy units for  each tank in the mission, but I don't know how.

Thanks
Title: Re: WW2 Tank Firing
Post by: h- on 20 Apr 2007, 21:02:09
It's basicly easy, but it will eat resources and thus probably make your mission lag a bit..
What you need to do is to create a global array of all the enemy tanks and then write a script that monitors the knowsAbout for each of those enemy tanks..

init.sqs
Code: [Select]
my_enemytankArray = [nme_tank1,nme_tank2,nme_tank3,nme_tank4]
monitor.sqs (friendlytankname exec "monitor.sqs")
Code: [Select]
_i = 0

#check
? (_i + 1) == count my_enemytankArray: _i = 0
? !(alive _this): exit

_fuel = fuel _this
_nme = my_enemytankArray select _i
? _this knowsAbout _nme > 2: goto "haltForFiring"

_i = _i + 1
~0.1
goto "check"

#haltForFiring
_this setFuel 0
@_this knowsAbout _nme < 2
_this setFuel _fuel
goto "check"
I have no idea if that works though..
And the script continues to loop until the tank it monitors is dead so that might need improving upon..
Title: Re: WW2 Tank Firing
Post by: Ale on 20 Apr 2007, 23:00:08
It works perfectly, thank you. :clap:

Now I'm testing with more tanks and different "knowsabout" levels; thank to your help I have seen many duels between Tiger and Sherman, King Tiger and T34 and so on...
And I have seen that they never miss one shot; if the tank fires, it fires on the target.
It would be nice to add some more error in the firing ability of the ai tanks.
Title: Re: WW2 Tank Firing
Post by: h- on 21 Apr 2007, 00:17:04
You can cause the AI to shoot poorly by scripting dispersion..

That is done by 'catching' the fired shell by utilising the fired eventHandler and altering the shell's velocity, which causes it to go 'off course'..