Action Change Damage Type Wand

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
Hello Otland!

Here is a simple script that will allow you to change the damage type of a weapon. (ideal for wands) This system uses @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.

Tested on TFS 1.2

Special thanks to @Jano

Preview

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 = false, -- 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

   -- Damage Table
   [1] = {element = "Holy"},
   [2] = {element = "Fire"},
   [3] = {element = "Death"},
   [4] = {element = "Poison"},
   [5] = {element = "Energy"},
   [6] = {element = "Earth"},
   [7] = {element = "Ice"},
}
Installation

1)
Install the modal window helper: [TFS 1.2] Modal Window Helper Lib (https://otland.net/threads/tfs-1-2-modal-window-helper-lib.238773/)
2) Register the script in /data/actions/actions.xml by adding this line, replacing "ITEMID" with the item you want to use:
XML:
<action itemid="ITEMID" script="weapon_damage"/>
<action actionid="ACTIONID" script="weapon_damage"/>
3) Download actions-weapon_damage.lua into /data/actions/scripts and name it weapon_damage.lua

4)
Add the following line to your global.lua:
Lua:
dofile('data/lib/weapon_damage.lua')
5) Download lib-weapon_damage.lua into /data/actions/scripts and name it weapon_damage.lua
7)
Download weapons-weapon_damage.lua into /data/weapons/scripts and name it weapon_damage.lua
6)
Register the weapon in /data/weapons/weapons.xml by adding this line:
NOTE THIS LINE IS IF YOU ARE USING A WAND!
XML:
<wand id="ITEM ID HERE" level="300" mana="20" script="weapon_damage.lua"><!-- Shadow's Sceptre -->
            <vocation name="Sorcerer" />
</wand>
Enjoy!
 

Attachments

Last edited by a moderator:

Basiq GM

Developer / Graphic Designer / Mapper
Joined
Mar 30, 2014
Messages
350
Reaction score
51
Holy shiat. Thats so kewl :3 I wish this would work on 0.4 .. Would be sick for a donation wand on my 8.6 OT :<

anyways, its an amazing idea lol, GJ :p
 

silveralol

Veteran OT User
Joined
Mar 16, 2010
Messages
1,461
Reaction score
184
nice release ;)
I can ask "where is the "shoot" effect?" is only to weapon or wands, if is wands, how to configure the fixed damage ...
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
nice release ;)
I can ask "where is the "shoot" effect?" is only to weapon or wands, if is wands, how to configure the fixed damage ...
Its in the weapon script. Check these lines.


Code:
    combat[k]:setParameter(COMBAT_PARAM_TYPE, DamageType)
    combat[k]:setFormula(COMBAT_FORMULA_SKILL, 1.0, 0, 1.0, 0)
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
UPDATE
Added in shoot effect.
 

Mkalo

ボーカロイド
Joined
Jun 1, 2011
Messages
1,118
Reaction score
894
Location
Japan
UPDATE
Added in shoot effect.
Code:
    player:registerEvent("Modal_WeaponDam")
    player:unregisterEvent("Modal_WeaponDAM")
I'm not 100% sure if events are case sensitive but you might keep both the same just for safety.
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
Code:
    player:registerEvent("Modal_WeaponDam")
    player:unregisterEvent("Modal_WeaponDAM")
I'm not 100% sure if events are case sensitive but you might keep both the same just for safety.
They would be for linux not sure about windows.. You are right though thanks for pointing out.
 

SamX

VoltageOT Developer
Premium User
Joined
Aug 27, 2010
Messages
557
Reaction score
148
Location
Canada
Great work. Trying this out on my server.

I noticed once I added your script, my main and max values on weapons.xml are no longer valid. Seems I can hit anywhere from 0-140 when I have it set at 100-140. Is this configurable somewhere in your script?
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
Great work. Trying this out on my server.

I noticed once I added your script, my main and max values on weapons.xml are no longer valid. Seems I can hit anywhere from 0-140 when I have it set at 100-140. Is this configurable somewhere in your script?
TBH i found this problem out awhile ago and just havnt had time to look into it. I'll post here when i fix sometime this week.
 

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,448
Reaction score
600
Location
Estonia
function onGetFormulaValues(cid, level, maglevel) return min, max end

I think this was a function i used to use year ago when I still created Combat() things.
 

Tarek1337

Excellent OT User
Joined
Jun 9, 2012
Messages
3,563
Reaction score
1,000
Location
Sweden
Code:
    player:registerEvent("Modal_WeaponDam")
    player:unregisterEvent("Modal_WeaponDAM")
I'm not 100% sure if events are case sensitive but you might keep both the same just for safety.
like StruZ says, Linux is case sensetive but not Windows
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
Great work. Trying this out on my server.

I noticed once I added your script, my main and max values on weapons.xml are no longer valid. Seems I can hit anywhere from 0-140 when I have it set at 100-140. Is this configurable somewhere in your script?
Forgot to update this script with the fix for the damage output... Updated main post.
 
OP
strutZ

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,338
Reaction score
469
Updated whole script to new modal window system and updated weapons script.
 

Tampek

ECHO 'Zarkonia.online';
Joined
Dec 29, 2015
Messages
446
Reaction score
24
Location
Spain
with your scripts can i add the critical or manaleech for example?
 
Top