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

[JASS] Converting a projectile system from points to coords

Status
Not open for further replies.
Edit: Never mind, just going to fix bpowers gui missile system instead because even if this did work it'll lag anyways.

Custom Projectiles System Is the one I have tried to convert and don't know where I messed up when everything looks copied perfectly...

[trigger=]
CPS Loop
Events
Time - Every 0.02 seconds of game time
Conditions
Actions
Set CPS_Off = True
For each (Integer CPS_Loop) from 1 to CPS_MUI, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_Missile[CPS_Loop] Not equal to No unit
Then - Actions
Custom script: set udg_cps_real[1]=GetUnitX(udg_CPS_Missile[udg_CPS_Loop])
Custom script: set udg_cps_real[2]=GetUnitY(udg_CPS_Missile[udg_CPS_Loop])
Custom script: set udg_cps_real[3]=GetUnitX(udg_CPS_TargetUnit[udg_CPS_Loop])
Custom script: set udg_cps_real[4]=GetUnitY(udg_CPS_TargetUnit[udg_CPS_Loop])
-------- --------
Custom script: set udg_cps_real[5]=bj_RADTODEG*Atan2(udg_cps_real[4]-udg_cps_sourcey[udg_CPS_Loop],udg_cps_real[3])-udg_cps_sourcex[udg_CPS_Loop]
Custom script: set udg_cps_real[6]=udg_cps_sourcex[udg_CPS_Loop] + udg_CPS_TraveledDistance[udg_CPS_Loop]*Cos(udg_cps_real[5]*bj_DEGTORAD)
Custom script: set udg_cps_real[7]=udg_cps_sourcey[udg_CPS_Loop] + udg_CPS_TraveledDistance[udg_CPS_Loop]*Sin(udg_cps_real[5]*bj_DEGTORAD)
-------- --------
-------- Setting the if block --------
Custom script: set udg_cps_real[8]=udg_cps_real[6]-udg_cps_real[3]
Custom script: set udg_cps_real[9]=udg_cps_real[7]-udg_cps_real[4]
Custom script: set udg_cps_real[10]=SquareRoot(udg_cps_real[8]*udg_cps_real[8]+udg_cps_real[9]*udg_cps_real[9])
Custom script: if udg_cps_real[10] >= udg_CPS_Speed[udg_CPS_Loop]+10 then
-------- Setting the if block --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- MOVE PROJECTILE --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- --------
Custom script: set udg_cps_real[11]=bj_RADTODEG*Atan2(udg_cps_real[4]-udg_cps_real[7],udg_cps_real[3]-udg_cps_real[6])
Custom script: set udg_cps_real[12]=udg_cps_real[6] + udg_CPS_Speed[udg_CPS_Loop] *Cos(udg_cps_real[11]*bj_DEGTORAD)
Custom script: set udg_cps_real[13]=udg_cps_real[7] + udg_CPS_Speed[udg_CPS_Loop] * Sin(udg_cps_real[11]*bj_DEGTORAD)
-------- --------
Custom script: set udg_cps_real[14]=udg_cps_sourcex[udg_CPS_Loop]-udg_cps_real[3]
Custom script: set udg_cps_real[15]=udg_cps_sourcey[udg_CPS_Loop]-udg_cps_real[4]
Custom script: set udg_CPS_ArcReal[0]=SquareRoot(udg_cps_real[14]*udg_cps_real[14]+udg_cps_real[15]*udg_cps_real[15])
Set CPS_ArcReal[1] = (CPS_ArcReal[0] / 2.00)
-------- --------
Custom script: set udg_cps_real[16]=udg_cps_sourcex[udg_CPS_Loop] + udg_CPS_ArcReal[1]*Cos(udg_cps_real[5]*bj_DEGTORAD)
Custom script: set udg_cps_real[17]=udg_cps_sourcey[udg_CPS_Loop] + udg_CPS_ArcReal[1] * Sin(udg_cps_real[5]*bj_DEGTORAD)
-------- --------
Custom script: set udg_cps_real[18]=udg_cps_real[16]-udg_cps_real[12]
Custom script: set udg_cps_real[19]=udg_cps_real[17]-udg_cps_real[13]
Custom script: set udg_CPS_ArcReal[2]=SquareRoot(udg_cps_real[18]*udg_cps_real[18]+udg_cps_real[19]*udg_cps_real[19])
Set CPS_TraveledDistance[CPS_Loop] = (CPS_TraveledDistance[CPS_Loop] + CPS_Speed[CPS_Loop])
Custom script: call SetUnitX(udg_CPS_Missile[udg_CPS_Loop], udg_cps_real[12])
Custom script: call SetUnitY(udg_CPS_Missile[udg_CPS_Loop], udg_cps_real[13])
Unit - Make CPS_Missile[CPS_Loop] face cps_real[5] over 0.00 seconds
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- HORIZONTAL ARC PROJECTILE'S CREATING --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_HArc[CPS_Loop] Equal to True
Then - Actions
Set CPS_ArcReal[3] = ((CPS_ArcReal[2] / CPS_ArcReal[1]) x CPS_HArcWidth[CPS_Loop])
Set CPS_ArcReal[4] = (CPS_ArcReal[1] - CPS_ArcReal[2])
-------- Setting the if block --------
Custom script: set udg_cps_real[20]=udg_cps_real[12]-udg_cps_real[3]
Custom script: set udg_cps_real[21]=udg_cps_real[13]-udg_cps_real[4]
Custom script: set udg_cps_real[22]=SquareRoot(udg_cps_real[20]*udg_cps_real[20]+udg_cps_real[21]*udg_cps_real[21])
Custom script: if udg_cps_real[22] >= udg_CPS_ArcReal[1] then
Set CPS_MissileDistance[CPS_Loop] = (CPS_MissileDistance[CPS_Loop] + CPS_ArcReal[3])
Custom script: else
Set CPS_MissileDistance[CPS_Loop] = (CPS_MissileDistance[CPS_Loop] - CPS_ArcReal[3])
-------- Setting the if block --------
Custom script: endif
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_HArcLeftRight[CPS_Loop] Equal to True
Then - Actions
Custom script: set udg_cps_real[23]=bj_RADTODEG*(Atan2(udg_cps_real[4]-udg_cps_real[7],udg_cps_real[6]-udg_cps_real[3]) + 90)
Custom script: set udg_cps_real[24]=udg_cps_real[12] + Cos(udg_cps_real[23])*udg_CPS_MissileDistance[udg_CPS_Loop]
Custom script: set udg_cps_real[25]=udg_cps_real[13] + Sin(udg_cps_real[23])*udg_CPS_MissileDistance[udg_CPS_Loop]
Else - Actions
Custom script: set udg_cps_real[23]=bj_RADTODEG*(Atan2(udg_cps_real[4]-udg_cps_real[7],udg_cps_real[6]-udg_cps_real[3]) - 90)
Custom script: set udg_cps_real[24]=udg_cps_real[12] +udg_CPS_MissileDistance[udg_CPS_Loop]* Cos(udg_cps_real[23]*bj_DEGTORAD)
Custom script: set udg_cps_real[25]=udg_cps_real[13] + udg_CPS_MissileDistance[udg_CPS_Loop] * Sin(udg_cps_real[23]*bj_DEGTORAD)
-------- Setting the if block --------
-------- instead of copying the code, just use whats already done above since its before the if --------
Custom script: if udg_cps_real[22] >= udg_CPS_ArcReal[1] then
Custom script: set udg_CPS_ArcReal[5]=bj_RADTODEG*Atan2(udg_cps_real[2]-udg_cps_real[25],udg_cps_real[1]-udg_cps_real[24])
Custom script: else
Custom script: set udg_CPS_ArcReal[5]=bj_RADTODEG*Atan2(udg_cps_real[3]-udg_cps_real[25],udg_cps_real[4]-udg_cps_real[24])
-------- Setting the if block --------
Custom script: endif
Custom script: call SetUnitX(udg_CPS_Missile[udg_CPS_Loop], udg_cps_real[24])
Custom script: call SetUnitY(udg_CPS_Missile[udg_CPS_Loop], udg_cps_real[25])
Unit - Make CPS_Missile[CPS_Loop] face CPS_ArcReal[5] over 0.00 seconds
Else - Actions
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- VERTICAL ARC PROJECTILE'S SETTING --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_VArc[CPS_Loop] Equal to True
Then - Actions
Set CPS_ArcReal[3] = ((CPS_ArcReal[2] / CPS_ArcReal[1]) x CPS_VArcHeight[CPS_Loop])
Set CPS_ArcReal[4] = (CPS_ArcReal[1] - CPS_ArcReal[2])
Custom script: set udg_cps_real[26]=udg_cps_real[12]-udg_cps_real[3]
Custom script: set udg_cps_real[27]=udg_cps_real[13]-udg_cps_real[4]
Custom script: set udg_cps_real[28]=SquareRoot(udg_cps_real[26]*udg_cps_real[26]+udg_cps_real[27]*udg_cps_real[27])
Custom script: if udg_cps_real[28] >= udg_CPS_ArcReal[1] then
Set CPS_ArcReal[5] = ((Current flying height of CPS_Missile[CPS_Loop]) + CPS_ArcReal[3])
Set CPS_ArcReal[6] = (2.50 x (Atan((CPS_ArcReal[5] / CPS_ArcReal[4]))))
Custom script: else
Set CPS_ArcReal[5] = ((Current flying height of CPS_Missile[CPS_Loop]) - CPS_ArcReal[3])
Set CPS_ArcReal[6] = (1.50 x (Atan((CPS_ArcReal[4] / CPS_ArcReal[5]))))
-------- Setting the if block --------
Custom script: endif
Custom script: call SetUnitAnimationByIndex( udg_CPS_Missile[udg_CPS_Loop], R2I(udg_CPS_ArcReal[6]) )
Animation - Change CPS_Missile[CPS_Loop] flying height to CPS_ArcReal[5] at 0.00
Else - Actions
Custom script: else
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- CAUSE DAMAGE AND CREATE EFFECTS --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
Set SPSD_Caster = CPS_Source[CPS_Loop]
Set SPSD_TargetUnit = CPS_TargetUnit[CPS_Loop]
Set SPSD_TargetPoint = (Position of CPS_TargetUnit[CPS_Loop])
Custom script: if udg_CPS_Trigger[udg_CPS_Loop] != null then
Custom script: call TriggerExecute(udg_CPS_Trigger[udg_CPS_Loop])
Custom script: endif
Set CPS_Point[12] = (Position of CPS_TargetUnit[CPS_Loop])
Special Effect - Create a special effect at CPS_Point[12] using CPS_Impact[CPS_Loop]
Special Effect - Destroy (Last created special effect)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_UnitOrPoint[CPS_Loop] Equal to True
Then - Actions
Unit - Cause CPS_Source[CPS_Loop] to damage CPS_TargetUnit[CPS_Loop], dealing CPS_Damage[CPS_Loop] damage of attack type CPS_AttackType[CPS_Loop] and damage type CPS_DamageType[CPS_Loop]
Else - Actions
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
Custom script: set bj_wantDestroyGroup = true
Unit Group - Pick every unit in (Units within CPS_AoE[CPS_Loop] of CPS_Point[12]) and do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Picked unit) is A structure) Equal to False
((Picked unit) is Mechanical) Equal to False
((Picked unit) is alive) Equal to True
((Picked unit) belongs to an enemy of (Owner of CPS_Source[CPS_Loop])) Equal to True
Then - Actions
Unit - Cause CPS_Source[CPS_Loop] to damage (Picked unit), dealing CPS_Damage[CPS_Loop] damage of attack type CPS_AttackType[CPS_Loop] and damage type CPS_DamageType[CPS_Loop]
Else - Actions
Unit - Remove CPS_TargetUnit[CPS_Loop] from the game
Custom script: call RemoveLocation(udg_CPS_Point[12])
Custom script: call RemoveLocation(udg_SPSD_TargetPoint)
Unit - Remove CPS_Missile[CPS_Loop] from the game
Set CPS_Missile[CPS_Loop] = No unit
Custom script: endif
Set CPS_Off = False
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_Off Equal to True
Then - Actions
Set CPS_MUI = 0
Trigger - Turn off (This trigger)
Else - Actions

