• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Compiling Random value in C++

whiteblXK

Active Member
Joined
Apr 20, 2011
Messages
315
Solutions
9
Reaction score
32
Location
Poland
Hello, in const.h I added
Code:
MAGIC_EFFECT_HIT1           = 0x89,
MAGIC_EFFECT_HIT2           = 0x8B,
in enum MagicEffect_t

In game.cpp I change:
Code:
 case RACE_BLOOD:
                 textColor = COLOR_RED;
                 magicEffect = MAGIC_EFFECT_DRAW_BLOOD;
                 splash = Item::CreateItem(ITEM_SMALLSPLASH, FLUID_BLOOD);
                 break;
to
Code:
 case RACE_BLOOD:
                 textColor = COLOR_RED;
                 magicEffect = random_range(MAGIC_EFFECT_HIT1,MAGIC_EFFECT_HIT2);
                 splash = Item::CreateItem(ITEM_SMALLSPLASH, FLUID_BLOOD);
                 break;
and I have this error when I compile:
Code:
\src\game.cpp:4489: error: invalid conversion from 'int32_t' to 'MagicEffect_t'
How to fix it? I use TFS 0.4 r3884
 
random_range(0, 1) == 1 ? MAGIC_EFFECT_HIT1 : MAGIC_EFFECT_HIT2
you could also try random_range((int32_t)MAGIC_EFFECT_HIT1, (int32_t)MAGIC_EFFECT_HIT2)
 
Code:
error: invalid conversion from 'int32_t' to 'MagicEffect_t'
In lua I would so:
MAGIC_EFFECT_HIT1 = 0x89, -- 137
MAGIC_EFFECT_HIT2 = 0x8B, -- 139

math.random(137, 139)

I don't know how to do in c++ :/
 
Back
Top