HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[JASS] Trigger terraining + Random questions + Common.j

05-27-2009, 12:42 AM#1
Silvenon
Trigger terraining:

Ok, I'm not sure if I should post it here or in the Terrain forum :D, but I'm guessing this one will be more fitting.

Now, I'm trying to find all the possibilities and limits in making a terrain via triggers. I have some questions and stuff, may not be able to remember all the questions, so I will add them as I remember them. By terrain I mean everything visible in the map, ground, sky, fog etc.

Ok, here are the things I've found out, I can:
  • raise/lower the terrain with TerrainDeformCrater (by inserting positive and negative values)
  • probably create water if I use shallow water + increase one (with disabled Enforce Water Height Limits), then lower the terrain with TerrainDeformCrater
  • with TerrainDeformCrater I can probably create a reset height field effect (there's a tutorial on that)
  • set the terrain type via SetTerrainType
  • set the fog via SetTerrainFogEx, which is probably a duh
  • change the sky with SetSkyModel
  • affect the visibility with fade filters if necessary
  • add blight with SetBlight
If you know some other ways/functions to modify the terrain with triggers, feel free to post them.

Anyways, my questions are (or at least what I can think of right now):
  • there's a big problem with coding a terrain right? I mean the fact that when you load a saved game, all the permanent terrain deformations will be "forgotten", right?
    ANSWER: The deformations can be saved in a gamecache
  • what is the best way to place doodads with triggers?
  • is there a way to create cliffs? if there is, there's probably no way to create a ramp, right?
    ANSWER: No.
  • is there a way to find out what is the height of a doodad raised with ctrl + pgdwn/pgup?
    ANSWER: GetDestructableOccluderHeight
  • is there a way to avoid that sudden change in height when using TerrainDeformWave?
Anyways, when I finish researching this, I may post a tutorial on that (that is, if there is enough information that people don't know already).

Random questions:
  • according to PitzerMike's ability guide, the Channel ability can be used as a base ability multiple times per units without interfering as long as I change the order id on each spell? why isn't anyone using that method (as far as I have seen)? isn't that like uber cool? I've always had troubles with running out of abilities to use as a base
    ANSWER: Channel can't give buffs and doesn't have a missile art.
  • is there a way to decrease the line of sight of a unit? or at least to make it look that way (without using fade filters, because those don't look realistic much)
    ANSWER: Using dummy units with various lines of sight
  • is there a way to make unit unselectable? but not with Locust ability, I don't want it to be invulnerable, to ignore the pathing limitations etc. will morphing it with Chaos into the same model and then giving it Locust work? is that what that part of the PitzerMike's tutorial was talking about? (check the Aloc part)
  • is there a way to detect when a mouse hovers over a certain unit? (well, I suppose not)
    ANSWER: Nope.
  • are there any problems with creating a learn system using images + trackables?
    ANSWER: Not really, only that trackables can't be destroyed.
  • can I use GetLocalPlayer with images?
    [size=1]ANSWER: Yes. (Yaaaay :D)/SIZE]
  • are there any problems with RemoveUnit?
    ANSWER: Only if groups are involved. Make sure that you remove the unit from any unit group before you remove it.
  • are there any mutliboard tutorials in JASS?
    Dumb question
  • is there a way to get the current camera bounds? I don't mean the map camera bounds (do GetCameraBound functions do that?)
  • is putting looping through a group faster when done in the boolexpr function (with GroupEnum functions, for example)?
Common.j:
  • what does GetLocalizedHotkey function do?
    ANSWER: It returns a localized hotkey, because hotkeys can differ from state to state
  • what does RegionAddCell do?
    ANSWER: Adds a 32x32 cell, where the given coordinates fit, to a region.
  • why does SetUnitAbilityLevel return an integer? what does that integer mean?
  • how do you use IssueInstantPointOrder and what does it do?
  • what does GetAbilityEffect(ById) do?
  • what does IsTerrainPathable do exactly? I suppose it doesn't work properly if everyone is using other algorithms
    ANSWER: It only checks the terrain tile, and ignores pathing of destructables, units.
  • what does SetTerrainPathable do exactly? I don't understand what does setting a pathing type for a single point mean
    ANSWER: It sets the pathing type of the whole terrain tile in which the X/Y coordinates fit.
  • what are those a, b, c, d and e values in SetTerrainFog?
  • what do these functions do:
    Collapse JASS:
    native Preload          takes string filename returns nothing
    native PreloadEnd       takes real timeout returns nothing
    native PreloadStart     takes nothing returns nothing
    native PreloadRefresh   takes nothing returns nothing
    native PreloadEndEx     takes nothing returns nothing
    native PreloadGenClear  takes nothing returns nothing
    native PreloadGenStart  takes nothing returns nothing
    native PreloadGenEnd    takes string filename returns nothing
    native Preloader        takes string filename returns nothing

    I know about Preload (does it work for every path?), but I don't know about the rest

I enhanced the text a bit, so it's maybe easier to read. As you answer, I will edit the first post and copy the answers there. Also, I will edit the first post if new questions pop up (you can also ask random questions here if you want, I can add them to the list in the first post).

Btw, I realize this is a lot of questions, but I figured I should just lay them out totally random.
05-27-2009, 01:23 AM#2
darkwulfv
Quote:
is there a way to create cliffs? if there is, there's probably no way to create a ramp, right?
No.

Quote:
according to PitzerMike's ability guide, the Channel ability can be used as a base ability multiple times per units without interfering as long as I change the order id on each spell? why isn't anyone using that method (as far as I have seen)? isn't that like uber cool? I've always had troubles with running out of abilities to use as a base
Plenty of people do, but it's so easy to cover up and make it look like a normal ability that you probably would never know. And even then, many times a Blizz spell turned dummy (like Acid Bomb) is a better choice, since Channel has no missile art and can't give buffs. (Can it?)

Quote:
is there a way to detect when a mouse hovers over a certain unit? (well, I suppose not)
Trackables? Maybe? Otherwise, I think Reinventing the Craft has something for that.

Quote:
are there any problems with RemoveUnit?
Depends. If you're using groups, if a unit is removed from play before it's removed from the group, it can leave a "shadow". Griff did a big thing on that, but the bug is extraordinarily easy to prevent anyways. Not including certain systems which need to track units properly, RemoveUnit has no drawbacks, except that units disappear immediately; no death animation, no decay, etc.

Quote:
how do you use IssueInstantPointOrder and what does it do?
You know, I have no idea. That's a weird function.
05-27-2009, 01:48 AM#3
rain9441
Quote:
Originally Posted by Silvenon
according to PitzerMike's ability guide, the Channel ability can be used as a base ability multiple times per units without interfering as long as I change the order id on each spell? why isn't anyone using that method (as far as I have seen)? isn't that like uber cool? I've always had troubles with running out of abilities to use as a base

Beware. Channel based spells cancel the animation once the cast point is achieved. A unit with a cast point of 0.00 will seemingly cast spells without any animation at all. Normally a unit who is ordered to cast a normal spell will play the animation and the animation will continue until either the unit was ordered to do something else, or the animation's duration has been reached. This is why I avoid channel based spells in favor of spells like chain lightning or roar.
05-27-2009, 01:55 AM#4
darkwulfv
I've never experienced that problem before, rain, and I use Channel for a number of spells without any problems whatsoever.
05-27-2009, 08:29 AM#5
Silvenon
Quote:
No.

Too bad :(

Quote:
Plenty of people do, but it's so easy to cover up and make it look like a normal ability that you probably would never know. And even then, many times a Blizz spell turned dummy (like Acid Bomb) is a better choice, since Channel has no missile art and can't give buffs. (Can it?)

Yeah, it can't. But it's great for making triggered spell that don't need a buff or a missile art.

Quote:
Trackables? Maybe? Otherwise, I think Reinventing the Craft has something for that.

Er, yeah, but one tiny problem is that trackables can't be moved and units move all the time... I don't think RtC has a function for that, it just has for left, right mouse click and wheel. Nvm then.

Quote:
Depends. If you're using groups, if a unit is removed from play before it's removed from the group, it can leave a "shadow". Griff did a big thing on that, but the bug is extraordinarily easy to prevent anyways. Not including certain systems which need to track units properly, RemoveUnit has no drawbacks, except that units disappear immediately; no death animation, no decay, etc.

I was just asking if it leaks, because it seemed to me that people are avoiding to use it, they often use expired timers instead.

Quote:
You know, I have no idea. That's a weird function.

Lol, yeah, for example there's just one use for IssueInstantTargetOrder (in PitzerMike's tut) :).

Anyways, thanks for helping out, darkwulfv. I find your Weird Ability Guide really useful.

Quote:
Beware. Channel based spells cancel the animation once the cast point is achieved. A unit with a cast point of 0.00 will seemingly cast spells without any animation at all. Normally a unit who is ordered to cast a normal spell will play the animation and the animation will continue until either the unit was ordered to do something else, or the animation's duration has been reached. This is why I avoid channel based spells in favor of spells like chain lightning or roar.

I'll keep an eye on that and I'll try to reproduce that bug.
05-27-2009, 09:54 AM#6
Eleandor
Quote:
Originally Posted by Silvenon
there's a big problem with coding a terrain right? I mean the fact that when you load a saved game, all the permanent terrain deformations will be "forgotten", right? then I should use a Save/Load code? I still don't understand what a Save/Load code is...actually, I forgot
I haven't tried this, but you could perhaps store terrain deformation information in variables or game cache and upon load, reproduce all deformations. I.e.
Collapse JASS:
struct Deformation
    real x
    real y
    real radius
    real depth

    static method create takes real x, real y, real radius, real depth returns Deformation
        // create...
    endmethod

    method deform takes nothing returns nothing
        call TerrainDeformCrater(this.x, this.y, this.radius, this.depth)
    endmethod
endstruct
Upon loading you just call .deform on all Deformations you have.

Quote:
what is the best way to place doodads with triggers?
There's no way. You must use destructables for that, and there's only 1 way to place destructables, by [ljass]CreateDestructable()[/jass]
Quote:
is there a way to find out what is the height of a doodad raised with ctrl + pgdwn/pgup?
GetDestructableOccluderHeight perhaps?

Quote:
Channel has no missile art and can't give buffs. (Can it?)
I recall giving one of my channel spells a buff... But maybe I'm wrong.
Quote:
is there a way to decrease the line of sight of a unit? or at least to make it look that way (without using fade filters, because those don't look realistic much)
You can use day/night time to change line of sight. Only allows for 2 ranges though.
Other way I can think of is giving the unit no sight range at all, and have several dummy units with various sightranges who are instantly moved to the unit's position. Swap dummy units to get a different sightrange.
There's also a night-elf upgrade infravision.
Quote:
is there a way to make unit unselectable? but not with Locust ability, I don't want it to be invulnerable, to ignore the pathing limitations etc. will morphing it with Chaos into the same model and then giving it Locust work? is that what that part of the PitzerMike's tutorial was talking about? (check the Aloc part)
Add locust + hide unit + remove locust + show unit will make the unit unclickable, but vulnerable + pathable again. However, it's still selectable with drag-select, which you'll have to disable...
Quote:
can I use GetLocalPlayer with images?
Untested, but I guess this should work:
Collapse JASS:
local string imgpath = ""
if GetLocalPlayer() == Player(i) then
    set imgpath = "MyImage.blp"
endif
call CreateImage(imgpath, x, y, ...) // note how the image is created for everyone, but invisible for all other players
Quote:
are there any mutliboard tutorials in JASS?
Don't know, but the natives are pretty easy to understand.
Quote:
what does GetLocalizedHotkey function do?
Returns a localized hotkey... I.e. for germans, the "Holy Light" spell is named in german and is likely to have a different hotkey too.
Quote:
what does RegionAddCell do?
It adds a specific X/Y coordinate to the region. Not really sure how it works though...
Quote:
why does SetUnitAbilityLevel return an integer? what does that integer mean?
Don't know, test it? My bet is that it returns that specific ability's level on the unit. I guess it can be useful in those cases you SetUnitAbilityLevel larger than the ability's maximum level.
Quote:
what does IsTerrainPathable do exactly? I suppose it doesn't work properly if everyone is using other algorithms
It only checks the terrain tile, and ignores pathing of destructables, units.
Quote:
what does SetTerrainPathable do exactly? I don't understand what does setting a pathing type for a single point mean
It sets the pathing type of the whole terrain tile in which the X/Y coordinates fit.
05-27-2009, 11:46 AM#7
akolyt0r
you know that Mac users wont be able to play your map AFAIK ... since those terrain deform natives cause Mac users to desync..
05-27-2009, 12:36 PM#8
wraithseeker
Also with GetLocationZ...
05-27-2009, 01:18 PM#9
Dark.Revenant
Quote:
Originally Posted by akolyt0r
you know that Mac users wont be able to play your map AFAIK ... since those terrain deform natives cause Mac users to desync..
A great deal of things will make mac players desync. When working with something very complicated, it's almost inevitable.
05-27-2009, 01:23 PM#10
Anitarf
There is a passive ability that can modify a unit's sight range called Item Sight Range Bonus, so you needn't use upgrades or dummy units for that.
05-27-2009, 01:58 PM#11
busterkomo
I'm at school, so the syntax on this might be a bit off.

For detecting when the mouse is hovering over a unit in RtC, you could do something like:

Collapse JASS:
function IsMouseOnUnit takes real x, real y, real leeway, unit u returns boolean
    local real dx = GetMouseTargetX() - GetUnitX(u)
    local real dy = GetMouseTargetY() - GetUnitY(u)
    return SquareRoot(dx * dx + dy * dy) <= leeway
endfunction

And to use, something like this:

Collapse JASS:
function whatever takes nothing returns nothing
local real x
if IsMouseOnUnit(GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 30) then
set x = 1
endif
endfunction
05-27-2009, 03:00 PM#12
Silvenon
Quote:
There's no way. You must use destructables for that, and there's only 1 way to place destructables, by CreateDestructable()

I just remembered, what about Volcano ability? PitzerMike's tutorial mentioned it's the only ability that can create doodads. Maybe I can create them with dummy units casting Volcanos, though that might be limited.

Quote:
GetDestructableOccluderHeight perhaps?

Works. Thanks :D

Quote:
Add locust + hide unit + remove locust + show unit will make the unit unclickable, but vulnerable + pathable again. However, it's still selectable with drag-select, which you'll have to disable...

Hmm what is the best way to disable drag-select? Is there a good way to disable selection so it doesn't show? Because if you just make a trigger that deselects the unit on selection, it will be selected for a moment, then deselected (which is bad).

Quote:
Untested, but I guess this should work:

Will test it soon.

Quote:
Don't know, test it? My bet is that it returns that specific ability's level on the unit. I guess it can be useful in those cases you SetUnitAbilityLevel larger than the ability's maximum level.

I recall testing it, but I don't remember what it returned. I think it wasn't very logical. I will test it again soon.

Thanks, Eleandor, you've been of great help. I added the answers to the first post.
Quote:
There is a passive ability that can modify a unit's sight range called Item Sight Range Bonus, so you needn't use upgrades or dummy units for that.

*edited

Thanks :D

Quote:
you know that Mac users wont be able to play your map AFAIK ... since those terrain deform natives cause Mac users to desync..

I'm really sorry. I wasn't thinking about that. But like Dark Revenant said, that probably won't be the only thing desyncing.

@busterkomo
I need to detect when the mouse hovers over a unit, not is mouse on a unit. But thanks for help.

In future, I don't think I'll use RtC for this map (since it's not stable yet and since people will have to get RtC to play my map).

Btw, this is a really really stupid noob question, but what is that NewGen Warcraft thing? Also, do people have to have NewGen to play a map made in NewGen?
05-27-2009, 03:32 PM#13
Zandose
Quote:
probably create water if I use shallow water + increase one (with disabled Enforce Water Height Limits), then lower the terrain with TerrainDeformCrater
You cann use a dummy water model instead.

Quote:
with TerrainDeformCrater I can probably create a reset height field effect (there's a tutorial on that)
Yes. You should be able to reserve any deformation effect by using a opposite depth.

Quote:
there's a big problem with coding a terrain right? I mean the fact that when you load a saved game, all the permanent terrain deformations will be "forgotten", right? then I should use a Save/Load code? I still don't understand what a Save/Load code is...actually, I forgot
Terrain information is forgotten. As you make deformations (or destructables) save all the information to code variables, and reload it as needed. Save/Load code is generally used for storing a "units/Heroes" information in a string of numbers/letter so the player can reload the hero in another map. It doesn't have much to do with terrain, and that method is not viable for transferring terrain information; it would be too long.

Quote:
what is the best way to place doodads with triggers?
Change the doodads to destructables. Some cannot be done, such as cliffs, ramps, etc.

Quote:
is there a way to create cliffs? if there is, there's probably no way to create a ramp, right?
Use the wave deformation with no waves and a long duration. Don't know about ramps, maybe a crater deformation (to walk up) attached to a wave deformation. You'll need to use pathing blockers.

Also, use a thin wave deformation to create walls. Add pathing blockers, change terrain to a cliff style, and add some rocks?

Quote:
is there a way to find out what is the height of a doodad raised with ctrl + pgdwn/pgup?
No, you cannot find the height of doodads or destructables. But there are workarounds, either create the destructables in-game and save its height information to a variable. There is also a program to remove a maps destructables and change them into trigger code, "CreateDestructableWithZ()".

Quote:
is there a way to avoid that sudden change in height when using TerrainDeformWave?[/list]
Yes, but I don't remember exactly how. Something like a long duration, 0 waves, crazy long time between waves?


Quote:
is there a way to detect when a mouse hovers over a certain unit? (well, I suppose not)
No. See below for ideas.

Quote:
are there any problems with creating a learn system using images + trackables?
Yes, but the cost is not worth it. You'll lose map space because you cannot remove them. For each player you'll need to create separate/local trackables, and depending on the size/scale of it you may incur some lag. Just a note, you need to edit (alpha out i think) and import images. There's a alternative by using a unit and detecting a right mouse click (move/smart command) to get a x/y point. Check out the pre-made trigger section for a demo of something similar.

Quote:
can I use GetLocalPlayer with images?
Yes. Many things are be displayed to only one player. The rules are simple (as I see them): Always create anything for all players, but edit the string/image/model locally for a player.

Quote:
are there any problems with RemoveUnit?
Remove the unit from the group first, if it has one?

Quote:
what does GetAbilityEffect(ById) do?
I think, all objects in the game have codes which the game/blizzard uses for referencing stuff. GetAbilityEffect(ById) is just the id code instead of the string name. Look at the unit triggers, there should be similar stuff for getunitbyid and unitconvertidtostring or unitconvertstringtoid.

Quote:
what does IsTerrainPathable do exactly? I suppose it doesn't work properly if everyone is using other algorithms
As implied, "can my unit walk/fly over this terrain?"

Quote:
what does SetTerrainPathable do exactly? I don't understand what does setting a pathing type for a single point mean
"What!? Like hell I can't walk here! *special attack!* SetTerrainPathable(). Haha, just try to stop me...I dare ya."
05-27-2009, 04:37 PM#14
Ammorth
Terrain deformations are horrible and should never be used. They leak and there is no way to clear them. They also cause Macs to desync (as stated before).
05-27-2009, 04:45 PM#15
Deaod
call EnableDragSelect(false, false) will diable drag select ... duh.