HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Problems with side detection system

09-30-2007, 03:52 AM#1
Gorman
i made a system that would detect if a unit was within 45 degrees of a line perpendicular to either its left or right sides, but there seems to be a problem with the code, i removed all variables, because i thought that may be causing a problem, the only variable that remains is "target" which is the unit that will be detected.

heres the code (in GUI)

Trigger:
Arc detection
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) matching (((Picked unit) has buff In range ) Equal to True)) and do (Actions)
Collapse Loop - Actions
Set Target = (Picked unit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(((Facing of ShipPlayer1) + 45.00) Less than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and ((((Facing of ShipPlayer1) + 135.00) Greater than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and (((Triggering unit) has buff In range ) Equal to True))
Collapse Then - Actions
Floating Text - Create floating text that reads Left side ready! at Point1 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 20.00 towards 90.00 degrees
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
Floating Text - Change the age of (Last created floating text) to 1.00 seconds
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
Special Effect - Destroy (Last created special effect)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(((Facing of ShipPlayer1) - 45.00) Greater than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and ((((Facing of ShipPlayer1) - 135.00) Less than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and (((Triggering unit) has buff In range ) Equal to True))
Collapse Then - Actions
Floating Text - Create floating text that reads Right side ready! at Point1 with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 20.00 towards 90.00 degrees
Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
Floating Text - Change the age of (Last created floating text) to 1.00 seconds
Special Effect - Create a special effect attached to the overhead of (Triggering unit) using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
Special Effect - Destroy (Last created special effect)
Else - Actions

im thinking its something wrong with this line:
Trigger:
(((Facing of ShipPlayer1) + 45.00) Less than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and ((((Facing of ShipPlayer1) + 135.00) Greater than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and (((Triggering unit) has buff In range ) Equal to True))
Maybe there is something i have put in backwards, or Angle from Point1 to Point2 finds the polar offset or the angle between the two vectors or some other random thing, rather then the bearing (which is what i expected it to do).

*note: this line is not retarded, the buff is called "In range" so dont think that that is a lack of buff.
Trigger:
Unit Group - Pick every unit in (Units in (Playable map area) matching (((Picked unit) has buff In range ) Equal to True)) and do (Actions)

any ideas?
09-30-2007, 10:17 PM#2
botanic
Have you added in debug messages?
10-01-2007, 01:05 AM#3
Gorman
FIXED: there was an instance of "triggering unit" used in the conditions, but there was no triggering unit =)
10-01-2007, 03:59 AM#4
Gorman
Having problems detecting units on the left side, it seems to only let me detect the unit if the original unit is either below or to the right of the target unit, here is the code(the problem area has multiple arrows around it):


Trigger:
Arc detection
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Unit - Remove Fire left cannon (dummy) from ShipPlayer1
Unit - Remove Fire right cannon (dummy) from ShipPlayer1
Set Facing = (Facing of ShipPlayer1)
Collapse >>>>>If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Facing + 45.00) Less than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and (((Facing + 135.00) Greater than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and ((Target has buff In range ) Equal to True))
Collapse Then - Actions
Unit - Add Fire left cannon (dummy) to ShipPlayer1
Else - Actions <<<<<
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Facing - 45.00) Greater than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and (((Facing - 135.00) Less than or equal to (Angle from (Position of ShipPlayer1) to (Position of Target))) and ((Target has buff In range ) Equal to True))
Collapse Then - Actions
Unit - Add Fire right cannon (dummy) to ShipPlayer1
Else - Actions
10-01-2007, 06:01 AM#5
Monky-Master
Have you tried creating a point variable, and assigning it to ShipPlayer1 ?

I think the trigger has your unit locations messed up, or isn't grabbing them correctly in the right areas.
10-01-2007, 11:18 AM#6
Gorman
hm.. i used to have it like that, but i didnt want to have too many variables, ill try putting them in once i hav a bit of time