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

[Solved] Terrain detection and buffing bugs.

Status
Not open for further replies.
Level 26
Joined
Jun 5, 2008
Messages
1,767
Well, I got a friend of mine to make me a terrain detection system, to detect what kind of terrain the hero is on and buff him while he is on the terrain.

There's a minor problem however. When leaving one terrain the buff remains for a pretty long amount of time before disappearing. So yeah, he considered it impossible, so I'll leave it in the hands of you pros to see a if there is a solution to the problem. :O

What I would want to see working is that the buff and the ability instantly disappear and is replaced by the new buff and ability when entering another terrain.
 

Attachments

  • Road System[2].w3x
    14.2 KB · Views: 54
Level 11
Joined
Sep 12, 2008
Messages
657
Just to tell you that.. this wasnt my original version ;p
the original 1 is vjass, but he didnt like it, so i made this 1 quite fast.
and im pretty sure there is no bug, as far as MY comp can tell..
but anyways, as far as he told me, i understand the bug is about WC3 buff engine,
which doesnt end immideatly, and has delay.
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Just to tell you that.. this wasnt my original version ;p
the original 1 is vjass, but he didnt like it, so i made this 1 quite fast.
and im pretty sure there is no bug, as far as MY comp can tell..
but anyways, as far as he told me, i understand the bug is about WC3 buff engine,
which doesnt end immideatly, and has delay.

Just to point out, the same bug appeared in the jass version and the severely lacking documentation didn't help. :O
 
