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

Use variables into item description ?

Status
Not open for further replies.
Level 3
Joined
Dec 2, 2013
Messages
25
Hi my lords, i wanted to know if it is possible to use variables into an item description... At the map initialisation, i load an huge amount of variable like this one (30 array / item, Approximately 50 items) :

Set DATAlightcrossbow[1] = 5
Set DATAlightcrossbow[2] = 1.3
Set DATAlightcrossbow[3] = 3
.
.
.

And now i just wanted to put these variables into an item description like this :

Light crossbow
Flat damage : DATAlightcrossbow[1]
Critical strike modifier : DATAlightcrossbow[2]
Weight : DATAlightcrossbow[3]

But i don't know if it's possible... For now i m directly writing these variables by myself but it is pretty annoying... Here is an example :

Light crossbow
Flat damage : 5
Critical strike modifier : 1.3
Weight :3

My goal, if i can use directely variables, is to update very quickely my items description just by changing

DATAlightcrossbow[1] = 5
to
DATAlightcrossbow[1] = 7
for example.

Hope that you understood my request ^^ Thanks for the help :)
 
Level 21
Joined
Dec 4, 2007
Messages
1,478
This is somewhat possible with huge workarounds (yet again). But even then very limited.
Investigate the water elemental spell, which is referencing unit data of the water elemental in its tooltip (like health, damage etc).

But really, you'll want to use another way to display your stats for such a system.
Most probably printing your values as a message to the inquiring player.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can reference object data values in object data text fields.
Sadly object data can only read from object data and triggers usually cannot read from object data, so you will probably have to write each value twice. Once as variable and once in object data.

As A]mum said, you can also read hit points from units which is one of the very few values, that can be read from triggers as well: create the unit and read it's maximum health
I would not recommend doing that though.

You can also create dummy abilities, that only contain data which is read by other abilities for example. This way you don't have to edit the text fields of the actual ability, but only have to change some values in a dummy ability. It is especially useful, when this data is used by multiple abilities.

Changing object data fields is impossible during the game. You cannot change tooltips and they are created at map initialization, so you can also not set tooltips to variables, as tooltips are probably generated before your variables are set.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Well, code introspection + object modification but then the compiled map should be separated else the substitution would happen the first time but then it's fixed. In wurst you can run compiletime functions to generate objects. You can do this in vJass, too, but only as external blocks that cannot really exchange information with the map script. A very ugly solution was to write textmacros that output both external blocks and generate variables. In DWC, I stepped completely away from it, externalized the data and wrote a compiler to convert it to both object files and injectable code modules.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Does it even work with newer versions of Warcraft III? If so one can surely expect it to be patched eventually..

I suggest writing a formula in the tooltip and maybe adding a chat command if people have problems with mental arithmetic. This will not increase loading time or use unsafe exploits.

Wont deny that, it does not work on the latest patches.
Still, easily doable if you are still running 1.26 or something
 
Status
Not open for further replies.
Top