help with Growth ability = time based hitpoint and scaling value increase

Status
Not open for further replies.
Level 9
Joined
Jun 10, 2013
Messages
473
hello all >:D its been a while since I've been triggering so im a little rusty basically I need help triggering a passive time based hitpoint and scalling value increase ability which will increase a units hitpoints and scaling value the longer it lives the exact description of the ability is below:

Growth:
The warrior as all forces of nature grow and gain strength over time. After every minute the treant will gain an additional 10 hitpoints and increase in size (scale value would increase by 3% or 0.03)

any trigger and dummy object data ability help will be appreciated. Thanks in advance and in case I forget :)
 
Last edited:
Level 9
Joined
Jun 10, 2013
Messages
473
Try out SetUnitMaxState.
You can just call a function in a custom script that will increase the hp of your unit.

For the size, you would have to keep track of them.
Something like GetUnitScale would do the trick.

sounds good how ever I have no experience with JASS so if the links you posted are good enough for me to learn what to do then awesome :) and thanks if not thanks any ways but....
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
You have to learn about how to use global variables in custom scripts so you will be able to use them in the function calls.

The hp is quite simple.
In SetUnitMaxState, there is a function "AddUnitMaxState()" in which the first parameter has to be your unit, the second one will be "UNIT_STATE_MAX_LIFE" and the third will be "10".
So: "call SetUnitMaxState(udg_MyUnit, UNIT_STATE_MAX_LIFE, 10)"
(I still have to whack the creator for his completely rubbish logic behind making SetState the base function instead of the AddState function...)

The scale is slightly harder to use.
 
