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

Doodad height

Status
Not open for further replies.

Tzi

Tzi

Level 4
Joined
Jan 7, 2009
Messages
57
Greetings from Germany:grin:,

I've got a problem with some doodads that I want to place a little bit in the air after they get placed.
I have found a solution in this thread, but I have very light skills at JASS. (only removing leaks)
I read the lines a few times and low myself between them:cry:
It have to be a "Last created doodad" command.

Would any1 please help me?


Dears,

Tzi:smile:
 
Sure thing. If they are directly placed in the editor, just select them and use CTRL+Page Up to raise and CTRL+Page Down to lower.

If you want it by coding, here you go, I made a script specifically for your problem:
JASS:
function SetDestructableZ takes destructable d, real z, real face, real scale, integer variation returns destructable
    local real x = GetDestructableX(d)
    local real y = GetDestructableY(d)
    local integer id = GetDestructableTypeId(d)
    local location l = Location(x,y)
    local real zz = GetLocationZ(l)
    call RemoveDestructable(d)
    set bj_lastCreatedDestructable = CreateDestructableZ(id,x,y,zz+z,face,scale,variation)
    call RemoveLocation(l)
    set l = null
    return bj_lastCreatedDestructable
endfunction

Implement:

Copy and paste that. Place it in your map's header (sorry I accidentally changed the function so the actual code that was pasted is wrong, this just shows the area):
header.jpg

Parameters:


Now, do the following. Find wherever you create the destructible. Example:
  • jhklj
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set DestLoc = (Point(121.00, -203.00))
      • Set Facing = (Random angle)
      • Destructible - Create a Summer Tree Wall at DestLoc facing (Random angle) with scale 1.20 and variation 3
      • Set MyDest = (Last Created Destructible)
      • Custom script: call RemoveLocation(udg_DestLoc)
This is just an example. Instead, use the functions you used to create your destructible.

Now, take note of some of the things:
  • MyDest: The destructible variable. Only really necessary if you aren't going to alter the Z when it is created. So if you want to change the Z later, set this to a variable.
  • DestLoc: This is the location of your destructible. You don't need to store this information since my function doesn't need it.
  • Facing: This is ONLY required if you use (Random Angle). This is a real variable. Create it in your variable editor. You can name it whatever you'd like! =D
    realvar.jpg
  • Scale: If you use something like (Random real between (1 and 2)) then you will need to store the variable. To do that, just create a new real variable (like for facing) and then you can set it to the random real before you create the destructible. Make sure you use it when creating the destructible as well, otherwise it might choose a different random real. Scaling is how large the destructible is. The max and minimum scaling is determined in the object editor.
  • Variation: Same as above. If you choose "random # between..", then you need to save it in a variable. Otherwise, no. You can find the different variations in the object editor or by selecting the destructible on the map and viewing the different variations listed on the left side:
    randomVariate.jpg

Using the Function:

To actually use the function, do this:
  • Custom script: call SetDestructableZ(udg_MyDest,GetRandomReal(1,800),udg_Facing,1.2,3)
Copy and paste the entire "SetDestructableZ(udg_MyDest,GetRandomReal(1,800),udg_Facing,1.2,3)".

Ok, now let's discuss the parameters:
JASS:
function SetDestructableZ takes destructable d, real z, real face, real scale, integer variation returns destructable

  • d: This is the destructible you want to change the height of. Use the variable if you created it via triggering. If it is on the map, then create a new trigger named asdfjkslfj or anything. Add the action "Kill (Destructible)" and select your destructible on the map. It should show up as something like Summer Tree wall 0006 <gen>. Go to Edit -> Convert to Custom Text and copy the entire "gg_dest_xxxx_0###" (Eg: gg_dest_LTlt_0000) Copy and paste that into the function and use that.
    For more info of these generated globals:
    [Mini-Tutorial] Generated Globals
  • Z: This is height you want the destructible in the air. 1-50 is hardly noticeable. About 200 is somewhat off the ground and 800 is pretty high up. I used "GetRandomReal(1,800)" for testing purposes. Simply replace that with the real Z value you want. (eg: 500 or 200 or 324 etc..)
  • Face: This is the facing. If you used a random angle for facing, use the variable. Place "udg_" first then the variable name. (Ex: udg_Facing) udg is User Defined Global. Otherwise, set it to the angle you want. Angles go from 0-360 degrees, where 0 is eastward, 90 is northward, 180 is westward, and 270 southward. (Eg: 180 or 90 or 34 or 278 etc..)
  • Scale: The scaling of the destructible. Same thing, if it is a random real between x and y then use the variable you set it as. Otherwise, just set it to whatever you put as the scale. (Eg: 1.2 or .8 or .93 etc..)
  • Variation: Same thing as above. If you used random number between x and y use the variable. Otherwise, just input your value.

Then you are done. You can refer to this destructable with (Last Created Destructible), so you can use it in GUI. Note that this does overwrite your previous last created destructible! Example of usage:
  • jfdsjfkd
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Custom script: call SetDestructableZ(MyDest,500,90,0.9,0)
      • Set MyDest = (Last created destructible)
      • Destructible - Set max life of MyDest to 200.00
  • --- This will work. MyDest will be the Z destructible. This will change its max life to 200 ---
If you want to alter the Z of the last created destructible, put this in the "destructible d" part:
JASS:
bj_lastCreatedDestructable
Eg:
JASS:
call SetDestructableZ(bj_lastCreatedDestructable,300,47,0.8,1)

Good luck. Yeah, this is a long block of text but it is easy and fast if you know what you're doing.
 

Tzi

Tzi

Level 4
Joined
Jan 7, 2009
Messages
57
Thank you it works perfectly :D
I will add your post to my favorits +rep!
 

Tzi

Tzi

Level 4
Joined
Jan 7, 2009
Messages
57
Now I have an other problem. The selection area of the doodad is a little bit difficult to handle because you can only select it by keep pressing the mouse button like the way you do, when you are selecting some units.
The hard thing is that the camera of the player get bound by a trigger on the ground.
It is important for my map that the players are able to select the doodads in their height^^

EDIT: I found out that doodads on an other place can be selected in the right way. So I give you some additional informations:

The camera is showing to 45° direction.
The doodas which are working are in the right half of the screen. These doodads are looking to 180° direction.
The doodas which are not working are in the left half of the screen. These doodads are looking to 270° direction.

In additional it would be nice to know how to create a "Selected Destructible" trigger^^

Yours,

Tzi :)
 
Last edited:
Status
Not open for further replies.
Top