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

[Spell] rotating objects around a unit causes minor problem

Status
Not open for further replies.
Level 12
Joined
Jan 13, 2008
Messages
559
Hi, I am trying to rotate objects around the unit in the center and move them closer and closer towards it. This works fine except for the very first spawned object and I don't understand why. The first object seems to spawn not with an offset of 600 but more? i really dont know.

Any help is appreciated. Thanks

Code:
Evil Sorcerer Shots Cast
    Events
        Time - Every 4.00 seconds of game time
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (evil sorcerer area <gen> contains player_hero[1]) Equal to True
                (evil sorcerer area <gen> contains player_hero[0]) Equal to True
        (Evil Sorcerer 0059 <gen> is alive) Equal to True
    Actions
        Custom script:   set bj_wantDestroyGroup=true
        Animation - Play Evil Sorcerer 0059 <gen>'s stand channel animation
        Sound - Play CharmTarget1 <gen>
        For each (Integer A) from 0 to 8, do (Actions)
            Loop - Actions
                Set z_leakRemove_point = (Position of Evil Sorcerer 0059 <gen>)
                Unit - Create 1 dummy_evilSorcerer_shots for Player 11 (Dark Green) at (z_leakRemove_point offset by 600.00 towards (270.00 + ((Real((Integer A))) x 40.00)) degrees) facing ((Angle from (Position of (Last created unit)) to (Position of Evil Sorcerer 0059 <gen>)) + 90.00) degrees
                Unit - Add a 5.50 second Generic expiration timer to (Last created unit)
                Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
                Special Effect - Destroy (Last created special effect)
                Custom script:   call RemoveLocation(udg_z_leakRemove_point)


Code:
Move shots
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units of type dummy_evilSorcerer_shots) and do (Actions)
            Loop - Actions
                Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 2.00 towards (Facing of (Picked unit)) degrees)
                Unit - Make (Picked unit) face ((Angle from (Position of Evil Sorcerer 0059 <gen>) to (Position of (Picked unit))) + 120.00) over 0.00 seconds
Screenshot_2.png
Screenshot_1.png
 
Level 13
Joined
May 10, 2009
Messages
868
Whenever you're about to create those dummies, you're doing this:

  • Unit - Create 1 dummy_evilSorcerer_shots for Player 11 (Dark Green) at (z_leakRemove_point offset by 600.00 towards (270.00 + ((Real((Integer A))) x 40.00)) degrees) facing ((Angle from (Position of (Last created unit)) to (Position of Evil Sorcerer 0059 <gen>)) + 90.00) degrees
"Angle from (Position of (Last created unit)) to (Position of Evil Sorcerer 0059 <gen>)"

Last created unit might be pointing to another unit. It can't refer to the dummy unit, because it's not created yet. Also, the Polar Projection creates another point/location, and you're not storing it in a variable. It's leaking for now.

You could do this in order to fix it:
  • Actions
    • Animation - Play Evil Sorcerer 0059 <gen>'s stand channel animation
    • Sound - Play CharmTarget1 <gen>
    • Set z_leakRemove_point = (Position of Evil Sorcerer 0059 <gen>)
    • For each (Integer A) from 0 to 8, do (Actions)
      • Loop - Actions
        • Set point = (z_leakRemove_point offset by 600.00 towards (270.00 + ((Real((Integer A))) x 40.00)) degrees)
        • Unit - Create 1 dummy_evilSorcerer_shots for Player 11 (Dark Green) at point facing ((Angle from point to z_leakRemove_point) + 90.00) degrees
        • Unit - Add a 5.50 second Generic expiration timer to (Last created unit)
        • Special Effect - Create a special effect at (Position of (Last created unit)) using Abilities\Weapons\FrostWyrmMissile\FrostWyrmMissile.mdl
        • Special Effect - Destroy (Last created special effect)
        • Custom script: call RemoveLocation(udg_point)
    • Custom script: call RemoveLocation(udg_z_leakRemove_point)
The set bj_wantDestroyGroup = true should be placed here:

  • Move shots
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type dummy_evilSorcerer_shots) and do (Actions)
        • Loop - Actions
          • Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 2.00 towards (Facing of (Picked unit)) degrees)
          • Unit - Make (Picked unit) face ((Angle from (Position of Evil Sorcerer 0059 <gen>) to (Position of (Picked unit))) + 120.00) over 0.00 seconds
 
Level 13
Joined
May 10, 2009
Messages
868
Either way, it's better to create a unit group when the game starts and only add the units that are supposed to turn around the caster - It wouldn't be a good idea to enumerate through all units of a player just for that.
 
Status
Not open for further replies.
Top