Level 11
Joined
Sep 12, 2008
Messages
657
Well then.. i supose posting triggers help:

  • Road Initialization
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Set road_index[0] = (road_index[0] + 1)
      • Set road_type[road_index[0]] = Lordaeron Winter - Snow
      • Set road_ability[road_index[0]] = Endurance Aura
      • -------- ----------------- --------
      • Set road_index[0] = (road_index[0] + 1)
      • Set road_type[road_index[0]] = Lordaeron Winter - Grass
      • Set road_ability[road_index[0]] = Brilliance Aura
      • -------- ----------------- --------
      • Set road_index[0] = (road_index[0] + 1)
      • Set road_type[road_index[0]] = Lordaeron Winter - Rock
      • Set road_ability[road_index[0]] = Thorns Aura
      • -------- ----------------- --------
      • Countdown Timer - Start road_timer as a Repeating timer that will expire in 0.03 seconds
  • Road Loop
    • Events
      • Time - road_timer expires
    • Conditions
    • Actions
      • Set road_group = (Units in (Playable map area))
      • Unit Group - Pick every unit in road_group and do (Actions)
        • Loop - Actions
          • Set road_loc = (Position of (Picked unit))
          • For each (Integer road_index[1]) from 1 to road_index[0], do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at road_loc) Equal to road_type[road_index[1]]
                • Then - Actions
                  • Unit - Add road_ability[road_index[1]] to (Picked unit)
                • Else - Actions
                  • Unit - Remove road_ability[road_index[1]] from (Picked unit)
          • Custom script: call RemoveLocation(udg_road_loc)
      • Custom script: call DestroyGroup(udg_road_group)
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Level 26
Joined
Jun 5, 2008
Messages
1,767
Bumping this thread since it beats creating an identical topic asking about the exact same thing. The other technique worked in theory, and possibly if it was alone. But it did not work in combination with this code. Gave it a shot trying to add it anyhow, but it's not really working. :/

  • Road Initialization
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set road_hash = (Last created hashtable)
      • -------- ----------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
          • (Terrain pathing at (Position of (Triggering unit)) of type Walkability is off) Equal to False
        • Then - Actions
          • -------- ----------------- --------
          • Set road_index = (road_index + 1)
          • Set road_ability[road_index] = Terrain Effect (Shallow Water)
          • Set road_buffs[road_index] = Terrain Effect: Shallow Water
        • Else - Actions
      • -------- ----------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
          • (Terrain pathing at (Position of (Triggering unit)) of type Walkability is off) Equal to True
        • Then - Actions
          • Set road_index = (road_index + 1)
          • Set road_ability[road_index] = Terrain Effect (Deep Water)
          • Set road_buffs[road_index] = Terrain Effect: Deep Water
        • Else - Actions
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Cityscape - Round Tiles
      • Set road_ability[road_index] = Terrain Effect (Industrial Road)
      • Set road_buffs[road_index] = Terrain Effect: Industrial Road
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Grass
      • Set road_ability[road_index] = Terrain Effect (Grass)
      • Set road_buffs[road_index] = Terrain Effect: Grass
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Dirt
      • Set road_ability[road_index] = Terrain Effect (Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Rough Dirt
      • Set road_ability[road_index] = Terrain Effect (Rough Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Rough Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Lumpy Grass
      • Set road_ability[road_index] = Terrain Effect (Lumpy Grass)
      • Set road_buffs[road_index] = Terrain Effect: Lumpy Grass
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Vines
      • Set road_ability[road_index] = Terrain Effect (Vines)
      • Set road_buffs[road_index] = Terrain Effect: Vines
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Grassy Dirt
      • Set road_ability[road_index] = Terrain Effect (Grassy Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Grassy Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Leaves
      • Set road_ability[road_index] = Terrain Effect (Leaves)
      • Set road_buffs[road_index] = Terrain Effect: Leaves
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Village Fall - Cobble Path
      • Set road_ability[road_index] = Terrain Effect (Cobble Path)
      • Set road_buffs[road_index] = Terrain Effect: Cobble Path
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Sunken Ruins - Sand
      • Set road_ability[road_index] = Terrain Effect (Sand)
      • Set road_buffs[road_index] = Terrain Effect: Sand
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Icecrown Glacier - Dark Ice
      • Set road_ability[road_index] = Terrain Effect (Dark Ice)
      • Set road_buffs[road_index] = Terrain Effect: Dark Ice
      • -------- ----------------- --------
      • For each (Integer A) from 1 to road_index, do (Actions)
        • Loop - Actions
          • -------- Stores the ability for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 0 , udg_road_ability[bj_forLoopAIndex])
          • -------- Stores the buff for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 1 , udg_road_buffs[bj_forLoopAIndex])
      • -------- ----------------- --------
      • Countdown Timer - Start road_timer as a Repeating timer that will expire in 0.03 seconds
  • Road Loop
    • Events
      • Time - road_timer expires
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set unit = (Picked unit)
          • Custom script: set udg_id = GetHandleId(udg_unit)
          • -------- Gets terrain type at unit's pos --------
          • Custom script: set udg_integer1 = GetTerrainType(GetUnitX(udg_unit), GetUnitY(udg_unit))
          • -------- Gets terrain type at previous pos --------
          • Custom script: set udg_integer2 = LoadInteger(udg_road_hash , udg_id , 0)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • integer1 Not equal to integer2
            • Then - Actions
              • -------- Removes ability --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
              • -------- Removes buff --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
              • -------- Adds new ability --------
              • Custom script: call UnitAddAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer1, 0))
              • -------- Stores new terrain type --------
              • Custom script: call SaveInteger(udg_road_hash , udg_id, 0, udg_integer1)
            • Else - Actions
I was thinking about if It could be possible to check with an extra variable. However, I don't have a clue what I'm doing to be quite honest. I'd appreciate any help you guys could give me. I gave up a while ago, but as new ideas popped up in my head, I realized I need the water detection to work as well, as I could build on that too. :D
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
Should be:
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to False
Additionaly it leaks location. Use point variable to fix that. Things that leak.

