Jump to content

Recommended Posts

Hello! Before getting things started, please do consider I haven't mod for a long time now, so dumbing down replies would be most helpful :-). Thank you.

I'm making a character using the same mechanics as Wolfgang but using sanity instead of hunger. Health should not affect the character either. Here's the prefab file:

 

local easing = require("easing")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/amaury.zip" ),Asset("ANIM", "anim/amaury_blue.zip"),Asset("ANIM", "anim/amaury_black.zip"),--Asset("ANIM", "anim/player_wolfgang.zip"),        Asset( "ANIM", "anim/ghost_amaury_build.zip" ),}local prefabs = {}local start_inv = {-- Custom starting items}-- The Following is the Wolfgang Ripofflocal function applymightiness(inst)local percent = inst.components.hunger:GetPercent()local damage_mult = TUNING.WOLFGANG_ATTACKMULT_NORMALlocal hunger_rate = TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMALlocal health_max = TUNING.WOLFGANG_HEALTH_NORMALlocal scale = 1local mighty_scale = 1local wimpy_scale = 1if inst.strength == "mighty" thenlocal mighty_start = (TUNING.WOLFGANG_START_MIGHTY_THRESH/TUNING.WOLFGANG_HUNGER) local mighty_percent = math.max(0, (percent - mighty_start) / (1 - mighty_start))damage_mult = easing.linear(mighty_percent, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MAX - TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, 1)health_max = easing.linear(mighty_percent, TUNING.WOLFGANG_HEALTH_NORMAL, TUNING.WOLFGANG_HEALTH_MIGHTY - TUNING.WOLFGANG_HEALTH_NORMAL, 1) hunger_rate = easing.linear(mighty_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, TUNING.WOLFGANG_HUNGER_RATE_MULT_MIGHTY - TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, 1) scale = easing.linear(mighty_percent, 1, mighty_scale - 1, 1) elseif inst.strength == "wimpy" thenlocal wimpy_start = (TUNING.WOLFGANG_START_WIMPY_THRESH/TUNING.WOLFGANG_HUNGER) local wimpy_percent = math.min(1, percent/wimpy_start )damage_mult = easing.linear(wimpy_percent, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MAX - TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, 1)health_max = easing.linear(wimpy_percent, TUNING.WOLFGANG_HEALTH_WIMPY, TUNING.WOLFGANG_HEALTH_NORMAL - TUNING.WOLFGANG_HEALTH_WIMPY, 1) hunger_rate = easing.linear(wimpy_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL - TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, 1) scale = easing.linear(wimpy_percent, wimpy_scale, 1 - wimpy_scale, 1) end    inst:ApplyScale("mightiness", scale)inst.components.hunger:SetRate(hunger_rate*TUNING.WILSON_HUNGER_RATE)inst.components.combat.damagemultiplier = damage_multlocal health_percent = inst.components.health:GetPercent()inst.components.health:SetMaxHealth(health_max)inst.components.health:SetPercent(health_percent, true)endlocal function becomewimpy(inst, silent)    if inst.strength == "wimpy" then        return    end    inst.AnimState:SetBuild("amaury_blue")    if not silent then        inst.sg:PushEvent("powerdown")        inst.components.talker:Say(GetString(inst, "ANNOUNCE_NORMALTOWIMPY"))        inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/shrink_medtosml")    end    inst.talksoundoverride = "dontstarve/characters/wolfgang/talk_small_LP"    inst.hurtsoundoverride = "dontstarve/characters/wolfgang/hurt_small"    inst.strength = "wimpy"endlocal function becomenormal(inst, silent)    if inst.strength == "normal" then        return    end    inst.AnimState:SetBuild("amaury")    if not silent then        if inst.strength == "mighty" then            inst.components.talker:Say(GetString(inst, "ANNOUNCE_MIGHTYTONORMAL"))            inst.sg:PushEvent("powerdown")            inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/shrink_lrgtomed")        elseif inst.strength == "wimpy" then            inst.components.talker:Say(GetString(inst, "ANNOUNCE_WIMPYTONORMAL"))            inst.sg:PushEvent("powerup")            inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/grow_smtomed")        end    end    inst.talksoundoverride = nil    inst.hurtsoundoverride = nil    inst.strength = "normal"endlocal function becomemighty(inst, silent)    if inst.strength == "mighty" then        return    end    inst.AnimState:SetBuild("amaury_black")    if not silent then        inst.components.talker:Say(GetString(inst, "ANNOUNCE_NORMALTOMIGHTY"))        inst.sg:PushEvent("powerup")        inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/grow_medtolrg")    end    inst.talksoundoverride = "dontstarve/characters/wolfgang/talk_large_LP"    inst.hurtsoundoverride = "dontstarve/characters/wolfgang/hurt_large"    inst.strength = "mighty"endlocal function onhungerchange(inst, data, forcesilent)    if inst.sg:HasStateTag("nomorph") or        inst:HasTag("playerghost") or        inst.components.health:IsDead() then        return    end    local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent    if inst.strength == "mighty" then        if inst.components.hunger.current < TUNING.WOLFGANG_END_MIGHTY_THRESH then            if silent and inst.components.hunger.current < TUNING.WOLFGANG_START_WIMPY_THRESH then                becomewimpy(inst, true)            else                becomenormal(inst, silent)            end        end    elseif inst.strength == "wimpy" then        if inst.components.hunger.current > TUNING.WOLFGANG_END_WIMPY_THRESH then            if silent and inst.components.hunger.current > TUNING.WOLFGANG_START_MIGHTY_THRESH then                becomemighty(inst, true)            else                becomenormal(inst, silent)            end        endelseif inst.components.hunger.current > TUNING.WOLFGANG_START_MIGHTY_THRESH then        becomemighty(inst, silent)    elseif inst.components.hunger.current < TUNING.WOLFGANG_START_WIMPY_THRESH then        becomewimpy(inst, silent)    endapplymightiness(inst)endlocal function onnewstate(inst)    if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then        inst._wasnomorph = not inst._wasnomorph        if not inst._wasnomorph then            onhungerchange(inst)        end    endendlocal function onbecamehuman(inst)    if inst._wasnomorph == nil then        inst.strength = "normal"        inst._wasnomorph = inst.sg:HasStateTag("nomorph")        inst.talksoundoverride = nil        inst.hurtsoundoverride = nil        inst:ListenForEvent("hungerdelta", onhungerchange)        inst:ListenForEvent("newstate", onnewstate)        onhungerchange(inst, nil, true)    endendlocal function onbecameghost(inst)    if inst._wasnomorph ~= nil then        inst.strength = "normal"        inst._wasnomorph = nil        inst.talksoundoverride = nil        inst.hurtsoundoverride = nil        inst:RemoveEventCallback("hungerdelta", onhungerchange)        inst:RemoveEventCallback("newstate", onnewstate)    endendlocal function onload(inst)    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)    inst:ListenForEvent("ms_becameghost", onbecameghost)    if inst:HasTag("playerghost") then        onbecameghost(inst)    else        onbecamehuman(inst)    endend-- This initializes for both clients and the hostlocal common_postinit = function(inst) -- Minimap iconinst.MiniMapEntity:SetIcon( "amaury.tex" )end-- This initializes for the host onlylocal master_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "wilson"-- Stats inst.components.health:SetMaxHealth(100)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(150)-- Wolfgang Ripoffinst.strength = "normal"    inst._wasnomorph = nil    inst.talksoundoverride = nil    inst.hurtsoundoverride = nilinst.components.hunger:SetMax(TUNING.WOLFGANG_HUNGER)inst.components.hunger.current = TUNING.WOLFGANG_START_HUNGERinst.components.sanity.night_drain_mult = 1.1inst.components.sanity.neg_aura_mult = 1.1    inst.OnLoad = onload    inst.OnNewSpawn = onloadendreturn MakePlayerCharacter("amaury", prefabs, assets, common_postinit, master_postinit, start_inv)
 
