A Lightning until detecting a cliff [PROBLEM]

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
Hello guys, well, I am trying to make a unit cast a lightning that stops with the nearest cliff ahead (I mean in front of the unit, not detecting the closest cliff)

I have this trigger and it doesn't seem to work :

A Lightning that stops with the nearest cliff ahead
  • Actions
    • Set i = 1
    • For Each Integer (f) from 1 to i --- do actions
      • Loop - Actions
        • Set TempPoint = (Position of -My Unit- offset by (f x 10) towards (Facing Angle of (My Unit)
        • If/Then/Else
          • Conditions
            • Terrain Cliff Height in TempPoint Equal to 2
          • Then - Actions
            • Set i = i +1
          • Else - Actions
            • Lightning - Create a lightning effect between source 'TempPoint' and Target '(Position of MyUnit)'
          • -- removed leaks after that
 
The logic in your trigger doesn't make sense. Your loop increment the maximum i value when the location is on cliff level 2, else you create a lightning effect when it is on level 1.

You should loop towards a direction, create a point in a certain interval until you hit a cliff greater than your unit. When you hit a cliff, you should break out of a loop and use the last created point as the target location for your lightning.

  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Temp_Int = 0
      • Set unitCliffLevel = (Terrain cliff level at (Position of Peasant 0000 <gen>))
      • Custom script: loop
      • Set Temp_Point = ((Position of Peasant 0000 <gen>) offset by (16.00 x (Real(Temp_Int))) towards (Facing of Peasant 0000 <gen>) degrees)
      • Custom script: exitwhen GetTerrainCliffLevelBJ(udg_Temp_Point) > udg_unitCliffLevel or udg_Temp_Int * 16 == 600
      • Set Temp_Int = (Temp_Int + 1)
      • Custom script: endloop
      • Lightning - Create a Chain Lightning - Primary lightning effect from source (Position of Peasant 0000 <gen>) to target Temp_Point
 
Status
Not open for further replies.
Top