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

[General] Custom Blight with Shallow Water

Level 6
Joined
May 13, 2023
Messages
44
Hi, I'm creating an altered melee map and 1 of the Races in the map is Naga, so what I want is whenever naga builds a structure the terrain around it will turn into shallow water. This is like undead requiring blight to build their structures. I made the naga structures sea-pathable so they can be only built on shallow or deep water.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Here's a better version that fixes most of the problems. Requires the latest patch to open.

I basically made the Pylon system from Starcraft. I gave the Naga buildings a buildability requirement of Sea Pathable. Then I made some triggers/code to create a ring of Sea Pathable pathing around newly constructed Naga structures. When a Naga structure is destroyed, it's Sea Pathable pathing is destroyed with it. I use a Water model I found on Hive PuddleOfWaterItem+WardAv035 and vB003 (credits to kellym0) to visualize the effects. The Water is a Special Effect that is "attached" to the Naga buildings using Unit Indexing.

The code for changing pathing:
vJASS:
library WaterPathing

    globals
        hashtable WP_Hash = InitHashtable()
    endglobals

    function WP_Add_Pathing takes location p, real radius returns nothing
        local real centerX = GetLocationX(p)
        local real centerY = GetLocationY(p)
        local real stepsX = radius / 16 // Calculate how many steps are needed based on radius
        local real stepsY = radius / 16
        local real currentX = centerX - radius
        local real currentY
        local integer waterCount = 0
        local integer x = 0
        local integer y = 0
        // For debugging:
        //local effect sfx
 
        loop
            exitwhen currentX > centerX + radius
 
            set currentY = centerY - radius
 
            loop
                exitwhen currentY > centerY + radius
 
                // For debugging:
                //set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", currentX, currentY)
                //call BlzSetSpecialEffectScale(sfx, 0.4)
   
                set x = R2I(currentX)
                set y = R2I(currentY)
                set waterCount = LoadInteger(WP_Hash, x, y)
                call SaveInteger(WP_Hash, x, y, waterCount + 1)
                // Add pathing if this is the first instance of this pathing at the given coordinates
                if (waterCount == 0) then
                    call SetTerrainPathable(currentX, currentY, PATHING_TYPE_FLOATABILITY, true)
                endif
 
                set currentY = currentY + 16.0
            endloop
 
            set currentX = currentX + 16.0
        endloop
    endfunction

    function WP_Remove_Pathing takes location p, real radius returns nothing
        local real centerX = GetLocationX(p)
        local real centerY = GetLocationY(p)
        local real stepsX = radius / 16 // Calculate how many steps are needed based on radius
        local real stepsY = radius / 16
        local real currentX = centerX - radius
        local real currentY
        local integer waterCount = 0
        local integer x = 0
        local integer y = 0
 
        loop
            exitwhen currentX > centerX + radius
 
            set currentY = centerY - radius
 
            loop
                exitwhen currentY > centerY + radius
 
                set x = R2I(currentX)
                set y = R2I(currentY)
                set waterCount = LoadInteger(WP_Hash, x, y)
                call SaveInteger(WP_Hash, x, y, waterCount - 1)
                // Remove pathing if this is the last instance of this pathing at the given coordinates
                if (waterCount == 1) then
                    call SetTerrainPathable(currentX, currentY, PATHING_TYPE_FLOATABILITY, false)
                endif
 
                set currentY = currentY + 16.0
            endloop
 
            set currentX = currentX + 16.0
        endloop
    endfunction
endlibrary
The triggers for managing the Naga structures/pathing code:
  • Naga Town Hall Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Temple of Tides)) and do (Actions)
        • Loop - Actions
          • Set VariableSet WP_Structure = (Picked unit)
          • Set VariableSet WP_CV = (Custom value of WP_Structure)
          • Set VariableSet WP_Point = (Position of WP_Structure)
          • Trigger - Run Create Water Effect <gen> (ignoring conditions)
  • Naga Structure Finishes
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Level of Naga (Classification) for (Triggering unit)) Greater than 0
    • Actions
      • Set VariableSet WP_Structure = (Triggering unit)
      • Set VariableSet WP_CV = (Custom value of WP_Structure)
      • Set VariableSet WP_Point = (Position of WP_Structure)
      • Trigger - Run Create Water Effect <gen> (ignoring conditions)
  • Naga Structure Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Naga (Classification) for (Triggering unit)) Greater than 0
    • Actions
      • Set VariableSet WP_Structure = (Triggering unit)
      • Set VariableSet WP_CV = (Custom value of WP_Structure)
      • -------- --------
      • Custom script: if udg_WP_Water_Effect[udg_WP_CV] != null then
      • Set VariableSet WP_Point = (Position of WP_Structure)
      • Trigger - Run Destroy Water Effect <gen> (ignoring conditions)
      • Custom script: endif
  • Create Water Effect
    • Events
    • Conditions
    • Actions
      • Custom script: local effect udg_WP_Local_Sfx = AddSpecialEffectLoc( "ItemPuddleOfWaterAv035.mdx", udg_WP_Point )
      • Custom script: set udg_WP_Water_Effect[udg_WP_CV] = udg_WP_Local_Sfx
      • Custom script: call WP_Add_Pathing( udg_WP_Point, 576.00 )
      • Custom script: call RemoveLocation( udg_WP_Point )
      • -------- --------
      • Special Effect - Set Scale of WP_Local_Sfx to 11.00
      • Special Effect - Set Time Scale of WP_Local_Sfx to 3.33
      • Special Effect - Play Special Effect: WP_Local_Sfx, Animation: Spell
      • Special Effect - Set Height of WP_Local_Sfx to: -16.00
      • -------- --------
      • Wait 3.00 game-time seconds
      • -------- --------
      • Special Effect - Play Special Effect: WP_Local_Sfx, Animation: Stand
      • Special Effect - Set Time Scale of WP_Local_Sfx to 0.04
  • Destroy Water Effect
    • Events
    • Conditions
    • Actions
      • Custom script: call WP_Remove_Pathing( udg_WP_Point, 576.00 )
      • Custom script: call RemoveLocation( udg_WP_Point )
      • Special Effect - Set Scale of WP_Water_Effect[WP_CV] to 0.01
      • Special Effect - Set Height of WP_Water_Effect[WP_CV] to: 5000.00
      • Special Effect - Set Time Scale of WP_Water_Effect[WP_CV] to 1.00
      • Special Effect - Destroy WP_Water_Effect[WP_CV]
      • Custom script: set udg_WP_Water_Effect[udg_WP_CV] = null