Level 14
Joined
Oct 18, 2013
Messages
724
For you, I would suggest having a Unit Group containing all the Treants, and then a periodic trigger that runs through each of them and gives them a tome of HP (change the item's ability to only increase Max HP by 10) and increases their size.
 
Level 9
Joined
Jun 10, 2013
Messages
473
For you, I would suggest having a Unit Group containing all the Treants, and then a periodic trigger that runs through each of them and gives them a tome of HP (change the item's ability to only increase Max HP by 10) and increases their size.

Well where the hell have you been >:D How ever I still like a challenge and from my understanding this system will allow me to do much more so if you would be so kind to continue from my last post wietlol :)
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Well, you should definately download JNGP 2.0
Not only does it allow you to write vJASS and use the precompiler of external tools, but it also gives you many more features such as more tiles in your tileset, larger map bounds, creates backups (life saver), etc.

I guess it is a good idea to take this into two steps (1: HP, 2: Size) and finish 1 before starting on 2.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Well, you should definately download JNGP 2.0
Not only does it allow you to write vJASS and use the precompiler of external tools, but it also gives you many more features such as more tiles in your tileset, larger map bounds, creates backups (life saver), etc.

I guess it is a good idea to take this into two steps (1: HP, 2: Size) and finish 1 before starting on 2.

before I saw your comment I already installed this http://www.wc3c.net/showthread.php?t=90999
is that okay? and thanks for your dedicated help!
 
Level 9
Joined
Jun 10, 2013
Messages
473
Well... ofcourse it is better to just use the newest version but that was the version before 2.0 and it was used pretty well, so it doesnt really matter for now.

alright welli'm starting to get an idea of how to do things now but concerning the two walls of jass code I need in order to automatically creat all those abilities

http://www.hiveworkshop.com/forums/graveyard-418/system-bonus-mod-setunitmaxstate-65622/

where do I put them? in a trigger comment? in case I did not explain it well i'm not to sure what to do with the jass codes in the implementation instructions section
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
When you select one of your triggers (create a new one for this), you can do "Edit -> Convert to custom text".

GUI triggers are only an editor version of pure code.
The code used by the triggers is JASS (the code that is used in warcraft 3 maps).
Custom scripts also link to direct JASS code (if you ever wondered how custom scripts work).

So, when you convert it to custom text, you can see the JASS implementation of your trigger.
If you do that to a new trigger and you paste the JASS code that you need.
(However, you should just copy and paste from the example map of SetUnitMaxState.)

The ability generation is done using an external tool.
In the JASSHelper precompiler, you can use external tools to modify your map's data.
For example, add some abilities (objectmerger), automatically generated code (structs), load in data from your object editor (mpq reader), etc.

But there should be some "how to install" instructions in the thread of SetUnitMaxState.
 
Level 9
Joined
Jun 10, 2013
Messages
473
When you select one of your triggers (create a new one for this), you can do "Edit -> Convert to custom text".

GUI triggers are only an editor version of pure code.
The code used by the triggers is JASS (the code that is used in warcraft 3 maps).
Custom scripts also link to direct JASS code (if you ever wondered how custom scripts work).

So, when you convert it to custom text, you can see the JASS implementation of your trigger.
If you do that to a new trigger and you paste the JASS code that you need.
(However, you should just copy and paste from the example map of SetUnitMaxState.)

The ability generation is done using an external tool.
In the JASSHelper precompiler, you can use external tools to modify your map's data.
For example, add some abilities (objectmerger), automatically generated code (structs), load in data from your object editor (mpq reader), etc.

But there should be some "how to install" instructions in the thread of SetUnitMaxState.

I keep getting an unable to find macro: optional error
 
Level 9
Joined
Apr 23, 2010
Messages
312
For you, I would suggest having a Unit Group containing all the Treants, and then a periodic trigger that runs through each of them and gives them a tome of HP (change the item's ability to only increase Max HP by 10) and increases their size.

If your unit is a hero Kakerate's suggestion will work, otherwise you will have to do something a little more time consuming.

You'll want to create an ability like the manual of health (Base Ability: Item Life Bonus). Then add as many levels as you want, but for the health increases you'll have to use a negative number (To do this hold Shift when you click the field), below is an ability I made for a map.

Untitled.jpg

After you set the ability then you want to trigger it. The one I used is a lot larger, but this will do the same thing.

  • Untitled Trigger 001
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set incrament = (incrament + 1)
      • Set temp_group = (Units of type Treant)
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Unit - Add Increase Health to (Picked unit)
          • Unit - Set level of Increase Health for (Picked unit) to incrament
          • Unit - Remove Increase Health from (Picked unit)
      • Custom script: call DestroyGroup(udg_temp_group)
 
Level 14
Joined
Oct 18, 2013
Messages
724
Doesn't really matter if it's a unit or a hero afaik. Units just need to be given the inventory ability before they are given the tome. I haven't tested in editor but 13oot-Me's method might mess up in the event of the treants transforming (robogoblin, stuff like that)

I know the tome of HP method bugs with transformations. If your map does use transformations, youd have to keep an integer that keeps track of how many tomes each unit has been given, and give them that many HP tomes. At that point it gets pretty inneffient. If 13oot-Me's method doesn't have that bug and your treants have transformation abilities, definitely use his idea.

saru, you should test and see if 13oot-Me's idea plays nice with transformations. For one of my maps I have a unit thats given tomes of HP and Damage when it spawns, and it transforms. Makes it tedious having to feed the tomes back to the unit everytime it transforms. If it does, I should probably just use that method instead.
Any way to replace the need of using damage tomes would be nice too.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Doesn't really matter if it's a unit or a hero afaik. Units just need to be given the inventory ability before they are given the tome. I haven't tested in editor but 13oot-Me's method might mess up in the event of the treants transforming (robogoblin, stuff like that)

Maybe you did it differently than I did, but as a test I gave footman the hero inventory then had a trigger every 2 seconds give all footman a tome of health. The tome was just placed at the location of the unit, not in the inventory nor was it consumed. Also tried this with the ability of the tome itself, both failed for me.
 
Level 9
Joined
Jun 10, 2013
Messages
473
well if there's a non-inventory way using triggers i'd rather use that and due note I want the unit to constantly be getting its health increased by 10 every minute and if it never dies then it never stops getting the 10 hit points added to it every minute this would also affect around 6 units who are all trainable as reg units with no inventories and I don't no one you mean by transform but its always the same unit

//can't I just make an upgrade go off every minute adding 10 to the hit points of the desired unit types , however I guess that wouldn't work since I want newly trained units to start off with their original health :/
 
Level 9
Joined
Apr 23, 2010
Messages
312
well if there's a non-inventory way using triggers i'd rather use that and due note I want the unit to constantly be getting its health increased by 10 every minute and if it never dies then it never stops getting the 10 hit points added to it every minute this would also affect around 6 units who are all trainable as reg units with no inventories and I don't no one you mean by transform but its always the same unit

//can't I just make an upgrade go off every minute adding 10 to the hit points of the desired unit types , however I guess that wouldn't work since I want newly trained units to start off with their original health :/

Well just make sure you have enough levels in the ability and you should be fine. 1 minute for 1 level basically, but if you want it to be different for every unit like you said then you'll need a few more additions to your code. You'll want to assign every treant its own number so you can call that specific units level of the ability rather than the ability as a whole (the way it is now). I can help more later when I have access to the editor.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Well just make sure you have enough levels in the ability and you should be fine. 1 minute for 1 level basically, but if you want it to be different for every unit like you said then you'll need a few more additions to your code. You'll want to assign every treant its own number so you can call that specific units level of the ability rather than the ability as a whole (the way it is now). I can help more later when I have access to the editor.

but then there will still be a shortage on levels since theirs and indefinite amount of minutes
 
Level 14
Joined
Oct 18, 2013
Messages
724
Maybe you did it differently than I did, but as a test I gave footman the hero inventory then had a trigger every 2 seconds give all footman a tome of health. The tome was just placed at the location of the unit, not in the inventory nor was it consumed. Also tried this with the ability of the tome itself, both failed for me.
Looking at my map, I notice now that in the Object Editor the unit has an inventory ability, based off of the Footman Inventory Ability. I don't know if which Inv. ability it is matters or not. I modified the Footman One to give 0 inventory slots, which funnily enough still allows the use of tomes.

If Units require having the inventory ability as specified by the Object Editor on compile, then my method is somewhat limited. I could probably get around to testing these things and getting back to this post. As a safeguard, I remove the Inventory ability from the unit after all tomes are given to it. In your map, you would want to do this as well, incase the player tries picking up any stray Stat Tomes up with the treants (causing a crash) Don't worry about not being to give it tomes after you remove the ability, whenever you need to give it another tome, just add the ability quick.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Looking at my map, I notice now that in the Object Editor the unit has an inventory ability, based off of the Footman Inventory Ability. I don't know if which Inv. ability it is matters or not. I modified the Footman One to give 0 inventory slots, which funnily enough still allows the use of tomes.

If Units require having the inventory ability as specified by the Object Editor on compile, then my method is somewhat limited. I could probably get around to testing these things and getting back to this post. As a safeguard, I remove the Inventory ability from the unit after all tomes are given to it. In your map, you would want to do this as well, incase the player tries picking up any stray Stat Tomes up with the treants (causing a crash) Don't worry about not being to give it tomes after you remove the ability, whenever you need to give it another tome, just add the ability quick.

alright well can you give me a pic of the trigger?
 
Level 9
Joined
Apr 23, 2010
Messages
312
but then there will still be a shortage on levels since theirs and indefinite amount of minutes

True, but how long do you think a long game will last for what you're working on? Even if it lasts for 50 minutes, this will be different for each Treant, and who knows if that unit will live to the end.

Sorry it took so long to get back to you I was having some issues with the trigger. Firstly with the ability, make each level the same bonus (-10) to work properly, example below.
Untitled.jpg

To make this work for each individual Treant separately and on different levels we have to store the level of the ability for that unit to it's custom value. The custom value is called before we add the ability so we can increase the level and add more health.

  • Untitled Trigger 002
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Treant) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Set ability_level = ((Custom value of (Picked unit)) + 1)
          • Unit - Add Increase Health to (Picked unit)
          • Unit - Set level of Increase Health for (Picked unit) to ability_level
          • Unit - Remove Increase Health from (Picked unit)
          • Unit - Set the custom value of (Picked unit) to ability_level
      • Custom script: call DestroyGroup(udg_temp_group)
 
Level 9
Joined
Jun 10, 2013
Messages
473
True, but how long do you think a long game will last for what you're working on? Even if it lasts for 50 minutes, this will be different for each Treant, and who knows if that unit will live to the end.

Sorry it took so long to get back to you I was having some issues with the trigger. Firstly with the ability, make each level the same bonus (-10) to work properly, example below.
Untitled.jpg

To make this work for each individual Treant separately and on different levels we have to store the level of the ability for that unit to it's custom value. The custom value is called before we add the ability so we can increase the level and add more health.

  • Untitled Trigger 002
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Treant) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Set ability_level = ((Custom value of (Picked unit)) + 1)
          • Unit - Add Increase Health to (Picked unit)
          • Unit - Set level of Increase Health for (Picked unit) to ability_level
          • Unit - Remove Increase Health from (Picked unit)
          • Unit - Set the custom value of (Picked unit) to ability_level
      • Custom script: call DestroyGroup(udg_temp_group)