Btw ain't it silly to manually increase/use index while you can just use number itself? I see you're creating some kind of library so:
  • Set road_type[1] = Cityscape - Round Tiles
  • Set road_ability[1] = Terrain Effect (Industrial Road)
  • Set road_buffs[1] = Terrain Effect: Industrial Road
  • -------- ----------------- --------
  • Set road_type[2] = Ashenvale - Grass
  • Set road_ability[2] = Terrain Effect (Grass)
  • Set road_buffs[2] = Terrain Effect: Grass
  • -------- ----------------- --------
  • Set road_type[3] = Ashenvale - Dirt
  • Set road_ability[3] = Terrain Effect (Dirt)
  • Set road_buffs[3] = Terrain Effect: Dirt
  • -------- ----------------- --------
  • Set road_type[4] = Ashenvale - Rough Dirt
  • Set road_ability[4] = Terrain Effect (Rough Dirt)
  • Set road_buffs[4] = Terrain Effect: Rough Dirt
  • -------- ----------------- --------
  • Set road_type[5] = Ashenvale - Lumpy Grass
  • Set road_ability[5] = Terrain Effect (Lumpy Grass)
  • Set road_buffs[5] = Terrain Effect: Lumpy Grass
  • -------- ----------------- --------
  • Set road_type[6] = Ashenvale - Vines
  • Set road_ability[6] = Terrain Effect (Vines)
  • Set road_buffs[6] = Terrain Effect: Vines
  • -------- ----------------- --------
  • Set road_type[7] = Ashenvale - Grassy Dirt
  • Set road_ability[7] = Terrain Effect (Grassy Dirt)
  • Set road_buffs[7] = Terrain Effect: Grassy Dirt
  • -------- ----------------- --------
  • Set road_type[8] = Ashenvale - Leaves
  • Set road_ability[8] = Terrain Effect (Leaves)
  • Set road_buffs[8] = Terrain Effect: Leaves
  • -------- ----------------- --------
  • Set road_type[9] = Village Fall - Cobble Path
  • Set road_ability[9] = Terrain Effect (Cobble Path)
  • Set road_buffs[9] = Terrain Effect: Cobble Path
  • -------- ----------------- --------
  • Set road_type[10] = Sunken Ruins - Sand
  • Set road_ability[10] = Terrain Effect (Sand)
  • Set road_buffs[10] = Terrain Effect: Sand
  • -------- ----------------- --------
  • Set road_type[11] = Icecrown Glacier - Dark Ice
  • Set road_ability[11] = Terrain Effect (Dark Ice)
  • Set road_buffs[11] = Terrain Effect: Dark Ice
And not till then use ifs - meaning follow script above with:
~(Triggering unit) returns null - it's not generic even (actually it isn't unit event at all..). You have to use global unit variable.
  • Set unit = <whatever>
  • Set p = (Position of (unit))
  • Set road_index = 12
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at p of type Floatability is off) Equal to False
      • (Terrain pathing at p of type Walkability is off) Equal to False
    • Then - Actions
      • Set road_index = (road_index + 1)
      • Set road_ability[road_index] = Terrain Effect (Shallow Water)
      • Set road_buffs[road_index] = Terrain Effect: Shallow Water
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at p of type Floatability is off) Equal to False
      • (Terrain pathing at p of type Walkability is off) Equal to True
    • Then - Actions
      • Set road_ability[road_index] = Terrain Effect (Deep Water)
      • Set road_buffs[road_index] = Terrain Effect: Deep Water
    • Else - Actions
  • Custom script: call RemoveLocation(udg_p)
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
Should be:
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to False
Additionaly it leaks location. Use point variable to fix that. Things that leak.

Btw ain't it silly to manually increase/use index while you can just use number itself?

There's leaks? The floatation part was created by me, the rest by Maker. His system worked and still does, flawlessly.
However, I want the system to detect if the unit is in water as well. If the leak is in the area about floatation, then it's my fault.