Requires Bribe's Unit Indexer. Also, I use a hidden ability based on Storm Hammers as a pseudo-classification to detect Naga units. In my triggers I call this ability Naga (Classification). It's only purpose is to be used as a Condition. All of the Naga structures need this ability to use the system properly.

WP variables:
1692323494748.png
 

Attachments

  • Naga Water Pathing 1.w3m
    28.8 KB · Views: 3
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Tnx for the reply, I copied your code and Spreading of the Waterpathing works perfectly, but there aren't any water effects showing, does this have to do with custom imported model
You need to copy everything over. Assets, abilities, etc.
  • Custom script: local effect udg_WP_Local_Sfx = AddSpecialEffectLoc( "ItemPuddleOfWaterAv035.mdx", udg_WP_Point )
^ This is creating the Special Effect. It's referencing the custom Water model. If that doesn't exist then it'll create a blank Special Effect.

Also, you need the Unit Indexer if you didn't copy that over.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
How did you open my map if you use 1.30.4? Do you have two separate installations?

1.30.4 most likely doesn't support the Special Effect actions, I think they were added in 1.31:
  • Actions
    • Special Effect - Set Scale of WP_Local_Sfx to 11.00
    • Special Effect - Set Time Scale of WP_Local_Sfx to 3.33
    • Special Effect - Play Special Effect: WP_Local_Sfx, Animation: Spell
    • Special Effect - Set Height of WP_Local_Sfx to: -16.00
    • Wait 3.00 game-time seconds
    • Special Effect - Play Special Effect: WP_Local_Sfx, Animation: Stand
    • Special Effect - Set Time Scale of WP_Local_Sfx to 0.04
Anyway, your model has the wrong file path and the custom script is using the wrong file path:
1692332227828.png

  • Custom script: local effect udg_WP_Local_Sfx = AddSpecialEffectLoc( "ItemPuddleOfWaterAv035_Portrait.mdx", udg_WP_Point )
ItemPuddleOfWaterAv035_Portrait needs to be ItemPuddleOfWaterAv035

Also, I can't guarantee that this will work:
  • Naga Town Hall Setup
    • Events
      • Dialog - A dialog button is clicked for Races
    • Conditions
      • (Clicked dialog button) Equal to NagaButton
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Temple of Tides (Naga))) and do (Actions)
        • Loop - Actions
          • Set VariableSet WP_Structure = (Picked unit)
          • Set VariableSet WP_CV = (Custom value of WP_Structure)
          • Set VariableSet WP_Point = (Position of WP_Structure)
          • Trigger - Run Create Water Effect <gen> (ignoring conditions)
I assume you're using this same Event to create the Temple of Tides. Maybe add a 0.01 second Wait so this always happens AFTER that. Or just run these Actions in that trigger after the building is created.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
It would throw you an error if it wasn't in 1.30. Can you actually see the Water model? Have you tried testing it outside of triggers. Try to narrow things down by using debug messages in the triggers and confirming that the model is even working in the first place.
 
Level 6
Joined
May 13, 2023
Messages
44
Yeah the water model worked fine i used it on a custom unit
Maybe it has something to do with the maps terrain? I did use TFT map Emerald Gardens as a base so it could be that the map's elevation could be way too high?
 
Level 6
Joined
May 13, 2023
Messages
44
Hi I think i found the problem, Whenever I use
page.gif
Custom script: local effect udg_WP_Local_Sfx = AddSpecialEffectLoc( "ItemPuddleOfWaterAv035.mdx", udg_WP_Point )
it doesn't show the effect this also applies to every custom imported model that has path war3mapImported infront of it. I used models without this path and it worked but the problem is depending on the model special effect has different interactions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
Hi I think i found the problem, Whenever I use

it doesn't show the effect this also applies to every custom imported model that has path war3mapImported infront of it. I used models without this path and it worked but the problem is depending on the model special effect has different interactions
I told you that the paths need to match. You need to give that AddSpecialEffectLoc() function the file name of the model that you want the Special Effect to use. For custom models it'll be whatever file name you've set it to in the Asset Manager. I deleted the war3mapImported\ part of my file name because it's unnecessary.

Here's the file path for a standard Warcraft 3 model:
1692381102380.png

You would copy that text and paste it into the function:
  • Custom script: local effect udg_WP_Local_Sfx = AddSpecialEffectLoc( "Abilities\Spells\Other\Tornado\TornadoElementalSmall.mdl", udg_WP_Point )
 
Last edited:
Top