for some reason I can't set max life gained to a negative value even though I have them enable in map preferences
 
Level 9
Joined
Apr 23, 2010
Messages
312
Level 9
Joined
Jun 10, 2013
Messages
473
You're using 2 different groups. You set temp_group, then for the loop you call tempgroup1. Change tempgroup1 to temp_group, also move the custom script outside of the loop otherwise you will kill the trigger before it finishes and it will only effect 1 unit.

It happens ;)

Ah dumb ass me XD thanks, will get back to you

EDIT// it works perfectly except a 10 second lag at the first time the hp is granted but only one time and never again ! thanks now for the second part of changing their scale by 0.03 every 60 seconds
 
Last edited:
Level 9
Joined
Apr 23, 2010
Messages
312
Ah dumb ass me XD thanks, will get back to you

EDIT// it works perfectly except a 10 second lag at the first time the hp is granted but only one time and never again ! thanks now for the second part of changing their scale by 0.03 every 60 seconds

Yeah im not sure exactly why it lags the game when it begins the trigger, maybe the initial setting of the group? Ok for the sizing try the below code. The 3.00 is basically just adding a 3% scaling size to the unit. Add these lines just after where you set ability_level.

  • Set size = (100.00 + ((Real(ability_level)) x 3.00))
  • Animation - Change (Picked unit)'s size to (size%, size%, size%) of its original size
 