I wasn't really asking for a efficiency try here. I mean, I was asking for a solution, not a critique on Makers code that again, works flawlessly.
If there was a solution in there, I don't get it. :O
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Since Maker is great coder I'm pretty sure he applied changes I've shown you above. If code doesn't own such method it's either: your fault because of wrong CnP or Maker had bad day. You can even ask him about this topic once again. ;)

(Position of (Triggering unit)) leaks and here I'm 100% sure Maker doesn't paste you code with this.
Furthermore, I've shown you the solution. Don't you see the difference between:

(Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
And:
(Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to False

And don't negate my post since it's here just to help you.
Spinnaker said:
~(Triggering unit) returns null - it's not generic even (actually it isn't unit event at all..). You have to use global unit variable.
Next mistake in your code lies here. Use global as said.
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Since Maker is great coder I'm pretty sure he applied changes I've shown you above. If code doesn't own such method it's either: your fault because of wrong CnP or Maker had bad day. You can even ask him about this topic once again. ;)

(Position of (Triggering unit)) leaks and here I'm 100% sure Maker doesn't paste you code with this.
Furthermore, I've shown you the solution. Don't you see the difference between:
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to [B][COLOR="Red"]True[/COLOR][/B]
And:
  • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to [COLOR="Red"][B]False[/B][/COLOR]
And don't negate my post since it's here just to help you.

What are you on about? He gave me a file to download. I'm pretty sure the file could be still downloaded in this thread. Anyhow, still looking for a solution. :O
I have said that my intention was to get it to detect water, stop going on about or leaks.. because.. well, I don't really care. ;O
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Edited the post, and no file can not be dled anymore. I don't get you man - (Triggering unt) is the main issue here, listen to me, or stay with fail trigger.

I already said that the floatation part was made by me. Trying to figure out a way to get it to detect water. What part of that is hard to understand? I'm looking for a solution. Not a quality check. :O
Also, I'm not exactly a pro at this. I asked if you could tell me if there was a way for it to apply the float thingy to his terrain detection. I obviously failed, is there a way? The idea is that it should either detect terrain or detect water. Meaning, if it goes from the land down to shallow water, the Terrain Effect will change from Grass, to Water. pretty much. Granted, I should say thank you for correcting the float about the true and false thingy.

This code (Below here, this tiny little bit), was made by me. It's flawed beyond belief, but I ask, like I did before, can I apply this to makers terrain detection? Is there a way? Or at least, can my concept be applied?
Can Makers code also be edited to detect water? If so, how?
  • -------- ----------------- --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
      • (Terrain pathing at (Position of (Triggering unit)) of type Walkability is off) Equal to False
    • Then - Actions
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_ability[road_index] = Terrain Effect (Shallow Water)
      • Set road_buffs[road_index] = Terrain Effect: Shallow Water
    • Else - Actions
  • -------- ----------------- --------
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at (Position of (Triggering unit)) of type Floatability is off) Equal to True
      • (Terrain pathing at (Position of (Triggering unit)) of type Walkability is off) Equal to True
    • Then - Actions
      • Set road_index = (road_index + 1)
      • Set road_ability[road_index] = Terrain Effect (Deep Water)
      • Set road_buffs[road_index] = Terrain Effect: Deep Water
    • Else - Actions
  • -------- ----------------- --------
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Additionaly for detecting water:
(Terrain pathatbility at Loc of type Floatability is off) Equal to False
OR
(Terrain pathing at Loc of type Amphibious Pathing is off) Not equal to True

For searching if water is shallow or deep you have to add additional 'Clif' condition.

Okey I post it last time and then I call Maker to ensure you with this:

Freaking (Triggering unit) RETURNS NOTHING (that is null!) if you use that with:
  • Events
    • Time - Elapsed game time is 0.05 seconds
It's not **** generic event - don't you understand that? It's time event and it doesn't provide proper (Triggering unit) at all.
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Okey I post it last time and then I call Maker to ensure you with this:

