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

Gain Wood per level

Status
Not open for further replies.
Level 3
Joined
May 1, 2008
Messages
43
Greetings everybody!
Now it has come to that, i am working on something, such as - you gain 2 wood when you gain a lvl. The problem here is that, if your character Hero gains too much exp and gains 2 lvls or even 3, as example you go from lvl 1 to 3 or 4 instantly, you still gain 2 wood and not 2xlvl gain. So when you gain enough exp to lvl from 1 to 4 you still earn 2 wood, how can this be fixed? Any ideas..?:con:
 
Level 27
Joined
Sep 24, 2006
Messages
4,979
Like?

Event:
When <Unit> Gains a level
Condition:
N/A
Action:
Add 2 Lumber to <Player>

Or?

Event:
When a unit owned by <Player> gains a level
Condition:
N/A
Action:
Add 2 Lumber to <Player>

Or?

Event:
When a unit gains a level
Condition:
Unit equal to <Unit>
Action:
Add 2 lumber to owner of <Triggering Unit>

Well?
 
Level 3
Joined
May 1, 2008
Messages
43
Post your triggers, please. It would be much easier to help.
But actually, I think this should work fine with a simple 2 line trigger, I go and check it now.


Well my triggers are:
Event:
--> Unit - A unit Gains a level
Condition:
N/a
Action:
Player - Add 2 to (Owner of (Triggering unit) Current lumber


And that works fine really, when my hero gains a lvl i get 2 lumber.
BUT the problem is, if lets say i gain 2 lvls or 3 lvls instantly, such as:
Each lvl = 300 exp needed.
Now i do a quest and earn 900 exp, that means my Hero will go from lvl 1 to lvl 4 ( lvl 1 + 300 = lvl 2 + 300 = lvl 3 + 300 = lvl 4 ) I will still only earn 2 lumber. See the problem? >.<
 
Level 17
Joined
Apr 13, 2008
Messages
1,597
Well, I recreated a simple 2liner and you are right, you'll gain only 2 lumber this way.

Whenever your hero levels up you increase its custom unit value by one. If your custom unit value is not equal to your hero's level then add as many times two lumber as the difference between your hero and its custom unit value.

Edit: sorted the thing out a little, I was in a hurry.
Edit2: I wrote it in JASS (if you know JASS)
JASS:
local integer diff
    set diff = GetHeroLevel(GetTriggerUnit()) - GetUnitUserData(GetTriggerUnit())
    call SetUnitUserData( GetTriggerUnit(), GetUnitUserData(GetTriggerUnit()) + diff)
    call SetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) + diff )
 
Last edited:
Level 3
Joined
May 1, 2008
Messages
43
Well, I recreated a simple 2liner and you are right, you'll gain only 2 lumber this way.

Whenever your hero levels up you increase its custom unit value by one. If your custom unit value is not equal to your hero's level then add as many times two lumber as the difference between your hero and its custom unit value.

Edit: sorted the thing out a little, I was in a hurry.
Edit2: I wrote it in JASS (if you know JASS)
JASS:
local integer diff
    set diff = GetHeroLevel(GetTriggerUnit()) - GetUnitUserData(GetTriggerUnit())
    call SetUnitUserData( GetTriggerUnit(), GetUnitUserData(GetTriggerUnit()) + diff)
    call SetPlayerState( GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER, GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) + diff )


Aaaaaah! But of course! Damn, lmao can't see why i didn't think of that! :xxd:
Thanks alot mate, ill use it, nice thinking tbh :gg:
 
Status
Not open for further replies.
Top