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

Feature New types of DAMAGE (how to create)

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
in enums.h
below it, or below in another type of combat:
Code:
COMBAT_FIREDAMAGE = 1 << 3,
add (in this line "dark" is the name of a new combat... you can choose another name, of course):
Code:
COMBAT_DARKDAMAGE = 1 << 4, // this number I don't know what means, but leave 1 << 4, hehe
you need increase the counter, is just increase the number of damages that you put for the first, in this case just one...
Code:
COMBAT_COUNT = 12 // normal counter
now with the increase:
Code:
COMBAT_COUNT = 13 // counter increased
in game.cpp
below the case, you will need create a new case this is very important, here you choose the color of your damage, what effect he will have when is used...
Code:
case COMBAT_LIFEDRAIN: {
            color = TEXTCOLOR_RED;
            effect = CONST_ME_MAGIC_RED;
            break;
        }
add:
Code:
case COMBAT_DARKDAMAGE: {
            color = TEXTCOLOR_DARKRED; // here you choose the color possible to your damage
            effect = CONST_ME_BLACKSMOKE;  // here is the effect of your damage
            break;
        }
here the colors possible to your damage, i'm not sure that is only this colors, if have more, someone comment and I'll put here.
Code:
TEXTCOLOR_BLUE = 5,
    TEXTCOLOR_LIGHTGREEN = 30,
    TEXTCOLOR_LIGHTBLUE = 35,
    TEXTCOLOR_MAYABLUE = 95,
    TEXTCOLOR_DARKRED = 108,
    TEXTCOLOR_LIGHTGREY = 129,
    TEXTCOLOR_SKYBLUE = 143,
    TEXTCOLOR_PURPLE = 154,
    TEXTCOLOR_RED = 180,
    TEXTCOLOR_ORANGE = 198,
    TEXTCOLOR_YELLOW = 210,
    TEXTCOLOR_WHITE_EXP = 215,
    TEXTCOLOR_NONE = 255,