Freaking (Triggering unit) RETURNS NOTHING (that is null!) if you use that with:
  • Events
    • Time - Elapsed game time is 0.05 seconds
It's not **** generic event - don't you understand that? It's time event and it doesn't provide proper (Triggering unit) at all.

It appears you have not read my reply then. My map does not use cliffs, it uses elevations and doodads simulating cliffs. As it looks better. Now, stop bitching about my noobiness and try to help me reach my goal instead. :O
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Here you go: Link

The paladin can go on deep water.

The system could be triggered a bit better if it was made in JASS, but it works just fine now also.

Hm. Tested it, it doesn't work nearly as flawlessly as the other system you made. The way it takes time for the buff to disappear reminds me of Dardas system.
If you walked from one terrain onto another kind of terrain in the water, all terrain effects disappear altogether. It does come back though if I walk back and forth between terrains on land though.

Also, does these effects only apply to heroes? I intended it to apply to all units. How much more effective would this be in Jass? ;D

Edit:
Wait, scratch that, it appears to be working well now. I wonder what that was? A temporary error?
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
As you can see Maker's trigger doesn't own any location leaks (he even used coordinates), plus as said you had to replace (Triggering unit) with global (I see Maker called it just 'unit') - thats about loop trigger. In initialization trigger you can see that part of trigger has been even omited, in case previouly shown trigger wouldn't initialize data properly.
Why didn't you listen to me, but wait untill I pm'ed Maker? I'm pretty sad that you didn't want my help, oh well..

Jass can add some efficiency into system, although it's mostly custom scripting anyways.

The delay may occur if your computer has many files open at the same time (or it's old).
For appling the effect for all units just change group creation trigger:
  • Add heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Grupa jednostek - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is alive) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to road_group
However, I'm pretty sure that it cause lags if you gonna put many units on playable area. You might consider 'selecting' which units should be affected by system and which not.

@Maker Road index can be removed without any problems, just enter the numbers themselves.
 
Last edited:
Level 26
Joined
Jun 5, 2008
Messages
1,767
As you can see Maker's trigger doesn't own any location leaks (he even used coordinates), plus as said you had to replace (Triggering unit) with global (I see Maker called it just 'unit') - thats about loop trigger. In initialization trigger you can see that part of trigger has been even omited, in case previouly shown trigger wouldn't initialize data properly.
Why didn't you listen to me, but wait untill I pm'ed Maker? I'm pretty sad that you didn't want my help, oh well..

Jass can add some efficiency into system, although it's mostly custom scripting anyways.

The delay may occur if your computer has many files open at the same time (or it's old).
For appling the effect for all units just change group creation trigger:
  • Add heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Grupa jednostek - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is alive) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to road_group
However, I'm pretty sure that it cause lags if you gonna put many units on playable area. You might consider 'selecting' which units should be affected by system and which not.

@Maker Road index can be removed without any problems, just enter the numbers themselves.

It appears that it only works with models that are already on the map when you start it up. If you buy your hero in the beginning, like my game, the effects doesn't even show up. :/
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Ah, you should said that ealier ^^ I was following what Maker has already done.

You can delete 'Add heroes' trigger, 'road_group' variable won't be needed either. Change the loop this way:
  • Road Loop
    • Events
      • Time - road_timer expires
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is alive) Equal to True)) and do (Actions)
        • Loop - Actions
          • Set unit = (Picked unit)
          • Custom script: set udg_id = GetHandleId(udg_unit)
          • -------- Gets terrain type at unit's pos --------
          • Custom script: set udg_integer1 = GetTerrainType(GetUnitX(udg_unit), GetUnitY(udg_unit))
          • -------- Gets terrain type at previous pos --------
          • Custom script: set udg_integer2 = LoadInteger(udg_road_hash , udg_id , 0)
          • -------- Is terrain floatable? --------
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_FLOATABILITY)) then
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_WALKABILITY)) then
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[1])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[1])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[0])
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[0])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[0])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[1])
          • Custom script: endif
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[0])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[0])
          • Custom script: endif
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[1])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[1])
          • Custom script: endif
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • integer1 Not equal to integer2
            • Then - Actions
              • -------- Removes ability --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
              • -------- Removes buff --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
              • -------- Adds new ability --------
              • Custom script: call UnitAddAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer1, 0))
              • -------- Stores new terrain type --------
              • Custom script: call SaveInteger(udg_road_hash , udg_id, 0, udg_integer1)
            • Else - Actions
          • Custom script: endif
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Cool. I'll probably try that.

