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

Lua Function doPlayerSetExtraAttackSpeed(cid, speed)

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Function tested in TFS 0.3.5Pl1

player.cpp
Find:
Code:
lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = 0;

Replace with this:
Code:
lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = extraAttackSpeed = 0;

Find:
Code:
return vocation->getAttackSpeed()

And replace with this:
Code:
return vocation->getAttackSpeed() - getPlayer()->getExtraAttackSpeed();

At the end of the file paste this:
Code:
void Player::setPlayerExtraAttackSpeed(uint32_t speed)
{
	extraAttackSpeed = speed;
}

player.h
Below:
Code:
uint64_t getSpentMana() const {return manaSpent;}

Paste this:
Code:
uint32_t getExtraAttackSpeed() const {return extraAttackSpeed;}
void setPlayerExtraAttackSpeed(uint32_t speed);

Below:
Code:
uint32_t idleTime;

Paste this:
Code:
uint32_t extraAttackSpeed;

luascript.cpp
Below:
Code:
	//doPlayerAddSoul(cid, soul)
	lua_register(m_luaState, "doPlayerAddSoul", LuaInterface::luaDoPlayerAddSoul);

Add this:
Code:
	//doPlayerSetExtraAttackSpeed(cid, speed)
	lua_register(m_luaState, "doPlayerSetExtraAttackSpeed", LuaInterface::luaDoPlayerSetExtraAttackSpeed);

After:
Code:
int32_t LuaInterface::luaDoPlayerAddSoul(lua_State* L)
{
	//doPlayerAddSoul(cid, soul)
	int32_t soul = popNumber(L);

	ScriptEnviroment* env = getEnv();
	if(Player* player = env->getPlayerByUID(popNumber(L)))
	{
		player->changeSoul(soul);
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}

Paste this:
Code:
int32_t LuaInterface::luaDoPlayerSetExtraAttackSpeed(lua_State *L)
{    
    uint32_t speed = popNumber(L);           	
    ScriptEnviroment* env = getEnv();
       if(Player* player = env->getPlayerByUID(popNumber(L))){    
			player->setPlayerExtraAttackSpeed(speed);
            lua_pushnumber(L, true);
       }    
       else{       
           errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
           lua_pushnumber(L, false);
       }       
    return 1;
}

luacript.h
Below:
Code:
		static int32_t luaDoPlayerAddSoul(lua_State* L);

Add:
Code:
		static int32_t luaDoPlayerSetExtraAttackSpeed(lua_State* L);

How to use?
Lua:
doPlayerSetExtraAttackSpeed(cid, 2000) <- attack speed will be 2 seconds more faster

Now compile and enjoy :)
 
Last edited:
awesome
now we can do many things that i don't imagined *---*


ctrl+D plax
 
tested and fully working?
 
you can try make the speed like a condition... is usefull for making spells like fast attack with a limit time (players can abuse the fast attack system and is very easy option for rpg's :S)
 
someone here is named richux?
 
Hey, sorry to bother but this piece of code edit makes it possible to create a faster attack speed.
if i read it correct?

if so thanks in advance! :)
going to try it out.

yours spoof
 
So I tried reverse-engineering this to work with 8.54+ and I honestly, for the life of me, can't figure out how to make it work.

Anyone have any idea..?
 
doPlayerSetExtraAttackSpeed(cid, 1000) <--- player will get 1 second faster
doPlayerSetExtraAttackSpeed(cid, 0) <--- attack speed returns to default.
 
runs perfect on tfs 0.3.6pl1 for tibia 8.54
the only thing u must change some things on sources 'cause it gives errors on compiling, but are easy things to be corrected

Thanks for sharing it darkhaos ^^
 
Back
Top