Here's Wolfgang's code : 

local easing = require("easing")local MakePlayerCharacter = require("prefabs/player_common")local assets ={    Asset("ANIM", "anim/wolfgang.zip"),    Asset("ANIM", "anim/wolfgang_skinny.zip"),    Asset("ANIM", "anim/wolfgang_mighty.zip"),    Asset("ANIM", "anim/player_wolfgang.zip"),Asset("SOUND", "sound/wolfgang.fsb"),    Asset("ANIM", "anim/ghost_wolfgang_build.zip"), }local function applymightiness(inst)local percent = inst.components.hunger:GetPercent()local damage_mult = TUNING.WOLFGANG_ATTACKMULT_NORMALlocal hunger_rate = TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMALlocal health_max = TUNING.WOLFGANG_HEALTH_NORMALlocal scale = 1local mighty_scale = 1.25local wimpy_scale = .9if inst.strength == "mighty" thenlocal mighty_start = (TUNING.WOLFGANG_START_MIGHTY_THRESH/TUNING.WOLFGANG_HUNGER) local mighty_percent = math.max(0, (percent - mighty_start) / (1 - mighty_start))damage_mult = easing.linear(mighty_percent, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MAX - TUNING.WOLFGANG_ATTACKMULT_MIGHTY_MIN, 1)health_max = easing.linear(mighty_percent, TUNING.WOLFGANG_HEALTH_NORMAL, TUNING.WOLFGANG_HEALTH_MIGHTY - TUNING.WOLFGANG_HEALTH_NORMAL, 1) hunger_rate = easing.linear(mighty_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, TUNING.WOLFGANG_HUNGER_RATE_MULT_MIGHTY - TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL, 1) scale = easing.linear(mighty_percent, 1, mighty_scale - 1, 1) elseif inst.strength == "wimpy" thenlocal wimpy_start = (TUNING.WOLFGANG_START_WIMPY_THRESH/TUNING.WOLFGANG_HUNGER) local wimpy_percent = math.min(1, percent/wimpy_start )damage_mult = easing.linear(wimpy_percent, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, TUNING.WOLFGANG_ATTACKMULT_WIMPY_MAX - TUNING.WOLFGANG_ATTACKMULT_WIMPY_MIN, 1)health_max = easing.linear(wimpy_percent, TUNING.WOLFGANG_HEALTH_WIMPY, TUNING.WOLFGANG_HEALTH_NORMAL - TUNING.WOLFGANG_HEALTH_WIMPY, 1) hunger_rate = easing.linear(wimpy_percent, TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, TUNING.WOLFGANG_HUNGER_RATE_MULT_NORMAL - TUNING.WOLFGANG_HUNGER_RATE_MULT_WIMPY, 1) scale = easing.linear(wimpy_percent, wimpy_scale, 1 - wimpy_scale, 1) end    inst:ApplyScale("mightiness", scale)inst.components.hunger:SetRate(hunger_rate*TUNING.WILSON_HUNGER_RATE)inst.components.combat.damagemultiplier = damage_multlocal health_percent = inst.components.health:GetPercent()inst.components.health:SetMaxHealth(health_max)inst.components.health:SetPercent(health_percent, true)endlocal function becomewimpy(inst, silent)    if inst.strength == "wimpy" then        return    end    inst.AnimState:SetBuild("wolfgang_skinny")    if not silent then        inst.sg:PushEvent("powerdown")        inst.components.talker:Say(GetString(inst, "ANNOUNCE_NORMALTOWIMPY"))        inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/shrink_medtosml")    end    inst.talksoundoverride = "dontstarve/characters/wolfgang/talk_small_LP"    inst.hurtsoundoverride = "dontstarve/characters/wolfgang/hurt_small"    inst.strength = "wimpy"endlocal function becomenormal(inst, silent)    if inst.strength == "normal" then        return    end    inst.AnimState:SetBuild("wolfgang")    if not silent then        if inst.strength == "mighty" then            inst.components.talker:Say(GetString(inst, "ANNOUNCE_MIGHTYTONORMAL"))            inst.sg:PushEvent("powerdown")            inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/shrink_lrgtomed")        elseif inst.strength == "wimpy" then            inst.components.talker:Say(GetString(inst, "ANNOUNCE_WIMPYTONORMAL"))            inst.sg:PushEvent("powerup")            inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/grow_smtomed")        end    end    inst.talksoundoverride = nil    inst.hurtsoundoverride = nil    inst.strength = "normal"endlocal function becomemighty(inst, silent)    if inst.strength == "mighty" then        return    end    inst.AnimState:SetBuild("wolfgang_mighty")    if not silent then        inst.components.talker:Say(GetString(inst, "ANNOUNCE_NORMALTOMIGHTY"))        inst.sg:PushEvent("powerup")        inst.SoundEmitter:PlaySound("dontstarve/characters/wolfgang/grow_medtolrg")    end    inst.talksoundoverride = "dontstarve/characters/wolfgang/talk_large_LP"    inst.hurtsoundoverride = "dontstarve/characters/wolfgang/hurt_large"    inst.strength = "mighty"endlocal function onhungerchange(inst, data, forcesilent)    if inst.sg:HasStateTag("nomorph") or        inst:HasTag("playerghost") or        inst.components.health:IsDead() then        return    end    local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent    if inst.strength == "mighty" then        if inst.components.hunger.current < TUNING.WOLFGANG_END_MIGHTY_THRESH then            if silent and inst.components.hunger.current < TUNING.WOLFGANG_START_WIMPY_THRESH then                becomewimpy(inst, true)            else                becomenormal(inst, silent)            end        end    elseif inst.strength == "wimpy" then        if inst.components.hunger.current > TUNING.WOLFGANG_END_WIMPY_THRESH then            if silent and inst.components.hunger.current > TUNING.WOLFGANG_START_MIGHTY_THRESH then                becomemighty(inst, true)            else                becomenormal(inst, silent)            end        endelseif inst.components.hunger.current > TUNING.WOLFGANG_START_MIGHTY_THRESH then        becomemighty(inst, silent)    elseif inst.components.hunger.current < TUNING.WOLFGANG_START_WIMPY_THRESH then        becomewimpy(inst, silent)    endapplymightiness(inst)endlocal function onnewstate(inst)    if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then        inst._wasnomorph = not inst._wasnomorph        if not inst._wasnomorph then            onhungerchange(inst)        end    endendlocal function onbecamehuman(inst)    if inst._wasnomorph == nil then        inst.strength = "normal"        inst._wasnomorph = inst.sg:HasStateTag("nomorph")        inst.talksoundoverride = nil        inst.hurtsoundoverride = nil        inst:ListenForEvent("hungerdelta", onhungerchange)        inst:ListenForEvent("newstate", onnewstate)        onhungerchange(inst, nil, true)    endendlocal function onbecameghost(inst)    if inst._wasnomorph ~= nil then        inst.strength = "normal"        inst._wasnomorph = nil        inst.talksoundoverride = nil        inst.hurtsoundoverride = nil        inst:RemoveEventCallback("hungerdelta", onhungerchange)        inst:RemoveEventCallback("newstate", onnewstate)    endendlocal function onload(inst)    inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman)    inst:ListenForEvent("ms_becameghost", onbecameghost)    if inst:HasTag("playerghost") then        onbecameghost(inst)    else        onbecamehuman(inst)    endendlocal function master_init(inst)inst.strength = "normal"    inst._wasnomorph = nil    inst.talksoundoverride = nil    inst.hurtsoundoverride = nilinst.components.hunger:SetMax(TUNING.WOLFGANG_HUNGER)inst.components.hunger.current = TUNING.WOLFGANG_START_HUNGERinst.components.sanity.night_drain_mult = 1.1inst.components.sanity.neg_aura_mult = 1.1    inst.OnLoad = onload    inst.OnNewSpawn = onloadendreturn MakePlayerCharacter("wolfgang", nil, assets, nil, master_init)

 
Issues :
-The character's texture files disappear in game whenever going into wimpy or mighty form. Why? I'm using for these forms respectively the anim files "amaury_blue" and "amaury_black". These anim files are exact copies of the anim file "amaury" used for the normal form, with only the build renamed using Build Renamer. So why does the character turn invisible?
 