Level 9
Joined
Jun 10, 2013
Messages
473
Yeah im not sure exactly why it lags the game when it begins the trigger, maybe the initial setting of the group? Ok for the sizing try the below code. The 3.00 is basically just adding a 3% scaling size to the unit. Add these lines just after where you set ability_level.

  • Set size = (100.00 + ((Real(ability_level)) x 3.00))
  • Animation - Change (Picked unit)'s size to (size%, size%, size%) of its original size

I had to change the x amount to 0.03 other wise he would go through the roof and it only works the first time and not again how ever the hp bonus still works perfectly
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
That lag is called preloading.
It takes the game quite some data to store everything properly of all those levels that you have for your ability.
The first time that that ability is added to a unit, it will load all data from the HD and set it in the RAM (variables), that should be done at map init so this 10s lagg will not occur during the game itself.
To do the preloading at map init, you just create a unit and give it the ability and remove the unit... nothing special about it.
 
Level 9
Joined
Apr 23, 2010
Messages
312
I had to change the x amount to 0.03 other wise he would go through the roof and it only works the first time and not again how ever the hp bonus still works perfectly

Hmm... 3.00 works pretty well for me but it's whatever you want haha I'll just attach my test map for you since you've done all the work anyways.

I also put in an initial spawn for a unit and gave it the ability to try what wietlol said, I couldn't tell a difference but maybe because there isn't a whole lot on the test map.
 
Level 9
Joined
Jun 10, 2013
Messages
473
Hmm... 3.00 works pretty well for me but it's whatever you want haha I'll just attach my test map for you since you've done all the work anyways.

I also put in an initial spawn for a unit and gave it the ability to try what wietlol said, I couldn't tell a difference but maybe because there isn't a whole lot on the test map.
well I copied your trigger and still had to change the increase to 0.03 however it only increases his size the first time only instead of every minute

  • Growth
    • Events
      • Time - Every 6.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_group = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Ent) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in temp_group and do (Actions)
        • Loop - Actions
          • Set ability_level = ((Custom value of (Picked unit)) + 1)
          • Set size = (100.00 + ((Real(ability_level)) x 0.03))
          • Animation - Change (Picked unit)'s size to (size%, size%, size%) of its original size
          • Unit - Add Growth health increase to (Picked unit)
          • Unit - Set level of Growth health increase for (Picked unit) to ability_level
          • Unit - Remove Growth health increase from (Picked unit)
          • Unit - Set the custom value of (Picked unit) to ability_level
      • Custom script: call DestroyGroup(udg_temp_group)
 
Status
Not open for further replies.
Top