• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Position of Unit... is not position of unit.

Status
Not open for further replies.
Level 7
Joined
May 11, 2010
Messages
278
Yadda yadda, projectile system, yadda yadda.

  • Projectile Test
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Projectile Test
    • Actions
      • Set projectileMaxIndex = (projectileMaxIndex + 1)
      • Set TempNumber = (Player number of (Owner of (Triggering unit)))
      • Set ProjectileCaster[projectileMaxIndex] = (Triggering unit)
      • -------- The unit that casts the ability. --------
      • Set ProjectileTarget[projectileMaxIndex] = TargetofPlayer[TempNumber]
      • -------- The target the attack will be aimed at. --------
      • Set ProjectileDamage[projectileMaxIndex] = (20.00 x (DamageModifier[TempNumber] x DamageReduction[(Player number of (Owner of Target[maxIndex]))]))
      • -------- The damage the attack will deal. --------
      • -------- Change only the "1.00". --------
      • Set ProjectileRange[projectileMaxIndex] = 500.00
      • -------- How far the projectile will travel. --------
      • Set ProjectileDuration[projectileMaxIndex] = 2.00
      • -------- The max time the projectile will spend in the air. --------
      • Set ProjectileImpactArea[projectileMaxIndex] = 75.00
      • -------- How close to a unit the projectile must get to hit. --------
      • Set ProjectilePoiseDamage[projectileMaxIndex] = 0
      • -------- How much the enemies poise will be reduced. --------
      • Set ProjectileAnimation[projectileMaxIndex] = attack
      • -------- The animation the caster will play. --------
      • Set ProjectileModelType[projectileMaxIndex] = Peasant
      • -------- The model of the projectile. It's a unit. --------
      • Set ProjectileManaGen[projectileMaxIndex] = 5.00
      • -------- How much mana will be generated from the attack. --------
      • Set ProjectileSoundLaunch[projectileMaxIndex] = StormBoltLaunch <gen>
      • -------- The sound that plays on launch. --------
      • Set ProjectileSoundImpact[projectileMaxIndex] = ThunderBoltMissileDeath <gen>
      • -------- The sound that plays on hit. --------
      • Set ProjectileExtraEffect[projectileMaxIndex] = None <gen>
      • -------- Does the ability have any extra effects? Choose trigger here. --------
      • -------- Last, plays the animation and sets the last variables. --------
      • Wait 0.00 seconds
      • Unit - Order (Triggering unit) to Stop
      • Unit - Make (Triggering unit) face ProjectileTarget[projectileMaxIndex] over 0.00 seconds
      • Animation - Play (Triggering unit)'s ProjectileAnimation[projectileMaxIndex] animation
      • Set TempPoint = (Position of (Triggering unit))
      • Sound - Play ProjectileSoundLaunch[projectileMaxIndex] at 100.00% volume, located at TempPoint with Z offset 0.00
      • Unit - Create 1 ProjectileModelType[projectileMaxIndex] for (Owner of (Triggering unit)) at TempPoint facing Default building facing degrees
      • Set ProjectileModel[projectileMaxIndex] = (Last created unit)
      • Set TempPoint2 = (Position of ProjectileTarget[projectileMaxIndex])
      • Set ProjectileAngle[projectileMaxIndex] = (Angle from TempPoint to TempPoint2)
      • Set ProjectileEndPoint[projectileMaxIndex] = (TempPoint offset by ProjectileRange[projectileMaxIndex] towards ProjectileAngle[projectileMaxIndex] degrees)
      • Set ProjectileTickMovement[projectileMaxIndex] = (ProjectileRange[projectileMaxIndex] / (ProjectileDuration[projectileMaxIndex] x 0.03))
      • -------- Runs the triggers. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • projectileMaxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on ProjectileLoop <gen>
        • Else - Actions
      • -------- Runs the triggers. --------
  • ProjectileLoop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer ProjectileTempIndex) from 1 to projectileMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ProjectileDuration[ProjectileTempIndex] Greater than 0.00
            • Then - Actions
              • Set ProjectileDuration[ProjectileTempIndex] = (ProjectileDuration[ProjectileTempIndex] - 0.03)
              • Set ProjectileTempPoint[1] = (Position of ProjectileModel[ProjectileTempIndex])
              • Set ProjectileTempPoint[2] = (ProjectileTempPoint[1] offset by ProjectileTickMovement[ProjectileTempIndex] towards ProjectileAngle[ProjectileTempIndex] degrees)
              • Unit - Move ProjectileModel[ProjectileTempIndex] instantly to ProjectileTempPoint[2]
              • Set TempGroup = (Units within ProjectileImpactArea[ProjectileTempIndex] of ProjectileTempPoint[2] matching (((Matching unit) belongs to an ally of (Owner of ProjectileCaster[ProjectileTempIndex])) Equal to False))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TempGroup) Greater than or equal to 1
                • Then - Actions
                  • Unit Group - Pick every unit in TempGroup and do (Actions)
                    • Loop - Actions
                      • Unit - Cause ProjectileCaster[ProjectileTempIndex] to damage (Picked unit), dealing ProjectileDamage[ProjectileTempIndex] damage of attack type Chaos and damage type Normal
                      • Set TempNumber = (Player number of (Owner of (Picked unit)))
                      • Set PoiseCurrent[TempNumber] = (PoiseCurrent[TempNumber] - ProjectilePoiseDamage[ProjectileTempIndex])
                      • Set PoiseTime[TempNumber] = PoiseRecoveryTime
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • PoiseCurrent[TempNumber] Less than or equal to 0
                        • Then - Actions
                          • Trigger - Run Poise Break <gen> (ignoring conditions)
                        • Else - Actions
                      • Trigger - Run ExtraEffect[TempIndex] (ignoring conditions)
                  • Unit - Set mana of ProjectileCaster[ProjectileTempIndex] to ((Mana of ProjectileCaster[ProjectileTempIndex]) + ProjectileManaGen[ProjectileTempIndex])
                  • Sound - Play ProjectileSoundImpact[ProjectileTempIndex] at 100.00% volume, located at TempPoint2 with Z offset 0.00
                  • -------- Index Recycling --------
                  • Trigger - Run ProjectileIndexRecycle <gen> (ignoring conditions)
                • Else - Actions
            • Else - Actions
              • Unit - Remove ProjectileModel[ProjectileTempIndex] from the game
              • Floating Text - Create floating text that reads Miss! at ProjectileEndPoint[ProjectileTempIndex] with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 10.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
              • -------- Index Recycling --------
              • Trigger - Run ProjectileIndexRecycle <gen> (ignoring conditions)
  • ProjectileIndexRecycle
    • Events
    • Conditions
    • Actions
      • Set ProjectileAngle[TempIndex] = ProjectileAngle[projectileMaxIndex]
      • Set ProjectileCaster[ProjectileTempIndex] = ProjectileCaster[projectileMaxIndex]
      • Set ProjectileDamage[ProjectileTempIndex] = ProjectileDamage[projectileMaxIndex]
      • Set ProjectileDuration[ProjectileTempIndex] = ProjectileDuration[projectileMaxIndex]
      • Set ProjectileEndPoint[ProjectileTempIndex] = ProjectileEndPoint[projectileMaxIndex]
      • Set ProjectileExtraEffect[ProjectileTempIndex] = ProjectileExtraEffect[projectileMaxIndex]
      • Set ProjectileImpactArea[ProjectileTempIndex] = ProjectileImpactArea[projectileMaxIndex]
      • Set ProjectileManaGen[ProjectileTempIndex] = ProjectileManaGen[projectileMaxIndex]
      • Set ProjectileModel[ProjectileTempIndex] = ProjectileModel[projectileMaxIndex]
      • Set ProjectilePoiseDamage[ProjectileTempIndex] = ProjectilePoiseDamage[projectileMaxIndex]
      • Set ProjectileRange[ProjectileTempIndex] = ProjectileRange[projectileMaxIndex]
      • Set ProjectileSoundImpact[ProjectileTempIndex] = ProjectileSoundImpact[projectileMaxIndex]
      • Set ProjectileTickMovement[ProjectileTempIndex] = ProjectileTickMovement[projectileMaxIndex]
      • Set projectileMaxIndex = (projectileMaxIndex - 1)
      • Set ProjectileTempIndex = (ProjectileTempIndex - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • projectileMaxIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Skip remaining actions
        • Else - Actions
The unit is created in a corner of the map, instead of where it should be.
How do I fix this? Is there anything else I've done wrong? (Yes, this leaks. I know. Will fix.)
Poise Break and ExtraEffect[] is currently two empty triggers (I haven't made them yet).
 
Level 7
Joined
May 11, 2010
Messages
278
the wait in ur cast trigger could be messing it up.

u dont need that ProjectileTempIndex just use a normal tempInt

If I don't use the wait, the stop command will cause the spell to not go on cooldown. If I don't use the stop command, the animation won't play. If you have a better solution, I'd be delighted to hear it, because I know this is sub-par.

I use ProjectileTempIndex because i already use TempIndex in another system like this one (however, that system works).

----------------

I realized what the issue is. The formula for calculating distance per tick is faulty, causing the unit to be moved a huge distance each tick. This makes it seem like it spawns in the wrong place.

Edit: Yep. That fixed it. This can be marked as solved.
 
Last edited:
Level 7
Joined
May 11, 2010
Messages
278
a temp integer is a temp integer. that means u can use it in all of ur spells and it wont cause a problem.

u cant use a temp integer with a wait. ( because then its not a temp int)

i use tempInt or tempUnit in just about every spell there will never be a conflict unless i use a wait.

Okay! Thanks!

Instead of having a 0 second wait to make the stop command work on instant self cast abilities, you can pause and instantly unpause the unit before issueing the stop order. Sounds like blizzard magic and makes no sense, but it works in several cases.

Awesome! Thanks!
 
Status
Not open for further replies.
Top