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

[TFS 1.2] Change Weapon Damage 2.0

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,391
Solutions
7
Reaction score
550
Hello Otland!
I have converted my change weapon damage script to use @Non Sequitur modal window system which can be found HERE

You will have to install that in order to be able to use this system.

Why use this one instead?
Much cleaner then the last version you just need to add the action script and the lib files. There is no need to register the scripts on login.lua or add creaturescripts!

It also has a much better damage system which can be easily configured.

Information on the system
It has an easy config section for you to customize it how you would like it! You just need to fill out the config table found in the action script (pictured below)
Lua:
-- Config

-- Set wand how the wand deals damage
DamageTypeWand = {
   values = true, -- If this is set to true then it will use the min and max values. If set to false the wand will use the formula
 
   -- Damage Values min/max
   wandMinDam = 20,
   wandMaxDam = 50,
 
   -- Damage Formula
   formula = {
     wandMinDam = function(level, maglevel) return -((level / 5) + (maglevel * 1.4) + 8) end,
     wandMaxDam = function(level, maglevel) return -((level / 5) + (maglevel * 2.2) + 14) end,
   }
}

-- Modal window config and storage id
local config = {
   storage = "10009",
   titleMsg = "Change Weapon Damage Type",
   mainMsg = "Choose a damage type from the list",
-- End Config

Installation

1)
Install the modal window helper HERE

2) Register the script in /data/actions/actions.xml by adding this line (Replacing "ITEMID" with the item you want to use: (Note you can use an action ID aswell)
XML:
<action itemid="ITEMID" script="weapon_damage.lua"/>
3) Create a new text document in /data/actions/scripts and name it "weapon_damage.lua" and paste the following:
http://pastebin.com/hqR2eihZ
4) Add the following line to your global.lua:
Lua:
dofile('data/lib/weapon_damage.lua')
5) Create a new text document in /data/lib/ and name it "weapon_damage.lua" and paste the following:
http://pastebin.com/M9GFYJ4A
6)Register the script in /data/weapons/weapons.xml by adding this line (Replacing "ITEMID" with the item you want to use:
XML:
<wand id="25249" level="300" mana="20" script="weapon_damage.lua">
            <vocation name="Sorcerer" />
</wand>
7) Create a new text document in /data/weapons/scripts and name it "weapon_damage.lua" and paste the following:
http://pastebin.com/78fW9Wq9


Enjoy =)
 
Last edited:
help \;


Lua Script Error: [Main Interface]
data/global.lua
cannot open data/lib/modalwindow.lua: No such file or directory
stack traceback:
[C]: in ?
[C]: in function 'dofile'
data/lib/libs.lua:11: in main chunk
[C]: in function 'dofile'
data/global.lua:1: in main chunk
[Warning - ScriptingManager::loadScriptSystems] Can not load data/global.lua
 
cant log


Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/login.lua:eek:nLogin
data/creaturescripts/scripts/others/login.lua:73: attempt to index global 'nextUseStaminaTime' (a nil value)
stack traceback:
[C]: in function '__newindex'
data/creaturescripts/scripts/others/login.lua:73: in function <data/creaturescripts/scripts/others/login.lua:56>

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/others/logout.lua:eek:nLogout
data/creaturescripts/scripts/others/logout.lua:3: attempt to index global 'nextUseStaminaTime' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/others/logout.lua:3: in function <data/creaturescripts/scripts/others/logout.lua:1>
Lukan has logged out.
 
Your first error is becuase you didnt install the modal window helper library properly... as for the second error it is unrelated to the script... However because i'm a nice guy, Post me your login.lua here.
 
Your first error is becuase you didnt install the modal window helper library properly... as for the second error it is unrelated to the script... However because i'm a nice guy, Post me your login.lua here.
u are not! :rolleyes:
 
all libs its ook https://uploaddeimagens.com.br/imagens/sem_titulo-png--15819

my login
-- ordered as in creaturescripts.xml
local events = {
'TutorialCockroach',
'ElementalSpheresOverlords',
'BigfootBurdenVersperoth',
'BigfootBurdenWarzone',
'BigfootBurdenWeeper',
'BigfootBurdenWiggler',
'SvargrondArenaKill',
'NewFrontierShardOfCorruption',
'NewFrontierTirecz',
'ServiceOfYalaharDiseasedTrio',
'ServiceOfYalaharAzerus',
'ServiceOfYalaharQuaraLeaders',
'InquisitionBosses',
'InquisitionUngreez',
'KillingInTheNameOfKills',
'MastersVoiceServants',
'SecretServiceBlackKnight',
'ThievesGuildNomad',
'WotELizardMagistratus',
'WotELizardNoble',
'WotEKeeper',
'WotEBosses',
'WotEZalamon',
'PlayerDeath',
'AdvanceSave',
'AdvanceRookgaard',
'PythiusTheRotten',
'Butterfly',
'Devovorga',
'freebless',
'FirstItems',
'LevelItem',
'onPrepareDeath',
'LevelRecompense',
'DropLoot',
'ModalWeaponDAM'
}

local function onMovementRemoveProtection(cid, oldPosition, time)
local player = Player(cid)
if not player then
return true
end

local playerPosition = player:getPosition()
if (playerPosition.x ~= oldPosition.x or playerPosition.y ~= oldPosition.y or playerPosition.z ~= oldPosition.z) or player:getTarget() then
player:setStorageValue(Storage.combatProtectionStorage, 0)
return true
end

addEvent(onMovementRemoveProtection, 1000, cid, oldPosition, time - 1)
end

function onLogin(player)
local loginStr = 'Welcome to ' .. configManager.getString(configKeys.SERVER_NAME) .. '!'
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. ' Please choose your outfit.'
player:sendTutorial(1)
else
if loginStr ~= '' then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end

loginStr = string.format('Your last visit was on %s.', os.date('%a %b %d %X %Y', player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)

local playerId = player:getId()

-- Stamina
nextUseStaminaTime[playerId] = 0

-- Promotion
local vocation = player:getVocation()
local promotion = vocation:getPromotion()
if player:isPremium() then
local value = player:getStorageValue(Storage.Promotion)
if not promotion and value ~= 1 then
player:setStorageValue(Storage.Promotion, 1)
elseif value == 1 then
player:setVocation(promotion)
end
elseif not promotion then
player:setVocation(vocation:getDemotion())
end

-- Events
for i = 1, #events do
player:registerEvent(events)
player:registerEvent("uchihagaeshi")
if getPlayerStorageValue(player, 3482101) ~= 0 then
setPlayerStorageValue(player, 3482101, 0)
end
end

if player:getStorageValue(Storage.combatProtectionStorage) <= os.time() then
player:setStorageValue(Storage.combatProtectionStorage, os.time() + 10)
onMovementRemoveProtection(playerId, player:getPosition(), 10)
end
return true
end
 
Last edited:
Sorry i went for a coffee! however you do not need to register this in your login.lua! looks like you are using my old version man!

@StreamSide You are a turtle.
 
You forgot to add .lua at the end of weapon_damage
4) Add the following line to your global.lua:
Code:
dofile('data/lib/weapon_damage')
Please change it, took me like 3 min to notice lmao :(

Edit: Now tested and fully working, love your work keep it up :p
 
Last edited:
It's working for me. But I have a doubt, how can I set an attack value to the formula. I want to use it on weapons with atk.
 
@strutZ is possible use it with the rods/wands with critical damage, mana leech, life leech ?
 
Back
Top