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

[Trigger] Scaling Heroes on Levelup?

Status
Not open for further replies.
Level 17
Joined
Sep 2, 2005
Messages
1,029
Is there a way (Jass or GUI) to scale a hero on levelup. I'm thinking along the lines of the units in Dungeon Keeper.

I'm hoping there is a way without making 30 copies (levels are going to 30 I believe) of the same unit at a different scale, and then either having to make the player reselect their abilities, or having to transfer all the abilities and items to the new hero.

I'm thinking just a "set unit scale" or something along those lines. If nothing else works I could make a global caster I guess, and cast a buffless version of bloodlust that has (whatever the max duration is) and then recast it before it wears off, but that seems A) Ridiculous, and B) Very inefficient.

If there's a way to do this differently it would be alot of help.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
1. Go learn math.
2. Use a equatation that uses the level as a variable.

Example: ((Hero Level) of (Leveling Unit)) * 20.

3. Don't get offended, im just really annoyed (and annoying) lately.

By the way, when do heros chaneg their sizes in Dungeon Keeper ? o0
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
1. Go learn math.
2. Use a equatation that uses the level as a variable.

Example: ((Hero Level) of (Leveling Unit)) * 20.

3. Don't get offended, im just really annoyed (and annoying) lately.

By the way, when do heros chaneg their sizes in Dungeon Keeper ? o0


The Math is not the problem. Finding a function that will do the scaling(as opposed to changing the model's scale in the object editor) is what I haven't been able to do. And in Dungeon keeper the creatures scale whenever they level up (all the creatures level up). At level 10 (Max level) they're about double size.
 
Last edited:
Level 17
Joined
Sep 2, 2005
Messages
1,029
That game actually was 3d :)

now that I'm thinking of it, conceptually DK would make a good warcraft 3 map :)

I thought about that already, youd need dirt that conforms to the size of a tile and is in square chunkc, as well as another one for gold. It would work if you had those though. They would have toi be a destructible.

And I dunno about DK2, but in DK1 all the monsters scaled. I remember I trained an imp to level 10 (most people wouldnt, theyre just imps) (crappy builder units) - but the imps get haste if you level them up a bit and then work much faster and run much faster.

Also for a DK map in WC3, how would you work the dungeon keeper in, who can pick up any of his units and drop them anywhere on his own terrain?

a DK map would be awesome, but alot of work. I'd start one if there were others who wanted to work on it with me though.

We'd need someone who's completely proficient in jass. I could do any of the other parts, though if there were a few peopel things would go faster.

We could use wc3 models for a while but eventually we'd need the more unique ones, like the horned reaper.


And yet still, I'm trying to come up with a jass function that handles the scaling of a unit, and I havent found anything from looking it up and there doesnt seem to be anything in gui.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Basic idéa of picking units up thing:

A spell that you target the unit you want to move saving it into a variable (unit), then you use the spell (same or another that replaces it) to set the specific area you want it to fall down to, and by triggers you use:

Unit - Move unit to target position of ability being cast.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Basic idéa of picking units up thing:

A spell that you target the unit you want to move saving it into a variable (unit), then you use the spell (same or another that replaces it) to set the specific area you want it to fall down to, and by triggers you use:

Unit - Move unit to target position of ability being cast.

Talk about the DK map Here

Now back to the Scaling issue. I just want to know how I change a unit's scale in jass. the name of a function would be fine then I can look it up.

I may have actually missed the solution. Time to test this animation set unit size thing.

This is like some other issues I've had with the WE. The inability to find what I'm looking for.

Like how I can't find the skull of Gul'dan model, even though I know its in there I just don't seem to be able to find it.
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
I think I know

Ok first off, do you have JassCraft?
(If not get it, helps sh*tloads)
Second, do you have the 1.21b patch of Warcraft?
(Again, if not, get it you may need it)

The function actually is SetUnitScale(), except some patches do not have certain functions

If you get JassCraft, you can search for functions based on like half of a word
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Ok first off, do you have JassCraft?
(If not get it, helps sh*tloads)
Second, do you have the 1.21b patch of Warcraft?
(Again, if not, get it you may need it)

The function actually is SetUnitScale(), except some patches do not have certain functions

If you get JassCraft, you can search for functions based on like half of a word

got jasscraft. It came with the Jass NewGen pack I believe. I found it under animation - setunitsize, i think it was. It's up above. It's working great now :p GhostWolf put the function up.

