HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit in LOS - "Discovery"

08-23-2003, 12:08 PM#1
cideh
I don't know if this has been done before. If it has, sorry then.

It took me a great while to figure out how to do this, but now it's done.

I have created a trigger that checks whether a unit is within the line of sight of another. The line of sight(from now abbreviated as "los") is as wide as the units point value.

Is this a new "discovery", or has it already been done and released to the public?

If you are interested in how I did it, reply here, and I will write it all down.

EDIT: This can be (and will be in my map) very useful if you want to have units sneak behind the back of the AI. Just set the acquisition range to 1(0 means unlimited I think), and have the unit attack the other if it's in the LoS.
08-23-2003, 01:14 PM#2
TheZaCrew
I would like to know
08-23-2003, 01:53 PM#3
Dead-Inside
If you just made "Point Valvue" equal to either Aquisition range or Attack range, then this thing explains itself. But it's always good with creative thinking. Now tell me the whole story, so there's no misunderstanding nor any problems for newbies to understand.

Regards
Dead-Inside
08-23-2003, 02:03 PM#4
cideh
Okay, here goes.

I can probably rewrite it better now that I know how to do.

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Substring((String((Angle from (Position of Peasant 0000 <gen>) to (Position of Peasant 0001 <gen>)))), 1, 1)) Not equal to -
Then - Actions
Set AngleBetweenUnits = (360.00 - (Angle from (Position of Peasant 0000 <gen>) to (Position of Peasant 0001 <gen>)))
Else - Actions
Set AngleBetweenUnits = (Real((Substring((String((Angle from (Position of Peasant 0000 <gen>) to (Position of Peasant 0001 <gen>)))), 2, 5))))

Set FacingAngle = (360.00 - (Facing of Peasant 0000 <gen>))

Set MinMaxFacing[1] = (FacingAngle + ((Real((Point-value of Peasant 0000 <gen>))) / 2.00))

Set MinMaxFacing[2] = (FacingAngle - ((Real((Point-value of Peasant 0000 <gen>))) / 2.00))

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
MinMaxFacing[1] Greater than 360.00
Then - Actions
Set MinMaxFacing[1] = (MinMaxFacing[1] - 360.00)
Else - Actions
Do nothing

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Substring((String(MinMaxFacing[2])), 1, 1)) Equal to -
Then - Actions
Set MinMaxFacing[2] = (MinMaxFacing[2] + 360.00)
Else - Actions
Do nothing

Variable Explanation
AngleBetweenUnits - Real -> Sets the angle between the units.
Cannot use normal Math - Angle between points, as it only goes from 0 to +/-180.

FacingAngle - Real -> The angle the unit is facing. As the unit is facing the opposite of the AngleBetweenUnits, I subtracted the angle from 360 to retrieve the opposite.

MinMaxFacing[1] - Real -> The MAXIMUM angle of the unit. This is used to calculate the LoS.

MinMaxFacing[2] - Real -> Same as above but MINIMUM.

The LoS in degrees is half of the unit's point value.

To find out whether the unit is in the LoS or not, check if AngleBetweenUnits is lesser than MinMaxFacing[1] and greater than MinMaxFacing[2].