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

A New Look at Bonus Libs

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
So, I've been working a bit on the rewrite of my Bonus lib and I ended up coming up with a pretty neato architecture-

JASS:
/****************************************************************************************
*                                                                                       *
*                                   SETTINGS                                            *
*                                                                                       *
****************************************************************************************/
//! textmacro BONUS_CONFIG
    /****************************************************************************************
    *                                                                                       *
    *                               Limited Bonus Power                                     *
    *                                                                                       *
    *   Power determines how big a bonus range can go. For example, a power of 15 would be  *
    *   -(2^16) to 2^(16-1), or -65536 to 65535.                                            *
    *                                                                                       *
    ****************************************************************************************/
    //! i powers[armor] =           12      --> bonus armor
    //! i powers[damage] =          15      --> bonus damage
    //! i powers[agility] =         13      --> bonus agility
    //! i powers[strength] =        13      --> bonus strength
    //! i powers[intelligence] =    13      --> bonus intelligence
    //! i powers[liferegen] =       15      --> bonus life regen
    //! i powers[manaregen] =       8       --> bonus mana regen (%) (8 max?)
    //! i powers[sight] =           10      --> bonus sight range (10 max)
    //! i powers[attackspeed] =     8       --> bonus attack speed (%) (8 max)
    /****************************************************************************************
    *                                                                                       *
    *                               Unlimited Bonus Power                                   *
    *                                                                                       *
    *   Power for unlimited bonuses increases speed of add/remove for larger values         *
    *   and makes larger values easier to get to. For example, 50,000,000 is much           *
    *   faster adding units of 1,048,576 than adding units of 16. In units of 16,           *
    *   50,000,000 might as well be impossible to get to.                                   *
    *                                                                                       *
    ****************************************************************************************/
    //! i powers[life] =            14      --> bonus life
    //! i powers[mana] =            14      --> bonus mana
    /****************************************************************************************
    *                                                                                       *
    *                               ENABLED                                                 *
    *                                                                                       *
    *   Should the bonus be implemented into the system? By disabling a bonus, it will not  *
    *   be in the system at all. Abilities and constants won't be made.                     *
    *                                                                                       *
    ****************************************************************************************/
    //! i enabled[armor] =          true	--> bonus armor
    //! i enabled[damage] =         true	--> bonus damage
    //! i enabled[agility] =        true	--> bonus agility
    //! i enabled[strength] =       true	--> bonus strength
    //! i enabled[intelligence] =   true	--> bonus intelligence
    //! i enabled[liferegen] =      true	--> bonus life regen
    //! i enabled[manaregen] =      true	--> bonus mana regen (%)
    //! i enabled[sight] =          true	--> bonus sight range
    //! i enabled[attackspeed] =    true	--> bonus attack speed (%)
    
    //! i enabled[life] =           true	--> bonus life
    //! i enabled[mana] =           true	--> bonus mana
//! endtextmacro
/****************************************************************************************
*                                                                                       *
*                                       CODE                                            *
*                                                                                       *
****************************************************************************************/
//! externalblock extension=lua ObjectMerger $FILENAME$
//! runtextmacro LUA_FILE_HEADER()
//! i dofile("GetVarObject")
//! i dofile("BonusAbility")
//! i dofile("BonusJASS.lua")

/********************
*                   *
*   ability ids     *
*                   *
********************/
//! i local ABILITY_MAX =   10
//! i   local armor =         0
//! i   local damage =        1
//! i   local agility =       2
//! i   local strength =      3
//! i   local intelligence =  4
//! i   local life =          5
//! i   local liferegen =     6
//! i   local mana =          7
//! i   local manaregen =     8
//! i   local sight =         9
//! i   local attackspeed =   10

/********************
*                   *
*   configuration   *
*                   *
********************/
//! i local powers =        {}          --> stores max powers for abilities
//! i local enabled =       {}          --> is ability enabled?
//! runtextmacro BONUS_CONFIG()         --> configure powers and enabled

/********************
*                   *
*   ability data    *
*                   *
********************/
//! i local abilities =     {}          --> array of abilities
//                                           perc    abil   field    name          ranged   enabled                max power
//! i abilities:insert( Ability.new( false, "AId1", "Idef", "ARMOR",        true,  enabled[armor],        powers[armor]))        --> armor
//! i abilities:insert( Ability.new( false, "AItg", "Iatt", "DAMAGE",       true,  enabled[damage],       powers[damage]))       --> damage
//! i abilities:insert( Ability.new( false, "AIa1", "Iagi", "AGILITY",      true,  enabled[agility],      powers[agility]))      --> agility
//! i abilities:insert( Ability.new( false, "AIs1", "Istr", "STRENGTH",     true,  enabled[strength],     powers[strength]))     --> strength
//! i abilities:insert( Ability.new( false, "AIi1", "Iint", "INTELLIGENCE", true,  enabled[intelligence], powers[intelligence])) --> intelligence
//! i abilities:insert( Ability.new( false, "AIlz", "Ilif", "LIFE",         false, enabled[life],         powers[armor]))        --> life
//! i abilities:insert( Ability.new( false, "Arel", "Ihpr", "LIFE_REGEN",   true,  enabled[liferegen],    powers[armor]))        --> life regen
//! i abilities:insert( Ability.new( false, "AImv", "Iman", "MANA",         false, enabled[mana],         powers[armor]))        --> mana
//! i abilities:insert( Ability.new( true,  "AIrm", "Imrp", "MANA_REGEN",   true,  enabled[manaregen],    powers[armor]))        --> mana regen
//! i abilities:insert( Ability.new( false, "AIsi", "Isib", "SIGHT",        true,  enabled[sight],        powers[armor]))        --> sight
//! i abilities:insert( Ability.new( true,  "AIsx", "Isx1", "ATTACK_SPEED", true,  enabled[attackspeed],  powers[armor]))        --> attack speed

//! i abilities = Ability.getvalid(abilities)
//! i abilities.limited = Ability.limitedenabled(abilities)
//! i abilities.unlimited = Ability.unlimitedenabled(abilities)

/********************
*                   *
*   jass script     *
*                   *
********************/
//! i local jass = BonusJASS.getjass(abilities)                 --> convert abilities object into JASS script

//! i writejass("BONUS",jass)

/********************
*                   *
*   update objects  *
*                   *
********************/
//! i updateobjects()
//! endexternalblock


That's just ofc in the main file. Anyways, what I'm wondering is if people want me to include effects in this new update or write a separate effects lib? As can be seen, it's nicely organized and one can pick whatever features they want to enable. If a feature isn't enabled, the vjass code won't even be written (all of the vjass code is now generated by Lua).
 
Status
Not open for further replies.
Top