Search the Community
Showing results for tags 'grenade'.
-
Hi, I have been working on RGD-33 grenade. I have used Napsack prefab as my template and it has no error screen so far but when I throw it it won't do any damage. I don't get all those explosive functions so if anyone here could help me I will be happier person. Prefab here: local assets= { Asset("ANIM", "anim/rgd3_nade.zip"), Asset("ANIM", "anim/swap_rgd3_nade.zip"), Asset("ATLAS", "images/inventoryimages/rgd3_nade.xml"), Asset("IMAGE", "images/inventoryimages/rgd3_nade.tex"), } local prefabs = { } local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_rgd3_nade", "rgd3") 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 OnExplodeFn(inst) --nothing works SpawnPrefab("explode_small").Transform:SetPosition(x, y, z) end local function OnHit(inst, attacker, target) local x, y, z = inst.Transform:GetWorldPosition() inst:Remove() SpawnPrefab("explode_small").Transform:SetPosition(x, y, z) end local function OnThrown(inst) inst:AddTag("NOCLICK") inst.persists = false inst.AnimState:PlayAnimation("spin") inst.Physics:SetMass(1) inst.Physics:SetCapsule(0.2, 0.2) inst.Physics:SetFriction(0) inst.Physics:SetDamping(0) inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS) inst.Physics:ClearCollisionMask() inst.Physics:CollidesWith(COLLISION.WORLD) inst.Physics:CollidesWith(COLLISION.OBSTACLES) inst.Physics:CollidesWith(COLLISION.ITEMS) end local function ReticuleTargetFn() local player = ThePlayer local ground = TheWorld.Map local pos = Vector3() --Attack range is 8, leave room for error --Min range was chosen to not hit yourself (2 is the hit range) for r = 6.5, 3.5, -.25 do pos.x, pos.y, pos.z = player.entity:LocalToWorldSpace(r, 0, 0) if ground:IsPassableAtPoint(pos:Get()) and not ground:IsGroundTargetBlocked(pos) then return pos end end return pos end ---------------------------------------------------- ---------------------------------------------------- ---------------------------------------------------- local function fn(Sim) local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() MakeInventoryPhysics(inst) inst:AddTag("projectile") inst:AddTag("explosive") inst.AnimState:SetBank("rgd3") inst.AnimState:SetBuild("rgd3_nade") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("locomotor") inst:AddComponent("reticule") inst.components.reticule.targetfn = ReticuleTargetFn inst.components.reticule.ease = true local advancedtargeting = TheNet:GetServerGameMode() == "lavaarena" if advancedtargeting then inst.components.reticule.reticuleprefab = "reticuleaoe" inst.components.reticule.pingprefab = "reticuleaoeping" inst.components.reticule.mouseenabled = true inst:AddTag("nopunch") end inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "rgd3_nade" inst.components.inventoryitem.atlasname = "images/inventoryimages/rgd3_nade.xml" inst:AddComponent("inspectable") inst:AddComponent("equippable") MakeHauntableLaunch(inst) inst.components.equippable:SetOnEquip( OnEquip ) inst.components.equippable:SetOnUnequip( OnUnequip ) inst:AddComponent("complexprojectile") inst.components.complexprojectile:SetHorizontalSpeed(15) inst.components.complexprojectile:SetGravity(-35) inst.components.complexprojectile:SetLaunchOffset(Vector3(.25, 1, 0)) inst.components.complexprojectile:SetOnLaunch(OnThrown) inst.components.complexprojectile:SetOnHit(OnHit) if not advancedtargeting then inst:AddComponent("weapon") inst.components.weapon:SetDamage(0) inst.components.weapon:SetRange(8, 10) end inst:AddComponent("explosive") inst.components.explosive:SetOnExplodeFn(OnExplodeFn) inst.components.explosive.explosivedamage = TUNING.GUNPOWDER_DAMAGE inst.components.explosive.explosiverange = 3 return inst end return Prefab("common/inventory/rgd3_nade", fn, assets, prefabs)