[/trigger]
[trigger=]
CPS Creating
Events
Conditions
Actions
Set CPS_MUI = (CPS_MUI + 1)
Set CPS_AoE[CPS_MUI] = Projectile_AoE
Set CPS_AttackType[CPS_MUI] = Projectile_AttackType
Set CPS_Damage[CPS_MUI] = Projectile_Damage
Set CPS_DamageType[CPS_MUI] = Projectile_DamageType
Set CPS_Destroy[CPS_MUI] = Projectile_DestroyTree
Set CPS_Impact[CPS_MUI] = Projectile_Impact
Set CPS_UnitOrPoint[CPS_MUI] = Projectile_UnitOrPoint
Set CPS_Speed[CPS_MUI] = Projectile_Speed
Set CPS_VArc[CPS_MUI] = Projectile_VArc
Set CPS_VArcHeight[CPS_MUI] = Projectile_VArcHeight
Set CPS_Height[CPS_MUI] = Projectile_Height
Set CPS_HArc[CPS_MUI] = Projectile_HArc
Set CPS_HArcWidth[CPS_MUI] = Projectile_HArcWidth
Set CPS_HArcLeftRight[CPS_MUI] = Projectile_HArcLeftOrRight
Set CPS_Source[CPS_MUI] = Projectile_Source
Custom script: set udg_cps_sourcex[udg_CPS_MUI]=GetUnitX(udg_Projectile_Source)
Custom script: set udg_cps_sourcey[udg_CPS_MUI]=GetUnitY(udg_Projectile_Source)
Set CPS_Trigger[CPS_MUI] = Projectile_Trigger
Set CPS_TraveledDistance[CPS_MUI] = 0.00
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Projectile_UnitOrPoint Equal to True
Then - Actions
Set CPS_TargetUnit[CPS_MUI] = Projectile_TargetUnit
Custom script: set udg_cps_real[29]=GetUnitX(udg_Projectile_TargetUnit)
Custom script: set udg_cps_real[30]=GetUnitY(udg_Projectile_TargetUnit)
Custom script: set udg_CPS_Angle=bj_RADTODEG*Atan2(udg_cps_real[30]-udg_cps_sourcey[udg_CPS_MUI],udg_cps_real[31]-udg_cps_sourcey[udg_CPS_MUI])
Else - Actions
Unit - Create 1 CPS_DummyType for (Owner of CPS_Source[CPS_MUI]) at Projectile_TargetPoint facing Default building facing degrees
Set CPS_TargetUnit[CPS_MUI] = (Last created unit)
Set CPS_Point[2] = (Position of (Last created unit))
Set CPS_Angle = (Angle from CPS_Point[1] to CPS_Point[2])
Custom script: call RemoveLocation(udg_CPS_Point[2])
Custom script: set udg_CPS_Missile[udg_CPS_MUI]=CreateUnit(GetOwningPlayer(udg_Projectile_Source),udg_CPS_DummyType,udg_cps_sourcex[udg_CPS_MUI],udg_cps_sourcey[udg_CPS_MUI],udg_CPS_Angle)
Unit - Add Crow Form to CPS_Missile[CPS_MUI]
Unit - Remove Crow Form from CPS_Missile[CPS_MUI]
Custom script: call SetUnitX(udg_CPS_Missile[udg_CPS_MUI],udg_cps_sourcex[udg_CPS_MUI])
Custom script: call SetUnitY(udg_CPS_Missile[udg_CPS_MUI],udg_cps_sourcey[udg_CPS_MUI])
Animation - Change CPS_Missile[CPS_MUI] flying height to Projectile_Height at 0.00
Animation - Change CPS_Missile[CPS_MUI]'s size to (Projectile_Size%, 0.00%, 0.00%) of its original size
Special Effect - Create a special effect attached to the origin of CPS_Missile[CPS_MUI] using Projectile_Model
Set CPS_MissileDistance[CPS_MUI] = 0.00
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Projectile_VArc Equal to False
Then - Actions
Custom script: call SetUnitAnimationByIndex( udg_CPS_Missile[udg_CPS_MUI] , 90 )
Else - Actions
Custom script: call RemoveLocation(udg_Projectile_TargetPoint)
Custom script: call TriggerExecute( gg_trg_CPS_Init )
Trigger - Turn on CPS Loop <gen>
[/trigger]
[trigger=]
CPS Init
Events
Map initialization
Conditions
Actions
Set CPS_DummyType = Dummy
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- RESET SETTINGS --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
Set Projectile_AoE = 0.00
Set Projectile_AttackType = Magic
Set Projectile_Damage = 0.00
Set Projectile_DamageType = Normal
Set Projectile_DestroyTree = False
Set Projectile_HArc = False
Set Projectile_Height = 50.00
Set Projectile_Impact = none
Set Projectile_Model = none
Set Projectile_Size = 100.00
Set Projectile_Source = No unit
Set Projectile_Speed = 25.00
Set Projectile_TargetUnit = No unit
Custom script: set udg_Projectile_Trigger = null
Set Projectile_UnitOrPoint = True
Set Projectile_VArc = False
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
-------- DUMMY CREATING --------
-------- [][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][]X[][] --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CPS_Dummy Equal to No unit
Then - Actions
Set TempPoint = (Center of (Playable map area))
Unit - Create 1 CPS_DummyType for Neutral Passive at TempPoint facing Default building facing degrees
Unit - Add Harvest (Neutral) to (Last created unit)
Set CPS_Dummy = (Last created unit)
Custom script: call RemoveLocation(udg_TempPoint)
Else - Actions
[/trigger]


 

Attachments

  • System - Custom Projectiles coords attempt.w3x
    67 KB · Views: 19
Last edited:
You should probably start by renaming your variables in a readable way, like cps_missile_x instead of cps_real[1], or it's going to be very difficult to work with it.
I considered that but decided it wasnt worth the extra variable space and was planning on using comments.

Edit: Realized that makes helping me almost impossible, will try to update later with comments at least.
 
Last edited:
Status
Not open for further replies.
Top