ArashiOtter Posted January 7, 2015 Share Posted January 7, 2015 I'm working on a custom character for a friend and ultimately will be making one for myself and was wondering if anyone could help me come up with a few scripts for perks. The character has 3 perks-------------------------------Perk #1: Wild Carnivore: Ability to consume raw foods for an extra increase on health and hunger,but with a decrease on sanity. This applies to meat based foods only, while plant matter will harm health and sanity while still filling hunger. Perk #2: Cat Nap: While sleeping in a bedroll this character has half the normal hunger drain,and bedrolls can be used twice instead of once. Random chance of passing out due to low sanitywith hunger and health decrease without a bedroll. Perk #3: Hunter: Ok this will flat out with no doubt be the hardest to do. Allows hunting and catching rabbits barehand no traps. Allows for character to get close to animals and prey without sending them screaming away. Chance of catching birds barehanded ~15%-20% chance.-----------------------------I'm not gonna lie I'm new to coding and scripting. I've had some experience with similar languages ie. python, But this is different never made a character mod like this before any help is much appreciated -Arashi Link to comment Share on other sites More sharing options...
ArashiOtter Posted January 8, 2015 Author Share Posted January 8, 2015 Is there a way to call on a variable from another script file in the main game directory. So like call in rabbit brain and make it so this character can get closer than other characters? Link to comment Share on other sites More sharing options...
rezecib Posted January 9, 2015 Share Posted January 9, 2015 Perk #1: Wild Carnivore Adding this to your character's master_postinit should do it:local OldEat = inst.components.eater.Eatinst.components.eater.Eat = function(self, food) if self:CanEat(food) then if food:HasTag("meat") and not( food.prefab:find("cooked") or food.prefab:find("dried") ) then food.components.edible.hungervalue = 1.1*food.components.edible.hungervalue food.components.edible.healthvalue = food.components.edible.healthvalue + 10 elseif food:HasTag("veggie") then food.components.edible.healthvalue = -10 food.components.edible.sanityvalue = -10 end end return OldEat(self, food)endYou might want to change the math depending on the specifics of how you want the increases/penalties to work. Perk #2: Cat Nap: This honestly looks pretty hard to implement, and like it would be very messy-- you'd have to adjust the SGWilson stategraph states, add custom saving information to bedrolls, etc... Perk #3: Hunter: I think this one is easy. Just put this in the common_postinit:inst:RemoveTag("scarytoprey")I'm kinda thinking this character needs some downsides, though Link to comment Share on other sites More sharing options...
ArashiOtter Posted January 9, 2015 Author Share Posted January 9, 2015 Thank you. I've got the code in, but I can not seem to get either perk to work is there something I'm missing? [/script][codesyntax]-- This initializes for both clients and the hostlocal common_postinit = function(inst)-- Minimap iconinst.MiniMapEntity:SetIcon( "machete.tex" )-- Hunter Perkinst:RemoveTag("scarytoprey")end-- This initializes for the host onlylocal master_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "wolfgang"-- Statsinst.components.health:SetMaxHealth(200)inst.components.hunger:SetMax(150)inst.components.sanity:SetMax(250)--Wild Carnivore Perklocal OldEat = inst.components.eater.Eatinst.components.eater.Eat = function(self, food)if self:CanEat(food) thenif food:HasTag("meat") and not( food.prefab:find("cooked") or food.prefab:find("dried") ) thenfood.components.edible.hungervalue = 1.1*food.components.edible.hungervaluefood.components.edible.healthvalue = food.components.edible.healthvalue + 10elseif food:HasTag("veggie") thenfood.components.edible.healthvalue = -25food.components.edible.sanityvalue = -25endendreturn OldEat(self, food)endend[/codesyntax] Link to comment Share on other sites More sharing options...
ArashiOtter Posted January 9, 2015 Author Share Posted January 9, 2015 Never mind hunter works on rabbits just not on bird. But carrots and other food items do not modify health and sanity negatively Link to comment Share on other sites More sharing options...
rezecib Posted January 10, 2015 Share Posted January 10, 2015 (edited) @ArashiOtter, Try changing this lineelseif food:HasTag("veggie") thento this:elseif food.components.edible.foodtype == FOODTYPE.VEGGIE thenEdit: Oh, hmm... looks like birds specifically check for both the player and scarytoprey tag (also the monster tag). I'm not really familiar with modifying brains... Edited January 10, 2015 by rezecib Link to comment Share on other sites More sharing options...
ArashiOtter Posted January 10, 2015 Author Share Posted January 10, 2015 Thank you again so much. Works now, I'm not to worried about the birds 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