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

[Solved] Custom Stat System

Status
Not open for further replies.
Level 5
Joined
Apr 29, 2015
Messages
143
Is there a way to make something like "every x strength, increase 1 armor"?
I tried this system but I got mindblocked on how to use those API.
The listed APIs are...

CSS_GetBonus takes unit u, integer bonusType returns integer
CSS_AddBonus takes unit u, integer amount, integer bonusType returns nothing
CSS_ClearBonus takes unit u, integer bonusType

Those bonus type are simply code which I do know how to use but the rest, I just don't know how since there are no explanation or samples on how to do it. :(
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
JASS:
//**************************************************************************************
//* Bonus Types Identifier:                                                            *
//*                                                                                    *
//* Armor Bonus:        0                                                              *
//* Attack Speed Bonus: 1                                                              *
//* Damage Bonus:       2                                                              *
//* Agility Bonus:      3                                                              *
//* Intelligence Bonus: 4                                                              *
//* Strength Bonus:     5                                                              *
//* Life Regen Bonus:   6                                                              *
//* Mana Regen Bonus:   7                                                              *
//* Life Bonus:         8                                                              *
//* Mana Bonus:         9                                                              *
//* Sight Range Bonus:  10                                                             *
//**************************************************************************************

//********************************************************************************
//* Generic Bonus APIs                                                           *
//*                                                                              *
//* CSS_GetBonus takes unit u, integer bonusType returns integer                 *
//* CSS_AddBonus takes unit u, integer amount, integer bonusType returns nothing *
//* CSS_ClearBonus takes unit u, integer bonusType                               *
//********************************************************************************

If you want to add a bonus to a unit, use call CSS_AddBonus(whichUnit, someAmount, whichBonusType). I believe using a negative value for someAmount will work as well. If you want to get rid of all the bonus of a bonus type you added, then you use call CSS_ClearBonus(whichUnit, whichBonusType).
 
Level 5
Joined
Apr 29, 2015
Messages
143
Ok so now I understand this better than before but if to use variables... Should I just?

call CSS_AddBonus(udg_TempUnit, udg_TempInteger, 5)

Something like this, right?
 
Level 5
Joined
Apr 29, 2015
Messages
143
Ok then this pretty much helps me now, will try this at home and thanks for helping. :)
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Ahh sorry I just realized something with one of your previous posts.
call CSS_AddBonus(udg_TempUnit, udg_TempInteger, 5)
You stated that you wanted to give 1 armor for every X strength. If you look at the API, you are giving udg_TempUnit bonus type 5, which is Strength. In simpler terms, you gave udg_TempUnit X Strength. If you want to give armor, make sure to use bonus type 0: call CSS_AddBonus(udg_TempUnit, 1, 0)
 
Level 5
Joined
Apr 29, 2015
Messages
143
I know, its just there as a example.
I would do it like.

Code:
ExtraStrengthDefense
    Events
        Unit - A unit Acquires an item
        Unit - A unit Loses an item
        Unit - A unit Gains a level
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set TempInteger = ((Strength of (Triggering unit) (Include bonuses)) - (Strength of (Triggering unit) (Exclude bonuses)))
        Set TempUnit = (Triggering unit)
        Custom script:   call CSS_AddBonus(udg_TempUnit, udg_TempInteger, 0)

And for the base strength, it is made into another trigger which is upgrade based.
I want to give reputation but sadly, haven't spread to other players yet. :(
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
If you are going to post GUI triggers, use [trigger][/trigger] tags :p

If that unit can only get strength via those events (ex: not getting strength from the actual system), then that's fine. My only suggestion for you is to first store (Triggering unit) into TempUnit, and then referring to that variable afterwards instead of calling the (Triggering unit) function twice in the TempInteger line.
 
Level 5
Joined
Apr 29, 2015
Messages
143
Oh ok, will remember that BBcode. :)
And now changed to...

  • ExtraStrengthDefense
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempUnit = (Triggering unit)
      • Set TempInteger = (((Strength of TempUnit (Include bonuses)) - (Strength of TempUnit (Exclude bonuses))) / 10)
      • Custom script: call CSS_ClearBonus(udg_TempUnit, 0)
      • Custom script: call CSS_AddBonus(udg_TempUnit, udg_TempInteger, 0)
 
Level 5
Joined
Apr 29, 2015
Messages
143
Ok so I got another problem with this and because it is still related with the same CSS system, I will have to reuse this thread, I guess.

Code:
call CSS_GetBonus(<unit>, <bonusType>)

I'm trying to get a bonus but if this function now gets a value, how will other variables get the value of the bonus stats?
 
Status
Not open for further replies.
Top