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

Permanent invisible bug sometimes happening after using this ability.

Status
Not open for further replies.
Level 14
Joined
Jul 19, 2007
Messages
772
I have this ability named "Heroic Leap" in my map that sometimes getting bugged and makes the casting Hero permanent invisible all the time after using it until you're using it again. What's the cause of it?
  • Heroic LeapVariables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- //////////////////////////////////////LEAP\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ --------
      • -------- //THE ABILITY ID --------
      • Set VariableSet Leap_Ability = Heroic Leap
      • Set VariableSet Leap_Ability_Buff = Heroic Leap (Buff)
      • -------- ///////////////////////////////////// --------
      • -------- //THE UNIT ID --------
      • Set VariableSet Leap_Unit_Dummy = Heroic Leap (Dummy Unit)
      • -------- ///////////////////////////////////// --------
      • -------- //THE RANGE OF LEAP. THE INDEX CORRESPONDS TO THE LEVEL OF THE SKILL --------
      • Set VariableSet Leap_Maximum_Distance[1] = 630.00
      • Set VariableSet Leap_Maximum_Distance[2] = 690.00
      • Set VariableSet Leap_Maximum_Distance[3] = 780.00
      • Set VariableSet Leap_Maximum_Distance[4] = 840.00
      • -------- //////////////////////////////////////////////////////////////////////END OF LEAP --------
  • Heroic LeapCast
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Leap_Ability
    • Actions
      • -------- //ONLY IF WHERE THERE ARE NO INSTANCES IT WILL START TRIGGER OF LEAPING --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Leap_MUI Equal to 0
        • Then - Actions
          • Trigger - Turn on Heroic LeapMove <gen>
        • Else - Actions
      • -------- ///////////////////////// --------
      • Set VariableSet Leap_MUI = (Leap_MUI + 1)
      • Set VariableSet Leap_MUI_2 = (Leap_MUI_2 + 1)
      • Set VariableSet Leap_Factor[Leap_MUI_2] = -120
      • Set VariableSet Leap_Unit[Leap_MUI_2] = (Triggering unit)
      • Set VariableSet Leap_Point[Leap_MUI_2] = (Position of (Triggering unit))
      • Set VariableSet Leap_CastPoint[Leap_MUI_2] = (Position of (Triggering unit))
      • Set VariableSet Leap_Angle[Leap_MUI_2] = (Facing of (Triggering unit))
      • Set VariableSet Leap_Level[Leap_MUI_2] = (Level of Leap_Ability for (Triggering unit))
      • Set VariableSet Leap_Offset[Leap_MUI_2] = (Leap_Maximum_Distance[Leap_Level[Leap_MUI_2]] / 10.00)
      • Unit - Add Storm Crow Form to (Triggering unit)
      • Unit - Remove Storm Crow Form from (Triggering unit)
  • Heroic LeapMove
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to Leap_MUI_2, do (Actions)
        • Loop - Actions
          • Set VariableSet Leap_Factor[(Integer A)] = (Leap_Factor[(Integer A)] + 24)
          • Set VariableSet Leap_Point[(Integer A)] = (Leap_Point[(Integer A)] offset by Leap_Offset[(Integer A)] towards Leap_Angle[(Integer A)] degrees.)
          • Set VariableSet Leap_Distance[(Integer A)] = (Distance between Leap_Point[(Integer A)] and Leap_CastPoint[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Playable map area) contains Leap_Point[(Integer A)]) Equal to True
            • Then - Actions
            • Else - Actions
              • Set VariableSet Leap_Distance[(Integer A)] = Leap_Maximum_Distance[4]
          • Animation - Change Leap_Unit[(Integer A)] flying height to ((-0.01 x (Power((Real(Leap_Factor[(Integer A)])), 2.00))) + 200.00) at 0.00
          • Unit - Move Leap_Unit[(Integer A)] instantly to Leap_Point[(Integer A)]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Leap_Distance[(Integer A)] Greater than or equal to Leap_Maximum_Distance[Leap_Level[(Integer A)]]
            • Then - Actions
              • Set VariableSet Temp_Point = (Random point in (Playable map area))
              • Unit - Create 1 Leap_Unit_Dummy for (Owner of Leap_Unit[(Integer A)]) at Temp_Point facing Default building facing degrees
              • Unit - Set level of Heroic Leap (Buff) for (Last created unit) to Leap_Level[(Integer A)]
              • Unit - Order (Last created unit) to Orc Shaman - Bloodlust Leap_Unit[(Integer A)]
              • Custom script: call RemoveLocation(udg_Temp_Point)
              • Set VariableSet Leap_Dummy_Unit[(Integer A)] = (Last created unit)
              • Set VariableSet Leap_MUI = (Leap_MUI - 1)
              • Animation - Change Leap_Unit[(Integer A)] flying height to 0.00 at 0.00
              • Custom script: call RemoveLocation(udg_Leap_Point[GetForLoopIndexA()])
              • Custom script: call RemoveLocation(udg_Leap_CastPoint[GetForLoopIndexA()])
              • Custom script: set udg_Leap_Dummy_Unit[GetForLoopIndexA()] = null
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Leap_MUI Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Animation - Change Leap_Unit[(Integer A)] flying height to 0.00 at 0.00
          • Custom script: set udg_Leap_Unit[GetForLoopIndexA()] = null
          • Unit - Remove Leap_Dummy_Unit[(Integer A)] from the game
          • Set VariableSet Leap_MUI_2 = 0
        • Else - Actions
 
