Help C++ or Lua

massinha

New Member
Joined
Mar 13, 2019
Messages
8
Reaction score
0
Hello everyone, i want a little help...
i want a knight spell but i don't wanna say to active this spell, i want when i login this spell active...
like a buff but when i login active automatic.
when you have a life less than 20%... you gain attack speed, and axe sword, club +10

can someone help me ? Thanks for all ...
 

Togu

Active Member
Joined
Jun 22, 2018
Messages
240
Reaction score
93
Location
Brazil
player.h:
Code:
int32_t getAttackSpeed() const {
    return vocation->getAttackSpeed();
}
change to:
Code:
int32_t getAttackSpeed() const {
    if (health <= 0.2 * healthMax) {
        return vocation->getAttackSpeed() / 2; //its the same of "return 1000" (1 attack per second)
    } else {
        return vocation->getAttackSpeed();
    }
}
Didnt tested but i think that will work, attackspeed will have twice speed when hp is less or equal 20% of max hp

Axe sword and club bonus can be done via .lua i guess. There is healthChange creature event:
Code:
//scripting
        bool executeOnLogin(Player* player) const;
        bool executeOnLogout(Player* player) const;
        bool executeOnThink(Creature* creature, uint32_t interval);
        bool executeOnPrepareDeath(Creature* creature, Creature* killer);
        bool executeOnDeath(Creature* creature, Item* corpse, Creature* killer, Creature* mostDamageKiller, bool lastHitUnjustified, bool mostDamageUnjustified);
        void executeOnKill(Creature* creature, Creature* target);
        bool executeAdvance(Player* player, skills_t, uint32_t, uint32_t);
        void executeModalWindow(Player* player, uint32_t modalWindowId, uint8_t buttonId, uint8_t choiceId);
        bool executeTextEdit(Player* player, Item* item, const std::string& text);
        void executeHealthChange(Creature* creature, Creature* attacker, CombatDamage& damage);
        void executeManaChange(Creature* creature, Creature* attacker, CombatDamage& damage);
        void executeExtendedOpcode(Player* player, uint8_t opcode, const std::string& buffer);
You can make something like "every time health changes and is less than 20% -> give bonus skill" on a creature script.
I've done half work, maybe tomorrow I finish it or somebody else.
 
Last edited:
Top