• 🏆 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] Detecting Pathability Issue (Items on the ground are considered not walkable)

Status
Not open for further replies.
Level 10
Joined
Apr 4, 2010
Messages
509
[Solved] Detecting Pathability Issue (Items are considered notwalkable)

It is a bouncing Mechanic by ap0calypse
http://www.hiveworkshop.com/forums/members/ap0calypse/

There is a ball bouncing around and it ricochets off of walls, buildings, etc. But it ALSO bounces off of items. I tried changing it to IsWalkable, IsLocationCliff. The ball still bounces off Items. I have no idea what I'm doing. I'm self taught in GUI and I don't know jack about JASS.
It need the ball to go over everything that is walkable. Will give credit and +Rep

http://www.hiveworkshop.com/forums/world-editor-help-zone-98/ball-bouncing-off-wall-230009/

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function IsPathable takes real x, real y returns boolean
    call SetItemPosition(udg_Item, x, y)
    
    if GetItemX(udg_Item) == x and GetItemY(udg_Item) == y then
        return true
    endif
    return false
endfunction

  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Unit = Footman 0033 <gen>
      • Set Speed = 25.00
      • Set Angle = (Random angle)
      • Set Item = Dummy Item 0057 <gen>
  • Move
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Loc1 = (Position of Unit)
      • Set Loc2 = (Loc1 offset by Speed towards Angle degrees)
      • Custom script: set udg_Boolean = IsPathable(GetLocationX(udg_Loc2), GetLocationY(udg_Loc2))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Boolean Equal to False
        • Then - Actions
          • Set Angle = (360.00 - Angle)
          • Custom script: call RemoveLocation(udg_Loc2)
          • Set Loc2 = (Loc1 offset by Speed towards Angle degrees)
          • Special Effect - Create a special effect at Loc2 using Abilities\Spells\Items\SpellShieldAmulet\SpellShieldCaster.mdl
          • Special Effect - Destroy (Last created special effect)
          • Custom script: set udg_Boolean = IsPathable(GetLocationX(udg_Loc2), GetLocationY(udg_Loc2))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Boolean Equal to False
            • Then - Actions
              • Set Angle = ((Angle + 180.00) mod 360.00)
              • Custom script: call RemoveLocation(udg_Loc2)
              • Set Loc2 = (Loc1 offset by Speed towards Angle degrees)
              • Custom script: set udg_Boolean = IsPathable(GetLocationX(udg_Loc2), GetLocationY(udg_Loc2))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Boolean Equal to False
                • Then - Actions
                  • Set Angle = (360.00 - Angle)
                  • Custom script: call RemoveLocation(udg_Loc2)
                  • Set Loc2 = (Loc1 offset by Speed towards Angle degrees)
                • Else - Actions
            • Else - Actions
        • Else - Actions
      • Unit - Move Unit instantly to Loc2
      • Custom script: call RemoveLocation(udg_Loc1)
Get the map --> http://www.hiveworkshop.com/forums/...0753861-ball-bouncing-off-wall-bouncemove.w3x
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
function IsPathable_Enum takes nothing returns nothing
    if IsItemVisible(GetEnumItem()) then
        set udg_IsPathable_ItemsC = udg_IsPathable_ItemsC + 1
        set udg_IsPathable_Items[udg_IsPathable_ItemsC] = GetEnumItem()
        call SetItemVisible(GetEnumItem(), false)
    endif
endfunction

function IsPathable takes real x, real y returns boolean
    if (udg_IsPathable_Rect == null) then
        set udg_IsPathable_Rect = Rect(0, 0, 0, 0)
    endif

    set udg_IsPathable_ItemsC = -1
    call SetRect(udg_IsPathable_Rect, x - 64, y - 64, x + 64, y + 64)

    call EnumItemsInRect(udg_IsPathable_Rect, null, function IsPathable_Enum)

    call SetItemPosition(udg_Item, x, y)

    loop
        exitwhen (udg_IsPathable_ItemsC < 0)

        call SetItemVisible(udg_IsPathable_Items[udg_IsPathable_ItemsC], true)
        set udg_IsPathable_Items[udg_IsPathable_ItemsC] = null
        
        set udg_IsPathable_ItemsC = udg_IsPathable_ItemsC - 1
    endloop

    if GetItemX(udg_Item) == x and GetItemY(udg_Item) == y then
        return true
    endif

    return false
endfunction

Variables:
IsPathable_Items -> item array
IsPathable_ItemsC -> integer
IsPathable_Rect -> rect
 
Last edited:
Status
Not open for further replies.
Top