Level 14
Joined
Jun 15, 2016
Messages
749
I see nothing wrong with this initial scripts:
- Unless something inside "Heroic LeapMove <gen>" which you may want to post here.
- Heroic Leap (Buff) based on which spell?
- Any other scripts that accidentally add invisible without casting condition or inside their loops?
- Any other spells share same variables with this?
 
Level 14
Joined
Jul 19, 2007
Messages
772
Have you tried using a different unit Model? I said this before, it's most likely due to the Model and the Animations.
No it's nothing wrong with the model. It's just a normal standard wc3 model... I think it's something wrong with my "isterrainwalkable" functions because my map uses 2 functions of it.
vJASS:
library TerrainPathability initializer Init
//******************************************************************************
//* BY: Rising_Dusk
//* 
//* This script can be used to detect the type of pathing at a specific point.
//* It is valuable to do it this way because the IsTerrainPathable is very
//* counterintuitive and returns in odd ways and aren't always as you would
//* expect. This library, however, facilitates detecting those things reliably
//* and easily.
//* 
//******************************************************************************
//* 
//*    > function IsTerrainDeepWater    takes real x, real y returns boolean
//*    > function IsTerrainShallowWater takes real x, real y returns boolean
//*    > function IsTerrainLand         takes real x, real y returns boolean
//*    > function IsTerrainPlatform     takes real x, real y returns boolean
//*    > function IsPointWalkable     takes real x, real y returns boolean
//* 
//* These functions return true if the given point is of the type specified
//* in the function's name and false if it is not. For the IsPointWalkable
//* function, the MAX_RANGE constant below is the maximum deviation range from
//* the supplied coordinates that will still return true.
//* 
//* The IsTerrainPlatform works for any preplaced walkable destructable. It will
//* return true over bridges, destructable ramps, elevators, and invisible
//* platforms. Walkable destructables created at runtime do not create the same
//* pathing hole as preplaced ones do, so this will return false for them. All
//* other functions except IsPointWalkable return false for platforms, because
//* the platform itself erases their pathing when the map is saved.
//* 
//* After calling IsPointWalkable(x, y), the following two global variables
//* gain meaning. They return the X and Y coordinates of the nearest walkable
//* point to the specified coordinates. These will only deviate from the
//* IsPointWalkable function arguments if the function returned false.
//* 
//* Variables that can be used from the library:
//*     [real]    TerrainPathability_X
//*     [real]    TerrainPathability_Y
//* 
    globals
        private constant real    MAX_RANGE     = 10.
        private constant integer DUMMY_ITEM_ID = 'sehr'
    endglobals

    globals   
        private item       Item   = null
        private rect       Find   = null
        private item array Hid
        private integer    HidMax = 0
        public  real       X      = 0.
        public  real       Y      = 0.
    endglobals

    function IsTerrainDeepWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction
    function IsTerrainShallowWater takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction
    function IsTerrainLand takes real x, real y returns boolean
        return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
    endfunction
    function IsTerrainPlatform takes real x, real y returns boolean
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
    endfunction

    private function HideItem takes nothing returns nothing
        if IsItemVisible(GetEnumItem()) then
            set Hid[HidMax] = GetEnumItem()
            call SetItemVisible(Hid[HidMax], false)
            set HidMax = HidMax + 1
        endif
    endfunction
    function IsPointWalkable takes real x, real y returns boolean
        //Hide any items in the area to avoid conflicts with our item
        call MoveRectTo(Find, x, y)
        call EnumItemsInRect(Find ,null, function HideItem)
        //Try to move the test item and get its coords
        call SetItemPosition(Item, x, y) //Unhides the item
        set X = GetItemX(Item)
        set Y = GetItemY(Item)
        static if LIBRARY_IsPointWalkable then
            //This is for compatibility with the IsPointWalkable library
            set IsPointWalkable_X = X
            set IsPointWalkable_Y = Y
        endif
        call SetItemVisible(Item, false)//Hide it again
        //Unhide any items hidden at the start
        loop
            exitwhen HidMax <= 0
            set HidMax = HidMax - 1
            call SetItemVisible(Hid[HidMax], true)
            set Hid[HidMax] = null
        endloop
        //Return walkability
        return (X-x)*(X-x)+(Y-y)*(Y-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    endfunction

    private function Init takes nothing returns nothing
        set Find = Rect(0., 0., 128., 128.)
        set Item = CreateItem(DUMMY_ITEM_ID, 0, 0)
        call SetItemVisible(Item, false)
    endfunction
endlibrary

vJASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function TerrainWalk takes nothing returns nothing
    set udg_TW_MAX_RANGE = 10
    set udg_TW_X = 0
    set udg_TW_Y = 0
    set udg_TW_r = Rect(0, 0, 128, 128)
    set udg_TW_check = CreateItem('ciri', 0, 0)
    call SetItemVisible(udg_TW_check, false)
    set udg_TW_hiddenMax = 0 
endfunction

function HideBothersomeItem takes nothing returns nothing
    if IsItemVisible(GetEnumItem()) then
        set udg_TW_hidden[udg_TW_hiddenMax] = GetEnumItem()
        call SetItemVisible(udg_TW_hidden[udg_TW_hiddenMax], false)
        set udg_TW_hiddenMax = udg_TW_hiddenMax + 1
    endif
endfunction

function IsTerrainWalkable takes location loc returns boolean
local real x = GetLocationX(loc)   
local real y = GetLocationY(loc)   
    call MoveRectTo(udg_TW_r, x, y)
    call EnumItemsInRect(udg_TW_r, null, function HideBothersomeItem)

    call SetItemPosition(udg_TW_check, x, y)//this unhides the item...
    set udg_TW_X=GetItemX(udg_TW_check)
    set udg_TW_Y=GetItemY(udg_TW_check)
    call SetItemVisible(udg_TW_check, false)//...so we must hide it again
   
    loop
        exitwhen udg_TW_hiddenMax <= 0
        set udg_TW_hiddenMax = udg_TW_hiddenMax - 1
        call SetItemVisible(udg_TW_hidden[udg_TW_hiddenMax], true)
        set udg_TW_hidden[udg_TW_hiddenMax] = null
    endloop
   
    return (x - udg_TW_X) * (x - udg_TW_X) + (y - udg_TW_Y) * (y - udg_TW_Y) < udg_TW_MAX_RANGE * udg_TW_MAX_RANGE
endfunction
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,538
Neither of those scripts do anything to the Unit, they're unrelated.

I've seen units become "invisible" when using SetUnitX/Y in certain movement triggers. It was as if their position hadn't updated yet.

It could also be due to Flying Height. A unit that's too high or too low could be "invisible". I believe this is the issue.

I think I mentioned all of this stuff before. You need to disable some of these mechanics and see if the issue still happens.
 
Last edited:
Level 14
Joined
Jul 19, 2007
Messages
772
Neither of those scripts do anything to the Unit, they're unrelated.

I've seen units become "invisible" when using SetUnitX/Y in certain movement triggers. It was as if their position hadn't updated yet.

It could also be due to Flying Height. A unit that's too high or too low could be "invisible". I believe this is the issue.

I think I mentioned all of this stuff before. You need to disable some of these features and see if the issue still happens.
Well is there a way to make a command that could unhide the Hero again? Like -debug Hero and it should make the Hero visible again?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,538
You need to figure out what's causing the problem then go from there. I would disable the flying height for starters and test it a bunch of times to see if it still happens.

Understand that many different things can be the cause of this "invisibility", it's not like there's a line of code that says "1 out of 10 times make the unit invisible". It could be flying height, another trigger going off that you're unaware of, transparency (vertex coloring), a Reforged bug, etc...
 
Last edited:
Level 14
Joined
Jul 19, 2007
Messages
772
You need to figure out what's causing the problem then go from there. I would disable the flying height for starters and test it a bunch of times to see if it still happens.

Understand that many different things can be the cause of this "invisibility", it's not like there's a line of code that says "1 out of 10 times make the unit invisible". It could be flying height, another trigger going off that you're unaware of, transparency (vertex coloring), a Reforged bug, etc...
Well how about adding in the trigger a trigger that resets the height of the casting Hero when the ability is casted?
 
Level 14
Joined
Jul 19, 2007
Messages
772
I would just disable all of the Actions that have to do with Flying Height and test it a bunch of times. If the bug stops happening then we know that was the issue and can work from there.
I tested to make a debug command and it did work! So the problem is that it sometimes for an unknown reason doesn't reset the flying height.
  • Debug Gwaer
    • Events
      • Player - Player 1 (Red) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 2 (Blue) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 3 (Teal) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 4 (Purple) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 6 (Orange) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 7 (Green) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 8 (Pink) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 9 (Gray) types a chat message containing -Debug Gwaer as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -Debug Gwaer as An exact match
    • Conditions
    • Actions
      • Unit - Add Crow Form to Gwaer of Rhûn 0306 <gen>
      • Unit - Remove Crow Form from Gwaer of Rhûn 0306 <gen>
      • Animation - Change Gwaer of Rhûn 0306 <gen> flying height to 0.00 at 0.00
 
Status
Not open for further replies.
Top