in monsters.cpp
below this else if:
Code:
} else if (tmpName == "lifedrain") {
            combat->setParam(COMBAT_PARAM_TYPE, COMBAT_LIFEDRAIN);
you put your damage:
Code:
} else if (tmpName == "dark") {
            combat->setParam(COMBAT_PARAM_TYPE, COMBAT_DARKDAMAGE);
now, you will put the damage as imunity to monsters...
in monsters.cpp
below:
Code:
} else if ((attr = immunityNode.attribute("lifedrain"))) {
                if (attr.as_bool()) {
                    mType->damageImmunities |= COMBAT_LIFEDRAIN;
                }
add:
Code:
} else if ((attr = immunityNode.attribute("dark"))) {
                if (attr.as_bool()) {
                    mType->damageImmunities |= COMBAT_DARKDAMAGE;
                }
yeahhh, now you need put the attribute for elementies percent to monsters...
yet in monsters.cpp
below:
Code:
} else if ((attr = elementNode.attribute("lifedrainPercent"))) {
                mType->elementMap[COMBAT_LIFEDRAIN] = pugi::cast<int32_t>(attr.value());
add:
Code:
} else if ((attr = elementNode.attribute("darkPercent"))) {
                mType->elementMap[COMBAT_DARKDAMAGE] = pugi::cast<int32_t>(attr.value());
in spells.cpp
below :
Code:
"lifedrain",
add:
Code:
"dark",
the change of spells is about the reserved names for runes and spells in your spells.xml from data pack, be sure that the name that you will put in the new damage not is name of runes or spells, just for not give warning when you run the tfs
Its is all...
but make sure that the names that u always put will be the same, if mine is DARKDAMAGE u can change and leave the name you want, but always with the same name in all the changes ...
credit: for me, I never see it before.

EDIT: TFS 1.1, or 1.2 works, I don't know in anothers distribuitions.
 
Last edited:
Awesome work man! Thanks for this release/tutorial! That's really dope, and I encourage people to make their own if they can successfully do this and still keep up to date with master branch! I wanted to make water damage and ice damage seperate damages and colors and now I can do that very easily thanks to you :D
 
you welcome! me too wanted create a water damage, diferent of ice and drown hehe
but now we can :D
 
bump, just for another people see
 
Last edited:
Nice tutorial, I may try it out one day. Thanks for sharing! :D
 
Short explanation:
PHP:
1 << 3
1 is just 1, which is binary:
0 0 0 0, 0 0 0 1
<< is binary shift left operation [move all bits to left, add zeros at empty positions], which is equivalent of arithmetic '* 2'
3 is number of bits to move by 'shift left', so after 3 'shift left' operations its:
0 0 0 0, 1 0 0 0
which is number.. 8 (and its: 1 * 2 * 2 *2 = 8! )
 
Short explanation:
PHP:
1 << 3
1 is just 1, which is binary:
0 0 0 0, 0 0 0 1
<< is binary shift left operation [move all bits to left, add zeros at empty positions], which is equivalent of arithmetic '* 2'
3 is number of bits to move by 'shift left', so after 3 'shift left' operations its:
0 0 0 0, 1 0 0 0
which is number.. 8 (and its: 1 * 2 * 2 *2 = 8! )

1 * 2 * 2 * 2 is not equal to 8 factorial (8! = 40320).
 
Last edited:
Very nice! I'll introduce new elements in my server with this, thx!

Edit:
If you don't know what colors do you have in your server for the textcolor, just look for this in const.h.

Code:
enum TextColor_t
{
   TEXTCOLOR_BLUE     = 5,
   TEXTCOLOR_GREEN     = 18,
   TEXTCOLOR_TEAL     = 35,
   TEXTCOLOR_LIGHTGREEN   = 66,
   TEXTCOLOR_DARKBROWN   = 78,
   TEXTCOLOR_LIGHTPURPLE   = 83,
   TEXTCOLOR_LIGHTBLUE   = 89,
   TEXTCOLOR_MAYABLUE   = 95,
   TEXTCOLOR_DARKPURPLE   = 112,
   TEXTCOLOR_BROWN     = 120,
   TEXTCOLOR_GREY     = 129,
   TEXTCOLOR_DARKRED   = 144,
   TEXTCOLOR_DARKPINK   = 152,
   TEXTCOLOR_PURPLE   = 154,
   TEXTCOLOR_DARKORANGE   = 156,
   TEXTCOLOR_RED     = 180,
   TEXTCOLOR_PINK     = 190,
   TEXTCOLOR_ORANGE   = 192,
   TEXTCOLOR_DARKYELLOW   = 205,
   TEXTCOLOR_YELLOW   = 210,
   TEXTCOLOR_WHITE     = 215,

   TEXTCOLOR_NONE     = 255,
   TEXTCOLOR_UNKNOWN   = 256
};

This is mine on tfs 0.3.6pl1, I just added MAYABLUE and LIGHTPURPLE.

Greets!
 
Last edited:
Bro you know if I can put more colors?
exemple: TEXTCOLOR_DARKGREEN = (number of the color)
I don't know the list of colors that the Tibia use
 
qtConEx01ColorCodes.jpg

@silveralol

Searched for C++ Color Codes, should work I guess.

Edit -- nevermind, it goes from 0-255 but they are different colors, will search it and will post it in here, if there is a way to add new text colors I will tell you.
 
Last edited:
Bro you know if I can put more colors?
exemple: TEXTCOLOR_DARKGREEN = (number of the color)
I don't know the list of colors that the Tibia use
@silveralol

Searched for C++ Color Codes, should work I guess.

Edit -- nevermind, it goes from 0-255 but they are different colors, will search it and will post it in here, if there is a way to add new text colors I will tell you.
Tibia 'Outfit colors' and 'Animated text colors' viewer:
http://ots.me/colors

Outfit colors (I don't know generator, but I got old list of colors):
PHP:
array( 0 => 'FFFFFF',
                        1 => 'FFD4BF',
                        2 => 'FFE9BF',
                        3 => 'FFFFBF',
                        4 => 'E9FFBF',
                        5 => 'D4FFBF',
                        6 => 'BFFFBF',
                        7 => 'BFFFD4',
                        8 => 'BFFFE9',
                        9 => 'BFFFFF',
                        10 => 'BFE9FF',
                        11 => 'BFD4FF',
                        12 => 'BFBFFF',
                        13 => 'D4BFFF',
                        14 => 'E9BFFF',
                        15 => 'FFBFFF',
                        16 => 'FFBFE9',
                        17 => 'FFBFD4',
                        18 => 'FFBFBF',
                        19 => 'DADADA',
                        20 => 'BF9F8F',
                        21 => 'BFAF8F',
                        22 => 'BFBF8F',
                        23 => 'AFBF8F',
                        24 => '9FBF8F',
                        25 => '8FBF8F',
                        26 => '8FBF9F',
                        27 => '8FBFAF',
                        28 => '8FBFBF',
                        29 => '8FAFBF',
                        30 => '8F9FBF',
                        31 => '8F8FBF',
                        32 => '9F8FBF',
                        33 => 'AF8FBF',
                        34 => 'BF8FBF',
                        35 => 'BF8FAF',
                        36 => 'BF8F9F',
                        37 => 'BF8F8F',
                        38 => 'B6B6B6',
                        39 => 'BF7F5F',
                        40 => 'BF9F5F',
                        41 => 'BFBF5F',
                        42 => '9FBF5F',
                        43 => '7FBF5F',
                        44 => '5FBF5F',
                        45 => '5FBF7F',
                        46 => '5FBF9F',
                        47 => '5FBFBF',
                        48 => '5F9FBF',
                        49 => '5F7FBF',
                        50 => '5F5FBF',
                        51 => '7F5FBF',
                        52 => '9F5FBF',
                        53 => 'BF5FBF',
                        54 => 'BF5F9F',
                        55 => 'BF5F7F',
                        56 => 'BF5F5F',
                        57 => '919191',
                        58 => 'BF6A3F',
                        59 => 'BF943F',
                        60 => 'BFBF3F',
                        61 => '94BF3F',
                        62 => '6ABF3F',
                        63 => '3FBF3F',
                        64 => '3FBF6A',
                        65 => '3FBF94',
                        66 => '3FBFBF',
                        67 => '3F94BF',
                        68 => '3F6ABF',
                        69 => '3F3FBF',
                        70 => '6A3FBF',
                        71 => '943FBF',
                        72 => 'BF3FBF',
                        73 => 'BF3F94',
                        74 => 'BF3F6A',
                        75 => 'BF3F3F',
                        76 => '6D6D6D',
                        77 => 'FF5500',
                        78 => 'FFAA00',
                        79 => 'FFFF00',
                        80 => 'AAFF00',
                        81 => '54FF00',
                        82 => '00FF00',
                        83 => '00FF54',
                        84 => '00FFAA',
                        85 => '00FFFF',
                        86 => '00A9FF',
                        87 => '0055FF',
                        88 => '0000FF',
                        89 => '5500FF',
                        90 => 'A900FF',
                        91 => 'FE00FF',
                        92 => 'FF00AA',
                        93 => 'FF0055',
                        94 => 'FF0000',
                        95 => '484848',
                        96 => 'BF3F00',
                        97 => 'BF7F00',
                        98 => 'BFBF00',
                        99 => '7FBF00',
                        100 => '3FBF00',
                        101 => '00BF00',
                        102 => '00BF3F',
                        103 => '00BF7F',
                        104 => '00BFBF',
                        105 => '007FBF',
                        106 => '003FBF',
                        107 => '0000BF',
                        108 => '3F00BF',
                        109 => '7F00BF',
                        110 => 'BF00BF',
                        111 => 'BF007F',
                        112 => 'BF003F',
                        113 => 'BF0000',
                        114 => '242424',
                        115 => '7F2A00',
                        116 => '7F5500',
                        117 => '7F7F00',
                        118 => '55F700',
                        119 => '2A7F00',
                        120 => '007F00',
                        121 => '007F2A',
                        122 => '007F55',
                        123 => '007F7F',
                        124 => '00547F',
                        125 => '002A7F',
                        126 => '00007F',
                        127 => '2A007F',
                        128 => '54007F',
                        129 => '7F007F',
                        130 => '7F0055',
                        131 => '7F00A2',
                        132 => '7F0000');
Animated text color PHP generator (based on OTClient code):
PHP:
function getAnimatedTextColor($colorId)
{
    if($colorId >= 216 || $colorId <= 0)
    {
        $r = 0;
        $g = 0;
        $b = 0;
    }
    else
    {
        $r = (int) ($colorId / 36) % 6 * 51;
        $g = (int) ($colorId / 6) % 6 * 51;
        $b = $colorId % 6 * 51;
    }

   return ['red' => $r, 'green' => $g, 'blue' => $b];
}
 
Short explanation:
PHP:
1 << 3
1 is just 1, which is binary:
0 0 0 0, 0 0 0 1
<< is binary shift left operation [move all bits to left, add zeros at empty positions], which is equivalent of arithmetic '* 2'
3 is number of bits to move by 'shift left', so after 3 'shift left' operations its:
0 0 0 0, 1 0 0 0
which is number.. 8 (and its: 1 * 2 * 2 *2 = 8! )

what a headache lol, i saw once c++ script where they made it able to change healing numbers etc. configurable at config.lua instead of going into c++
which is also nice for the community i think
 
Back
Top