Jump to content

Adding custom sound effects (HELP)


BahadirBY

Recommended Posts

I've been working on this for a while. I'm giving up now. I think it will be better for me to get help. I'm making a weapon mod. I cannot add the sound file. 

This is my prefab.


local assets=

{ 

    Asset("ANIM", "anim/excalibur.zip"), 
    Asset("ANIM", "anim/swap_excalibur.zip"),  

    Asset("ATLAS", "images/inventoryimages/excalibur.xml"), 
    Asset("IMAGE", "images/inventoryimages/excalibur.tex"), 
	
	Asset("SOUNDPACKAGE", "sound/excalibur_sound.fev"),
	Asset("SOUND", "sound/excalibur_sound.fsb"),
}


local function IsValidVictim(victim)

    return victim ~= nil
	
        and not (victim:HasTag("sword") or
		
                victim:HasTag("kill") or
				
                victim:HasTag("king"))
				
        and victim.components.health ~= nil
		
        and victim.components.combat ~= nil
		
end

local function OnAttack(inst)

    inst.SoundEmitter:PlaySound("excalibur_sounds/sound/excalibur_attack")

	
end

local function OnTool(inst)

	inst.SoundEmitter:PlaySound("excalibur_sounds/sound/excalibur_tool")
	
    end


local function onattack(attacker, target)

	if not target:IsValid() then
	
		return
		
	end
	
		if target.components.combat ~= nil then
	 
			target.components.combat:SuggestTarget(attacker)
			
			
		end
	
			if target.components.sleeper ~= nil and target.components.sleeper:IsAsleep() then
	
				target.components.sleeper:WakeUp()
		
			end
	
	end

local function fn()

    local function OnEquip(inst, owner)
	
        owner.AnimState:OverrideSymbol("swap_object", "swap_excalibur", "excalibur")
		
        owner.AnimState:Show("ARM_carry") 
        owner.AnimState:Hide("ARM_normal") 
		inst.SoundEmitter:PlaySound("excalibur_sounds/sound/excalibur_equip")
		
    end

    local function OnUnequip(inst, owner) 
	
        owner.AnimState:Hide("ARM_carry") 
        owner.AnimState:Show("ARM_normal") 
		inst.SoundEmitter:PlaySound("excalibur_sounds/sound/excalibur_unequip")
		
    end

	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
    local anim = inst.entity:AddAnimState()
	local sound = inst.entity:AddSoundEmitter()
	
	inst.entity:AddTransform()
	inst.entity:AddAnimState()
    inst.entity:AddNetwork()	
	inst.entity:SetPristine()

	MakeInventoryPhysics(inst)
    MakeHauntableLaunch(inst)
	
    anim:SetBank("excalibur")
    anim:SetBuild("excalibur")
    anim:PlayAnimation("idle")
	
	if not TheWorld.ismastersim then
      
	return inst
	  
    end
    
	inst:AddComponent("weapon")
	inst.components.weapon:SetOnAttack(onattack)
	inst.components.weapon:SetDamage(50)
	inst.components.weapon.onattack = OnAttack
	
	inst:AddComponent("tool")
    inst.components.tool:SetAction(ACTIONS.CHOP)
	
	inst:AddComponent("finiteuses")
    inst.components.finiteuses:SetMaxUses(250)
    inst.components.finiteuses:SetUses(250)
    inst.components.finiteuses:SetOnFinished(inst.Remove)
	
	inst:AddComponent("inspectable")
	inst:AddComponent("lootdropper")
	inst:AddComponent("tradable")
	
    inst:AddComponent("equippable")
    inst.components.equippable:SetOnEquip( OnEquip )
    inst.components.equippable:SetOnUnequip( OnUnequip )
	
	inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "excalibur"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/excalibur.xml"
	
	inst:ListenForEvent("equip", function(inst, data) onequip(inst, data) end)
	inst:ListenForEvent("unequip", function(inst, data) onunequip(inst, data) end)

    return inst
	
end

return  Prefab("common/inventory/excalibur", fn, assets, prefabs)

 

What am I doing wrong ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...