• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Selecting units in a cone

Status
Not open for further replies.

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Pick units around the caster and then compare the angle between picked unit and caster to the angle between the target point and the caster. You will get a circular sector shape.
You should calculate the angle between the target point and the caster first and store it in a variable, so you don't have to do it in the unit group loop.
 
Level 13
Joined
Oct 12, 2016
Messages
769
Alternatively, you could do something like setting the level of Forked Lightning to a factor of the related stat.
Of course, there's limits to this if you have heroes with obscene amounts of stats.

For Example:
In my map, the maximum intelligence a hero can have is 90.
I chose to increase the damage of any spell with every 5 points of a stat. In other words: the maximum ability level for Forked Lightning is 18.
- (side note: I don't recommend going over 20 levels for any ability... it causes epic object data lag and greatly increased map loading times)
Finally, I made a trigger that changes the level of Forked Lightning whenever the hero levels up or picks up an item with +stats.
 
Level 2
Joined
Aug 29, 2015
Messages
7

hahaha :grin:

  • Cone
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Forked Lightning Mage
    • Actions
      • Set UnitGroup_FL_Targets[Integer_FL_Index] = (Units within 600.00 of Point_FL_Caster[Integer_FL_Index] matching ((((Angle from Point_FL_Caster[Integer_FL_Index] to Point_FL_Target[Integer_FL_Index]) Greater than or equal to 45.00) and ((Angle from Point_FL_Caster[Integer_FL_Index] to Point_FL_Target[Integer_FL_Index]) Less than or equal to 135.00))


EDIT:
is this possible?
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
hahaha :grin:

  • Cone
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Forked Lightning Mage
    • Actions
      • Set UnitGroup_FL_Targets[Integer_FL_Index] = (Units within 600.00 of Point_FL_Caster[Integer_FL_Index] matching ((((Angle from Point_FL_Caster[Integer_FL_Index] to Point_FL_Target[Integer_FL_Index]) Greater than or equal to 45.00) and ((Angle from Point_FL_Caster[Integer_FL_Index] to Point_FL_Target[Integer_FL_Index]) Less than or equal to 135.00))


EDIT:
is this possible?

No.

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Forked Lightning Mage
  • Actions
    • Set ConeAngle = 30.00
    • Set CastingUnit = (Triggering unit)
    • Set CasterPoint = Position of CastingUnit
    • Set TargetPoint = Position of (Target unit of Ability being cast)
    • Set TargetsUnitGroup = Units within 600 range of CasterPont
    • Set SpellAngle = Angle between (CasterPoint) and (TargetPoint)
    • Custom script: call RemoveLocation(udg_TargetPoint)
    • Unit Group - Pick all units in (TargetUnitGroup) and do actions
      • Loop - Actions
        • Set TempUnit = (Picked unit)
        • Set TempPoint = Position of TempUnit
        • If - Then - Else (Multiple actions)
          • If - Conditions
            • Boolean comparison - (Owner of CastingUnit) is an enemy of (Owner of TempUnit) equals to true
            • Real comparison - If angle between CastterPoint and TempPoint Greater than or equal to (SpellAngle - ConeAngle)
            • Real comparison - If angle between CastterPoint and TempPoint Less than or equal to (SpellAngle + ConeAngle)
          • Then - Actions
            • >>>>>>> Insert Spell Effects here <<<<<<<<
          • Else - Actions
        • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: call RemoveLocation(udg_CasterPoint)
    • Custom script: call DestroyGroup(udg_TargetUnitGroup)
You are looking at something like this.
You may have to add a full circle to all angles to avoid any quadrant errors.
Also, I am not entirely sure if some of those functions work in Radians instead of Degree.

 
I would import for example [vJASS] - [Snippet] Field of View (IsUnitInSight + IsUnitBehind), and then:
  • Set Caster = <Yout Unit>
  • Set AngleTollerance = 60.00
  • Set Group = UnitGroup - PickAllUnits In Range of 600 of Caster
  • Unit Group - Pick All Units in Group
    • Set Target = (Picked Unit)
    • Custom script: set udg_IsUnitInCone = IsUnitInSightOfUnit(udg_Caster, udg_Target, udg_AngleTollerance)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (IsUnitInCone Equals TRUE)
      • Then - Actions
        • ---- Unit is in cone
      • Else - Actions
        • ---- Unit is not in cone
Required variables
  • Caster [unit]
  • Target [unit]
  • Group [unit group]
  • AngleTollerance [real]
  • IsUnutInCone [boolean]
 
Last edited:
Status
Not open for further replies.
Top