OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: bardosy on 09 Jun 2006, 10:42:40

Title: sniper in the tower
Post by: bardosy on 09 Jun 2006, 10:42:40
I put a sniper on the top of a tower.
But when the fight begin and sniper started sneak for godd position or what, he fall from the towe and injury/die.

I tried write a script/trigger...
The tower is 15m high.

I inserted a trigger - condition: (getPos sniper select 2) < 15
activation: sniper setPos (snipposx, snipposy,15)

of course, the trigger is repeating. And snipposx, y was detected in the begining of the mission.

But doesn't work.
I printed the (getPos sniper select 2) value to the screen and I found, this value is 0.0002356 and not 15.
Ok I undersand the basic level is the top of the tower and the sniper are on basic level, but the trigger also doesn't triggered, but 0.00023 < 15.

Right! Can you help me? Any other idea, how can I stay the sniper in the tower?
Title: Re: sniper in the tower
Post by: Snuffles on 09 Jun 2006, 10:50:38
its actually pretty simple, to keep the sniper from falling off the tower, simply put dostop this in the units initialization line, and the unit will not move from that position unless ordered otherwise.
Title: Re: sniper in the tower
Post by: bedges on 09 Jun 2006, 12:32:52
it's not quite that simple. when the sniper spots an enemy, more often than not he'll go prone, making him fall out.

in the sniper's init field, put

Code: [Select]
dostop this; this setunitpos "up"
the sniper will now stay in the tower, and will also remain standing. all this is assuming he's not part of another group, in which case he'll try to return to formation eventually depending on what the leader tells him to do.
Title: Re: sniper in the tower
Post by: The-Architect on 09 Jun 2006, 12:58:45
I do this.

Create the sniper, select his formation as "None"; that bit is important if he's gonna be part of a group.
In his Init write:

This SetUnitPos "Up"; This DisableAI "Move"; This SetPos [(GetPos This Select 0), (GetPos This Select 1), 15]

Title: Re: sniper in the tower
Post by: Gogs on 09 Jun 2006, 13:57:16
The only thing about disableAI "Move" is that he won't move his feet at all. Which means his field of fire is limited to about 45 degrees of where he was pointing in the first place. You just have to be aware that he won't spin around and engage enemies behind him like this, though having said that, Its what I would use as well....
Title: Re: sniper in the tower
Post by: bardosy on 09 Jun 2006, 14:55:21
I can't use setUnitPos "up", because I used the setUnitPos "down".
If he is down, he can shoot with higher accuracy and the player can detect him harder.
The sniper is an individual guy (not in group) (but he reveal the player from script). He only move if he want (not a "return to formation"). But he moving a little bit when he targeting, and sometimes he falling down...

The solution of doStop don't solve my 'targeting move & fall' problem?

I try that disableAI "Move" and scripting the direction.
Title: Re: sniper in the tower
Post by: Mandoble on 09 Jun 2006, 18:52:18
disableAI "Move" prevents the unit to turn around unless he has already targeted an enemy. That is, the unit will not turn to adquire targets, but will turn to keep firing against current target if needed.
Title: Re: sniper in the tower
Post by: bardosy on 12 Jun 2006, 09:29:29
I tried your ideas, and finally the doStop was enough. But I modifie my trigger: the condition:

((getPos sniper select 2) < 15) and ((getPos sniper select 2) > 1)

Because when the sniper in the tower, his Z coord are lower then 1, but when he started falling, his Z coord become 14, 13, ...

And it's works!!! :D