Jump to content

Trying to create a blink item,but there's no hover effect


Recommended Posts

the function maybe right, i copied from the orange staff,but there's no mouse hover effect.

 

i looked into the common action files,but can't get further.

 

how can i have the mouse hover effect ,and get the position,that will help to invoke the blink function .

Link to comment
Share on other sites

who can help me with this.

 

i tried to add on to the action tab,but didnt work. 

 

what i want to do is a copy item like the orange staff, but it has less cost to blink,i thought it wont be this hard.

 

but the mouse dont have any hover effect at all, so when equip ,cant call the blink function by right click.

 

where did i go wrong?

Link to comment
Share on other sites

Upload your mod folder or mod files if you can.

local assets =

{

Asset("ANIM", "anim/amulets.zip"),

Asset("ANIM", "anim/torso_amulets.zip"),

Asset( "IMAGE", "images/inventoryimages/purpleamuletplus.tex" ),

Asset( "ATLAS", "images/inventoryimages/purpleamuletplus.xml" ),

}

local prefabs =

{

}

local function onblink(staff, pos, caster)

if caster.components.sanity ~= nil then

caster.components.sanity:DoDelta(-TUNING.SANITY_MED*.5)

end

end

local function blinkstaff_reticuletargetfn()

local player = ThePlayer

local rotation = player.Transform:GetRotation() * DEGREES

local pos = player:GetPosition()

for r = 13, 1, -1 do

local numtries = 2 * PI * r

local pt = FindWalkableOffset(pos, rotation, r, numtries)

if pt ~= nil then

return pt + pos

end

end

end

local function onequip_purple(inst, owner)

owner.AnimState:OverrideSymbol("swap_body", "torso_amulets", "purpleamulet")

if inst.components.fueled then

inst.components.fueled:StartConsuming()

end

end

local function onunequip_purple(inst, owner)

owner.AnimState:ClearOverrideSymbol("swap_body")

if inst.components.fueled then

inst.components.fueled:StopConsuming()

end

end

local function commonfn(anim, tag, custom_init)

local inst = CreateEntity()

inst.entity:AddTransform()

inst.entity:AddAnimState()

inst.entity:AddNetwork()

MakeInventoryPhysics(inst)

inst.AnimState:SetBank("amulets")

inst.AnimState:SetBuild("amulets")

inst.AnimState:PlayAnimation(anim)

if tag ~= nil then

inst:AddTag(tag)

end

inst.foleysound = "dontstarve/movement/foley/jewlery"

if custom_init ~= nil then

custom_init(inst)

end

inst.entity:SetPristine()

if not TheWorld.ismastersim then

return inst

end

inst:AddComponent("inspectable")

inst:AddComponent("equippable")

inst.components.equippable.equipslot = EQUIPSLOTS.BODY

inst.components.equippable.dapperness = TUNING.DAPPERNESS_SMALL

inst:AddComponent("inventoryitem")

inst.components.inventoryitem.atlasname = "images/inventoryimages/purpleamuletplus.xml"

return inst

end

local function purpleplus()

local inst = commonfn("purpleamulet")

inst:AddComponent("reticule")

inst.components.reticule.targetfn = blinkstaff_reticuletargetfn

inst.components.reticule.ease = true

if not TheWorld.ismastersim then

return inst

end

inst.fxcolour = {1, 145/255, 0}

inst.castsound = "dontstarve/common/staffteleport"

inst:AddComponent("blinkstaff")

inst.components.blinkstaff.onblinkfn = onblink

inst:AddComponent("fueled")

inst.components.fueled.fueltype = FUELTYPE.MAGIC

inst.components.fueled:InitializeFuelLevel(TUNING.PURPLEAMULET_FUEL)

inst.components.fueled:SetDepletedFn(inst.Remove)

inst.components.equippable:SetOnEquip(onequip_purple)

inst.components.equippable:SetOnUnequip(onunequip_purple)

inst.components.equippable.dapperness = -TUNING.DAPPERNESS_MED

inst.components.equippable.walkspeedmult = .6

MakeHauntableLaunch(inst)

return inst

end

return Prefab("common/inventory/purpleamuletplus", purpleplus, assets, prefabs)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...