Btw, I noticed another problem. The first of the terrains doesn't show. I made a lazy move to avoid dealing with it and added a terrain I don't use. But now, when you move from the water onto the second terrain (Which was the first before) My buff disappears completely.Like before, if you go up, walk back and forth between the terrains, it´s back again.

Granted, I got 13 terrains, including the shallow and deep water effects. Maybe that's the cause? Too many terrains?
I wonder how to fix this.
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
@Spinnaker, I'd rather not filter/enum units in the map every 0.03 second. It's better to use a group variable and add/remove unit from it. At the least, one should filter out structures.

@Minimage, post triggers and/or the map.

Gotcha, I actually tried Spinnaker's idea at first. It nullified the system, It was essentially like turning it off. Then I went with my idea. I'll post the triggers. I think the problem lies in the transition from land to water though.
Something about it just fucks it up. When you avoid the water, the first terrain in the list isn't working. When you go into the water, the water buff works, but when you go up on land, the buff disappears until you walk back and forth between the terrain on the land.

Anyhow, I suppose that's enough repeating, here's the triggers.

  • UnitBuffInitialization
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Run Add heroes <gen> (checking conditions)
  • Road Initialization
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set road_hash = (Last created hashtable)
      • -------- ----------------- --------
      • Set road_index = 1
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Village Fall - Stone Path
      • Set road_buffs[road_index] = Terrain Effect: Industrial Road
      • Set road_ability[road_index] = Terrain Effect (Industrial Road)
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Grass
      • Set road_ability[road_index] = Terrain Effect (Grass)
      • Set road_buffs[road_index] = Terrain Effect: Grass
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Dirt
      • Set road_ability[road_index] = Terrain Effect (Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Rough Dirt
      • Set road_ability[road_index] = Terrain Effect (Rough Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Rough Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Lumpy Grass
      • Set road_ability[road_index] = Terrain Effect (Lumpy Grass)
      • Set road_buffs[road_index] = Terrain Effect: Lumpy Grass
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Vines
      • Set road_ability[road_index] = Terrain Effect (Vines)
      • Set road_buffs[road_index] = Terrain Effect: Vines
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Grassy Dirt
      • Set road_ability[road_index] = Terrain Effect (Grassy Dirt)
      • Set road_buffs[road_index] = Terrain Effect: Grassy Dirt
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Ashenvale - Leaves
      • Set road_ability[road_index] = Terrain Effect (Leaves)
      • Set road_buffs[road_index] = Terrain Effect: Leaves
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Village Fall - Cobble Path
      • Set road_ability[road_index] = Terrain Effect (Cobble Path)
      • Set road_buffs[road_index] = Terrain Effect: Cobble Path
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Sunken Ruins - Sand
      • Set road_ability[road_index] = Terrain Effect (Sand)
      • Set road_buffs[road_index] = Terrain Effect: Sand
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Icecrown Glacier - Dark Ice
      • Set road_ability[road_index] = Terrain Effect (Dark Ice)
      • Set road_buffs[road_index] = Terrain Effect: Dark Ice
      • -------- ----------------- --------
      • -------- shallow water --------
      • -------- ----------------- --------
      • Set road_ability[0] = Terrain Effect (Shallow Water)
      • Set road_buffs[0] = Terrain Effect: Shallow Water
      • -------- ----------------- --------
      • -------- deep water --------
      • -------- ----------------- --------
      • Set road_ability[1] = Terrain Effect (Deep Water)
      • Set road_buffs[1] = Terrain Effect: Deep Water
      • -------- ----------------- --------
      • For each (Integer A) from 2 to road_index, do (Actions)
        • Loop - Actions
          • -------- Stores the ability for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 0 , udg_road_ability[bj_forLoopAIndex])
          • -------- Stores the buff for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 1 , udg_road_buffs[bj_forLoopAIndex])
      • -------- ----------------- --------
      • Countdown Timer - Start road_timer as a Repeating timer that will expire in 0.03 seconds
  • Add heroes
    • Events
      • Map initialization
    • 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)) is An Ancient) Equal to False)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • ((Triggering unit) is alive) Equal to True
                  • ((Triggering unit) is Summoned) Equal to False
                  • ((Triggering unit) is A flying unit) Equal to False
                  • ((Triggering unit) is A structure) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to road_group
            • Else - Actions
  • Road Loop
    • Events
      • Time - road_timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in road_group and do (Actions)
        • Loop - Actions
          • Set unit = (Picked unit)
          • Custom script: set udg_id = GetHandleId(udg_unit)
          • -------- Gets terrain type at unit's pos --------
          • Custom script: set udg_integer1 = GetTerrainType(GetUnitX(udg_unit), GetUnitY(udg_unit))
          • -------- Gets terrain type at previous pos --------
          • Custom script: set udg_integer2 = LoadInteger(udg_road_hash , udg_id , 0)
          • -------- Is terrain floatable? --------
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_FLOATABILITY)) then
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_WALKABILITY)) then
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[1])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[1])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[0])
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[0])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[0])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[1])
          • Custom script: endif
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[0])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[0])
          • Custom script: endif
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[1])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[1])
          • Custom script: endif
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • integer1 Not equal to integer2
            • Then - Actions
              • -------- Removes ability --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
              • -------- Removes buff --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
              • -------- Adds new ability --------
              • Custom script: call UnitAddAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer1, 0))
              • -------- Stores new terrain type --------
              • Custom script: call SaveInteger(udg_road_hash , udg_id, 0, udg_integer1)
            • Else - Actions
          • Custom script: endif
 
