• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Define/Change unit properties via vJass during initialization

Level 1
Joined
Jul 20, 2023
Messages
3
Hello
I did TD things through GUI. I´m trying to learn little bit of Jass coding because of flexibility and clarity. I read tutorials and did researches but i can´t figure out some stuff.
Now i transfer some triggers to Jass in current state of map because its "hard" to maintenance and do corrections

My goal is to create easy towerdefence.

I did wave code where i create unit and changing the unit properies. It all works because i changing LastCreateUnit properties. All from changing Footmans : skin, armorType, armor, hp etc via call BlzSetUnit...

I wonder. Can i set towers properties when map is initializing? I tried some code but not working ( something with BlzSetUnitWeaponIntegerFieldBJ, UNIT_WEAPON_IF_ATTACK_DAMAGE_BASE ). I did code where properties are done when construct/upgrade is done with condition IF but it isn´t solution what i´m looking for.

Thank you for help
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,589
Hello, so what's wrong with changing the tower's properties in the Object Editor?

To me it would only make sense to modify the towers in response to some kind of Upgrade which shouldn't be happening during Map Initialization.

Or does your map have some kind of randomness to it which you'd like to happen before the game starts?

It sounds like the real issue is that you're running into a lot of If Then Else statements and it's becoming difficult to manage:
  • Events
    • Unit - A unit finishes construction
  • Conditions
  • Actions
    • Set Variable Tower = (Constructed structure)
    • If (Unit-type of Tower) Equal to Fire Tower then...
    • If (Unit-type of Tower) Equal to Water Tower then...
    • If (Unit-type of Tower) Equal to Earth Tower then...
You can solve the above issue by using a Hashtable which works sort of like a 2d Array. You would use the Unit-Type of your tower as the hashtable's Parent Key and the tower data as it's Child Keys.

This way you can plug the Unit-Type of your newly constructed tower into your Hashtable and get all of the data related to it.
 
Last edited:
Level 1
Joined
Jul 20, 2023
Messages
3
Thank you for reply. I don´t like to scrolling up and down to set,changing properties and compare with upgrade tower in object editor so im looking for another way (its good when its colored to pink but i dont know.. is there way to filter rows with data?) For me its easier to have some integers/strings with dmg, hp, amor and changing these.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,589
Thank you for reply. I don´t like to scrolling up and down to set,changing properties and compare with upgrade tower in object editor so im looking for another way (its good when its colored to pink but i dont know.. is there way to filter rows with data?) For me its easier to have some integers/strings with dmg, hp, amor and changing these.
You can look into this:

Otherwise, a Hashtable and some Arrays like I described in my last post could be used to update the Units in-game:
  • Set Variable Tower_Type[1] = Fire Tower
  • Set Variable Tower_Min_Damage[1] = 100
  • Set Variable Tower_Max_Damage[1] = 200
  • Set Variable Tower_Range[1] = 800.00
  • -------- Move on to to the next tower --------
  • Set Variable Tower_Type[2] = Water Tower
  • Set Variable Tower_Min_Damage[2] = 200
  • Set Variable Tower_Max_Damage[2] = 400
  • Set Variable Tower_Range[2] = 600.00
Of course you can do this in Jass/Lua as well.
 
Last edited:
Level 1
Joined
Jul 20, 2023
Messages
3
It is too advanced for me. I will try your suggestion, but first i will do research about hashtable i don´t know much about it. Thank you for help
 
Top