Home   Help Search Login Register  

Author Topic: Finding Nearest Enemy Unit.  (Read 5047 times)

0 Members and 1 Guest are viewing this topic.

SheepOnMintSauce

  • Guest
Finding Nearest Enemy Unit.
« on: 23 Aug 2003, 08:19:31 »
I'm trying to find how to display the nearest enemy unit to a player. After checking out the command reference I spotted :

Quote
nearestObject pos
Operand types:
    pos: Array
Type of returned value:
    Object

Description:
    Nearest building of given type to given position or object. pos may be [x,y,z, "type"] or [object, "type"].

Example:
    nearestObject [player, "StreetLamp"]


Could I use that to find the nearest enemy unit to the player? If so, how would I go about doing that? I was thinking of trying :

Code: [Select]
nearestObject [player1, "east"]
Or something similar along those lines, without trying to get too complicated so it all goes over my head. Lol.  ;D

Help?  :-\

Knut Erik

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #1 on: 23 Aug 2003, 08:26:27 »
Try:

nearestObject [player1, "soldierEB"]

I think this will detect the nearest russian soldier that is in the "Soldier" class. To make the script detect everyone on the east side, you'll have to play arround with the TypeOf command, and that is far to complicaded to me  :P

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #2 on: 23 Aug 2003, 08:31:29 »
Lol, that's great. I basically want to detect any russian unit which isn't in a vehicle, but actually on foot. I think I'll have a look at the TypeOf command though. Thanks.  ;D

LAPD

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #3 on: 23 Aug 2003, 14:00:08 »
What Knut Erik meant was that it will detect only east soldiers. It won't detect east medics, east RPG soldier, east AA soldier and so on ... so it won't detect every east soldier on foot. :-\

Just wanted to make it clear. :)

I don't know about the TypeOf command and how to use it.

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #4 on: 23 Aug 2003, 14:04:10 »
Yeah, I gathered that. But, that still helped me a lot anyway. Thanks, for making it clear though.  :)
How do you find out the names of the other types of unit, apart from 'soldierEB'?

Knut Erik

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #5 on: 23 Aug 2003, 14:27:42 »
Here ya go !!

SoldierEB                       - Soldier
SoldierEG                      - Dunno
SoldierEMedic                - Medic
SoldierECrew                -Tank Crew
SoldierEPilot                  -Pilot
SoldierEMG                    -Machinegunner
SoldierELAW                  -Law Soldier
SoldierEAT                     -At soldier
SoldierEAA                     -At soldier
SoldierEMiner                 -Enginer
OfficerE                          -Officer
OfficerENight                  -Officer nightEq
SoldierESniper                -Sniper
SoldierESaboteurPipe     -SpetzNatz

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #6 on: 23 Aug 2003, 14:29:34 »
Ah thanks, noted!  ;D

GrimMonkey

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #7 on: 23 Aug 2003, 16:35:16 »
SoldierEG is probably a grenediar. It sure would seem like it.

Knut Erik

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #8 on: 23 Aug 2003, 16:37:44 »
Ah. I should have tought of that. :P

*Hangs arround in shame*

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #9 on: 23 Aug 2003, 17:43:15 »
Code: [Select]
_target = nearestobject [_sniper, "soldierEB"]
It doesn't seem to work either way. I get a error message '_target = nearestobject [_sniper, "soldierEB"]'|#| : Error 0 elements provided, 3 expected.

Today, isn't my lucky day.  :-\ Any explaination anyone?

Knut Erik

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #10 on: 23 Aug 2003, 19:17:06 »
How do you call your script ?

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #11 on: 24 Aug 2003, 01:41:18 »
Well, trying to keep it simple :

  • I start a script called 'spotter.sqs' from a trigger set off by radio alpha.
  • In 'spotter.sqs' it makes an action called actionstart which display an action 'Start spotting' which runs 'start.sqs'.
  • The 'start.sqs' does the following code :
Code: [Select]
_sniper removeaction actionstart
[] exec "spot.sqs"
  • Finally '_target = nearestobject [_sniper, "soldierEB"]' lies in the 'spot.sqs'


The script looks like this :