Last edited by a moderator:
Level 26
Joined
Jun 5, 2008
Messages
1,767
Shallow water is saved to [0] and deep water to [1]. You're missing the set road index = 1 after the hashtable initialization. The first index = index + 1 action comes after that, so the village stone path is then saved to [2].

Added it. The problem still remains. Well, you see the effect when you walk on the first one now. But it still is being fucked up when you have gone into the water and then out again. The buff disappears.
It appears the bug only presents itself when I go from the shallow water onto the first terrain now. ;O
 
Level 26
Joined
Jun 5, 2008
Messages
1,767
Does the problem exist in my test map? Post triggers/the map or else I can only guess what is the cause of that.

  • Road Initialization
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set road_hash = (Last created hashtable)
      • -------- ----------------- --------
      • Set road_index = 1
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Lordaeron Winter - Snow
      • Set road_ability[road_index] = Endurance Aura
      • Set road_buffs[road_index] = Endurance Aura
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Lordaeron Winter - Grass
      • Set road_ability[road_index] = Brilliance Aura
      • Set road_buffs[road_index] = Brilliance Aura
      • -------- ----------------- --------
      • Set road_index = (road_index + 1)
      • Set road_type[road_index] = Lordaeron Winter - Rock
      • Set road_ability[road_index] = Thorns Aura
      • Set road_buffs[road_index] = Thorns Aura
      • -------- ----------------- --------
      • -------- shallow water --------
      • -------- ----------------- --------
      • Set road_ability[0] = Unholy Aura
      • Set road_buffs[0] = Unholy Aura
      • -------- ----------------- --------
      • -------- deep water --------
      • -------- ----------------- --------
      • Set road_ability[1] = Vampiric Aura
      • Set road_buffs[1] = Vampiric Aura
      • -------- ----------------- --------
      • For each (Integer A) from 2 to road_index, do (Actions)
        • Loop - Actions
          • -------- Stores the ability for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 0 , udg_road_ability[bj_forLoopAIndex])
          • -------- Stores the buff for the terrain type --------
          • Custom script: call SaveInteger(udg_road_hash, udg_road_type[bj_forLoopAIndex] , 1 , udg_road_buffs[bj_forLoopAIndex])
      • -------- ----------------- --------
      • Countdown Timer - Start road_timer as a Repeating timer that will expire in 0.03 seconds
  • Add heroes
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to road_group
  • Road Loop
    • Events
      • Time - road_timer expires
    • Conditions
    • Actions
      • Unit Group - Pick every unit in road_group and do (Actions)
        • Loop - Actions
          • Set unit = (Picked unit)
          • Custom script: set udg_id = GetHandleId(udg_unit)
          • -------- Gets terrain type at unit's pos --------
          • Custom script: set udg_integer1 = GetTerrainType(GetUnitX(udg_unit), GetUnitY(udg_unit))
          • -------- Gets terrain type at previous pos --------
          • Custom script: set udg_integer2 = LoadInteger(udg_road_hash , udg_id , 0)
          • -------- Is terrain floatable? --------
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_FLOATABILITY)) then
          • Custom script: if not(IsTerrainPathable(GetUnitX(udg_unit), GetUnitY(udg_unit), PATHING_TYPE_WALKABILITY)) then
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[1])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[1])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[0])
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) == 0 then
          • -------- Removes ability --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_ability[0])
          • -------- Removes buff --------
          • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
          • Custom script: call UnitRemoveAbility(udg_unit , udg_road_buffs[0])
          • -------- Adds new ability --------
          • Custom script: call UnitAddAbility(udg_unit, udg_road_ability[1])
          • Custom script: endif
          • Custom script: endif
          • Custom script: else
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[0]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[0])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[0])
          • Custom script: endif
          • Custom script: if GetUnitAbilityLevel(udg_unit, udg_road_ability[1]) > 0 then
          • -------- Removes water ability --------
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_ability[1])
          • Custom script: call UnitRemoveAbility(udg_unit, udg_road_buffs[1])
          • Custom script: endif
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • integer1 Not equal to integer2
            • Then - Actions
              • -------- Removes ability --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 0))
              • -------- Removes buff --------
              • Custom script: call UnitRemoveAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer2, 1))
              • -------- Adds new ability --------
              • Custom script: call UnitAddAbility(udg_unit , LoadInteger(udg_road_hash, udg_integer1, 0))
              • -------- Stores new terrain type --------
              • Custom script: call SaveInteger(udg_road_hash , udg_id, 0, udg_integer1)
            • Else - Actions
          • Custom script: endif
As for the map, if you refer to my map, then I would probably send it with a PM. I don't wanna spread my map over the internet when it's not done yet.
Here you go: Link.

Anyhow, here's yours if that's the one you asked for.

Edit:
Just tested the test map again. Yeah, the same problem is there. :O
 
Last edited by a moderator:
Level 26
Joined
Jun 5, 2008
Messages
1,767
How about this: Link

By the way, use [hidden][/hidden] tags to post long triggers.

Sorry 'bout that. Will do in the future. Also, tested the code. It appears to be working well now. I can't detect any bugs. Will apply it to my map and give it a test run. ;D

Edit:
Fully tested in my map. Works flawlessly. Here's some more rep for your hard work. ;D

Edit x2:
The hive wont allow me to give you rep. Oh well, will do it at a later date when I can. XD
 
Last edited:
Status
Not open for further replies.
Top