• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [1.3] Spells hitEffect and hitColor

dami1310

◄ Unidentified ►
Joined
Jan 27, 2013
Messages
732
Solutions
12
Reaction score
664
Location
Poland
Firstable, I am using tfs 1.3 downgrade 8.6 by nekiro.
Secondable, I am trying to add spells hitEffect and hitColor like it was done in 0.3.6, but I have found some problems.

Right now both hitEffect and hitColor depends on the combat type, example:
combatGetTypeInfo in game.cpp
Code:
        case COMBAT_ICEDAMAGE: {
            color = TEXTCOLOR_LIGHTBLUE;
            effect = CONST_ME_LOSEENERGY;
            break;
        }

I want to read both of them from spell file, like that:
Code:
combat:setParameter(COMBAT_PARAM_HITCOLOR, TEXTCOLOR_ORANGE)
combat:setParameter(COMBAT_PARAM_HITEFFECT, 21)

So, I have added:
bool Combat::setParam in combat.cpp
Code:
case COMBAT_PARAM_HITEFFECT: {
            params.hittEffect = static_cast<uint8_t>(value);
            return true;
        }

        case COMBAT_PARAM_HITCOLOR: {
            params.hittColor = static_cast<TextColor_t>(value);
            return true;
        }

CombatParams in combat.h
Code:
    uint8_t hittEffect = CONST_ME_NONE;
    TextColor_t hittColor = TEXTCOLOR_NONE;

Both luaDoTargetCombat and luaDoAreaCombat in luascript.cpp
Code:
        params.hittEffect = getNumber<uint8_t>(L, 7);
        params.hittColor = getNumber<TextColor_t>(L, 7);

Near the rest of enums in luascript.cpp
Code:
    registerEnum(COMBAT_PARAM_HITCOLOR)
    registerEnum(COMBAT_PARAM_HITEFFECT)

CombatParam_t in enums.h
Code:
    COMBAT_PARAM_HITEFFECT,
    COMBAT_PARAM_HITCOLOR,

Then I have found where the effects and colors are used and its combatChangeHealth in game.cpp
My question is, how can I use these values there?
I've tried using:
Code:
CombatParams params;
params.hittColor
params.hittEffect
I can compile without any problems, but it is simply not working.
Additional info: it is only for personal use and I will have both of them registered in every single spell, so all I need is read and send these values properly without any checks etc.
 
Solution
That's compiling without any problem because you are creating a local variable of type CombatParams and all its attributes have default values.
Here you can find what are the defaults:

In the following lines there are executions of combatChangeHealth:

In these executions, you can pass some additional parameters.
For example extend combatChangeHealth prototype with 3 new arguments like isCustomEffectSet, customEffect and customTextColor...
That's compiling without any problem because you are creating a local variable of type CombatParams and all its attributes have default values.
Here you can find what are the defaults:

In the following lines there are executions of combatChangeHealth:

In these executions, you can pass some additional parameters.
For example extend combatChangeHealth prototype with 3 new arguments like isCustomEffectSet, customEffect and customTextColor (or even pass whole CombatParams argument). Then based on their values you can determine whether overwrite hitEffect and message.primary.color or not. You can do this right after following line (default hitEffect value is already known):

Remember that there might be needed some default values for those new parameters as there are executions without any additional setup in code, like:
https://github.com/nekiro/forgottenserver/blob/8.6-downgrade/src/luascript.cpp#L6961

Of course, there might be a better solution, but that's what you can do quickly.
 
Solution
Back
Top