Lua Function doPlayerSetExtraAttackSpeed(cid, speed)

Joined
Apr 17, 2008
Messages
1,922
Reaction score
181
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:

Hazen

Riariari dorgas mano
Joined
Jun 27, 2009
Messages
39
Reaction score
0
awesome
now we can do many things that i don't imagined *---*


ctrl+D plax
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,561
Reaction score
815
Location
Caribbean Sea
tested and fully working?
 

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
28
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)
 

cbrm

Top Class brunet scripter
Staff member
Global Moderator
Joined
Jan 6, 2009
Messages
6,561
Reaction score
815
Location
Caribbean Sea
someone here is named richux?
 

Thuggeh

Member
Joined
Jul 10, 2007
Messages
201
Reaction score
0
Awesome, you did as I requested, I'm loving it. =)

Thanks.
 

spoofghost

Member
Joined
May 11, 2008
Messages
35
Reaction score
1
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
 

elf

Sing, sing blue silver
Joined
Dec 11, 2007
Messages
3,663
Reaction score
105
Location
Cracow, Poland
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)
Easy :peace:
 

Icy

Active Member
Joined
Aug 4, 2009
Messages
881
Reaction score
25
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..?
 
OP
Darkhaos
Joined
Apr 17, 2008
Messages
1,922
Reaction score
181
Location
Venezuela
doPlayerSetExtraAttackSpeed(cid, 1000) <--- player will get 1 second faster
doPlayerSetExtraAttackSpeed(cid, 0) <--- attack speed returns to default.
 

Icy

Active Member
Joined
Aug 4, 2009
Messages
881
Reaction score
25
doPlayerSetExtraAttackSpeed(cid, 1000) <--- player will get 1 second faster
doPlayerSetExtraAttackSpeed(cid, 0) <--- attack speed returns to default.
derp, read more carefully
 

foxkbt

Member
Joined
Sep 29, 2009
Messages
293
Reaction score
7
Location
Salvador
sorry but it dosent work on 8.54~8.57
plx can u fixed it for me?
thx for advanced
 

Strack

Member
Joined
May 15, 2009
Messages
198
Reaction score
14
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 ^^
 
Top