Is it possible to make a weapon that has a chance on each attack that it'll cast a spell? I'd like to change the Flame Blade from being basically a "wand of fireballs" into a regular sword that has a chance of casting Fireburst when attacking.
I tried putting a function returning a string as the item's onAttack value, but that doesn't fly.
"Proc chance" weapons?
Re: "Proc chance" weapons?
The dismantler is a sword that is available in the game. It seems to have a random chance to cast a shock spell.
However, if you look at the definition of the dismantler (in the items.lua), there is nothing that indicates that ability.
Even worse: if you use that script in your mod you only have a basic sword and you don't get the random proc chance.
To get something with the effect that you want, follow these steps:
1) create your own weapon by copying and pasting the following script into your items.lua. Adjust the parameters where needed.
2) Add the following code to your init.lua or, if you already have a "party" defined, only copy and paste the "onAttack" function.
The disadvantages of this quick code are:
- A proc might go off, even if the player misses the monster
- A member from the back of the party can use this to proc a weapon even if they can't reach the monster (this can be solved with more scripting)
Hope this works as you intended!
However, if you look at the definition of the dismantler (in the items.lua), there is nothing that indicates that ability.
Even worse: if you use that script in your mod you only have a basic sword and you don't get the random proc chance.
To get something with the effect that you want, follow these steps:
1) create your own weapon by copying and pasting the following script into your items.lua. Adjust the parameters where needed.
SpoilerShow
Code: Select all
defineObject{
name = "fireburst_blade",
class = "Item",
uiName = "Fireburst Blade",
model = "assets/models/items/long_sword.fbx",
description = "A magical fire flickers on the glowing hot steel of the blade.",
skill = "swords",
gfxIndex = 216,
attackPower = 14,
damageType = "fire",
accuracy = 0,
coolDownTime = 3,
attackMethod = "meleeAttack",
attackSwipe = "vertical",
attackSound = "swipe",
impactSound = "impact_blade",
weight = 4.0,
}
SpoilerShow
Code: Select all
cloneObject{
name = "party",
baseObject = "party",
onAttack = function(champion, weapon)
-- check if it is the fireburst_blade
if weapon.name == "fireburst_blade" then
-- check if proc goes off (40 pct chance in example below)
if math.random(1, 100) <= 40 then
-- do actual spellcasting here
local dx, dy = getForward(party.facing)
local s = spawn("spawner", party.level, party.x+dx, party.y+dy, party.facing)
s:setSpawnedEntity("fireburst")
s:activate()
s:destroy()
end
end
end,
}
- A proc might go off, even if the player misses the monster
- A member from the back of the party can use this to proc a weapon even if they can't reach the monster (this can be solved with more scripting)
Hope this works as you intended!
Did you visit the Wine Merchant's Basement? And heard about the Awakening of Taarnab?
Re: "Proc chance" weapons?
Several weapons that can be made by the Smith in the ORRR2 do this... Dagger of Fireburst, for instance.
The Deathkiss sword in ORRR2 does this also; but it's not limited to just one spell.
The Deathkiss sword in ORRR2 does this also; but it's not limited to just one spell.