• 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 Critical hit animation

hesczu

New Member
Joined
Jun 14, 2007
Messages
148
Reaction score
0
THIS IS FOR TAGS.
TESTED IN REV 966

In your config.lua add this:
Code:
displayCriticalHitNotify = "yes" --made by elf

In configmanager.cpp
under this:

Code:
m_confInteger[WHITE_SKULL_TIME] = getGlobalNumber(L, "whiteSkullTime", 15 * 60 * 1000);

paste this

Code:
m_confString[DISPLAY_CRITICAL_HIT] = getGlobalString(L, "displayCriticalHitNotify", "no");

AFTER

In configmanager.h
Under this:
Code:
GENERATE_ACCOUNT_NUMBER,

paste this
Code:
DISPLAY_CRITICAL_HIT,

In player.cpp
In line 4274 add this:

Code:
void Player::sendCriticalHit() const
{
	if(g_config.getString(ConfigManager::DISPLAY_CRITICAL_HIT) == "yes")
		g_game.addAnimatedText(getPosition(), TEXTCOLOR_DARKRED, "CRITICAL!");
}

In player.h
line 564 add this:

Code:
void sendCriticalHit() const;

In weapons.cpp

In line 384 remplace this:

Code:
maxDamage <<= 1;

With this:
Code:
{
			maxDamage <<= 1;
			player->sendCriticalHit();
		}


In line 666 remplace this:

Code:
maxValue <<= 1;

with this:
Code:
{
		maxValue <<= 1;
		player->sendCriticalHit();
	}

In line 891 remplace this:
Code:
maxValue <<= 1;

with this

Code:
{
		maxValue <<= 1;
		player->sendCriticalHit();
	}

In line 996 remplace this:
Code:
if(maxDamage)
		return -maxChange;

	return random_range(-minChange, -maxChange, DISTRO_NORMAL);

With this:
Code:
if(maxDamage)
	{
		player->sendCriticalHit();
		return -maxChange;
	}

	return random_range(-minChange, -maxChange, DISTRO_NORMAL);

All credits to Elf, he made this code im only make some changes for capability with tags :D :D

If you think the weapons part is hard, feel free to download my attachment :D
 

Attachments

Last edited:
The code is quite unstable. Made my server crash every hit when someone critted.
 
Is it really included in the latest TFS? I can't find that line in config.lua

"displayCriticalHitNotify"
 
I'm having problems to get this work... i believe that it's better to give a code to locate where to add the code, because lines not always are the same xD.
 
(Problem deleted cause of autor stupidity)

After hard time with this code i made it myself ; D I just had to put a little faith in me.
This code is working grat on my TFS 0.2 : D many thanks
 
Last edited:
245 C:\Documents and Settings\Usuario\Mis documentos\0.3.6pl1\configmanager.cpp no matching function for call to `ConfigManager::getGlobalString(lua_State*&, const char[25], const char[3])'

error configmanager.cpp pls HELP =(
 
Back
Top