Cyde042 Posted February 15, 2013 Share Posted February 15, 2013 (edited) I'm now working on improving pigs by being able to give them armor and weapons (tools maybe too). The issue I've overcome for now are:[*]Armor protects them but doesn't show up[*]I can give the spear to the pigs, but when I hover over them it still shows "attack" so I had to remove component("weapon") for now, how can I fix that so "attack" doesn't show up?[*]Spear works (I have yet to try other tools and weapons) but doesn't show up (I think if it doesn't show up, means it doesn't have an animation which I can't yet make since we don't have decompiled animation files)[*]Amulet doesn't revive them and doesn't show up (yet)[*]Armor,amulet doesn't drop on death, the spear does[*]Can't add the edited lines/commands to the original .lua file without crash[*]I need to learn programming in luaOriginal pigman.lua:require "fonthelper"local assets ={ Asset("ANIM", "data/anim/ds_pig_basic.zip"), Asset("ANIM", "data/anim/ds_pig_actions.zip"), Asset("ANIM", "data/anim/ds_pig_attacks.zip"), Asset("ANIM", "data/anim/pig_build.zip"), Asset("ANIM", "data/anim/pigspotted_build.zip"), Asset("ANIM", "data/anim/werepig_build.zip"), Asset("ANIM", "data/anim/werepig_basic.zip"), Asset("ANIM", "data/anim/werepig_actions.zip"), Asset("SOUND", "data/sound/pig.fsb"),}local prefabs ={ "meat", "monstermeat", "poop", "tophat", "strawhat", "pigskin",}local FONTS = { { filename = "data/fonts/opensans50.zip", alias = DIALOGFONT },}AddFontAssets( assets, FONTS )local function CalcSanityAura(inst, observer) if inst.components.werebeast and inst.components.werebeast:IsInWereState() then return -TUNING.SANITYAURA_LARGE end if inst.components.follower and inst.components.follower.leader == observer then return TUNING.SANITYAURA_SMALL end return 0endlocal function ShouldAcceptItem(inst, item) if item.components.equippable and item.components.equippable.equipslot == EQUIPSLOTS.HEAD then return true end if item.components.edible then if (item.components.edible.foodtype == "MEAT" or item.components.edible.foodtype == "HORRIBLE") and inst.components.follower.leader and inst.components.follower:GetLoyaltyPercent() > 0.9 then return false end if item.components.edible.foodtype == "VEGGIE" then local last_eat_time = inst.components.eater:TimeSinceLastEating() if last_eat_time and last_eat_time < TUNING.PIG_MIN_POOP_PERIOD then return false end end return true endendlocal function OnGetItemFromPlayer(inst, giver, item) --I eat food if item.components.edible then --meat makes us friends if item.components.edible.foodtype == "MEAT" or item.components.edible.foodtype == "HORRIBLE" then if inst.components.combat.target and inst.components.combat.target == giver then inst.components.combat:SetTarget(nil) elseif giver.components.leader then inst.SoundEmitter:PlaySound("dontstarve/common/makeFriend") giver.components.leader:AddFollower(inst) inst.components.follower:AddLoyaltyTime(item.components.edible:GetHunger() * TUNING.PIG_LOYALTY_PER_HUNGER) end end if inst.components.sleeper:IsAsleep() then inst.components.sleeper:WakeUp() end end --I wear hats if item.components.equippable and item.components.equippable.equipslot == EQUIPSLOTS.HEAD then local current = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) if current then inst.components.inventory:DropItem(current) end inst.components.inventory:Equip(item) inst.AnimState:Show("hat") endendlocal function OnRefuseItem(inst, item) inst.sg:GoToState("refuse")endlocal function OnEat(inst, food) if food.components.edible and food.components.edible.foodtype == "MEAT" and inst.components.werebeast and not inst.components.werebeast:IsInWereState() then if food.components.edible:GetHealth() < 0 then inst.components.werebeast:TriggerDelta(1) end end if food.components.edible and food.components.edible.foodtype == "VEGGIE" then local poo = SpawnPrefab("poop") poo.Transform:SetPosition(inst.Transform:GetWorldPosition()) endendlocal builds = {"pig_build", "pigspotted_build"}local function NormalRetargetFn(inst) return FindEntity(inst, TUNING.PIG_TARGET_DIST, function(guy) if not guy.LightWatcher or guy.LightWatcher:IsInLight() then return guy:HasTag("monster") and guy.components.health and not guy.components.health:IsDead() and inst.components.combat:CanTarget(guy) end end)endlocal function NormalKeepTargetFn(inst, target) --give up on dead guys, or guys in the dark, or werepigs return inst.components.combat:CanTarget(target) and (not target.LightWatcher or target.LightWatcher:IsInLight()) and not (target.sg and target.sg:HasStateTag("transform") )endlocal function WerepigRetargetFn(inst) return FindEntity(inst, TUNING.PIG_TARGET_DIST, function(guy) return inst.components.combat:CanTarget(guy) and not guy:HasTag("werepig") and not (guy.sg and guy.sg:HasStateTag("transform") ) and not guy:HasTag("alwaysblock") end)endlocal function WerepigKeepTargetFn(inst, target) return inst.components.combat:CanTarget(target) and not target:HasTag("werepig") and not (target.sg and target.sg:HasStateTag("transform") )endfunction WerepigSleepTest(inst) return falseendfunction WerepigWakeTest(inst) return trueendlocal function SetWerePig(inst) local brain = require "brains/werepigbrain" inst:AddTag("werepig") inst:SetBrain(brain) inst:SetStateGraph("SGwerepig.lua") inst.AnimState:SetBuild("werepig_build") inst.components.combat:SetDefaultDamage(TUNING.WEREPIG_DAMAGE) inst.components.combat:SetAttackPeriod(TUNING.WEREPIG_ATTACK_PERIOD) inst.components.locomotor.runspeed = TUNING.WEREPIG_RUN_SPEED inst.components.locomotor.walkspeed = TUNING.WEREPIG_WALK_SPEED inst.components.sleeper:SetSleepTest(WerepigSleepTest) inst.components.sleeper:SetWakeTest(WerepigWakeTest) inst.components.lootdropper:SetLoot({"meat","meat", "pigskin"}) inst.components.lootdropper.numrandomloot = 0 inst.components.health:SetMaxHealth(TUNING.WEREPIG_HEALTH) inst.components.combat:SetTarget(nil) inst.components.combat:SetRetargetFunction(3, WerepigRetargetFn) inst.components.combat:SetKeepTargetFunction(WerepigKeepTargetFn) inst.components.trader:Disable() inst.components.follower:SetLeader(nil) inst.components.talker:IgnoreAll() inst.Label:Enable(false) inst.Label:SetText("")endlocal function NormalShouldSleep(inst) if inst.components.follower and inst.components.follower.leader then local fire = FindEntity(inst, 6, function(ent) return ent.components.burnable and ent.components.burnable:IsBurning() end, {"campfire"}) return DefaultSleepTest(inst) and fire and (not inst.LightWatcher or inst.LightWatcher:IsInLight()) else return DefaultSleepTest(inst) endendlocal function SetNormalPig(inst) inst:RemoveTag("werepig") local brain = require "brains/pigbrain" inst:SetBrain(brain) inst:SetStateGraph("SGpig.lua") inst.AnimState:SetBuild(inst.build) inst.components.combat:SetDefaultDamage(TUNING.PIG_DAMAGE) inst.components.combat:SetAttackPeriod(TUNING.PIG_ATTACK_PERIOD) inst.components.combat:SetKeepTargetFunction(NormalKeepTargetFn) inst.components.locomotor.runspeed = TUNING.PIG_RUN_SPEED inst.components.locomotor.walkspeed = TUNING.PIG_WALK_SPEED inst.components.sleeper:SetSleepTest(NormalShouldSleep) inst.components.sleeper:SetWakeTest(DefaultWakeTest) inst.components.lootdropper:SetLoot({}) inst.components.lootdropper:AddRandomLoot("meat",3) inst.components.lootdropper:AddRandomLoot("pigskin",1) inst.components.lootdropper.numrandomloot = 1 inst.components.health:SetMaxHealth(TUNING.PIG_HEALTH) inst.components.combat:SetRetargetFunction(3, NormalRetargetFn) inst.components.combat:SetTarget(nil) inst.components.trader:Enable() inst.Label:Enable(true) inst.components.talker:StopIgnoringAll()endlocal function fn(Sim) local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() local sound = inst.entity:AddSoundEmitter() local shadow = inst.entity:AddDynamicShadow() shadow:SetSize( 1.5, .75 ) inst.Transform:SetFourFaced() inst.entity:AddLightWatcher() inst.entity:AddLabel() inst.Label:SetFontSize(25) inst.Label:SetFont(DEFAULTFONT) inst.Label:SetPos(0,3,0) inst.Label:SetColour(.73, .05, .02) inst.Label:Enable(false) MakeCharacterPhysics(inst, 50, .5) inst:AddComponent("locomotor") -- locomotor must be constructed before the stategraph inst.components.locomotor.runspeed = TUNING.PIG_RUN_SPEED --5 inst.components.locomotor.walkspeed = TUNING.PIG_WALK_SPEED --3 inst:AddTag("character") inst:AddTag("pig") inst:AddTag("scarytoprey") inst.build = builds[math.random(#builds)] inst.AnimState:SetBuild(inst.build) anim:SetBank("pigman") anim:PlayAnimation("idle_loop") anim:Hide("hat") ------------------------------------------ inst:AddComponent("eater") inst.components.eater:SetOmnivore() inst.components.eater:SetCanEatHorrible() inst.components.eater.strongstomach = true -- can eat monster meat! inst.components.eater:SetOnEatFn(OnEat) ------------------------------------------ inst:AddComponent("combat") inst.components.combat.hiteffectsymbol = "pig_torso" MakeMediumBurnableCharacter(inst, "pig_torso") inst:AddComponent("named") inst.components.named.possiblenames = STRINGS.PIGNAMES inst.components.named:PickNewName() ------------------------------------------ inst:AddComponent("werebeast") inst.components.werebeast:SetOnWereFn(SetWerePig) inst.components.werebeast:SetOnNormalFn(SetNormalPig) inst.components.werebeast:SetTriggerLimit(4) ------------------------------------------ inst:AddComponent("follower") inst.components.follower.maxfollowtime = TUNING.PIG_LOYALTY_MAXTIME ------------------------------------------ inst:AddComponent("health") ------------------------------------------ inst:AddComponent("inventory") ------------------------------------------ inst:AddComponent("lootdropper") ------------------------------------------ inst:AddComponent("knownlocations") inst:AddComponent("talker") ------------------------------------------ inst:AddComponent("trader") inst.components.trader:SetAcceptTest(ShouldAcceptItem) inst.components.trader.onaccept = OnGetItemFromPlayer inst.components.trader.onrefuse = OnRefuseItem ------------------------------------------ inst:AddComponent("sanityaura") inst.components.sanityaura.aurafn = CalcSanityAura ------------------------------------------ inst:AddComponent("sleeper") inst.components.sleeper:SetResistance(2) ------------------------------------------ inst:AddComponent("inspectable") inst.components.inspectable.getstatus = function(inst) if inst:HasTag("werepig") then return "WEREPIG" elseif inst.components.follower.leader ~= nil then return "FOLLOWER" end end ------------------------------------------ inst.OnSave = function(inst, data) data.build = inst.build end inst.OnLoad = function(inst, data) inst.build = data.build or builds[1] if not inst.components.werebeast:IsInWereState() then inst.AnimState:SetBuild(inst.build) end end SetNormalPig(inst) return instendreturn Prefab( "common/characters/pigman", fn, assets, prefabs)Edited parts for armor compatibility (in order to make the body slot items give-able, I added inst:AddComponent("tradable") in their specific .lua files):local prefabs ={ "meat", "monstermeat", "poop", "tophat", "strawhat", "pigskin", "armor_wood", "amulet",}------------------local function ShouldAcceptItem(inst, item) if item.components.equippable and item.components.equippable.equipslot == EQUIPSLOTS.BODY then return true end------------------if item.components.equippable and item.components.equippable.equipslot == EQUIPSLOTS.BODY then local current = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY)if current then inst.components.inventory:DropItem(current) end inst.components.inventory:Equip(item) inst.AnimState:Show("armor") <--This doesn't do a thing endendEdited Parts for weapon compatibility(same thing as body slot items but only for spear now, I had to delete some lines so it's not considered a weapon since I don't know how to edit hovering other something commands):local prefabs ={ "meat", "monstermeat", "poop", "tophat", "strawhat", "pigskin", "amulet", "armor_wood", "spear",}------------local function ShouldAcceptItem(inst, item) Since there wasn't any slot given(or there is and I don't know) for "hand" equippables, I tried adding nothing if item.components.equippable then return true end------------if item.components.equippable then local current = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HAND) <-is this correct?if current then inst.components.inventory:DropItem(current) end inst.components.inventory:Equip(item) inst.AnimState:Show("ARM_carry") <-----this doesn't work endFuture plans:[*]Pig Commands like stay,keep chopping trees, retreat attack etc.[*]Pigs will harvest twigs,grass,crock pot (I may be going to ahead with this, I have yet to finish this mod first)[*]other...If you know how to fix some of my issues, please leave a comment. Edited February 15, 2013 by Cyde042 Link to comment Share on other sites More sharing options...
JoeW Posted February 15, 2013 Share Posted February 15, 2013 Please remember that all mods are to be used at your own risk. Klei will not be able to help you with any issues you may have with your game as a result of using a mod. Please remember that player made mods in Don't Starve are new and could cause issues with your current saved games. It is advised that you do not install game mods unless you are completely comfortable doing so. Link to comment Share on other sites More sharing options...
Cyde042 Posted February 15, 2013 Author Share Posted February 15, 2013 Please remember that all mods are to be used at your own risk. Klei will not be able to help you with any issues you may have with your game as a result of using a mod. Please remember that player made mods in Don't Starve are new and could cause issues with your current saved games. It is advised that you do not install game mods unless you are completely comfortable doing so.No no, I have no problems with my savegame, it's just I need to smash the code into one file and I don't know how. The issues are mostly flaws, not save corrupting issues. Link to comment Share on other sites More sharing options...
guyguyga Posted May 15, 2014 Share Posted May 15, 2014 No no, I have no problems with my savegame, it's just I need to smash the code into one file and I don't know how. The issues are mostly flaws, not save corrupting issues.No, they're basically just warnings that show up on any threads that has to do with mods. He's not saying that anything's wrong, he's just saying that IF something goes wrong, Klei is not responsible for it. 1 Link to comment Share on other sites More sharing options...
InaneDugong Posted May 15, 2014 Share Posted May 15, 2014 @Cyde042, I think you're better off asking each of your problems in different threads. This is a lot for anyone not involved to take on and I wouldn't expect such generosity. However, if each question were iterated in its own thread over time, you may be able to piece together the issue. Link to comment Share on other sites More sharing options...
ObsidianKing Posted May 15, 2014 Share Posted May 15, 2014 You guys do realise this thread is well over a year old, right? Link to comment Share on other sites More sharing options...
kraken121 Posted May 15, 2014 Share Posted May 15, 2014 You guys do realise this thread is well over a year old, right?lol, perfect avatar pic to point out the date of the thread to them 1 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