-I have no clue how to properly change the hunger system to sanity. Not because I don't know how to change "Wolfgang hunger tuning" to "Wolfgang sanity tuning" but because I want to enter my own values. How can I enter such coding where I have to enter which values of sanity will make the character go from one form to another?
 
-How do I delete the health change without breaking the game?
 
Thank you for reading, any help will be greatly appreciated :-).
Edited by Thibooms

You can find tuning values in data/scripts/tuning.lua, you can add your own in modmain.lua using:

 

GLOBAL.TUNING.YOURVALUEHERE = 123

 

Alternatively, you can replace all the "TUNING.SUMTHIN" in your prefab file with hardcoded values. That's easier, but less flexible.

You can find tuning values in data/scripts/tuning.lua, you can add your own in modmain.lua using:

 

GLOBAL.TUNING.YOURVALUEHERE = 123

 

Alternatively, you can replace all the "TUNING.SUMTHIN" in your prefab file with hardcoded values. That's easier, but less flexible.

Great! I didn't know how to make my own tunings, thanks! Any idea on how to fix the texture problem though? :)

 

Thanks for the quick reply as well by the way ;)

Update : I have figured out how to change the mecanic from hunger to sanity, same goes for the health problem. Only thing I still don't understand is the texture bug. Just to be clear, I used the same anime file for the "normal" state and for the "wimpy" and "mighty" forms for testing purposes (with the only difference being the build name thanks to Build Renamer so the game doesn't crash) but the character becomes invisible when entering "wimpy" and "mighty" form and is visible during "normal" form. Please help me out, guys :-)

Again, by the way, thank you @Mobbstar for the advice. I was able to fix the values :-)

 

Edit : I fixed it! Silly me, turns out you should always make sure to save your renamed build as "build.bin", I never put in the ".bin" part  :mad-new:  :mad-new:  :mad-new:  :mad-new:  :mad-new:

Edited by Thibooms

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
×
  • Create New...