Jump to content

Recommended Posts

I'm a somewhat beginner modder, and currently, I'm trying to create an ice-sword weapon that adds 1 coldness to the target per hit. I've tried using the Deerclop's lua files, but results have either ended up crashing or doing a grand total of nothing.

 

How would one implement an on-hit freeze effect? Any help would be appreciated.

Link to comment
https://forums.kleientertainment.com/forums/topic/37424-a-freezing-melee-weapon/
Share on other sites

local assets={	Asset("ANIM", "anim/bluegemsword.zip"),	Asset("ANIM", "anim/swap_bluegemsword.zip"),	Asset("ATLAS", "images/inventoryimages/bluegemsword.xml"), 	Asset("IMAGE", "images/inventoryimages/bluegemsword.tex") }local function onattack_blue(inst, attacker, target)    if target.components.freezable then        target.components.freezable:AddColdness(1)        target.components.freezable:SpawnShatterFX()    end	if attacker and attacker.components.sanity then		attacker.components.sanity:DoDelta(-3)    end    if target.components.sleeper and target.components.sleeper:IsAsleep() then        target.components.sleeper:WakeUp()    end    if target.components.burnable and target.components.burnable:IsBurning() then        target.components.burnable:Extinguish()    end    if target.components.combat then        target.components.combat:SuggestTarget(attacker)        if target.sg and not target.sg:HasStateTag("frozen") and target.sg.sg.states.hit then            target.sg:GoToState("hit")        end    endendlocal function onfinished(inst)    inst:Remove()endlocal function onequip(inst, owner)    --owner.AnimState:OverrideSymbol("swap_object", "swap_bluegemsword", "spear")    owner.AnimState:OverrideSymbol("swap_object", "swap_bluegemsword", "swap_bluegemsword")      owner.AnimState:Show("ARM_carry")     owner.AnimState:Hide("ARM_normal") end    local function onunequip(inst, owner)     owner.AnimState:Hide("ARM_carry")     owner.AnimState:Show("ARM_normal") endlocal function fn(Sim)    	local inst = CreateEntity()    	local trans = inst.entity:AddTransform()    	local anim = inst.entity:AddAnimState()    MakeInventoryPhysics(inst)        anim:SetBank("bluegemsword")    anim:SetBuild("bluegemsword")    anim:PlayAnimation("idle", true)    inst:AddTag("shadow")    inst:AddTag("sharp")        -------        inst:AddTag("icestaff")    inst:AddComponent("weapon")    inst.components.weapon:SetDamage(125)    inst.components.weapon:SetOnAttack(onattack_blue)    inst:AddComponent("finiteuses")    inst.components.finiteuses:SetMaxUses(150)    inst.components.finiteuses:SetUses(150)        inst.components.finiteuses:SetOnFinished( onfinished )    inst:AddComponent("inspectable")        inst:AddComponent("inventoryitem")	inst.components.inventoryitem.imagename = "bluegemsword"	inst.components.inventoryitem.atlasname = "images/inventoryimages/bluegemsword.xml"        inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( onequip )    inst.components.equippable:SetOnUnequip( onunequip )        return instendreturn Prefab( "common/inventory/bluegemsword", fn, assets) 

Here is my code of Blue Gem sword, try to re-make your code basing on that (look on "local function onattack_blue")

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
×
  • Create New...