Code: Select all
defineObject{
name = "water_shooter",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/revolver.fbx",
material = "zarchton_wand",
},
{
class = "Item",
uiName = "Water Shooter",
description = "A strange mechanics makes this weapon compressing water and shooting it out in some kind of a jet.",
gfxAtlas = "mod_assets/textures/iconatlas/iconatlas.dds",
gfxIndex = 33,
weight = 1.5,
traits = { "weapon", "firearm"},
primaryAction = "waterbolt",
secondaryAction = "waterbolt",
},
{
class = "ItemAction",
name = "waterbolt",
uiName = "Water Bolt",
cooldown = 5,
onAttack = function(self, champion, slot, chainIndex)
local spl = spawn("water_bolt",party.level,party.x,party.y,party.facing,party.elevation)
spl.projectile:setIgnoreEntity(party)
-- Set cast by champion so that experience is awarded for kills.
local ord = champion:getOrdinal()
spl.projectile:setCastByChampion(ord)
-- Simulate the position of a player-cast spell.
local left = nil
for i = 1,4 do
if party.party:getChampion(i):getOrdinal() == ord then
left = i == 1 or i == 3
break
end
end
local wpos = party:getWorldPosition()
local dx = nil
local dz = nil
if party.facing == 0 then
dx = left and -0.1 or 0.1
dz = -1
elseif party.facing == 1 then
dz = left and 0.1 or -0.1
dx = -1
elseif party.facing == 2 then
dx = left and 0.1 or -0.1
dz = 1
else -- party.facing == 3
dz = left and -0.1 or 0.1
dx = 1
end
spl:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
end,
},
},
}