Code: [Select]
?madeaction == "yes" : goto "spot"
actionstop = _sniper addaction ["Stop Spotting", "stop.sqs"]
madeaction = "yes"
#spot
_spotter move [getpos _sniper this select 0, getpos _sniper this select 1 + 10]
? not (unitready _spotter) : goto "spot"
_spotter setUnitPos "Down"
_spotter setdir [getdir _sniper]
_spotter selectweapon "binocular"
;now to get down to business
_soldier = ["OfficerE", "SoldierEPilot", "SoldierECrew", "SoldierEAT", "SoldierEAA", "SoldierEMG", "SoldierELAW", "SoldierEG", "SoldierEMedic", "SoldierESniper", "SoldierESaboteurPipe", "SoldierEB"]
_target = nearestobject [_sniper, "SoldierEB"]
_targetdist = _spotter distance _target
_targetdist = _targetdist + _targetdist*(((random 20)/100)-.1)
_spotter dowatch _target


deaddog

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #12 on: 24 Aug 2003, 04:49:33 »
Code: [Select]
_spotter move [getpos _sniper this select 0, getpos _sniper this select 1 + 10]
? not (unitready _spotter) : goto "spot"

Remove the word "this" (getpos _sniper select 0, etc)
Also, you shouldn't continously use the move command.  It only needs one.

Use:

@unitready _spotter

or

_spotter move [getpos _sniper select 0, (getpos _sniper select 1) + 10]  ***note the parenthesis
#wait
~2
?!unitready _spotter:goto "wait"


also,

Code: [Select]
_spotter setdir [getdir _sniper]
change the [ ] to ().

And, finally  :),  I don't think the nearestobject function is going to work. It has a finite range of 50 meters.  It will return 1e+010 if that object is greater than that.  I know because I just tried it and I also ran into that in another script.

Man, am i just a wealth of bad news or what  ;D

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #13 on: 24 Aug 2003, 05:45:52 »
Not, really. I found it very helpful, and I'll take all of your advice on-board.  ;D Thanks.

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #14 on: 24 Aug 2003, 08:49:20 »
Does the nearestobject command actually return the value of the nearest unit, or is it strictly for objects like streetlights or buildings?

I'm only asking because, I noticed the nearestbuilding command on the command reference too.

Quote
nearestBuilding obj

Operand types:
obj: Object
Type of returned value:
Object
Description:
Nearest building to given object.

Example:
neareastBuilding player

So that would obviously return the nearest building to an object (the unit.)

But :

Quote
nearestObject pos

Operand types:
pos: Array
Type of returned value:
Object
Description:
Nearest building of given type to given position or object. pos may be [x,y,z, "type"] or [object, "type"].

Example:
nearestObject [player, "StreetLamp"]

Does this mean it will only return the nearest building to an object (the unit), or position?  If so, is there anyway to find the nearest unit to a unit?

I just don't seem to be having any luck trying to detect russian units using the nearestObject command.  :-\

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #15 on: 24 Aug 2003, 13:25:53 »
I went away and had a little 'experiment' with the NearestObject command and I finally came up with something, thanks to all of you who gave me a hand.  :)

Code: [Select]
player1 = _this select 0
_near = nearestobject [player1,"soldiereb"]
hint format ["Nearest Object to %1 is %2",player1,_near]

I made it loop after the 'player1 = _this select 0' bit. Then placed a few russian soldiers down, and tested it out. It worked fine telling which soldier I was nearest to, except after shooting them I'd get a NOID return as the object.

Quote
I don't think the nearestobject function is going to work. It has a finite range of 50 meters.

That is what deaddog said, so when I use it I'm going to have to use it so that it detects from a position say 200 or so metres in front of my unit in my script, but I'll cross that bridge when I come to it. Also, I need to stop it from returning the NOID of dead objects . I can sense more problems ahead.  ;D

Thanks for your help everyone!  :D

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #16 on: 24 Aug 2003, 17:15:59 »
I unsolved this, because deaddog sent me a message which goes like so.

Quote
You shouldn't have solved your topic because your problem is really not solved. :)

Try another approach.

Create an array that contains all the enemy units by making a large east (or west) present, non-repeating trigger. In the activation put: enemyunits=+thislist

now, in your script put:

Code: [Select]
_dis=999999
_closest=player

{_d=_sniper distance _x;if (_d<_dis) then {_dis=_d;_closest=_x}} foreach enemyunits



Quote
The variable "_closest" will be equal to the nearest enemy unit to the sniper. If _closest equals the player, that means there are no enemy units left (in the array).  If you createunits later, be sure to add them to the enemyunits array.

And the variable "_dis" will be the distance to that enemy unit.  

