Jump to content

Recommended Posts

When I'm adding the new weapon, I just want to make sure I have everything right. 

- I added images\inventoryimages for the weapon image.

- I added scripts\prefabs\newweapon.lua

IMPORTANT (I think) lines of code that are inside prefabs\newweapon.lua are:

local assets=
{
    Asset("ANIM", "anim/newweapon.zip"),
    Asset("ANIM", "anim/swap_newweapon.zip"),
 
    Asset("ATLAS", "images/inventoryimages/newweapon.xml"),
    Asset("IMAGE", "images/inventoryimages/newweapon.tex"),
 
local function fn()
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
    MakeInventoryPhysics(inst)
 
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()
 
inst.AnimState:SetBank("newweapon")
    inst.AnimState:SetBuild("newweapon")
    inst.AnimState:PlayAnimation("idle")
 
if not TheWorld.ismastersim then
        return inst
    end
 
    local function OnEquip(inst, owner)
        owner.AnimState:OverrideSymbol("swap_object", "swap_newweapon", "swap_newweapon")
        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")
    end
 
    inst:AddComponent("inventoryitem")
inst.components.inventoryitem.keepondeath = true
    inst.components.inventoryitem.imagename = "elderwand"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/newweaopn.xml"
     
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
inst.components.inventoryitem.keepondeath = true
 
inst:AddComponent("inspectable")
 
  inst:AddComponent("weapon")
inst.components.weapon:SetOnAttack(onattack_newweapon)
    inst.components.weapon:SetDamage(75)
    inst.components.weapon:SetRange(8, 10)
inst.components.weapon:SetProjectile("character_projectile")
 
    return inst
 
end
 
return  Prefab("common/inventory/newweapon", fn, assets)
 
 
 
 
 
- Added these lines of codes in modmain.lua:
 
STRINGS.NAMES.ELDERWAND = "Example"
STRINGS.CHARACTERS.GENERIC.DESCRIBE.ELDERWAND = "..."
 
 
Is there anything I'm currently missing from all of this? And I'm curious on how the animations for the weapon will autocompile.

 

Edited by TacoChingChong
Link to comment
https://forums.kleientertainment.com/forums/topic/56038-new-character-weapon/
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
×
  • Create New...