Jump to content

Range/Melee Damage Request


Recommended Posts

@rons0n:

	local _cd = inst.components.combat.CalcDamage	inst.components.combat.CalcDamage = function(self, target, weapon, multiplier)		multiplier = multiplier or 1		local weprange = weapon and weapon.components.weapon.hitrange or self:GetAttackRange()		if weprange < 4 then			multiplier = multiplier * 0.5		else			multiplier = multiplier * 1.7		end		return _cd(self, target, weapon, multiplier)	end
Link to comment
Share on other sites

@DarkXero, Everything seems to be working fine and dandy! But may I request for one more thing?

 

So I have this One-Time-Use weapon that does absolute no damage on the enemy, but when it hits the opponent it'll create an aura that puts them in a stun-state for a few long seconds. Can this be possible?

 

As usual, all your help is very much appreciated!

 

Heres the lua file for the weapon:

 

 

tentonhammer.lua

Link to comment
Share on other sites

@DarkXero, Everything seems to be working fine and dandy! But may I request for one more thing?

 

So I have this One-Time-Use weapon that does absolute no damage on the enemy, but when it hits the opponent it'll create an aura that puts them in a stun-state for a few long seconds. Can this be possible?

 

As usual, all your help is very much appreciated!

 

Heres the lua file for the weapon:

Oh gosh, here comes Usopp I just realized. Any chance you'd be able to toy with something like the sleepdart for the base in place of a longer stun animation? I know it's not exactly what you're attempting to do, but it is a good approximation.

Link to comment
Share on other sites

@Noggle, Thanks, I worked off of your suggestion and now they're sleeping like babies. But I have a small problem, they're sleeping way longer than I hoped they would. I want it incredibly much shorter, perhaps in the 10 seconds range?

 

I also want it so that people can attack the enemy freely without startling him in his sleep

 

Appreciate the guidance!

 

Heres what I have right now:

local assets={    Asset("ANIM", "anim/tentonhammer.zip"),    Asset("ANIM", "anim/swap_tentonhammer.zip"),      Asset("ATLAS", "images/inventoryimages/tentonhammer.xml"),    Asset("IMAGE", "images/inventoryimages/tentonhammer.tex"),}local function OnEquip(inst, owner)    owner.AnimState:OverrideSymbol("swap_object", "swap_tentonhammer", "swap_tentonhammer")    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 onattack_tentonhammer(inst, attacker, target)	if attacker then		SpawnPrefab("maxwell_smoke").Transform:SetPosition(inst:GetPosition():Get())		inst.SoundEmitter:PlaySound("dontstarve/common/balloon_pop")	end	    if target.components.sleeper ~= nil then        target.components.sleeper:AddSleepiness(15, 15, inst)    elseif target.components.grogginess ~= nil then        target.components.grogginess:AddGrogginess(15, 15)    end    if target.components.combat ~= nil and not target:HasTag("player") then        target.components.combat:SuggestTarget(attacker)    end    target:PushEvent("attacked", { attacker = attacker, damage = 0, weapon = inst })end local function fn()      local inst = CreateEntity()     inst.entity:AddTransform()    inst.entity:AddAnimState()    inst.entity:AddSoundEmitter()    inst.entity:AddNetwork()         MakeInventoryPhysics(inst)             inst.AnimState:SetBank("tentonhammer")    inst.AnimState:SetBuild("tentonhammer")    inst.AnimState:PlayAnimation("idle")     inst:AddTag("sharp")	     if not TheWorld.ismastersim then        return inst    end     inst.entity:SetPristine()         inst:AddComponent("weapon")    inst.components.weapon:SetDamage(0)	inst.components.weapon:SetOnAttack(onattack_tentonhammer)	    inst:AddComponent("finiteuses")        inst.components.finiteuses:SetMaxUses(100)    inst.components.finiteuses:SetUses(100)    inst.components.finiteuses:SetOnFinished(inst.Remove)       inst:AddComponent("inspectable")          inst:AddComponent("inventoryitem")    inst.components.inventoryitem.imagename = "tentonhammer"    inst.components.inventoryitem.atlasname = "images/inventoryimages/tentonhammer.xml"          inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( OnEquip )    inst.components.equippable:SetOnUnequip( OnUnequip )         return instendreturn  Prefab("common/inventory/tentonhammer", fn, assets) 

Link to comment
Share on other sites

@rons0n:

local function onattack_tentonhammer(inst, attacker, target)    if attacker then        SpawnPrefab("maxwell_smoke").Transform:SetPosition(inst:GetPosition():Get())        inst.SoundEmitter:PlaySound("dontstarve/common/balloon_pop")    end	if target and target.brain and target.tentonstun ~= true then		target.tentonstun = true		target.brain:Stop()		if target.components.locomotor then			target.components.locomotor:Stop()		end		target:DoTaskInTime(10, function()			target.brain:Start()			target.tentonstun = nil		end)	endend
Link to comment
Share on other sites

