• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Dynamic environment based spells

Status
Not open for further replies.
Level 5
Joined
Jun 21, 2013
Messages
116
I'm lacking an idea on how could I make dynamic environment based spells that change as the unit changes position.
Let me give an example of what I mean.
We have a shaman unit on the map. He can manipulate the elements. But I don't want him to cast water-based spells in the desert, nor fire-based spells near ocean.
I would like him to have the abilities of an area he is currently in.
Is he near water? Then he can make the water take down his enemies
Is he near a cliff? Then he can pull the stone from it and hurl it at the enemies.
You probably get the idea.

My original idea was to split the map into regions, but regions can only be squares, as far as i can tell, so i would have to make thousands of them and include each in the trigger. So regions are out of the picture. (and I have regions covering the map, so it's probably best not to use 2 layers of regions).
 
Level 30
Joined
Apr 6, 2010
Messages
3,219
I don't know about water, but you can have the trigger's condition look for what type of terrain the unit is standing on and base the spell on that. As far as I can tell, there's no way around regions to make sure the unit's in water, maybe make the beaches fit in rectangles? Alternatively, use only one kind of terrain for water spells and make sure it's not used anywhere else.

If that doesn't work, maybe try making the spells weaker when on opposite terrain and stronger on similar terrain instead of blocking the spells entirely (if your spells already use triggers to scale with the hero's Intelligence, for example, add a x.5, x1 or x2 factor).

Another idea: Have only one spell per effect that changes models depending on terrain. For example, a single-target stun is an iceball on snow, boulder on dirt, fireball on lava, etc.
 
Last edited:
Level 14
Joined
Jul 1, 2008
Messages
1,314
If you want to use code, that helps you to recognize world editor water:

This jass snippet will help you differentiate between water and ground. There are others like this on the hive and they maybe better. But this here works in my maps:

copy this to your map "headder":
JASS:
function CheckLocationWaterType takes real x, real y returns integer
  // this function checks the pathability of a point for being shallow or deep water
  /*returns  0 - solid ground; 1 - shallow water; 2 - deep water; */
  local boolean pathable  = not IsTerrainPathable( x, y, PATHING_TYPE_WALKABILITY)
  local boolean floatable = not IsTerrainPathable( x, y, PATHING_TYPE_FLOATABILITY)
  if pathable and ( not floatable) then
  return 0 // location is solid ground
  elseif pathable and floatable then
  return 1 // location is shallow water
  elseif ( not pathable) and floatable then
  return 2 // location is deep water
  endif
  return 0
  endfunction

and use it like this:

  • set x = Some x
  • set y = Some y
  • Custom Script: if CheckLocationWaterType( udg_x, udg_y) > 0 then
  • // your action inside here, because you just recognized water
  • Custom Script: else
  • // everything not on water neither on shallow water goes in here
  • Custom Script: endif
 
Level 5
Joined
Jun 21, 2013
Messages
116
I think I'll just make dummy units with auras that affect only the hero I need, and then he could gain abilities according to the auras. Would making many units make the game lag?

Because the areas are not rectangular so regions are very bad idea, unless I want to have hundreds of regions...

And the seconds solution checks for certain x and y coordinates, while I would need to check every 0.5 seconds for every point inside 1500 range... Which is pretty inefficient...
 
Level 8
Joined
Jan 28, 2016
Messages
486
My original idea was to split the map into regions, but regions can only be squares, as far as i can tell, so i would have to make thousands of them and include each in the trigger. So regions are out of the picture. (and I have regions covering the map, so it's probably best not to use 2 layers of regions).

According to this thread, it is possible to create non-rectangular regions with rects. There's also this thread that explains how it can be done.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
You need to determine what is around the Shaman. On cast this could be done by sampling a variety of locations, say 9, 25 or some circular pattern, and then determining elemental availability based on the tile type at the points

You could also create "super" regions for every element which contain every point in the world they can be cast at. The cells within such regions could be computed algorithmically at map initialization.
 
Status
Not open for further replies.
Top