My only question now is, when the hero dies and gets revived, does the scaling stay? I'm going to set the scaling to considerably larger (like 4x size per lv) so that I can kill the hero, revive it, and see if it takes. And I gotta see if i can increase collision size and select scale. I probably can.

- Can't find collision size and selection scale in JassCraft. I think I have the patch I need. I'm the patch behind the no-cd.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Uh

I think it actually does, pretty recently I made a map where the unit tmeporarily has the avatar ability, which makes him like 1.5x the size, after he lost the ability + died before spell wore off, he rezed with his 1.5x scale

So I think it will stay if you do not change it back
Else, you could always just reset it with the death event

It kinda sucks, but I don't think you can change the collision size or the selection scale, at the same time I don't think the collision size even does anything >< (or at least works improperly)

Btw, if it takes you 5 mins to create a unit and/or change its name, thats due to the rush list being on, to turn it off go to the top of the World Editor --> Window --> Uncheck "Brush List" from the drop-down menu

Just an extremely useful tip
 
Level 12
Joined
Aug 20, 2007
Messages
866
Yeah, I'm not sure I think it might've had to do with something in the avatars coding, because there was supposed to be some kind of exit, but the spell was removed so it stayed permanent

I suppose if you don't feel like coding it in, you could just do that (add avatar ability, use it, then remove it) although that may be more code than the other way :bored:

Oh well, do what you please :thumbs_up:
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Code:
function Trig_Hero_Scaling_Actions takes nothing returns nothing
    //To make it easier to figure out scale
    local integer herolevel = GetHeroLevel(GetTriggerUnit())
    local integer maxlevel = 10
    local real finalsize = 200.00
    local real scaler 
    set scaler = 100.00 + ( (I2R(herolevel))*(finalsize/(maxlevel-1))) - (finalsize/maxlevel) ) 
    call SetUnitScalePercent( GetTriggerUnit(), scaler, scaler, scaler )
    call SetUnitMoveSpeed(GetTriggerUnit(), (40.00 *(scaler/100)))
    set scaler=null
    set finalsize=null
    set maxlevel = null
    set herolevel = null   
endfunction

Theres a syntax error on the set scaler line that I can't see. And my math is bad. can someone fix my formula?

Oh, and the scaling does stick.

And thirdly. is there a way to get a units id without making a gui function with it, converting it to custom text, copying the id, then scrapping the useless trigger, cause thats how I've been doing it because I can't figure out how to get to that info.
 
Last edited:
Level 10
Joined
Jun 26, 2005
Messages
236
Code:
function Trig_Hero_Scaling_Actions takes nothing returns nothing
    //To make it easier to figure out scale
    local integer herolevel = GetHeroLevel(GetTriggerUnit())
    local integer maxlevel = 10
    local real finalsize = 200.00
    local real scaler 
    set scaler = 100.00 + ( (I2R(herolevel))*(finalsize/(maxlevel-1))) - (finalsize/maxlevel) ) 
    call SetUnitScalePercent( GetTriggerUnit(), scaler, scaler, scaler )
    call SetUnitMoveSpeed(GetTriggerUnit(), (40.00 *(scaler/100)))
    set scaler=null
    set finalsize=null
    set maxlevel = null
    set herolevel = null   
endfunction

Should be:

JASS:
function Trig_Hero_Scaling_Actions takes nothing returns nothing
    //To make it easier to figure out scale
    local integer herolevel=GetHeroLevel(GetTriggerUnit())
    local integer maxlevel=10
    local real finalsize=200.
    local real scaler 
    set scaler=100.+((I2R(herolevel))*(finalsize/(maxlevel-1)))-(finalsize/maxlevel)
    call SetUnitScalePercent(GetTriggerUnit(),scaler,scaler,scaler)
    call SetUnitMoveSpeed(GetTriggerUnit(),(40.00*(scaler/100)))
endfunction

You can't null reals and integers, and you had an extra parenthisis after (finalsize/maxlevel).
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Should be:

JASS:
function Trig_Hero_Scaling_Actions takes nothing returns nothing
    //To make it easier to figure out scale
    local integer herolevel=GetHeroLevel(GetTriggerUnit())
    local integer maxlevel=10
    local real finalsize=200.
    local real scaler 
    set scaler=100.+((I2R(herolevel))*(finalsize/(maxlevel-1)))-(finalsize/maxlevel)
    call SetUnitScalePercent(GetTriggerUnit(),scaler,scaler,scaler)
    call SetUnitMoveSpeed(GetTriggerUnit(),(40.00*(scaler/100)))
