Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local assets =
- {
- Asset("ANIM", "anim/primitivegun.zip"),
- Asset("ANIM", "anim/swap_primitivegun.zip"),
- Asset("ATLAS", "images/inventoryimages/primitivegun.xml"),
- Asset("IMAGE", "images/inventoryimages/primitivegun.tex"),
- }
- local prefabs =
- {
- red =
- {
- "fire_projectile",
- "cutgrass",
- },
- }
- ---------RED STAFF---------
- local function onattack_red(inst, attacker, target, skipsanity)
- attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo")
- if not target:IsValid() then
- --target killed or removed in combat damage phase
- return
- end
- if target.components.combat ~= nil then
- target.components.combat:SuggestTarget(attacker)
- end
- target:PushEvent("attacked", { attacker = attacker, damage = 0, weapon = inst })
- end
- local function onlight(inst, target)
- if inst.components.finiteuses ~= nil then
- inst.components.finiteuses:Use(1)
- end
- end
- ---------COMMON FUNCTIONS---------
- local function onfinished(inst)
- inst.SoundEmitter:PlaySound("dontstarve/common/gem_shatter")
- inst:Remove()
- end
- local function onequip(inst, owner)
- owner.AnimState:OverrideSymbol("swap_object", "swap_primitivegun", "swap_primitivegun")
- 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
- local function commonfn(colour, tags, hasskin)
- local inst = CreateEntity()
- inst.entity:AddTransform()
- inst.entity:AddAnimState()
- inst.entity:AddSoundEmitter()
- inst.entity:AddNetwork()
- MakeInventoryPhysics(inst)
- --probably need to change this
- inst.AnimState:SetBank("primitivegun")
- inst.AnimState:SetBuild("primitivegun")
- inst.AnimState:PlayAnimation("primitivegun")
- if tags ~= nil then
- for i, v in ipairs(tags) do
- inst:AddTag(v)
- end
- end
- inst.entity:SetPristine()
- if not TheWorld.ismastersim then
- return inst
- end
- -------
- inst:AddComponent("finiteuses")
- inst.components.finiteuses:SetOnFinished(onfinished)
- inst:AddComponent("inspectable")
- inst:AddComponent("inventoryitem")
- inst.components.inventoryitem.imagename = "primitivegun"
- inst.components.inventoryitem.atlasname = "images/inventoryimages/primitivegun.xml"
- inst:AddComponent("tradable")
- inst:AddComponent("equippable")
- inst.components.equippable:SetOnUnequip(onequip)
- inst.components.equippable:SetOnUnequip(onunequip)
- return inst
- end
- ---------COLOUR SPECIFIC CONSTRUCTIONS---------
- local function creation()
- local inst = commonfn("red", {"rangedweapon"}, true)
- if not TheWorld.ismastersim then
- return inst
- end
- inst:AddComponent("weapon")
- inst.components.weapon:SetDamage(23)
- inst.components.weapon:SetRange(8, 10)
- inst.components.weapon:SetOnAttack(onattack_red)
- inst.components.weapon:SetProjectile("bullet")
- inst.components.finiteuses:SetMaxUses(15)
- inst.components.finiteuses:SetUses(15)
- MakeHauntableLaunch(inst)
- return inst
- end
- return Prefab("primitivegun", creation, assets, prefabs.red)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement