• 🏆 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!

circle region on target

Level 12
Joined
Oct 28, 2019
Messages
475
A ranged unit shoots an enemy from a distance, but the projectile (which follows the projectile missile system). He shoots in a random point circle region, this can make him miss the target. But if he kills units, the region circle is minor, then increases the range unit's effectiveness, and more chance to hit target

I thought of making square regions and placing them on the target, and depending on how many the ranged unit killed the region would shrink.

Any idea to make this region circular?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Regions should be used for static locations that never move.

Point With Polar Offset is the function that you want to use:
  • Set Variable CV = (Custom value of ranged unit)
  • Set Variable Offset = (Random real between 0.00 and AccuracyRange[CV])
  • Set Variable Point[0] = (Position of ranged unit)
  • Set Variable Point[1] = (Position of enemy)
  • Set Variable Point[2] = (Point1 offset by Offset towards Random angle)
  • // Create missile from Point[0] to Point[2]
AccuracyRange is a Real array that is used by each ranged unit. This is done using the Unit Indexing system in my example but you can use something else if you'd like (I recommend Unit Indexing, it's the easiest of them all).

For improving Accuracy you could also track kills using the Unit Indexing method:
  • Events
    • Unit - A unit dies
  • Conditions
    • (Unit-type of (Killing unit)) Equal to Ranged unit
  • Actions
    • Set Variable ACV = (Custom value of (Killing unit))
    • Set Variable AccuracyKills[ACV] = AccuracyKills[ACV] + 1
    • Set Variable AccuracyRange[ACV] = AccuracyTable[AccuracyKills[ACV]]
Then have an Array to represent the different Accuracy values at different kill counts:
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Variable AccuracyTable[0] = 300.00
    • Set Variable AccuracyTable[1] = 280.00
    • Set Variable AccuracyTable[2] = 280.00
    • Set Variable AccuracyTable[3] = 280.00
    • Set Variable AccuracyTable[4] = 260.00
    • Set Variable AccuracyTable[5] = 260.00
    • Set Variable AccuracyTable[6] = 260.00
    • Set Variable AccuracyTable[7] = 230.00
The more kills you have the higher the chance that the projectile will be closer to it's target. The [index] represents how many kills our ranged unit has. The value is our max offset from our target (how far away the projectile can be).

OR, if you have a simple pattern, you can avoid the above trigger and simply adjust AccuracyRange as you kill units:
  • Events
    • Unit - A unit dies
  • Conditions
    • (Unit-type of (Killing unit)) Equal to Ranged unit
  • Actions
    • Set Variable ACV = (Custom value of (Killing unit))
    • Set Variable AccuracyRange[ACV] = AccuracyRange[ACV] - 10.00
    • If AccuracyRange[ACV] Less than 0.00 Then Set Variable AccuracyRange[ACV] = 0.00 Else do nothing
I recommend using unique variables in this "A unit dies" trigger!

Edit:
Here's the triggers from my demo map:
  • Attack Projectile Launch
    • Events
      • Unit - A unit About to take damage
    • Conditions
      • (Level of Ranged Class (Hidden) for (Damage source)) Equal to 1
      • (Damage From Normal Attack) Equal to True
    • Actions
      • -------- Setup Missile System: --------
      • Set VariableSet MissileSource = (Damage source)
      • Set VariableSet MissileStart = (Position of MissileSource)
      • Set VariableSet MissileOwner = (Owner of MissileSource)
      • -------- --------
      • -------- Apply the Missile accuracy (AP_Accuracy_Offset should have an Initial Value!): --------
      • Set VariableSet AP_Target = (Damage Target)
      • Set VariableSet AP_Point = (Position of AP_Target)
      • Set VariableSet MissileFinish = (AP_Point offset by (Random real number between 0.00 and AP_Accuracy_Offset[(Custom value of MissileSource)]) towards (Random angle) degrees.)
      • Custom script: call RemoveLocation(udg_AP_Point)
      • -------- --------
      • -------- Apply some Missile properties using weapon properties (I'm using Weapon 2 for this): --------
      • Set VariableSet MissileModel = (Unit: MissileSource's Weapon String Field: Attack Projectile Art ('ua1m') at Index:1)
      • Set VariableSet MissileSpeed = (Unit: MissileSource's Weapon Real Field: Attack Projectile Speed ('ua1z') at Index:1)
      • Set VariableSet MissileArc = (Unit: MissileSource's Weapon Real Field: Attack Projectile Arc ('uma1') at Index:1)
      • Set VariableSet MissileDamage = 1000.00
      • Set VariableSet MissileStartZ = 60.00
      • Set VariableSet MissileFinishZ = 60.00
      • Set VariableSet MissileCollision = 25.00
      • Set VariableSet MissileVision = 0.00
      • -------- --------
      • -------- Setup Events used by the Missile System: --------
      • Set VariableSet Missile_onHit = Attack Projectile Impact <gen>
      • -------- --------
      • -------- LAUNCH THE MISSILE: --------
      • Trigger - Run MissileCreate <gen> (ignoring conditions)
  • Attack Projectile Impact
    • Events
    • Conditions
      • (MissileHitUnit belongs to an enemy of MissileOwner.) Equal to True
      • (MissileHitUnit is alive) Equal to True
      • (MissileHitUnit is invulnerable) Equal to False
    • Actions
      • Set VariableSet MissileDestroy = True
      • Unit - Cause MissileSource to damage MissileHitUnit, dealing MissileDamage damage of attack type Spells and damage type Normal
  • Attack Projectile Improve Accuracy
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Ranged Class (Hidden) for (Killing unit)) Equal to 1
    • Actions
      • -------- Reduce the max offset so that the projectile is more likely to be closer to the target's origin: --------
      • Set VariableSet AP_ACV = (Custom value of (Killing unit))
      • Set VariableSet AP_Accuracy_Offset[AP_ACV] = (AP_Accuracy_Offset[AP_ACV] - 50.00)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AP_Accuracy_Offset[AP_ACV] Less than 0.00
        • Then - Actions
          • Set VariableSet AP_Accuracy_Offset[AP_ACV] = 0.00
        • Else - Actions
      • -------- --------
      • Game - Display to (All players) for 30.00 seconds the text: (Accuracy Offset: + (String(AP_Accuracy_Offset[AP_ACV])))
Ranged Class (Hidden) is a passive ability based on Storm Hammers. It's icon is hidden and is given to ranged units that are meant to use this Missile System.
 

Attachments

  • Projectile System 1.w3x
    92.5 KB · Views: 1
Last edited:
Top