endfunction

You can't null reals and integers, and you had an extra parenthisis after (finalsize/maxlevel).

Thanks for the help dude +rep


-----------------------
Finished
-----------------------
If anyone's curious, this is the formula to scale according to size evenly, and accurately. it took me 4 hours to figure it out. I'm not a big fan of math formulas. Strangely enough my Girlfriend who's taking calculus and doing well ghave me a formula that didnt work and I had to figue it out by myself. Damn math.
JASS:
//variables
local real scaler //the number to set the scale to in setunitscalepercent()
local integer maxlevel //the max hero level in the map
local integer herolevel //the current level of the hero
local real finalsize //the max sixe to scale the hero to, upon reaching the final level
//This formula assumes you're starting scaled at 100% To use another number I have no idea, and I don't want to try to figure it out right now. too much math.
set scaler=100-(1/(maxlevel-1)*100)+((I2R(herolevel))*(finalsize-100)/(maxlevel-1))
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Couldn't understand why you do not just do something like Level*Constant.
Something like this:
JASS:
globals
    constant integer int = 10 // each level the unit will get bigger by 10
endglobals
function scalar takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer r = GetUnitLevel(u)
    call SetUnitScale(u, r * int, r * int, r * int) 
    set u = null
endfunction


And put the Max values (max level, max size) in a global block, no point recreating the locals every time.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Couldn't understand why you do not just do something like Level*Constant.
Something like this:
JASS:
globals
    constant integer int = 10 // each level the unit will get bigger by 10
endglobals
function scalar takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer r = GetUnitLevel(u)
    call SetUnitScale(u, r * int, r * int, r * int) 
    set u = null
endfunction


And put the Max values (max level, max size) in a global block, no point recreating the locals every time.

I want to be able to change the max level or max size and have it tweak all the levels to evenly scale to that size accordingly, as I'm not sure what the max scale or level are going to be yet. And I don't want them to NOT get to max size by max level, or to get to max size BEFORE max level. However, if you can change my formula to take another variable instead of 100, say MinSize, still evenly scale to max size by max level, and still have an initial size which is constant (this would be what the new variable would do), that would be really helpful. So if I put MinSize to 80, then at level 1 it would be 80 regardless of what maxsize was, and it gets to maxsize at level 10, regardless of what it is then its the perfect function.
 
