• 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.

2 questions (Arrays and Custom Scripts)

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi there.
As I said in the title, I have two questions, and I hope you can give me solutions:

1 - Is it possible to change the size of an array during the game? I know how to set the size at the beggining of the game, but not during the game.

2 - I'm trying to find the Z height of a point with a custom script, but i got an error when trying to save the map. The trigger is like this:

  • Hero's Position
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Position = (Position of Hero)
      • Custom script: set Position_Z = GetLocationZ(udg_Position)
Hero -> My character.
Position -> A point variable.
Position_Z -> A real variable.

It's the first time I try to do something like this, setting the value of a variable with a custom script. I wanted to try myself to do it before searching for more detailed information, but it seems that I am not able to make it work. When I try to save the map (in the editor), I take a compilation error, and the trigger gets off. I don't want to even imagine what would happen in-game...:goblin_boom:
Can you please help me? What's the right way to write that script?
Of course, it would be good if you can tell me if that trigger will give me the result I want (the Z height of the Hero).

Regards
 
Level 9
Joined
Apr 19, 2011
Messages
447

Could you explain how?

2. jass sucks :p

Yeah, I think the same thing. ¬¬
I wouldn't use anything related to JASS if I can use GUI for the same purpose.

Just use this if you want to find Z offset of a unit (Flying Unit)
  • Custom script: set udg_Z = GetUnitFlyHeight(YourUnit)
This will return the Z offset of your unit.
Z is Real variable

Are you sure that'll work? The unit is NOT a flying one. I thought that GetUnitFlyHeight() shows the unit's Z height OVER the ground, and that's not what I want.
I want to know the absolute Z height of the unit, not his Z height over the ground.
For example:
The unit is on a plateau - > Height 0.
The unit moves into a terrain deformation - > New height?

The purpose of this is to create a camera system. I want the camera to go up and down as the unit moves, and for that I need to know his Z height.

Regards
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
Arrays have a constant size of 8192, you cannot change that. If you use the GUI Variable Editor and you set size to n it only means the first n fields will have the specified default value assigned.

If you need the Z value of a point just create a location and get its Z value.
JASS:
local location loc = Location(udg_x, udg_y)
set udg_z = GetLocationZ(loc)
call RemoveLocation(loc)

The problem with your initial trigger:
  • Custom script: set Position_Z = GetLocationZ(udg_Position)
->
  • Custom script: set udg_Position_Z = GetLocationZ(udg_Position)
 
Level 9
Joined
Apr 19, 2011
Messages
447
Arrays have a constant size of 8192, you cannot change that. If you use the GUI Variable Editor and you set size to n it only means the first n fields will have the specified default value assigned.

If you need the Z value of a point just create a location and get its Z value.
JASS:
local location loc = Location(udg_x, udg_y)
set udg_z = GetLocationZ(loc)
call RemoveLocation(loc)

The problem with your initial trigger:
  • Custom script: set Position_Z = GetLocationZ(udg_Position)
->
  • Custom script: set udg_Position_Z = GetLocationZ(udg_Position)

Woah! I forgot to write udg_ before the name of the variable! (And I didn't even noticed...) OK, I'm going to make some more things to the map before testing again, but it looks that I'll work fine now.

About the arrays:
So they have a constant size of 8192... OK, it's good to know that.

Thank you muzzel. I'll test the map and I'll post the results.

Regards
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Oh I'm sorry, if you want to create a Lightning attached to a unit (Flying Unit), you directly fill the GetUnitFlyHeight(), you don't need to GetLocationZ() + GetUnitFlyHeight() provided that the terrain is at lower ground and flat.

But since it has terrain deformation and such, you should use the GetLocationZ.
And remember, if it is flying unit, then GetUnitFlyHeight plays its role.
 
Status
Not open for further replies.
Top