Shinoryoshu Posted September 2, 2016 Share Posted September 2, 2016 So im making my first mod and I got everything done besides the last perk i'm going to give the character. She powers up from getting hit by lightning much like Wx, but she gets a damage multiplier bonus instead of the light and run speed. The problem is when i went digging into Wx's script looking for the code that runs that I couldn't pinpoint the line that i need to copy and modify to give her this bonus. i was thinking it would be something like local function onlightingstrike(inst) inst.components.combat.damagemultiplier + (value) but of course I'm a noob when it comes to programming could some people help? I attached the LUA file for the character nora.lua Link to comment https://forums.kleientertainment.com/forums/topic/69945-help-with-some-lines-of-code-new-to-this-whole-thing/ Share on other sites More sharing options...
Mobbstar Posted September 3, 2016 Share Posted September 3, 2016 Take a look at this, I removed or disabled (with "--") all things but the attack multiplier and the talking. If you have questions, even stupid sounding ones, feel free to ask! Spoiler local MakePlayerCharacter = require "prefabs/player_common" local DAMAGEMULTIPLIER = 1.5 local function onupdate(inst, dt) inst.charge_time = inst.charge_time - dt if inst.charge_time <= 0 then inst.charge_time = 0 if inst.charged_task then inst.charged_task:Cancel() inst.charged_task = nil end --inst.SoundEmitter:KillSound("overcharge_sound") inst.charged_task = nil inst.components.combat.damagemultiplier = DAMAGEMULTIPLIER inst.components.talker:Say(GetString("nora", "ANNOUNCE_DISCHARGE")) else local runspeed_bonus = .5 -- Tune the bonus here! if inst.charge_time < 60 then runspeed_bonus = (inst.charge_time / 60)*runspeed_bonus end inst.components.combat.damagemultiplier = DAMAGEMULTIPLIER + runspeed_bonus end end local function onlightingstrike(inst) if inst.components.health and not inst.components.health:IsDead() then local protected = false -- RoG enabled if inst.components.inventory.IsInsulated then protected = inst.components.inventory:IsInsulated() end if not protected then inst.charge_time = inst.charge_time + TUNING.TOTAL_DAY_TIME*(.5 + .5*math.random()) --inst.components.health:DoDelta(TUNING.HEALING_SUPERHUGE,false,"lightning") --inst.components.sanity:DoDelta(-TUNING.SANITY_LARGE) inst.components.talker:Say(GetString("nora", "ANNOUNCE_CHARGE")) --inst.SoundEmitter:KillSound("overcharge_sound") --inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/charged", "overcharge_sound") --inst.AnimState:SetBloomEffectHandle( "shaders/anim.ksh" ) if not inst.charged_task then onupdate(inst, 0) inst.charged_task = inst:DoPeriodicTask(1, onupdate, nil, 1) end end end 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/nora.zip" ), } local prefabs = {} local start_inv = { -- Custom starting items --"flint", } local fn = function(inst) -- choose which sounds this character will play inst.soundsname = "willow" -- Minimap icon inst.MiniMapEntity:SetIcon( "nora.tex" ) -- Stats inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(115) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = DAMAGEMULTIPLIER -- Hunger rate (optional) inst.components.hunger.hungerrate = 1.1 * TUNING.WILSON_HUNGER_RATE -- Movement speed (optional) --inst.components.locomotor.walkspeed = 4 --inst.components.locomotor.runspeed = 6 -- RoG enabled if inst.components.playerlightningtarget then inst.components.playerlightningtarget:SetHitChance(1) inst.components.playerlightningtarget:SetOnStrikeFn(onlightingstrike) else -- Vanilla game inst:AddComponent("playerlightningtarget") inst:ListenForEvent("lightningstrike", onlightingstrike) end end return MakePlayerCharacter("nora", prefabs, assets, fn, start_inv) Link to comment https://forums.kleientertainment.com/forums/topic/69945-help-with-some-lines-of-code-new-to-this-whole-thing/#findComment-810019 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