Crykov Posted August 26, 2015 Share Posted August 26, 2015 (edited) hi! my name is mata, i'm working on a custom character mod for my character: crykov! crykov is half cat, half enderman, which are a mob type from popular indie game minecraft. you can find the mod in it's current status here: http://steamcommunit...s/?id=504987058 my original goal when i made this mod was just to shove my own character into the game so i could be unique, but i want it to be a mod that others can be able to use, that is also well-balanced here's what my character has so far *a starter item called "blink" with a place-holder inventory icon which was taken from the Pearl mod, i had trouble scripting my own item, due to an error that pointed out something that wasn't even in the script, so i used the pearl mod as a base.*low stats to balance out her ability to teleport (100 hunger, 150 health and 150 sanity)*slightly faster walk speed*70% custom dialogue here's what i want her to have in the future: (i'll cross out things i have successfully added) *slightly faster swing speed with all items (decided not to add this one)*The ability to generate her own stable source of Nightmare Fuel. (1 every 3 days?)*No sanity boost for prototyping unless it's from the Magic tab.*Small sanity loss when near a Science Machine*a small, purple glow that serves almost no purpose other than to keep Charlie away.*Small sanity boost at night*Heavy health loss depending on moisture levels. none when dry, slight when damp, and instant death when soaked.*custom recipes for custom weapons and items for the Magic tab (a few ideas i have is a custom campfire/fire pit, which gives off a very large and long-lasting glow (perhaps it lasts 2-3 days) but is only powered by nightmare fuel.*ability to eat purple gems, which boosts max stats. what i know how to do: *Add components from other items to make custom items work like them. (added the component "blinkstaff" to my teleportation item)*change walkspeed*reskinning and custom art (i have trouble with items, for some reason they do not appear on the ground or in my hand, and the arm disappears when the item is used)*VERY experienced in animation as seen here and i know how to make playable avatars with Flash scripting, as seen here, but no idea how to add custom animation to DST*renaming items, adding things to the prefab files and PrefabFiles code in modmain.lua*everything this guide describes how to do SO basically all the questions i have is how to do everything under "stuff i want my character to have in the future" if anyone knows ANYTHING on how to add ANY of this stuff, i'd appreciate a guide or tutorial link, or any primary-source help you can provide ! thank you!! Edited August 28, 2015 by Crykov Link to comment Share on other sites More sharing options...
Zackreaver Posted August 26, 2015 Share Posted August 26, 2015 (edited) *slightly faster swing speed with all itemsDon't bother with this, faster animations actually require creating entirely new animations. Woodie has his own animation for chopping, along with his own entry into the wilson stategraph.This kind of a feature would give a headache, I'd suggest a workaround. You can still do it, but it's a lot of extra work. *The ability to generate her own stable source of Nightmare Fuel. (1 every 3 days?)Elaborate on what you would want, just appearing directly into your inventory? *Small sanity loss when near a Science Machineif GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("researchlab", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 0 end) AddPrefabPostInit("researchlab2", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 0 end) AddComponentPostInit("sanityaura", function(self) local old = self.GetAura function self:GetAura(observer) if observer.prefab == "crykov" and (self.inst.prefab == "researchlab" or self.inst.prefab == "researchlab2") then return -0.5 --Adjust this to your liking end if old then return old(self,observer) end end end)end *a small, purple glow that serves almost no purpose other than to keep Charlie away.You can just make charlie not attack the character ever, light source isn't needed for that. *Small sanity boost at night--master_postinitinst.components.sanity.night_drain_mult = -0.1 *custom recipes for custom weapons and items for the Magic tab--common_postinitinst:AddTag("crykovcrafter") --modmainlocal TECH = GLOBAL.TECHlocal RECIPETABS = GLOBAL.RECIPETABSlocal customweapon_recipe = AddRecipe("customweapon", { Ingredient("nightmarefuel", 1), Ingredient("twigs", 1), Ingredient("cutgrass", 2) }, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter", "images/inventoryimages/customweapon.xml") Edited August 26, 2015 by Zackreaver 1 Link to comment Share on other sites More sharing options...
Crykov Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) thank you Zackreaver!! that helps a lot!! anywhere i could +rep you? To elaborate on the Nightmare Fuel thing, i'd love to add some kind of custom-animated aura around her, but I think I'd like to start with nightmare fuel just casually appearing in her inventory. and i do want a small glow, it would be part of the character's aesthetic. Edited August 26, 2015 by Crykov 1 Link to comment Share on other sites More sharing options...
Crykov Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) one more question. where is common_postinit? is that just the crykov.lua folder? found it! it was quite obvious ;x; Edited August 26, 2015 by Crykov Link to comment Share on other sites More sharing options...
Zackreaver Posted August 26, 2015 Share Posted August 26, 2015 (edited) thank you Zackreaver!! that helps a lot!! anywhere i could +rep you?I don't really know, I guess you could like the post, doesn't really matter to me though To elaborate on the Nightmare Fuel thing, i'd love to add some kind of custom-animated aura around her, but I think I'd like to start with nightmare fuel just casually appearing in her inventory.Here's a very basic version of this--master_postinitinst:AddComponent("periodicspawner")inst.components.periodicspawner:SetPrefab("nightmarefuel")inst.components.periodicspawner:SetRandomTimes(480,960)inst.components.periodicspawner:SetOnSpawnFn(function(inst,fuel) if fuel then inst.components.inventory:GiveItem(fuel) endend)The only problem with this is when you reload a save the timer resets, this can be fixed with a little bit of work though. But that's why I said it's a very simple method for it. one more question. where is common_postinit? is that just the crykov.lua folder? Yes, it's in the crykov.lua It's right above the function master_postinit Edited August 27, 2015 by Zackreaver 1 Link to comment Share on other sites More sharing options...
Crykov Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) thank u so much for the quick reply! i can throw all this stuff in before me and my friend's session. any know about how to add a glow? actually, i think i can just drag the Torch script over. thank you for the help !! Edited August 26, 2015 by Crykov 1 Link to comment Share on other sites More sharing options...
Zackreaver Posted August 27, 2015 Share Posted August 27, 2015 (edited) any know about how to add a glow? --master_postinit inst.glow = GLOBAL.SpawnPrefab("minerhatlight") inst.glow.Light:SetRadius(10) inst.glow.Light:SetColour(1,1,0) inst.glow.entity:SetParent(inst.entity) Edited August 27, 2015 by Zackreaver 1 Link to comment Share on other sites More sharing options...
Zackreaver Posted August 27, 2015 Share Posted August 27, 2015 (edited) *ability to eat purple gems, which boosts max stats.This was taken from WX78, modified a little bit--ModMainGLOBAL.FOODTYPE.PURPLEGEM = "PURPLEGEM"GLOBAL.FOODGROUP.CRYKOV = { name = "CRYKOV", types = { GLOBAL.FOODTYPE.VEGGIE, GLOBAL.FOODTYPE.SEEDS, GLOBAL.FOODTYPE.GENERIC, GLOBAL.FOODTYPE.MEAT, GLOBAL.FOODTYPE.PURPLEGEM, }, } if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("purplegem",function(inst) inst:AddComponent("edible") inst.components.edible.foodtype = GLOBAL.FOODTYPE.PURPLEGEM inst.components.edible.healthvalue = 0 inst.components.edible.hungervalue = 0 inst.components.edible.sanityvalue = 0 end)end--character.lualocal function applyupgrades(inst) local max_upgrades = 15 local minhunger = TUNING.WX78_MIN_HUNGER local maxhunger = TUNING.WX78_MAX_HUNGER local minhealth = TUNING.WX78_MIN_HEALTH local maxhealth = TUNING.WX78_MAX_HEALTH local minsanity = TUNING.WX78_MIN_SANITY local maxsanity = TUNING.WX78_MAX_SANITY inst.level = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil(minhunger + inst.level * (maxhunger - minhunger) / max_upgrades) inst.components.health.maxhealth = math.ceil(minhealth + inst.level * (maxhealth - minhealth) / max_upgrades) inst.components.sanity.max = math.ceil(minsanity + inst.level * (maxsanity - minsanity) / max_upgrades) inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent)endlocal function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.PURPLEGEM then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) -- inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup") endendlocal function onpreload(inst, data) if data ~= nil and data.level ~= nil then inst.level = data.level applyupgrades(inst) --re-set these from the save data, because of load-order clipping issues if data.health and data.health.health then inst.components.health:SetCurrentHealth(data.health.health) end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) endendlocal function onload(inst, data) --Didn't see anything worth keeping hereendlocal function onsave(inst, data) data.level = inst.level > 0 and inst.level or nilend--master_postinitinst.level = 0inst.components.eater:SetDiet({FOODGROUP.CRYKOV})inst.components.eater:SetOnEatFn(oneat)applyupgrades(inst)inst.OnSave = onsaveinst.OnLoad = onloadinst.OnPreLoad = onpreload Edited August 27, 2015 by Zackreaver 1 Link to comment Share on other sites More sharing options...
Crykov Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) Here's a very basic version of this--master_postinitinst:AddComponent("periodicspawner")inst.components.periodicspawner:SetPrefab("nightmarefuel")inst.components.periodicspawner:SetRandomTimes(480,960)inst.components.periodicspawner:SetOnSpawnFn(function(inst,fuel) if fuel then inst.components.inventory:GiveItem(fuel) end) i believe the code is faulty. I tried to add it under master_postinit, and i got the error saying the parenthesis at the end was unexpected. I removed it, and it told me it expected the parenthesis at the end. ????Thank you for the purple gem script. can you test these scripts before you send me them? Edited August 27, 2015 by Crykov Link to comment Share on other sites More sharing options...
Crykov Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) (i posted another issue here but i fixed it) Edited August 27, 2015 by Crykov Link to comment Share on other sites More sharing options...
Zackreaver Posted August 27, 2015 Share Posted August 27, 2015 (edited) i believe the code is faulty.Yeah I forgot to end the function, I fixed my original postinst.components.periodicspawner:SetOnSpawnFn(function(inst,fuel) if fuel then inst.components.inventory:GiveItem(fuel) end ) should actually beinst.components.periodicspawner:SetOnSpawnFn(function(inst,fuel) if fuel then inst.components.inventory:GiveItem(fuel) end end) can you test these scripts before you send me them? My apologies for that, most of the code I gave is very simple, I just forgot to end that one function there. Also, after rereading WX78's code, I realized I forgot to initialize the levels to 0 so be sure to put this into your master_postinit--master_postinitinst.level = 0 Edited August 27, 2015 by Zackreaver Link to comment Share on other sites More sharing options...
Crykov Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) thank u very much!! i feel like i should be paying you for this, you're basically making my mod for me what's your steam account? i would like to add you in the credits :0 Edited August 27, 2015 by Crykov Link to comment Share on other sites More sharing options...
Crykov Posted August 27, 2015 Author Share Posted August 27, 2015 (edited) the nightmare fuel script doesn't seem to work still, i've tried using LongUpdate(x) to test it as well as just playing normally, but no nightmare fuel appears. is "fuel" supposed to be "nightmarefuel" ? Edited August 28, 2015 by Crykov Link to comment Share on other sites More sharing options...
DarkXero Posted August 30, 2015 Share Posted August 30, 2015 @Crykov, my contribution.I fixed the PeriodicSpawner, a Start() was missing there.I made a Wilson replacement mod. All you need to do is put the modmain on the modmain things, and the master_postinit things in the master_postinit things, and etc.Pretty straightforward.WilsonCrykov.zip Link to comment Share on other sites More sharing options...
Crykov Posted August 30, 2015 Author Share Posted August 30, 2015 @Crykov, my contribution.I fixed the PeriodicSpawner, a Start() was missing there.I made a Wilson replacement mod. All you need to do is put the modmain on the modmain things, and the master_postinit things in the master_postinit things, and etc.Pretty straightforward. whoaa! you put all sorts of scripts that i needed in there! thank you so much !! Link to comment Share on other sites More sharing options...
Crykov Posted August 30, 2015 Author Share Posted August 30, 2015 (edited) @DarkXero sorry if i seems like i'm milking you now, you don't have to reply if you don't want to, as these extras aren't that important. can i set my character to say something when it begins raining? like, "i better get to cover soon" or something like that. also, my character gets the Eat prompt for the gem, but when i right-click to eat it or drag it onto my character, nothing happens. here's my modmain script:PrefabFiles = { "crykov", "blink",}Assets = { Asset( "IMAGE", "images/saveslot_portraits/crykov.tex" ), Asset( "ATLAS", "images/saveslot_portraits/crykov.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/crykov.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/crykov.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/crykov_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/crykov_silho.xml" ), Asset( "IMAGE", "bigportraits/crykov.tex" ), Asset( "ATLAS", "bigportraits/crykov.xml" ), Asset( "IMAGE", "images/map_icons/crykov.tex" ), Asset( "ATLAS", "images/map_icons/crykov.xml" ), Asset( "IMAGE", "images/avatars/avatar_crykov.tex" ), Asset( "ATLAS", "images/avatars/avatar_crykov.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_crykov.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_crykov.xml" ),}--pre-learned Magic recipes + craftable gemslocal require = GLOBAL.requirelocal STRINGS = GLOBAL.STRINGSlocal TECH = GLOBAL.TECHlocal RECIPETABS = GLOBAL.RECIPETABSlocal blink_recipe = AddRecipe("blink", { Ingredient("nightmarefuel", 1) }, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter", "images/inventoryimages/blink.xml")local nightsword_recipe = AddRecipe("nightsword", { Ingredient("nightmarefuel", 5), Ingredient("livinglog", 1) }, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local armor_sanity_recipe = AddRecipe("armor_sanity", { Ingredient("nightmarefuel", 5), Ingredient("papyrus", 3) }, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local nightlight = AddRecipe("nightsword", {Ingredient("nightmarefuel", 5), Ingredient("livinglog", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local amulet = AddRecipe("amulet", {Ingredient("goldnugget", 3), Ingredient("nightmarefuel", 2),Ingredient("redgem", 1) }, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local firestaff = AddRecipe("firestaff", {Ingredient("nightmarefuel", 2), Ingredient("spear", 1), Ingredient("redgem", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local icestaff = AddRecipe("icestaff", {Ingredient("spear", 1),Ingredient("bluegem", 1)}, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local redgem = AddRecipe("redgem", {Ingredient("nightmarefuel", 2),Ingredient("rocks", 3),Ingredient("torch", 1)}, RECIPETABS.REFINE, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")local bluegem = AddRecipe("bluegem", {Ingredient("nightmarefuel", 2),Ingredient("rocks", 3),Ingredient("ice", 1)}, RECIPETABS.REFINE, TECH.NONE, nil, nil, nil, nil, "crykovcrafter")STRINGS.RECIPE_DESC.BLINK = "Ender power!"STRINGS.RECIPE_DESC.REDGEM = "Harness the ruby's firey magic."STRINGS.RECIPE_DESC.BLUEGEM = "Harness the sapphire's icey power."-- The character select screen linesSTRINGS.CHARACTER_TITLES.crykov = "The Enderborn"STRINGS.CHARACTER_NAMES.crykov = "Crykov"STRINGS.CHARACTER_DESCRIPTIONS.crykov = "*Is half enderman. Produces nightmare fuel naturally.\n*Knows a lot about magic but hates science.\n*Likes the night and can see in the dark.\n*Can craft gems."STRINGS.CHARACTER_QUOTES.crykov = "\"It's me!\""-- Custom speech stringsSTRINGS.CHARACTERS.CRYKOV = require "speech_crykov"-- The character's name as appears in-game STRINGS.NAMES.CRYKOV = "Crykov"GLOBAL.STRINGS.NAMES.BLINK = "Blink"-- The default responses of examining the characterSTRINGS.CHARACTERS.GENERIC.DESCRIBE.CRYKOV = { GENERIC = "It's Crykov!", ATTACKER = "That Crykov looks shifty...", MURDERER = "Murderer!", REVIVER = "Crykov, friend of ghosts.", GHOST = "Crykov could use a heart.",}AddMinimapAtlas("images/map_icons/crykov.xml")-- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL.AddModCharacter("crykov", "FEMALE")-- sanity loss near science machineif GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("researchlab", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 0 end) AddPrefabPostInit("researchlab2", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 0 end) AddComponentPostInit("sanityaura", function(self) local old = self.GetAura function self:GetAura(observer) if observer.prefab == "crykov" and (self.inst.prefab == "researchlab" or self.inst.prefab == "researchlab2") then return -0.5 --Adjust this to your liking end if old then return old(self,observer) end end end)end-- Gem eating mechanicslocal ACTIONS = GLOBAL.ACTIONSlocal ActionHandler = GLOBAL.ActionHandler-- Tags purple gem to be eatenlocal function MakeDelicious(inst) inst:AddTag("purple_flavor")endAddPrefabPostInit("purplegem", MakeDelicious)-- Action of eating gem and gaining a levellocal function ProcessGem(act) if act.doer and act.doer:HasTag("purple_lover") then local obj = act.target or act.invobject if obj and obj:HasTag("purple_flavor") then if obj.components.stackable then obj.components.stackable:Get():Remove() else obj:Remove() end act.doer:PushEvent("gemmed_up") return true end endendAddAction("PROCESSPURPLE", "Eat", ProcessGem)-- Lets gem get a Eat prompt on inventorylocal function GemPrompt(inst, doer, actions) if inst and inst:HasTag("purple_flavor") then if doer and doer:HasTag("purple_lover") then table.insert(actions, ACTIONS.PROCESSPURPLE) end endendAddComponentAction("INVENTORY", "inspectable", GemPrompt)-- Looks like the player eats meatlocal processhandler = ActionHandler(ACTIONS.PROCESSPURPLE, "Eat")AddStategraphActionHandler("crykov", processhandler) here's my crykov.lua scriptlocal 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/crykov.zip" ), Asset( "ANIM", "anim/ghost_crykov_build.zip" ),}local prefabs = {}local start_hunger = 100local start_health = 150local start_sanity = 150local max_hunger = 200local max_health = 300local max_sanity = 250-- Custom starting itemslocal start_inv = { "blink",}-- When the character is revived from humanlocal function onbecamehuman(inst) -- Set speed when loading or reviving from ghost (optional) inst.components.locomotor.walkspeed = 6 inst.components.locomotor.runspeed = 8.5end-- When loading or spawning the characterlocal function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) if not inst:HasTag("playerghost") then onbecamehuman(inst) endend-- This initializes for both the server and client. Tags can be added here.local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "crykov.tex" ) -- crafter tag inst:AddTag("crykovcrafter") -- purple gem tag inst:AddTag("purple_lover")endlocal function applyupgrades(inst) local max_upgrades = 10 inst.level = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() inst.components.hunger.max = math.ceil(start_hunger + inst.level * (max_hunger - start_hunger) / max_upgrades) inst.components.health.maxhealth = math.ceil(start_health + inst.level * (max_health - start_health) / max_upgrades) inst.components.sanity.max = math.ceil(start_sanity + inst.level * (max_sanity - start_sanity) / max_upgrades) inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) if inst.level == max_upgrades then inst.components.hunger:DoDelta(max_hunger / 2) inst.components.health:DoDelta(max_health / 2) inst.components.sanity:DoDelta(max_sanity / 2) endendlocal function WetDamage(inst) local moisture = inst.components.moisture.moisture local dead = inst.components.health:IsDead() if moisture > 1 and not dead then inst.components.health:DoDelta(-inst.waterdamage, true, "WaterHate", false, nil, true) else if inst.wetdamagetask then inst.wetdamagetask:Cancel() inst.wetdamagetask = nil end endendlocal function changeHealthOnWet(inst, data) inst.waterdamage = inst.components.moisture:GetMoisturePercent() * 3 -- 3 damage per second at full moisture (percent is 1) -- Instakill near max moisture is brutal if not inst.wetdamagetask then inst.wetdamagetask = inst:DoPeriodicTask(1, WetDamage) endendlocal function OnSave(inst, data) data.level = inst.level > 0 and inst.level or nilendlocal function OnPreLoad(inst, data) if data and data.level then inst.level = data.level applyupgrades(inst) if data.health and data.health.health then inst.components.health:SetCurrentHealth(data.health.health) end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) endendlocal function OnGemEat(inst) inst.level = inst.level + 1 applyupgrades(inst)endlocal function OnSpawnFuel(inst, fuel) inst.components.inventory:GiveItem(fuel)endlocal function SpawnTest(inst) return not inst.components.health:IsDead()end-- This initializes for the server only. Components are added here.local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wendy" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(100) inst.components.sanity:SetMax(150) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 0.9 * TUNING.WILSON_HUNGER_RATE -- Nightmare fuel periodic spawner, be sure to be alive for it! inst:AddComponent("periodicspawner") inst.components.periodicspawner:SetPrefab("nightmarefuel") inst.components.periodicspawner:SetRandomTimes(480, 480) inst.components.periodicspawner:SetOnSpawnFn(OnSpawnFuel) inst.components.periodicspawner:SetSpawnTestFn(SpawnTest) inst.components.periodicspawner:Start() -- Sanity prototype boost only for magic tab local _UnlockRecipe = inst.components.builder.UnlockRecipe inst.components.builder.UnlockRecipe = function(self, recname) local _ignore = self.inst.components.sanity.ignore local recipe = GetValidRecipe(recname) if recipe and not recipe.nounlock and recipe.tab == RECIPETABS.MAGIC then self.inst.components.sanity:DoDelta(TUNING.SANITY_MED) end self.inst.components.sanity.ignore = true _UnlockRecipe(self, recname) self.inst.components.sanity.ignore = _ignore end -- Health loss on moisture inst.waterdamage = 0.1 inst:ListenForEvent("moisturedelta", changeHealthOnWet) -- Stats definition, and leveling system inst.level = 0 applyupgrades(inst) inst:ListenForEvent("gemmed_up", OnGemEat) -- night vision inst.entity:AddLight() inst.Light:Enable(true) inst.Light:SetRadius(6) inst.Light:SetFalloff(.5) inst.Light:SetIntensity(0.8) inst.Light:SetColour(206/255,139/255,235/255) --sanity boost at night inst.components.sanity.night_drain_mult = -1 inst.OnLoad = onload inst.OnNewSpawn = onload endreturn MakePlayerCharacter("crykov", prefabs, assets, common_postinit, master_postinit, start_inv) Edited August 30, 2015 by Crykov Link to comment Share on other sites More sharing options...
DarkXero Posted August 30, 2015 Share Posted August 30, 2015 @Crykov,AddStategraphActionHandler("crykov", processhandler)should have "wilson", because all characters use the SGwilson stategraph. For the rain thing, include this in your prefab filelocal function OnStartRain(inst) if inst:HasTag("playerghost") then inst.components.talker:Say("Good thing it goes through me.") else inst.components.talker:Say("I shouldn't let water soak me.") endendand inside the master_postinitinst:WatchWorldState("startrain", OnStartRain) Link to comment Share on other sites More sharing options...
Crykov Posted August 31, 2015 Author Share Posted August 31, 2015 thank you! the rain thing works perfectly. however, i'm still unable to eat the gem, even after correcting the wilson/crykov thing Link to comment Share on other sites More sharing options...
DarkXero Posted August 31, 2015 Share Posted August 31, 2015 however, i'm still unable to eat the gem, even after correcting the wilson/crykov thing ...local processhandler = ActionHandler(ACTIONS.PROCESSPURPLE, "Eat")Here you changed "eat", to "Eat".Change it back. "eat" refers to a state name, not the action string. Link to comment Share on other sites More sharing options...
Crykov Posted August 31, 2015 Author Share Posted August 31, 2015 oh, i thought I fixed that already. sorry about that!! i'm kind of a scripting noob ;; i've tested it out and everything seems to work ! thank you so much!! Link to comment 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