OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: elemental123 on 16 Aug 2005, 15:02:21
-
OK this may be a total noob question but, does anyone know how i can place AI units in guard towers?
-
Welcome to the forum!
Place the unit on the map, on top of the tower. Write this in the init field of the unit:-
this setpos [getpos this select 0, getpos this select 1, (getpos this select 2) + 6]; this setUnitPos "up"; doStop this; this disableAI "target"; this disableAI "move"
You may have to play with it a little to get exactly what you want: for example you may not want all the disable commands. Depending which tower it is, you may need to change the 6.
-
Sorry to threadjack but I have found a problem with what you have said Macguba, when you put
this setunitpos "up"
He looks like he's constantly aiming, so is there a way he will be "safe" then when he detects an enemy, he goes setunitpos "up". I guess it needs a "detected by side" trigger :(.
-
with some guard towers you can actually create a waypoint on top of it and when you edit the waypoint a new field saying pos : and it has a list of possible places that unt can move to within the tower
also you dont always need to set pos the unit into it it withs already placed you can just move the unit over the top of the tower and he should be in it
also with what Macguba said if you dont want your ai unit to fire use his but if you want the guy to fire at people remove
this disableAI "target"; from his code
hope that helps
-
Actually, if the tower is part of the map and not an object that has been added via the mission editor, you shouldn't have to change the unit's height. Just move him around the area of the tower until he is in it. OFP will automatically move the unit to the highest roadway lod if that lod is part of a permament object.
-Student Pilot
-
Sorry to threadjack but I have found a problem with what you have said Macguba, when you put
this setunitpos "up"
He looks like he's constantly aiming, so is there a way he will be "safe" then when he detects an enemy, he goes setunitpos "up". I guess it needs a "detected by side" trigger :(.
Yes dodgy,
Just set him safe or whatever,set up the trigger and then in the triggers On activ field put:- unitname setunitpos "up";unitname setbehaviour "combat";(if needed)this setcombatmode "red".
unitname=name your soldier and replace unitname with your soldiers name
Dont know how familiar you are with ofp codes,so excuse me if iam insulting you by telling you stuff you already know.
Dan :P
-
also with what Macguba said if you dont want your ai unit to fire use his but if you want the guy to fire at people remove
Code:this disableAI "target";
from his code
With disableAI target he will still fire.
What he will not do, is try to move to a new position from which to fire.
General Barron's Comment on the online comref:-
The "TARGET" section of the AI is likely different than what you would think. Normally, when an AI group is standing still and sees an enemy, the group will break formation and start moving towards the enemy. If you disable the "TARGET" AI, then the AI units will stay where they are at.
Even if you disable the "MOVE" AI, the units will still move out to attack the enemy, unless you disable the "TARGET" AI.
Disabling both these AI sections is useful when placing units in defensive positions. This way, you can have them stay behind their cover, and not run out into the open.
-
With disableAI target he will still fire.
What he will not do, is try to move to a new position from which to fire.
sorry there i thought it stopped him aiming at things my mistake
-
I think you might find that this is an easier way to put a solider in a guard tower:
Find the ID of the tower then put the following in the init field for the unit:
this setpos ( (object ID) buildingPos 1)
eg:
this setpos ( (object 16744) buildingPos 1)
for the guard tower at Ge75 on Malden
You then don't need to get the positioning just so for the unit on the map
You need the disable AI stuff then to make sure he doesn't walk out of the tower.
-
@Dan
There are two suggestions I can make. The first one is easier, but I don't know if it will work. The second is more complicated, but I think it might work.
1: Check the behaviour of the unit, if not SAFE, then setunitpos UP, ex:
#Loop
?behaviour UNIT != "SAFE": UNIT Setunitpos "UP"; exit
~.5
goto "Loop"
2:
Make a trigger area that covers the whole map and make it EnemyToUNIT present. ie, if UNIT is west, make the trigger east present, if UNIT is east then west present
then, in the trigger's condition field type:
{UNIT knowsabout _x >=.15} foreach thislist
On Activation:
UNIT SetUnitPos "UP"
UNIT is the name of the soldier in question.
Syntax not guarenteed.
-Student Pilot
-
There is a good script in the editors depot to put units in towers and if they fall out they get back in. This is for standard BIS islands.
Units in Towers by AK-Chester
http://www.ofpec.com/editors/index.php