@DarkXero, Thanks yet again! Everythings coming slowly but I'm actually stuck on one little thing, I have two items that are suppose to do nothing when they both reach 0%. Unfortunately it isn't as easy as I hoped. A good friend of mine has helped me for 1 item but we're both stuck on why the refueling portion isn't working as we hoped.

 

1st item:

local assets={        Asset("ANIM", "anim/impactdial.zip"),        Asset("ANIM", "anim/swap_impactdial.zip"),         Asset("ATLAS", "images/inventoryimages/impactdial.xml"),        Asset("IMAGE", "images/inventoryimages/impactdial.tex"),} local function onattack_impactdial(inst, attacker, target)        if not inst.components.fueled:IsEmpty() then                if attacker and attacker.components.health then                        attacker.components.health:DoDelta(-50)                                                           inst.SoundEmitter:KillSound("dontstarve/common/blackpowder_explo")                        inst.SoundEmitter:PlaySound("dontstarve/common/blackpowder_explo")                                               SpawnPrefab("explode_small").Transform:SetPosition(inst.Transform:GetWorldPosition())                  end                                   if attacker.components.combat.hurtsound ~= nil and attacker.SoundEmitter ~= nil then                        builder.SoundEmitter:PlaySound(builder.components.combat.hurtsound)                end                               attacker:PushEvent("damaged", {})                               inst.components.fueled:DoDelta(-1)        else                attacker.components.talker:Say("It has ran out of fuel")                inst.components.weapon:SetDamage(0)        endendlocal function ShouldAcceptItem(inst, item)    if item.prefab == "rocks" then       return true    end    return falseendlocal function OnGetItemFromPlayer(inst, giver, item)    if item.prefab == "rocks" then       inst.components.fueled.current = inst.components.fueled.current + inst.components.fueled.total * 0.5    end    if inst.components.fueled.current > inst.components.fueled.total then       inst.components.fueled.current = inst.components.fueled.total    endend local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_impactdial", "swap_impactdial")        owner.AnimState:Show("ARM_carry")        owner.AnimState:Hide("ARM_normal")        if inst.components.fueled:IsEmpty() then                inst.components.weapon:SetDamage(0)        else                inst.components.weapon:SetDamage(200)        end        inst.components.fueled:StopConsuming()end local function OnUnequip(inst, owner)        owner.AnimState:Hide("ARM_carry")        owner.AnimState:Show("ARM_normal")        inst.components.fueled:StopConsuming()end local function OnDepleted(inst)end local function fn()        local inst = CreateEntity()               inst.entity:AddTransform()        inst.entity:AddAnimState()        inst.entity:AddSoundEmitter()        inst.entity:AddNetwork()               MakeInventoryPhysics(inst)                 inst.AnimState:SetBank("impactdial")        inst.AnimState:SetBuild("impactdial")        inst.AnimState:PlayAnimation("idle")               inst:AddTag("sharp")               if not TheWorld.ismastersim then                return inst        end         inst.entity:SetPristine()                 inst:AddComponent("weapon")        inst.components.weapon:SetDamage(200)        inst.components.weapon:SetOnAttack(onattack_impactdial)               inst:AddComponent("fueled")        inst.components.fueled.fueltype = FUELTYPE.FLINT		inst.components.fueled:InitializeFuelLevel(2)		inst.components.fueled:SetDepletedFn(OnDepleted)        inst.components.fueled:StopConsuming()               inst:AddComponent("inspectable")               inst:AddComponent("inventoryitem")        inst.components.inventoryitem.imagename = "impactdial"        inst.components.inventoryitem.atlasname = "images/inventoryimages/impactdial.xml"               inst:AddComponent("equippable")        inst.components.equippable:SetOnEquip( OnEquip )        inst.components.equippable:SetOnUnequip( OnUnequip )               return instend return  Prefab("common/inventory/impactdial", fn, assets)

 

And in the modmain we added:

AddPrefabPostInit("flint", function(inst)    inst:AddComponent("fuel")    inst.components.fuel.fuelvalue = 1inst.components.fuel.fueltype = GLOBAL.FUELTYPE.FLINTend)

 

And then on my range weapon in particular i dont want it to do anything at all at 0%. It'll just be a hand item with no use until its refueled. This one uses the trader, which also can be spammed when at 0%.

 

local assets={    Asset("ANIM", "anim/kurokabuto.zip"),    Asset("ANIM", "anim/swap_kurokabuto.zip"),     Asset("ATLAS", "images/inventoryimages/kurokabuto.xml"),    Asset("IMAGE", "images/inventoryimages/kurokabuto.tex"),}local function onattack_kurokabuto(inst, attacker, target)    if attacker and attacker.components.health and attacker.components.hunger then        attacker.components.health:DoDelta(-1)		attacker.components.hunger:DoDelta(-2)    endendlocal function ShouldAcceptItem(inst, item)    if item.prefab == "rocks" then       return true    end    return falseendlocal function OnGetItemFromPlayer(inst, giver, item)    if item.prefab == "rocks" then       inst.components.finiteuses.current = inst.components.finiteuses.current + inst.components.finiteuses.total * 0.5    end    if inst.components.finiteuses.current > inst.components.finiteuses.total then       inst.components.finiteuses.current = inst.components.finiteuses.total    endendlocal 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("kurokabuto")    inst.AnimState:SetBuild("kurokabuto")    inst.AnimState:PlayAnimation("idle")		if not TheWorld.ismastersim then        return inst    end     local function OnEquip(inst, owner)        owner.AnimState:OverrideSymbol("swap_object", "swap_kurokabuto", "swap_kurokabuto")        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 = "kurokabuto"    inst.components.inventoryitem.atlasname = "images/inventoryimages/kurokabuto.xml"         inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( OnEquip )    inst.components.equippable:SetOnUnequip( OnUnequip )	inst.components.inventoryitem.keepondeath = true		inst:AddComponent("inspectable")			inst:AddTag("shadow") 	inst:AddComponent("weapon")	inst.components.weapon:SetOnAttack(onattack_kurokabuto)    inst.components.weapon:SetDamage(55)    inst.components.weapon:SetRange(24, 30)	inst.components.weapon:SetProjectile("usopp_projectile")	    inst:AddComponent("finiteuses")    inst.components.finiteuses:SetMaxUses(10)    inst.components.finiteuses:SetUses(10)    if inst.components.finiteuses.current < 0 then       inst.components.finiteuses.current = 0    end	    inst:AddComponent("trader")    inst.components.trader.onaccept = OnGetItemFromPlayer    inst.components.trader:SetAcceptTest(ShouldAcceptItem)    return inst	end	return  Prefab("common/inventory/kurokabuto", fn, assets)

 

Sorry about all these questions, I recently found this problem when i realised both weapons had infinite uses at 0%.

Edited by rons0n
Link to comment
Share on other sites

@rons0n:

local assets = {	Asset("ANIM", "anim/kurokabuto.zip"),	Asset("ANIM", "anim/swap_kurokabuto.zip"),	Asset("ATLAS", "images/inventoryimages/kurokabuto.xml"),	Asset("IMAGE", "images/inventoryimages/kurokabuto.tex"),}local function onattack_kurokabuto(inst, attacker, target)	if attacker and attacker.components.health and attacker.components.hunger then		attacker.components.health:DoDelta(-1)		attacker.components.hunger:DoDelta(-2)	endendlocal function ShouldAcceptItem(inst, item)	if item.prefab == "rocks" then		return true	end	return falseendlocal function OnGetItemFromPlayer(inst, giver, item)	inst.components.finiteuses:Use(-1)endlocal function OnEquip(inst, owner)	owner.AnimState:OverrideSymbol("swap_object", "swap_kurokabuto", "swap_kurokabuto")	owner.AnimState:Show("ARM_carry")	owner.AnimState:Hide("ARM_normal")endlocal function OnUnequip(inst, owner)	owner.AnimState:Hide("ARM_carry")	owner.AnimState:Show("ARM_normal")endlocal function onUseChange(inst, data)	if data.percent == 1 then		if inst.components.trader.enabled == true then			inst.components.trader:Disable()		end	else		if inst.components.trader.enabled ~= true then			inst.components.trader:Enable()		end	end	if data.percent > 0 then		if inst.components.weapon == nil then			inst:AddComponent("weapon")			inst.components.weapon:SetOnAttack(onattack_kurokabuto)			inst.components.weapon:SetDamage(55)			inst.components.weapon:SetRange(24, 30)			inst.components.weapon:SetProjectile("usopp_projectile")		end	else		if inst.components.weapon ~= nil then			inst:RemoveComponent("weapon")		end	endendlocal function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()	inst.entity:AddSoundEmitter()	inst.entity:AddNetwork()	MakeInventoryPhysics(inst)	inst.AnimState:SetBank("kurokabuto")	inst.AnimState:SetBuild("kurokabuto")	inst.AnimState:PlayAnimation("idle")	inst:AddTag("nopunch")	inst:AddTag("shadow")	inst.entity:SetPristine()	if not TheWorld.ismastersim then		return inst	end	inst:AddComponent("inventoryitem")	inst.components.inventoryitem.keepondeath = true	inst.components.inventoryitem.imagename = "kurokabuto"	inst.components.inventoryitem.atlasname = "images/inventoryimages/kurokabuto.xml"	inst:AddComponent("equippable")	inst.components.equippable:SetOnEquip(OnEquip)	inst.components.equippable:SetOnUnequip(OnUnequip)	inst.components.inventoryitem.keepondeath = true	inst:AddComponent("inspectable")	inst:AddComponent("trader")	inst.components.trader.onaccept = OnGetItemFromPlayer	inst.components.trader:SetAcceptTest(ShouldAcceptItem)	inst:ListenForEvent("percentusedchange", onUseChange)	inst:AddComponent("finiteuses")	inst.components.finiteuses:SetMaxUses(10)	inst.components.finiteuses:SetUses(10)	return instendreturn Prefab("common/inventory/kurokabuto", fn, assets)
Link to comment
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
 Share

×
  • Create New...