Level 15
Joined
Aug 18, 2007
Messages
1,390
Ok, simple way to scale heroes upon levelup:

  • Scaling
  • Events
    • Unit - A unit (Gains a level)
  • Conditions
  • Actions
    • Animation - Set units scaling value to ((current (X)scaling value of (Triggering unit) + (5)) (current (Y)scaling value of (Triggering unit) + (5)) (current (Z)scaling value of (Triggering unit) + (5))
Done, that trigger would increase the overall scaling of the hero by 5% when it level ups.
Not sure if that is what you need, but here it is anyway.

Edit: oh, already a solution, posted while i wrote... oh well.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I want to be able to change the max level or max size and have it tweak all the levels to evenly scale to that size accordingly, as I'm not sure what the max scale or level are going to be yet. And I don't want them to NOT get to max size by max level, or to get to max size BEFORE max level. However, if you can change my formula to take another variable instead of 100, say MinSize, still evenly scale to max size by max level, and still have an initial size which is constant (this would be what the new variable would do), that would be really helpful. So if I put MinSize to 80, then at level 1 it would be 80 regardless of what maxsize was, and it gets to maxsize at level 10, regardless of what it is then its the perfect function.

You simply do this formula: ((MaxSize - MinSize) / MaxLevel).
Now each level you increase by the value you got.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Ok, simple way to scale heroes upon levelup:

  • Scaling
  • Events
    • Unit - A unit (Gains a level)
  • Conditions
  • Actions
    • Animation - Set units scaling value to ((current (X)scaling value of (Triggering unit) + (5)) (current (Y)scaling value of (Triggering unit) + (5)) (current (Z)scaling value of (Triggering unit) + (5))
Done, that trigger would increase the overall scaling of the hero by 5% when it level ups.
Not sure if that is what you need, but here it is anyway.

Edit: oh, already a solution, posted while i wrote... oh well.

Your simplified scaling is nice, but won't work for me for the reasons specified above. I want the amount to scale per level to be calculated on a number of variables, and upon changing the variables I don't want to need to alter the formula.

I need Something that uses the Following Variables
StartSize - The size of the hero at level 1. it's a percentage times 100. 100 is default scale - It would be nice if this could take in whatever size I have set in the object editor somehow. The I can have it start from a different size depending on the unit
EndSize - The size we want him to grow to over however many levels a hero can get
CurrentLevel - Current Level of the hero. used to calculate what amount of the MaxSize to apply to the hero
MaxLevel - The Max level used in the map. If someone can make this actually use the customdata specifiec in the map without rewriting it into the variable that would be nice.
Scaler - This is just a variable to hold the answer.

If someone can adjust my formula to use the variables to better create the effect I'm looking for it would help alot.

Sidenote, I'm adjusting movement speed by the same amount. is there a way to access the default movement speed of a unit instead of what it's currently set to?
JASS:
//variables
local real scaler //the number to set the scale to in setunitscalepercent()
local integer maxlevel
local integer currentlevel
local real startsize
local real finalsize
//This formula assumes you're starting scaled at 100% To use another number I have no idea, and I don't want to try to figure it out right now. too much math.
set scaler=StartSize-(1/(maxlevel-1)*StartSize)+((I2R(currentlevel))*(finalsize-StartSize)/(maxlevel-1))

Here are some examples as to how the current formula works out.
CurrentLevel=10
MaxLevel=10
FinalSize=200

StartSize=100
scaler=100-(1/(10-1)*100)+((I2R(10))*(200-100)/(10-1)
scaler=100-(1/(9)*100)+(10)*(100)/(9)
scaler=100-(100/9)+(1000/9)
200=100-11.1~+111.1~ YAY!

StartSize=150
scaler=150-(1/(10-1)*150)+((I2R(10))*(200-150)/(10-1)
scaler=150-(150/(9))+(10)*(50)/(9)
199.8~=150-(16.6~)+(55.5~)YAY!(Close enough that I'm happy)

StartSize=90
scaler=90-(1/(10-1)*90)+((I2R(10))*(200-90)/(10-1)
scaler=90-(90/(9))+(10)*(110)/(10-1)
scaler=90-(10)+(122.2~)Boo!
222.2~=80+122

StartSize=80
scaler=80-(1/(10-1)*80)+((I2R(10))*(200-80)/(10-1)
scaler=80-(1/(9)*80)+(10)*(120)/(9)
scaler=80-(80/(9))+(1200)/(9)
204=80-(8.8~)+(133.3~) BOO!

StartSize=30
scaler=30-(1/(10-1)*30)+((I2R(10))*(200-30)/(10-1)
scaler=30-(30/9)+(1700)/(9)
215=30-(3.3~)+(188.8~) Boo!

StartSize=100
Maxlevel=30
scaler=100-(1/(30-1)*100)+(30)*(200-100)/(30-1)
scaler=100-(100/29)+(3000/29)
~106.89=100-(3100/29) SHIT

Apparently my formula only works at all if the maxlevel is 10. Can someone help me?

Conditions the formula needs to meet. (which my formula does not)
If CurrentLevel=Maxlevel, scaler = FinalSize
If CurrentLevel=1, scaler = StartSize
it should not matter what startsize, finalsize, or maxlevel are.
 
Last edited:
Level 12
Joined
Aug 20, 2007
Messages
866
Uhhhhh

I think your making this way more complicated than it really needs to be, although, I did notice something strange about the scaling when I did snowballs, the scaling was very odd, like 1000 compared to 100 was more like 100 ^ 10 rather than * 10

I don't know, I'll sleep on it and give you an answer
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
I think your making this way more complicated than it really needs to be, although, I did notice something strange about the scaling when I did snowballs, the scaling was very odd, like 1000 compared to 100 was more like 100 ^ 10 rather than * 10

I don't know, I'll sleep on it and give you an answer

I'm scaling plants. they can get pretty big. However, I don't want them to fill more than half the screen. Also, I don't know what size they will be, or what our max level will be yet. Since you'll be limited to 1 hero per player it will be more than 10.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
You simply do this formula: ((MaxSize - MinSize) / MaxLevel).
Now each level you increase by the value you got.

You posted that while I was writing the post that came after and I totally missed it.

Wow. I really overcomplicated things... I feel so retarded. lol. +rep

Now is there a way to access what the default scaling value of a unit is? I don't see like a GetUnitScale
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Just change it in the Object Manager.

...
I thought I explained myself as to why that wouldn't work.

The unit will be scaling as it gains levels, therefore getting bigger. I'll be doing this with more than one unit, and they may not all have the same default scale in the object editor.

Therefore, depending on the hero, I may have to start with a different value. If I can do it by having it retrieve what the thing says in the object editor, then I won't have to store the values of all my heroes starting scales in variables.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Wow

It just hit me that the scaling value in the object editor that you can manipulate, is exactly the same thing that is manipulated when you use triggers...

That'd be why the scale is all screwed up, it's like the percentage of the models proportions (or something odd like that), I tend to just increase them by small percentages (like 10% is usually significant, but not too much to be bothering)


Btw, if your not using it for anything else, using the custom value of a unit is great for animation type things that can't be edited normally (also for coloring you need to set to a variable)
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
It just hit me that the scaling value in the object editor that you can manipulate, is exactly the same thing that is manipulated when you use triggers...
Ahuh.

That'd be why the scale is all screwed up, it's like the percentage of the models proportions (or something odd like that), I tend to just increase them by small percentages (like 10% is usually significant, but not too much to be bothering)
Umm Sortof. The Scale Functions totally ignore the scale in the object editor. The just rewrite over it.

Btw, if your not using it for anything else, using the custom value of a unit is great for animation type things that can't be edited normally (also for coloring you need to set to a variable)

I have absolutely no idea what you're talking about here.
 
Level 12
Joined
Aug 20, 2007
Messages
866
Ok

The custom value of a unit is mostly used in gui (I have yet to see it in jass), but basically it is an integer attached to a unit, and every single unit in the game has a custom value
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
It's an integer for... a custom value...
It's just a value a unit has that doesn't have any meaning at all. The meaning the number has is entirely determined by the creator of the map, as he decides what the number does. It's actually quite a useful unit value, because unlike HP or Mana, you define yourself what the value is supposed to do.

In jass it's called "UserData", and gotten/set by a GetUnitUserData / SetUnitUserData functioncall.

Usually a handlevar system is used instead of this, although getting / setting the custom value is much faster than using a handlevar system.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
In most cases vJass removes the need for custom value.
In normal Jass I often needed it actually.
In GUI you need it like... ALOT.

Therefor, someone *points randomly at smart people* needs to create a system that can set and read custom values with diffrent digits.
For example: 111111111 as a base custom value, now you can for example change it to 111211111 and READ (if need be) that the 4th 1 was changed to 2.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
Nifty Idea. I could do that easily if this were java or vb. but I dunno if I could with jass.

Care to explain how jass is different than vjass? I know you need to instill something to use vjass, but I don't know what or what it does when you do.


Alright. I'm going to devise a system to deal with it. I'll encode an algorithm to change the numbers so it'll work, and instead of going by digit place I'll use 0 as a space. I'll do it by converting it to a string. I dunno how well it will work but I think its definitely worth a try. This of course means that you won't be able to use the standard function to access it or you'll just get a bunch of gibberish. However, I'm making a map where all sorts of creatures will have a fuckload of variables on them. And I don't know how I would deal with it other than making bigass arrays. This may work better.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
vJass allows you to use Jass in ways that are more OOB (Object Oriented whatever).
This means you can use structs (classes in Java), libararies and scopes.
In addition you can put global boxes to declare globals with text instead of the crappy variable editor, and it gives you some extra options in the Object Manager (shows some skills WE doesn't, allows you to specify a units rawcode when you make it, etc.).

To get vJass, you need to download JNGP (Jass New Gen Pack) which is a bunch of nice programs for Jass people made, and what it basicly do together is hack the WE.

In case you want to download it (very suggested for Jass users) click here.
 
Level 17
Joined
Sep 2, 2005
Messages
1,029
hmm. I have JNGP. How do I go about actually using vjass instead of Jass. I know now I have a native function checker, and that's nice, but for actual vJass how do I do access code libraries and what not.

Also how do I specify a rawcode when making a unit? And how do I make a function I can just call without having to make an actual trigger?
 
Level 12
Joined
Aug 20, 2007
Messages
866
Tuts are very helpful

Searching for tutorials on vJass is extremely helpful, here's a link to the vJass manual (which I found via searching on google x) )

vJass Manual

Btw, Ghostwolf it's OOP not OOB, and the "P" stands for programming
 
Status
Not open for further replies.
Top