Forum

> > CS2D > Scripts > % buff in script
Forums overviewCS2D overview Scripts overviewLog in to reply

English % buff in script

4 replies
To the start Previous 1 Next To the start

old % buff in script

Mami Tomoe
User Off Offline

Quote
Hi I'm trying to create an item in my RPG server that will give you 15% more damage but I can't find a way to do it without messing things up.

This is what I have created in the meanwhile:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if ITEMS[PLAYERS[id].Equipment[8]] and ITEMS[PLAYERS[id].Equipment[8]].effect==2 then
				if warriorBuff[id]==false then
					warriorBuff[id]=true
					local newDmg=PLAYERS[id].tmp.atk*(15/100)
					PLAYERS[id].tmp.atk=math.floor(PLAYERS[id].tmp.atk+newDmg)
				end
			else
				if warriorBuff[id]==true then
					warriorBuff[id]=false
					local newDmg=1
					if ITEMS[PLAYERS[id].Equipment[3]] and ITEMS[PLAYERS[id].Equipment[3]].atk>0 then
						local newDmg=newDmg+ITEMS[PLAYERS[id].Equipment[3]].atk
					end
					PLAYERS[id].tmp.atk=math.floor(newDmg)
				end
			end
It's in the updateEQ function below most of the code and the problem with that is that when I unequip and equip random things the attack can get to even below 0 (happens when I equip the weapon last)
Do you guys know how to do it the proper way?

old Re: % buff in script

Talented Doge
User Off Offline

Quote
You said give one 15% more damage, not 85% less damage. But what you do was to reduce the damage to 15% of the original.

Do it:

local newdmg= a*1.15

old Re: % buff in script

Mami Tomoe
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
if ITEMS[PLAYERS[id].Equipment[8]] and ITEMS[PLAYERS[id].Equipment[8]].effect==2 then
		if warriorBuff[id]==false then
			warriorBuff[id]=true
			local newDmg=PLAYERS[id].tmp.atk*1.15
			PLAYERS[id].tmp.atk=math.floor(newDmg)
		end
	else
		if warriorBuff[id]==true then
			warriorBuff[id]=false
			local newDmg=PLAYERS[id].tmp.atk*0.85
			PLAYERS[id].tmp.atk=math.floor(newDmg)
		end
	end
Like this? This doesn't work right either, I lose 2 atk every time I equip and unequip the buffing item.

old Re: % buff in script

Talented Doge
User Off Offline

Quote
What are you trying to do within this script anyway? I don't understand unless you explain briefly. From what I can see, you want to reduce the damage if warriorBuff is off, and to increase if it is on?

If that is the case, swap the true and false, you messed them up.

old Re: % buff in script

Yates
Reviewer Off Offline

Quote
This is a Tibia bug (well not exactly a bug but you can't do it like this). The whole system makes no sense and you have to recalculate everything again. One does not simply edit Tibia.

Send me a PM and I'll leave it unread until I get home as a reminder to check my own edit to see how I did it (that's in 4 hours by the way).
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview