rons0n Posted February 5, 2015 Share Posted February 5, 2015 Is this possible?I thought I could take this bit of code from the firestaff:local function onattack_red(inst, attacker, target, skipsanity) if target.components.burnable and not target.components.burnable:IsBurning() then if target.components.freezable and target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() else target.components.burnable:Ignite(true, attacker) end end if target.components.freezable then target.components.freezable:AddColdness(-1) --Does this break ice staff? if target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() end end if target.components.sleeper and target.components.sleeper:IsAsleep() then target.components.sleeper:WakeUp() end if target.components.combat then target.components.combat:SuggestTarget(attacker) if target.sg and target.sg.sg.states.hit and not target:HasTag("player") then target.sg:GoToState("hit") end end if attacker and attacker.components.sanity and not skipsanity then attacker.components.sanity:DoDelta(-TUNING.SANITY_SUPERTINY) end attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo") target:PushEvent("attacked", {attacker = attacker, damage = 0})endand just paste it in his prefab. Like a moving firestaff of doooooom. But only when he meleesI also have no idea what to write in the master_postinit. Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/ Share on other sites More sharing options...
Kzisor Posted February 5, 2015 Share Posted February 5, 2015 @rons0n, yes it is possible to deal fire damage on melee attacks. The question that you need to ask yourself is it only with his fists or with all weapons? Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-609979 Share on other sites More sharing options...
Ryuushu Posted February 5, 2015 Share Posted February 5, 2015 (edited) @rons0nIf by meelee you mean fists and meelee weapons (spear, hambat, etc...) then: ...local function onattack_red(attacker, target) if target.components.burnable and not target.components.burnable:IsBurning() then if target.components.freezable and target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() else target.components.burnable:Ignite(true, attacker) end end if target.components.freezable then target.components.freezable:AddColdness(-1) --Does this break ice staff? if target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() end end if target.components.sleeper and target.components.sleeper:IsAsleep() then target.components.sleeper:WakeUp() end if target.components.combat then target.components.combat:SuggestTarget(attacker) if target.sg and target.sg.sg.states.hit and not target:HasTag("player") then target.sg:GoToState("hit") end end attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo") target:PushEvent("attacked", {attacker = attacker, damage = 0})endlocal function DoCustomAttack(inst, targ, weapon) if inst.components.combat:CanHitTarget(targ, weapon) then inst:PushEvent("onattackother", {target = targ, weapon = weapon}) local damage = inst.components.combat:CalcDamage(targ, weapon) targ.components.combat:GetAttacked(inst, damage, weapon) onattack_red(inst, targ) if weapon then weapon.components.weapon:OnAttack(inst, targ, projectile) end inst.components.combat.lastdoattacktime = GetTime() endend...local master_postinit = function(inst)... local old_DoAttack = inst.components.combat.DoAttack inst.components.combat.DoAttack = function(self, target_override, weapon, projectile) local targ = target_override or self.target local weapon = weapon or self:GetWeapon() if not weapon or weapon and not weapon.components.weapon.attackrange then DoCustomAttack(inst, targ, weapon) else return old_DoAttack(self, target_override, weapon, projectile) end end...endSo, yes, you pretty much just copy-paste it inside your prefab and call it from combat's DoAttack. Edited February 5, 2015 by Ryuushu Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-609984 Share on other sites More sharing options...
rons0n Posted February 5, 2015 Author Share Posted February 5, 2015 @rons0n, yes it is possible to deal fire damage on melee attacks. The question that you need to ask yourself is it only with his fists or with all weapons? @Kzisor@Ryuushu Honestly i don't know, If i just let his fist burn stuff then i give him too much power over fire, kinda making him way too strong. On the other hand, If i let him burn stuff with anything, it'll be a nightmare as everything he touches will turn to ashes. Gosh, I didn't really think this through haha. Ryuushu I think I messed up: local MakePlayerCharacter = require "prefabs/player_common"local assets = { Asset( "ANIM", "anim/player_basic.zip" ), Asset( "ANIM", "anim/player_idles_shiver.zip" ), Asset( "ANIM", "anim/player_actions.zip" ), Asset( "ANIM", "anim/player_actions_axe.zip" ), Asset( "ANIM", "anim/player_actions_pickaxe.zip" ), Asset( "ANIM", "anim/player_actions_shovel.zip" ), Asset( "ANIM", "anim/player_actions_blowdart.zip" ), Asset( "ANIM", "anim/player_actions_eat.zip" ), Asset( "ANIM", "anim/player_actions_item.zip" ), Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ), Asset( "ANIM", "anim/player_actions_bugnet.zip" ), Asset( "ANIM", "anim/player_actions_fishing.zip" ), Asset( "ANIM", "anim/player_actions_boomerang.zip" ), Asset( "ANIM", "anim/player_bush_hat.zip" ), Asset( "ANIM", "anim/player_attacks.zip" ), Asset( "ANIM", "anim/player_idles.zip" ), Asset( "ANIM", "anim/player_rebirth.zip" ), Asset( "ANIM", "anim/player_jump.zip" ), Asset( "ANIM", "anim/player_amulet_resurrect.zip" ), Asset( "ANIM", "anim/player_teleport.zip" ), Asset( "ANIM", "anim/wilson_fx.zip" ), Asset( "ANIM", "anim/player_one_man_band.zip" ), Asset( "ANIM", "anim/shadow_hands.zip" ), Asset( "SOUND", "sound/sfx.fsb" ), Asset( "SOUND", "sound/wilson.fsb" ), Asset( "ANIM", "anim/beard.zip" ), Asset( "ANIM", "anim/ace.zip" ), Asset( "ANIM", "anim/ghost_ace_build.zip" ),}local prefabs = {}local start_inv = { -- Custom starting items}local function RestoreLight(inst) inst.Light:Enable(true) inst.Light:SetRadius(1) inst.Light:SetFalloff(.6) inst.Light:SetIntensity(0.9) inst.Light:SetColour(255/255,102/155,0/255)end-- This initializes for both clients and the hostlocal common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "ace.tex" )endlocal function onattack_red(attacker, target) if target.components.burnable and not target.components.burnable:IsBurning() then if target.components.freezable and target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() else target.components.burnable:Ignite(true, attacker) end end if target.components.freezable then target.components.freezable:AddColdness(-1) --Does this break ice staff? if target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() end end if target.components.sleeper and target.components.sleeper:IsAsleep() then target.components.sleeper:WakeUp() end if target.components.combat then target.components.combat:SuggestTarget(attacker) if target.sg and target.sg.sg.states.hit and not target:HasTag("player") then target.sg:GoToState("hit") end end attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo") target:PushEvent("attacked", {attacker = attacker, damage = 0})end local function DoCustomAttack(inst, targ, weapon) if inst.components.combat:CanHitTarget(targ, weapon) then inst:PushEvent("onattackother", {target = targ, weapon = weapon, projectile = projectile}) local damage = inst.components.combat:CalcDamage(targ, weapon) targ.components.combat:GetAttacked(inst, damage, weapon) onattack_red(inst, targ) if weapon then weapon.components.weapon:OnAttack(inst, targ, projectile) end inst.components.combat.lastdoattacktime = GLOBAL.GetTime() endendlocal function startfirebug(inst) inst.components.firebug:Enable()endlocal function stopfirebug(inst) inst.components.firebug:Disable()end-- This initializes for the host onlylocal master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wilson" -- Stats inst.components.health.fire_damage_scale = 0 inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(200) inst.components.combat.damagemultiplier = 0.5 inst.components.sanity.night_drain_mult = 1 inst.components.sanity.neg_aura_mult = 1 inst.entity:AddLight() inst.Light:Enable(true) inst.Light:SetRadius(1) inst.Light:SetFalloff(.6) inst.Light:SetIntensity(0.9) inst.Light:SetColour(255/255,102/155,0/255) inst:ListenForEvent( "nighttime", function() inst.entity:AddLight() end, GetWorld() ) inst:AddComponent("firebug") inst.components.firebug.prefab = "willowfire" inst.components.firebug.sanity_threshold = TUNING.WILLOW_LIGHTFIRE_SANITY_THRESH inst:ListenForEvent("ms_respawnedfromghost", RestoreLight) inst:ListenForEvent("ms_respawnedfromghost", startfirebug) inst:ListenForEvent("ms_becameghost", stopfirebug) inst:ListenForEvent("death", stopfirebug) startfirebug(inst) local old_DoAttack = inst.components.combat.DoAttack inst.components.combat.DoAttack = function(self, target_override, weapon, projectile) local targ = target_override or self.target local weapon = weapon or self:GetWeapon() if not weapon or weapon and not weapon.components.weapon.attackrange then DoCustomAttack(inst, targ, weapon) else return old_DoAttack(self, target_override, weapon, projectile) end endendreturn MakePlayerCharacter("ace", prefabs, assets, common_postinit, master_postinit, start_inv)I'm not sure its because i place it wrong or something looks a bit off. But based off the error im assuming it has to do with projectiles Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610011 Share on other sites More sharing options...
Ryuushu Posted February 5, 2015 Share Posted February 5, 2015 @rons0ninst.components.combat.lastdoattacktime:GLOBAL.GetTime()I knew I'd leave it here x.x Remove the GLOBAL.Hmm, Line 91.. Remove the param projectile.inst:PushEvent("onattackother", {target = targ, weapon = weapon}) Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610015 Share on other sites More sharing options...
rezecib Posted February 5, 2015 Share Posted February 5, 2015 @rons0n, Torches and lighters light things on fire with attacks, so you could take that code. It's chance-based at the moment, but you could easily remove that. Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610036 Share on other sites More sharing options...
SenL Posted February 5, 2015 Share Posted February 5, 2015 Wait, you can attack with your fists (ie nothing in hand slot) ? How? Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610112 Share on other sites More sharing options...
DrSmugleaf Posted February 5, 2015 Share Posted February 5, 2015 Wait, you can attack with your fists (ie nothing in hand slot) ? How? Simply click the enemy like if you had a weapon equipped, it will do 10 dmg. If its something neutral you are trying to attack hold ctrl+f. Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610115 Share on other sites More sharing options...
rons0n Posted February 5, 2015 Author Share Posted February 5, 2015 @rons0ninst.components.combat.lastdoattacktime:GLOBAL.GetTime()I knew I'd leave it here x.x Remove the GLOBAL.Hmm, Line 91.. Remove the param projectile.inst:PushEvent("onattackother", {target = targ, weapon = weapon}) Yup that worked! Thanks as always!And thanks everyone else about your suggestions! Time to get ready to release the fire pirate woot Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610120 Share on other sites More sharing options...
rons0n Posted February 6, 2015 Author Share Posted February 6, 2015 (edited) So this is awkward, but can I do it so it only effects his fists? My character is kinda experiencing the King Midas Golden Touch treatment, except replace gold with the whole world burning before him. Sorry if this is bothersome but i didn't expect Fire to be so deadly x_x Edited February 6, 2015 by rons0n Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610378 Share on other sites More sharing options...
Ryuushu Posted February 8, 2015 Share Posted February 8, 2015 @rons0nif not weapon or weapon and not weapon.components.weapon.attackrange thenStare at that line as long as you need. Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-610897 Share on other sites More sharing options...
rons0n Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) @rons0nif not weapon or weapon and not weapon.components.weapon.attackrange thenStare at that line as long as you need. @Ryuushu Pressed my eyeballs agaisnt my monitor all morning and I finally found out what you meant! Thank you as always! Shout-outs will be shouted-outs of course! Edited February 8, 2015 by rons0n Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-611106 Share on other sites More sharing options...
MarshallMabee Posted May 8, 2015 Share Posted May 8, 2015 I need something similar to this. My character mod, Pith the Pyromancer, has a custom weapon/tool. I want to add the same effects like the fire staff. I only want Pith to launch fire balls with his axe and drain his sanity when he uses it. Can you send me a code and tell me which file I should place it in. Pith's prefab is called "pith.lua" and his axe is "pyroaxe.lua". Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-635403 Share on other sites More sharing options...
DarkXero Posted May 8, 2015 Share Posted May 8, 2015 @MarshallMabee,inside pyroaxe.lua,-- on top, before and outside the function that contains CreateEntity()local function onattack_red(inst, attacker, target, skipsanity) if target.components.burnable and not target.components.burnable:IsBurning() then if target.components.freezable and target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() else if target.components.fueled and target:HasTag("campfire") and target:HasTag("structure") then -- Rather than worrying about adding fuel cmp here, just spawn some fuel and immediately feed it to the fire local fuel = SpawnPrefab("cutgrass") if fuel then target.components.fueled:TakeFuelItem(fuel) end else target.components.burnable:Ignite(true) end end end if target.components.freezable then target.components.freezable:AddColdness(-1) --Does this break ice staff? if target.components.freezable:IsFrozen() then target.components.freezable:Unfreeze() end end if target.components.sleeper and target.components.sleeper:IsAsleep() then target.components.sleeper:WakeUp() end if target.components.combat then target.components.combat:SuggestTarget(attacker) end if attacker and attacker.components.sanity and not skipsanity then attacker.components.sanity:DoDelta(-TUNING.SANITY_SUPERTINY) end attacker.SoundEmitter:PlaySound("dontstarve/wilson/fireball_explo") target:PushEvent("attacked", {attacker = attacker, damage = 0})end-- inside the function that contains CreateEntity(), after inst.components.weapon inst.components.weapon:SetDamage(0) inst.components.weapon:SetRange(8, 10) inst.components.weapon:SetOnAttack(onattack_red) inst.components.weapon:SetProjectile("fire_projectile") Link to comment https://forums.kleientertainment.com/forums/topic/50555-melee-fire-damage/#findComment-635447 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now