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

CreatureEvent Addon "Bonus System"

Dilio

Owner of Project Thala
Joined
Jun 8, 2008
Messages
188
Reaction score
7
Location
London, Ontario
Requested by a bunch of people in: http://otland.net/f132/need-bonus-system-addon-help-64200/

Basically, what it does, is if you have the addons of the specified outfit, you will get bonuses, more explained in the request thread.

First register it as:
Lua:
<event type="outfit" name="Addons" event="script" value="outfits.lua"/>
<event type="login" name="AddonsLogin" event="script" value="outfits.lua"/>

And here's the script:
Lua:
local hunter = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(hunter, CONDITION_PARAM_TICKS, -1)
setConditionParam(hunter, CONDITION_PARAM_SKILL_DISTANCE, 3)
 
local knight = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(knight, CONDITION_PARAM_TICKS, -1)
setConditionParam(knight, CONDITION_PARAM_SKILL_SWORD, 3)
 
local mage = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(mage, CONDITION_PARAM_TICKS, -1)
setConditionParam(mage, CONDITION_PARAM_STAT_MAGICLEVEL, 2)
 
local barbarian = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(barbarian, CONDITION_PARAM_TICKS, -1)
setConditionParam(barbarian, CONDITION_PARAM_SKILL_AXE, 3)
 