You can use this to replace the nearestobject command.

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #17 on: 24 Aug 2003, 23:21:25 »
Right, I tried what you said to do deaddog but with no success.  :(

So, I just decided to show you all the scripts I've come up with and see if you can see anything that would cause a problem. I also seem to be getting one hell of a lot of lag using it.

Spotter.sqs - the init script.

Code: [Select]
;A test spotter script by SheepOnMintSauce.

_sniper = _this select 0
_spotter = _this select 1

;Check to see if the spotter has an M16 and a Pair of Binoculars.
#weapon
?_spotter hasweapon "binocular" : goto "m16"
_spotter addWeapon "binocular"
#m16
?_spotter hasweapon "M16" : goto "start"
_spotter addMagazine "M16"
_spotter addMagazine "M16"
_spotter addweapon "M16"
;All tooled up and ready to go.
#start
actionstart = _sniper addaction ["Start Spotting", "spot.sqs"]

Spot.sqs

Code: [Select]
?madeaction == "yes" : goto "spot"
_sniper removeaction actionstart
actionstop = _sniper addaction ["Stop Spotting", "stop.sqs"]
_spotter setpos [(getpos _sniper select 0),(getpos _sniper select 1) + 10]
madeaction = "yes"
#wait
~2
?!unitready _spotter : goto "wait"
#spot
_spotter setUnitPos "Down"
_spotter setdir (getdir _sniper)
_spotter selectweapon "binocular"
;now to get down to business
_dis=999999
_closest=_sniper
{_d=_sniper distance _target;if (_d<_dis) then {_dis=_d;_closest=_target}} foreach enemyunits
[] exec "reveal.sqs"

Reveal.sqs

Code: [Select]
#reveal
_spotter sidechat format ["The target is%2%1 metres away.",_dis,_now]
~0.1
_now = "now "
_target addEventHandler ["hit", [] exec "hit.sqs"]
?!alive _spotter : [] exec "spotter.sqs"
?alive _target : goto "reveal"
~0.1
_spotter sidechat format ["The target is down."]
[] exec "spot.sqs"

Stop.sqs - from the Spot.sqs' action command.

Code: [Select]
_spotter setUnitPos "auto"
_spotter selectweapon "M16"
_sniper removeaction actionstop
[] exec "spotter.sqs"

Finally, hit.sqs

Code: [Select]
_spotter sidechat format ["The target is hit!"]
[] exec "reveal.sqs"

I'm not quite sure where I've gone wrong here now. Maybe it was too many scripts to keep track of, or something. I don't seem to get any errors with it now. But then again, I don't seem to get anything but lag from it either.  :-\ Perhaps I should start scripting in OFP by making easier scripts, lol.  ;)

Unnamed

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #18 on: 25 Aug 2003, 04:16:31 »
I may have it wrong, but arent you adding an event handler every time you loop through the reveal script? Could you not just add the Hit event to the init box of your target via the editor?

I know it's basic, but Just out of interest I was messing around with this:

Code: [Select]
;Use a sniper, he has better eye sight
Soldier1 RemoveWeapon "M21"

Soldier1 AddWeapon "Binocular"
~0.1
Soldier1 SelectWeapon "Binocular"

;Get the AI to point the Binoculars in the general direction of the target before he puts them away
Soldier1 DoWatch (GetPos Enemy1)

~1

#Loop

;I want the trigger to detect any unknown as well as enemy targets
;So get rid of all the units that are on our side
_Temp=(List Trigger1)
{If ((Side _x)==WEST) Then {_Temp=_Temp-[_x]}} ForEach _Temp

~0.5

Hint Format["Detected %1 Distance %2",_Temp,Soldier1 Distance Enemy1]

;Get the AI to point the Binoculars in the general direction of the target
Soldier1 DoWatch (GetPos Enemy1)

~1

Goto "Loop"

I'm trying to improve the AI's ability to act as a spotter. So far snipers are the best, thanks to some setting in the config.

But the AI will not use Binoculars long enough to be of any real effect. At the speed they use them, it will take half an hour to scan the horizon :(

DoWatch with GetPos will point the spotter in the general direction of the target, so he will spot them at long range with Binoculars, does not work with sniper scopes though.

However DoWatch with an object will allow the AI to track a target even when it moves out of site, and will get the AI sniper to fire at quite long ranges.

I attached the test mission if your interested, I added the switchcamera command to the radion to see what the spotter and sniper see.

Anyone know how to get the AI to use Binoculars for more than 4 to 5 seconds?

Thanks
« Last Edit: 25 Aug 2003, 07:30:02 by Unnamed »

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #19 on: 25 Aug 2003, 10:44:32 »
I was trying to go for flexabilty, so the target is unknown, and would mean putting the event handler in all the init fields of possible targets. If you get what I mean.

It's a good idea to use a sniper as a spotter though, I was toying with the idea of using one because of the ghilli suit, but I didn't know that the sniper had better eyesight, so that's pretty handy, thanks.  ;D

I'll take a look at your test mission too, it sounds interesting. The point of the script I'm trying to make comes from this thread, which might give you an insight as to what I'm trying to do here. I just thought it would be an interesting start to scripting, and I'm certainly learning a lot of new stuff from it, so it can't be all that bad.  :P

Hmm.. One point. Where's the test mission to?  :-\

« Last Edit: 25 Aug 2003, 10:46:07 by SheepOnMintSauce »

Unnamed

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #20 on: 25 Aug 2003, 15:59:07 »
Quote
I was trying to go for flexabilty, so the target is unknown, and would mean putting the event handler in all the init fields of possible targets. If you get what I mean.

I thought that maybe part of your lag problem? It dont know if this would even cause lag? But assuming your not checking the distance on loads of enemy, I could not see anything else that might slow it down.

But you could add something similar to the way you handle the snipers AddAction using a boolean _HasEvent:

Code: [Select]
_HasEvent=False

#reveal
_spotter sidechat format ["The target is%2%1 metres away.",_dis,_now]
~0.1

_now = "now "

?!_HasEvent : _target addEventHandler ["hit", [] exec "hit.sqs"] ; _HasEvent=True

?!alive _spotter : [] exec "spotter.sqs"
?alive _target : goto "reveal"

~0.1
_spotter sidechat format ["The target is down."]
[] exec "spot.sqs"

Perhaps add a pauses for a couple of seconds after the Distance ForEach loop?

Hmm I tried to attach the mission as a tiny zip file, if it does not work again, I will try and send it as a Private Message. The switch camera stuff is useful to see how, the AI prioritises it's targets.

I would like to check out your full mission if I can? Adding a Hit event to the current target could be come in very handy.

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #21 on: 25 Aug 2003, 16:42:46 »
Quote
I would like to check out your full mission if I can? Adding a Hit event to the current target could be come in very handy.

At the moment I've not made a mission, since I was just trying to get the script working. I've just placed three russian soldiers some distance away from a guy named sniper who is a sniper and a another guy called spotter who will act as the spotter (unless he dies) when the script is initiated.

I'll check your mission out though, it sounds good.  ;D

deaddog

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #22 on: 25 Aug 2003, 16:44:30 »
From reveal.sqs:
_
Code: [Select]
spotter sidechat format ["The target is%2%1 metres away.",_dis,_now]
_dis is a local variable (hence, the underscore).  You are trying to use a local variable from another script, in this case from Spotter.sqs.  You are going to have to pass the _dis variable from spotter.sqs to reveal.sqs like this:

[_dis] exec "reveal.sqs"

and the first line of reveal.sqs should be:

_dis=_this select 0

Remember, any variable that starts with _ is local and cannot be seen in other scripts.  That means you can have as many scripts as you want with _dis in them and they can all have different values (and not interfere with each other).   :)
« Last Edit: 25 Aug 2003, 16:45:04 by deaddog »

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #23 on: 25 Aug 2003, 16:56:18 »
Lol, that was probably how I was getting confused. I thought variables with an underscroll were global variables and variables without underscroll local. Right I've got it.  ;D

I did notice with a unit name put in the square brackets of a exec "script.sqs" command to use 'this select' means that you're refering to the information of that unit (position, direction, etc) when you define it as a variable and that using '_this select' means the unit itself. That added to my confusion too. I've seem to got it sorted now. Thanks.  :)

I tried the mission that you made Unnamed, and it worked pretty much exactly like I was thinking. But I was thinking that the spotter could be made to lie down when using the binoculars, to see if that animation is longer than if he was standing up using the binoculars (which I think is about 3 seconds long I think.) Also, although the spotter targets an enemy unit as his cross hairs are covering the unit and moving with it, he never actually looks at the unit through the binoculars as they're always looking in the same place which looks a bit odd, but no big problem as the script is for the sniper just to have a spotter. It's a cool looking script anyway.  ;D
« Last Edit: 25 Aug 2003, 18:04:14 by SheepOnMintSauce »

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #24 on: 25 Aug 2003, 23:29:50 »
I was just looking through the Init.sqs with your mission, and I noticed it uses 'Enemy1'. The reason I wanted to use the nearest object to detect the East soldiers was so you wouldn't have to put any name for any enemy soldiers. Since the nearest object only has a finite distance of 50 metres..

