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

Location issue

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Hi,

This spell is meant to cause the user to bounce around un-controllably for a while, dealing damage when it reaches each location.

Anyway the issue lies where sometimes the user flies to the center of the map (or near it) rather than moving to a nearby location. The main issue with this is that I have been put on the side of a cliff because of this. Any ideas?

  • BoH Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ball of Happiness
    • Actions
      • Trigger - Run Challenges The D <gen> (checking conditions)
      • Set BoH_MaxIndex = (BoH_MaxIndex + 1)
      • Set BoH_CasterUnit[BoH_MaxIndex] = (Triggering unit)
      • Set BoH_Bounces[BoH_MaxIndex] = (4 + (((Level of Ball of Happiness for (Triggering unit)) - 1) / 2))
      • Set BoH_Dmg[BoH_MaxIndex] = ((750.00 + (750.00 x (Real((Level of Ball of Happiness for (Triggering unit)))))) + ((Real((Agility of (Triggering unit) (Include bonuses)))) x 5.00))
      • Set BoH_TargetPoint[BoH_MaxIndex] = (Target point of ability being cast)
      • Set TempPoint = (Position of (Triggering unit))
      • Unit - Create 1 Dummy (Ball of Happiness) for (Owner of (Triggering unit)) at TempPoint facing Default building facing degrees
      • Set BoH_DummyUnit[BoH_MaxIndex] = (Last created unit)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BoH_MaxIndex Greater than or equal to 1
        • Then - Actions
          • Trigger - Turn on BoH Loop <gen>
        • Else - Actions
  • BoH Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BoH_LoopInt) from 1 to BoH_MaxIndex, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of BoH_CasterUnit[BoH_LoopInt])
          • -------- Move --------
          • Unit - Turn collision for BoH_CasterUnit[BoH_LoopInt] Off
          • Set TempPoint2 = (TempPoint offset by 20.00 towards (Angle from TempPoint to BoH_TargetPoint[BoH_LoopInt]) degrees)
          • Unit - Move BoH_CasterUnit[BoH_LoopInt] instantly to TempPoint2, facing BoH_TargetPoint[BoH_LoopInt]
          • Unit - Move BoH_DummyUnit[BoH_LoopInt] instantly to TempPoint2, facing BoH_TargetPoint[BoH_LoopInt]
          • Custom script: call RemoveLocation(udg_TempPoint2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Distance between TempPoint and BoH_TargetPoint[BoH_LoopInt]) Less than or equal to 20.00
                  • (Terrain pathing at TempPoint of type Walkability is off) Equal to True
                  • (BoH_CasterUnit[BoH_LoopInt] is dead) Equal to True
            • Then - Actions
              • -------- Explode --------
              • Special Effect - Create a special effect at TempPoint using Abilities\Spells\Undead\FrostNova\FrostNovaTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set TempUnitGroup = (Units within 350.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of BoH_CasterUnit[BoH_LoopInt])) Equal to True)))
              • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
                • Loop - Actions
                  • Unit - Cause BoH_DummyUnit[BoH_LoopInt] to damage (Picked unit), dealing BoH_Dmg[BoH_LoopInt] damage of attack type Spells and damage type Universal
              • Custom script: call DestroyGroup(udg_TempUnitGroup)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • And - All (Conditions) are true
                    • Conditions
                      • (BoH_CasterUnit[BoH_LoopInt] is alive) Equal to True
                      • BoH_Bounces[BoH_LoopInt] Greater than or equal to 1
                • Then - Actions
                  • -------- Bounce --------
                  • Custom script: call RemoveLocation(udg_BoH_TargetPoint[udg_BoH_LoopInt])
                  • Set BoH_TargetPoint[BoH_LoopInt] = (TempPoint offset by (Random real number between 250.00 and 400.00) towards (Random angle) degrees)
                  • Set BoH_Bounces[BoH_LoopInt] = (BoH_Bounces[BoH_LoopInt] - 1)
                • Else - Actions
                  • -------- Overwrite Index --------
                  • Unit - Turn collision for BoH_CasterUnit[BoH_LoopInt] On
                  • Unit - Kill BoH_DummyUnit[BoH_LoopInt]
                  • Set BoH_Bounces[BoH_LoopInt] = BoH_Bounces[BoH_MaxIndex]
                  • Set BoH_CasterUnit[BoH_LoopInt] = BoH_CasterUnit[BoH_MaxIndex]
                  • Set BoH_Dmg[BoH_LoopInt] = BoH_Dmg[BoH_MaxIndex]
                  • Set BoH_DummyUnit[BoH_LoopInt] = BoH_DummyUnit[BoH_MaxIndex]
                  • Custom script: call RemoveLocation(udg_BoH_TargetPoint[udg_BoH_LoopInt])
                  • Set BoH_TargetPoint[BoH_LoopInt] = BoH_TargetPoint[BoH_MaxIndex]
                  • Set BoH_LoopInt = (BoH_LoopInt - 1)
                  • Set BoH_MaxIndex = (BoH_MaxIndex - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BoH_MaxIndex Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
              • Floating Text - Create floating text that reads FUNZ at TempPoint with Z offset 0.00, using font size (Random real number between 15.00 and 25.00), color ((Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%, (Random real number between 0.00 and 100.00)%), and 0.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the lifespan of (Last created floating text) to 4.00 seconds
              • Floating Text - Change the fading age of (Last created floating text) to 3.00 seconds
              • Floating Text - Set the velocity of (Last created floating text) to (Random real number between 50.00 and 100.00) towards (Random angle) degrees
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Flying to the center of the map usually means that the location being used is invalid.

This means that one of the follow variables are either not set or being reset somewhere:
TempPoint, BoH_CasterUnit, BoH_LoopInt

After a quick read through, this might be the issue:
  • Set BoH_LoopInt = (BoH_LoopInt - 1)
You're setting the integer that is being used by the loop.

Maybe try a different index overwrite method. My preferred method is:
for loop b from loopint to maxindex
set variable[loop b] to variable[loop b + 1]
etc for each variable
set maxindex--
 
Level 13
Joined
Oct 16, 2010
Messages
731
Hi, I'm not sure I understand your method for overwriting the index but this is how I've done it for all of my spells so far (It's how a tutorial showed how to do it).

As for the cliff situation, I decided to add an "if, then, else" when picking the next location so that if he has hit a wall it will bounce him away from the wall rather than picking a random angle. Thanks anyway :)
 
Status
Not open for further replies.
Top