local norse = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(norse, CONDITION_PARAM_TICKS, -1)
setConditionParam(norse, CONDITION_PARAM_SKILL_SHIELD, 2)
setConditionParam(norse, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
 
local nightmare = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(nightmare, CONDITION_PARAM_TICKS, -1)
setConditionParam(nightmare, CONDITION_PARAM_SKILL_SHIELD, 3)
setConditionParam(nightmare, CONDITION_PARAM_STAT_MAXHEALTH, 100) --- hp
 
local yalaharian = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(yalaharian, CONDITION_PARAM_TICKS, -1)
setConditionParam(yalaharian, CONDITION_PARAM_STAT_MAGICLEVEL, 2)
setConditionParam(yalaharian, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
setConditionParam(yalaharian, CONDITION_PARAM_STAT_MAXMANA, 200) --- mana
 
local demonhunter = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(demonhunter, CONDITION_PARAM_TICKS, -1)
setConditionParam(demonhunter, CONDITION_PARAM_STAT_MAXHEALTH, 500) --- hp
setConditionParam(demonhunter, CONDITION_PARAM_STAT_MAXMANA, 500) -- mana
 
local brotherhood = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(brotherhood, CONDITION_PARAM_TICKS, -1)
setConditionParam(brotherhood, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
 
local hpmana100 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(hpmana100, CONDITION_PARAM_TICKS, -1)
setConditionParam(hpmana100, CONDITION_PARAM_STAT_MAXHEALTH, 100) --- hp
setConditionParam(hpmana100, CONDITION_PARAM_STAT_MAXMANA, 100) --- mana
 
local hpmana200 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(hpmana200, CONDITION_PARAM_TICKS, -1)
setConditionParam(hpmana200, CONDITION_PARAM_STAT_MAXHEALTH, 200) --- hp
setConditionParam(hpmana200, CONDITION_PARAM_STAT_MAXMANA, 200) --- mana
 
local mana100 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(mana100, CONDITION_PARAM_TICKS, -1)
setConditionParam(mana100, CONDITION_PARAM_STAT_MAXMANA, 100) --- mana
 
local mana200 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(mana200, CONDITION_PARAM_TICKS, -1)
setConditionParam(mana200, CONDITION_PARAM_STAT_MAXMANA, 200) --- mana
 
local hp100 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(hp100, CONDITION_PARAM_TICKS, -1)
setConditionParam(hp100, CONDITION_PARAM_STAT_MAXHEALTH, 100) --- hp
 
local speed1 = createConditionObject(CONDITION_HASTE)
setConditionParam(speed1, CONDITION_PARAM_TICKS, -1)
setConditionParam(speed1, CONDITION_PARAM_SPEED, 10)
 
local speed2 = createConditionObject(CONDITION_HASTE)
setConditionParam(speed2, CONDITION_PARAM_TICKS, -1)
setConditionParam(speed2, CONDITION_PARAM_SPEED, 20)
 
--- CONDITION_PARAM_STAT_MAXHEALTH, CONDITION_PARAM_STAT_MAXMANA
--- CONDITION_PARAM_BUFF
outfitBonusTable = { --- [] = {condition = , typ = }
	[128] = {condition = {speed1, hp100}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, [136] = {condition = {speed1, hp100}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, --Citizen --[maxHealth = 100]
	[129] = {condition = hunter}, [137] = {condition = hunter}, --Hunter
	[130] = {condition = mana200, typ = CONDITION_ATTRIBUTES}, [138] = {condition = mana200, typ = CONDITION_ATTRIBUTES}, --Mage
	[131] = {condition = knight, typ = CONDITION_ATTRIBUTES}, [139] = {condition = knight, typ = CONDITION_ATTRIBUTES}, --Knight
	[133] = {condition = mana100, typ = CONDITION_ATTRIBUTES}, [141] = {condition = mana100, typ = CONDITION_ATTRIBUTES}, --Summoner -- [maxMana = 100]
	[134] = {condition = knight, typ = CONDITION_ATTRIBUTES}, [142] = {condition = knight, typ = CONDITION_ATTRIBUTES}, --Warrior
	[143] = {condition = barbarian, typ = CONDITION_ATTRIBUTES}, [147] = {condition = barbarian, typ = CONDITION_ATTRIBUTES}, --Barbarian
	[144] = {condition = mage, typ = CONDITION_ATTRIBUTES}, [148] = {condition = mage, typ = CONDITION_ATTRIBUTES}, --Druid
	[145] = {condition = {hpmana100}, typ = CONDITION_ATTRIBUTES}, [149] = {condition = {hpmana100}, typ = CONDITION_ATTRIBUTES}, --Wizard --[maxHealth = 100, maxMana = 100]
	[146] = {condition = {speed1, hpmana200}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, [150] = {condition = {speed1, hpmana200}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, --Oriental --[maxHealth = 200, maxMana = 200]
	[152] = {condition = speed2, typ = CONDITION_HASTE}, [156] = {condition = speed2, typ = CONDITION_HASTE}, --Assassin
	[154] = {condition = mage, typ = CONDITION_ATTRIBUTES}, [158] = {condition = mage, typ = CONDITION_ATTRIBUTES}, --Shaman
	[251] = {condition = norse, typ = CONDITION_ATTRIBUTES}, [252] = {condition = norse, typ = CONDITION_ATTRIBUTES}, --Norse [maxHealth = 200]
	[268] = {condition = nightmare, typ = CONDITION_ATTRIBUTES}, [269] = {condition = nightmare, typ = CONDITION_ATTRIBUTES}, --Nightmare --[maxHealth = 100]
	[270] = {condition = {speed1, hpmana100}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, [273] = {condition = {speed1, hpmana100}, typ = {CONDITION_HASTE, CONDITION_ATTRIBUTES}}, --Jester --[maxHealth = 100, maxMana = 100]
	[278] = {condition = brotherhood, typ = CONDITION_ATTRIBUTES}, [279] = {condition = brotherhood, typ = CONDITION_ATTRIBUTES}, --Brotherhood -- [maxHealth = 200]
	[288] = {condition = speed2, typ = CONDITION_HASTE}, [289] = {condition = speed2, typ = CONDITION_HASTE}, --Demonhunter --[maxHealth = 500, maxMana = 500]
	[324] = {condition = yalaharian, typ = CONDITION_ATTRIBUTES}, [325] = {condition = yalaharian, typ = CONDITION_ATTRIBUTES} --Yalaharian -- [maxHealth = 200, maxMana = 200]
}
 
function onLogin(cid)
	registerCreatureEvent(cid, "Addons")
	--- local current = getCreatureOutfit(cid)
	return onOutfit(cid, {lookAddons = 1}, getCreatureOutfit(cid)) and true
end
 
function onOutfit(cid, old, current)
	if getPlayerAccess(cid) >= 3 then
		return print("Staff/support can't get any addon bonus!") and true
	end
	if old.lookAddons == 3 and outfitBonusTable[old.lookType] then --Bonus off
		if (outfitBonusTable[old.lookType]).typ ~= nil then
			if type((outfitBonusTable[old.lookType]).typ) == "table" then
				for _, value in pairs((outfitBonusTable[old.lookType]).typ) do
					doRemoveCondition(cid, value)
				end
			else
				doRemoveCondition(cid, (outfitBonusTable[old.lookType]).typ)
			end
		end
	end
	if current.lookAddons == 3 and outfitBonusTable[current.lookType] then --Bonus on
		if (outfitBonusTable[current.lookType]).condition ~= nil then
			if type((outfitBonusTable[current.lookType]).condition) == "table" then
				for _, value in pairs((outfitBonusTable[current.lookType]).condition) do
					doAddCondition(cid, value)
				end
			else
				doAddCondition(cid, (outfitBonusTable[current.lookType]).condition)
			end
		end
	end
	return true
end

If there's a cleaner more organized way to code it, be my guest. Also, it does not include every outfit, just what was requested by that thread starter.

This was the most annoying script I have ever written, and it easily took an hour to script, so please, if you plan on using it, some rep wouldn't hurt.

I tested with 0.3.6PL1 and it worked fine.

P.S In order to edit this, I'd recommend having at least a bit of LUA knowledge before attempting.

Edit: Credits to Hellboy for the fix and rewrite of the script.

Edit 2: Credits to Chojrak for sorting this out:
If you want to get extremely simple, using Outfits.xml you can just put something like:
Lua:
	<outfit id="2">
		<list gender="0" lookType="137" name="Hunter"/>
			<skill dist="3"/>
		</list>
		<list gender="1" lookType="129" name="Hunter"/>
			<skill dist="4"/>
		</list>
	</outfit>

FINAL EDIT: CREDIT TO HELLBOY FOR THE LATEST SCRIPT
 
Last edited:
Test
if current.lookAddons == 3 then

...

Uhm.... kay? .-. I tested it last night and it works. The system is meant to work if the character has Addons 1 and 2 worn, which iswhy I have lookAddons == 3, because that means 1+2 is worn...
 
doesn't work in tfs 0.2.5 :/

how can i add the function "onOutfit(cid, old, current)" ???
someone can help????
 
well, I didn't wanted to use conditions cause it will interfere with haste/paralize/buff spells but whatever :D

ah right, you used doChangeSpeed/aff tried to use doCreatureSetBaseSpeed :D/
When I saw many conditions i thought that you used haste for speed change, my bad
 
Last edited:
well, I didn't wanted to use conditions cause it will interfere with haste/paralize/buff spells but whatever :D
Actually, the only thing the outfits will interfere with is the attributes that are given from spell buffs. So, if you cast any of the new support spells like the one that adds 150% distance, it will effect the distance when you change to a different outfit, but otherwise it won't effect haste or anything. That's why I have the check to remove attribute condition only.
 
doesn't work in tfs 0.2.5 :/

how can i add the function "onOutfit(cid, old, current)" ???
someone can help????

Just check 0.2.5 for onOutfit, if it's not there then I'll write up a tutorial later on if no one else does, I'm currently in school so I don't have enough time.

it will work with tfs 0.3.5?

Wouldn't it have been easier if you just tried and then came back with a response? To answer your question, if it has all the functions I added in the "system" then you will be able to use the Addon System.
 

Very detailed and informative response. You could have at least stated what you were saying no to. If you don't have the functions, I can help with that, if you're just saying "No it wouldn't have been easier for me to test it" then I wouldn't have to waste my time replying.

So, if you don't mind, can you actually explain what your extremely well educated response was for?
 
Do not expect much wisdom from over 50% of users here. Btw. I will try to shorten this script. If I succeed, I would post it here.
 
Do not expect much wisdom from over 50% of users here. Btw. I will try to shorten this script. If I succeed, I would post it here.

Goodluck. :D I was thinking of using arrays, but there's too many variables to work with. Overall, I think my version might POSSIBLY be the shortest, unless there's functions that I don't know about. xD
 
i use tfs 0.3.5 and dont have function onoutfit:(
OTAL 1.0 instaled
Please Help
 
J have problem in the console he appears this error

[13/02/2010 13:21:52] [Error - CreatureEvent::configureEvent] No valid type for creature event.outfit
[13/02/2010 13:21:52] [Warning - BaseEvents::loadFromXml] Cannot configure an event

Did you help me ?
 
#Dilio#
1. Grat job, idea etc.
2. It won't work in TFS older than 0.3.6 and any 0.2.x without source edit
3. Shortened, not tested wersion

Lua:
outfitBonusTable = { --- [] = {condition = {}, maxHealth = , maxMana = ,changeSpeed = }
[128] = {maxHealth = 100, changeSpeed = 10}, [136] = outfitBonusTable[128], --Citizen
[129] = {condition = {CONDITION_PARAM_SKILL_DISTANCE, 3}}, [137] = outfitBonusTable[129], --Hunter
[130] = {maxMana = 200}, [138] = outfitBonusTable[130], --Mage
[131] = {condition = {CONDITION_PARAM_SKILL_SWORD, 3}}, [139] = outfitBonusTable[131], --Knight
[133] = {maxMana = 100}, [141] = outfitBonusTable[133], --Summoner
[134] = {condition = {CONDITION_PARAM_SKILL_SWORD, 3}}, [142] = outfitBonusTable[134], --Warrior
[143] = {condition = {CONDITION_PARAM_SKILL_AXE, 3}}, [147] = outfitBonusTable[143], --Barbarian
[144] = {condition = {CONDITION_PARAM_STAT_MAGICLEVEL, 2}}, [148] = outfitBonusTable[144], --Druid
[145] = {maxHealth = 100, maxMana = 100}, [149] = outfitBonusTable[145], --Wizard
[146] = {maxHealth = 200, maxMana = 200, changeSpeed = 10}, [150] = outfitBonusTable[146], --Oriental
[152] = {changeSpeed = 20}, [156] = outfitBonusTable[152], --Assassin
[154] = {condition = {CONDITION_PARAM_STAT_MAGICLEVEL, 2}}, [158] = outfitBonusTable[154], --Shaman
[251] = {condition = {CONDITION_PARAM_SKILL_SHIELD, 2}, maxHealth = 200}, [252] = outfitBonusTable[251], --Norse
[268] = {condition = {CONDITION_PARAM_SKILL_SHIELD, 3}, maxHealth = 100}, [269] = outfitBonusTable[268], --Nightmare
[270] = {maxHealth = 100, maxMana = 100, changeSpeed = 10}, [273] = outfitBonusTable[270], --Jester
[278] = {maxHealth = 200}, [279] = outfitBonusTable[278], --Brotherhood
[288] = {maxHealth = 500, maxMana = 500, changeSpeed = 20}, [289] = outfitBonusTable[288], --Demonhunter
[324] = {condition = {CONDITION_PARAM_STAT_MAGICLEVEL, 2}, maxHealth = 200, maxMana = 200}, [325] = outfitBonusTable[324] --Yalaharian
}

function onOutfit(cid, old, current)
	if(current.lookType == old.lookType) then
		return true
	end
	if old.lookAddons == 3 and outfitBonusTable[old.lookType] then --Bonus off
		if (outfitBonusTable[old.lookType]).maxHealth ~= nil then
			setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) -(outfitBonusTable[old.lookType]).maxHealth)
			doCreatureAddHealth(cid, -(outfitBonusTable[old.lookType]).maxHealth)
		end
		if (outfitBonusTable[old.lookType]).maxMana ~= nil then
			setCreatureMaxMana(cid, getCreatureMaxMana(cid) -(outfitBonusTable[old.lookType]).maxMana)
			doCreatureAddMana(cid, -(outfitBonusTable[old.lookType]).maxMana)
		end
		if (outfitBonusTable[old.lookType]).changeSpeed ~= nil then
			doChangeSpeed(cid, -(outfitBonusTable[old.lookType]).changeSpeed)
		end
		if (outfitBonusTable[old.lookType]).condition ~= nil then
			doRemoveCondition(cid, CONDITION_ATTRIBUTES)
		end
	end
	if current.lookAddons == 3 and outfitBonusTable[current.lookType] then --Bonus on
		if (outfitBonusTable[old.lookType]).maxHealth ~= nil then
			setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) +(outfitBonusTable[old.lookType]).maxHealth)
			doCreatureAddHealth(cid, (outfitBonusTable[old.lookType]).maxHealth)
		end
		if (outfitBonusTable[old.lookType]).maxMana ~= nil then
			setCreatureMaxMana(cid, getCreatureMaxMana(cid) +(outfitBonusTable[old.lookType]).maxMana)
			doCreatureAddMana(cid, (outfitBonusTable[old.lookType]).maxMana)
		end
		if (outfitBonusTable[old.lookType]).changeSpeed ~= nil then
			doChangeSpeed(cid, (outfitBonusTable[old.lookType]).changeSpeed)
		end
		if (outfitBonusTable[old.lookType]).condition ~= nil then
			local addonCondition = createConditionObject(CONDITION_ATTRIBUTES)
			setConditionParam(addonCondition, CONDITION_PARAM_TICKS, -1)
			setConditionParam(addonCondition, ((outfitBonusTable[old.lookType]).condition)[1], ((outfitBonusTable[old.lookType]).condition)[2])
			doAddCondition(cid, addonCondition)
		end
	end
	return true
end

PS: I think that script can be shorter :p
 
@hellboy
Well, you have to make condition object, then set its attributes and at last set in on player.
 
When you have all addons, and change from jester to oriental, you gain more HP and you can get easy free more HP.

BUG.
 
Ok ok... Going to explain it better... What you have to do is quite simple...

Using Jester and Oriental... You change to Jester full then Oriental full, then you tick one outfit addon, and relog, you change to jester full and then to oriental full and make the same, the difference is 100 hp or mp extra (i dont know this case, just a known bug)...

I saw druids level 150+ with 11k HP xD
 
Back
Top