Quote
I don't think the nearestobject function is going to work. It has a finite range of 50 meters.

See? Well, because of that. Would there be another way of detecting East soldiers (or any side for that matter,) without having to name any of the units. That is what I mean by making the script flexible. So you only need to declare what the name of the spotter and the sniper is, so you could use it in any mission without having to name enemies for it. Would it be possible to use a trigger to do it like you used the trigger to detect all the units?  :-\

Unnamed

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #25 on: 26 Aug 2003, 00:43:16 »
Quote
But I was thinking that the spotter could be made to lie down when using the binoculars, to see if that animation is longer than if he was standing up using the binoculars

I would prefer the spotter to lie down, it's just when you look from his point of view he is staring at the ground. He still appears to spot ok lying down staring at the dirt, but I will have to double-check this.

Quote
Also, although the spotter targets an enemy unit as his cross hairs are covering the unit and moving with it, he never actually looks at the unit through the binoculars as they're always looking in the same place which looks a bit odd

Yeah, I think the bino's are a bit clumsy. According to the DoWatch command he should be staring right at them, no amount of adjusting will get him to lower his head  :(

The thing with Binoculars is, you don't have to be looking directly at the target. If only I could get the AI to use them long enough to scan the horizon.

Quote
Would there be another way of detecting East soldiers (or any side for that matter,) without having to name any of the units. That is what I mean by making the script flexible.

The reason I hard coded Enemy1 was to give the AI chance to spot the target before putting away his Binoculars. In an ideal world he would scan the horizon and spot the advancing group from about 1000m away, I wrote the script to test how far I could get the AI to spot a target from just knowing it's position.

But to make it generic just change:
Code: [Select]
Soldier1 DoWatch (GetPos Enemy1)To
Code: [Select]
Soldier1 DoWatch (_Temp Select 0)This will select the first target in the list.
Or
Code: [Select]
Soldier1 DoWatch (_Temp Select ((Count _Temp)-1))This will select the last target in the list.

The actual list of targets (_Temp) is populated from a Trigger, set to detect anyone within the trigger radius detected by West.

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #26 on: 26 Aug 2003, 01:16:27 »
Quote
I would prefer the spotter to lie down, it's just when you look from his point of view he is staring at the ground. He still appears to spot ok lying down staring at the dirt, but I will have to double-check this.

Ok, I imagine it should be ok though, the sniper did lie down at one point, but I guess you're right about the spotter staring at the ground. I guess it's not too big a problem though. He'll become less of a target lying down anyway.

Could you use a playmove/switchmove animation of him lying down looking through binoculars to make it look like he's looking straight ahead. The idea behind the spotter really is just to spot and work out the distances for whoever the sniper is. Looking through the binoculars from the spotters POV isn't that important. I wonder if there is a way to keep the animation of him looking through the binoculars frozen so he keeps the binoculars up.

I'll try the changing the hard coded name for the variable then, and have a look at that. Wouldn't that also effect the camera though on the 'reset view'? Again that's not important, but it's got me wondering.  ;D

Unnamed

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #27 on: 26 Aug 2003, 02:36:27 »
Quote
Could you use a playmove/switchmove animation of him lying down looking through binoculars to make it look like he's looking straight ahead. The idea behind the spotter really is just to spot and work out the distances for whoever the sniper is.

Yeah, something like this works for when he is standing:

Code: [Select]
#loop

Soldier1 PlayMove "Binoc"
~0.01

goto "loop"

But this is just an animation, so it does not affect his ability to spot.

Quote
Wouldn't that also effect the camera though on the 'reset view'?

Doh! I was curious to see what it was like from there point of view, should set it back to the guy you start with :)

Komuna

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #28 on: 26 Aug 2003, 11:40:18 »
Funny... I've just tried to make my own spotting device, yet a realistic one. All I did was scanning for enemy units along the direction which the unit is scanning (You don't want your enemy to detect you while you're aproaching behind him, right?).

The scripts and funtions contained:

- A maximum sight range for the unit, according to its weapon's settings, behaviour and skill. For example, a sniper can see up to 900 meters away, while in stealth or combat modes;

- A terrain obstacle detector (HARD TRIGNOMETRY!), which wouldn't include buildings, unless you detect them through the following process:

- An enemy list provider, such as a function which detects several nearestObjects of the enemy types (The one's that were specified in this thread);

- A looping device, wich would apply the revealing function every X+50meters along the direction the unit's facing, until the predefined distance was reached;

- An unit's direction update (setFormDir), to improve the detecting skill;

- A few other settings.

About the "HARD TRIGNOMETRY" issue: It's not as hard as I say, all you must do is getting the terrain declivity (straight line) between the Scanning unit and the ToBeRevealed unit, and check if there's any terrain height (sea level detector needed) higher than the maximum specified by the declivity function (it's like checking if there's a hill between you and the ToBerevealed unit - of course, you won't be able to see him). If the maximum is breaked, the unit won't be revealed.
   I also tried to defined the maximum sight range according to the terrain configuration.


HOWEVER, this script got really wierd on my 400MHz, as you may guess... I just don't recomend it because of the lag...

My solution? Simple. Just create several addons with new settings specified for the units, such as higher eye sensivity, ear sensivity, less camouflage and higher weapon sight range for AI. They'll look like deadly commandos (For veterans only).
« Last Edit: 26 Aug 2003, 11:42:32 by Komuna »

SheepOnMintSauce

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #29 on: 26 Aug 2003, 17:25:01 »
I was just wondering something.

Code: [Select]
#loop

Soldier1 PlayMove "Binoc"
~0.01

goto "loop"

If you put that code in with a script does it just execute that over and over, or does it execute that while carrying on with the rest of the script at the same time? I suppose the easiest way to answer that would be :
Code: [Select]
#loop

Soldier1 PlayMove "Binoc"
~0.01

goto "loop"
hint format ["Yes it does."]

 ;D

Those scripts and functions sound great Komuna. Do you plan on releasing a copy of them soon, or are you going to make them into some sort of addon? I wouldn't mind checking it out either way!  :) It sounds very well thought out anyway.

Unnamed

  • Guest
Re:Finding Nearest Enemy Unit.
« Reply #30 on: 26 Aug 2003, 20:07:34 »
Quote
If you put that code in with a script does it just execute that over and over, or does it execute that while carrying on with the rest of the script at the same time?

Yes, depending on what you want to do? You could launch it as a seperate script to run in the background, as for when you want him to start and stop the anim will depend on what you want. But a basic global boolean will do the job.

Quote
Funny... I've just tried to make my own spotting device

I would have thought the role of dedicated observer's would cover more than just snipers and Indirect fire. I'm suprised there are not any addons already, I think Invansion1944 are working on a Binocular\Radio addon or at least I found an incomplete one in the demo,and SEB Nam has one, but I'm not sure if it does anything?

Quote
A terrain obstacle detector (HARD TRIGNOMETRY!)

I've been messing with the knowsabout function, does that not tell you if you have a direct line of site? I think the problem lies with understanding what the knowsabout value should be, if you can see that unit at that range e.t.c. Then doing a comparison?

I planned on using basic trigg and detectors to map out the cover arc, even if it's just a list of which sectors are visible from his current position, once he starts....err observing. OFP's scan horizon is next to useless, unless your on a flat plain.

Quote
- A looping device, wich would apply the revealing function every X+50meters along the direction the unit's facing, until the predefined distance was reached;

I've been wondering about this, that is, the best way to scan a large area. I tend to check out the horizon first then move to mid range in a Z pattern, but as time goes on it would be more on features like woods and roads e.t.c.

Quote
- HOWEVER, this script got really wierd on my 400MHz, as you may guess... I just don't recomend it because of the lag...

The trigonometry sounds like it would push a 400MHZ running OFP? Might be better on a faster machine, I would be interested in seeing if it is.

Quote
Just create several addons with new settings specified for the units, such as higher eye sensivity, ear sensivity, less camouflage and higher weapon sight range for AI. They'll look like deadly commandos (For veterans only).

The sniper with maximum skill is a pretty lousy shot over 700m, but enough to get you flustered. I was hoping to use this with my Mortar scripts.

I tried creating my own Binocular class, and failed miserably. I'm looking for a basic example of what classes I need to inherit from, to start overriding things like eye sensivity.

Forward observers are pretty innocuous: