SimasWat Posted August 13, 2019 Share Posted August 13, 2019 Hello, I've already seen someone ask a similar question already, but I had problems figuring it out. I'm making my first mod and I wanted to make my character pyrophobic, so have a fear of nearby fires. I looked through Willow's prefab file because I originally assumed I could just copy Willow's sanity gain near fires and somehow invert it, but I wasn't exactly able to figure it out and it kept crashing. If anybody could help me a little with this or send me a good tutorial, I'd be very thankful. Link to comment Share on other sites More sharing options...
zetake Posted August 13, 2019 Share Posted August 13, 2019 You didn't even pasted your error... I don't know how it's done, but I just added a minus before TUNING.SANITYAURA_TINY and it worked for me... Local function: Spoiler local function sanityfn(inst) local x,y,z = inst.Transform:GetWorldPosition() local delta = 0 local max_rad = 10 local ents = TheSim:FindEntities(x,y,z, max_rad, {"fire"}) for k,v in pairs(ents) do if v.components.burnable and v.components.burnable.burning then local sz = -TUNING.SANITYAURA_TINY local rad = v.components.burnable:GetLargestLightRadius() or 1 sz = sz * ( math.min(max_rad, rad) / max_rad ) local distsq = inst:GetDistanceSqToInst(v) delta = delta + sz/math.max(1, distsq) end end if SaveGameIndex:IsModeShipwrecked() or SaveGameIndex:IsModePorkland() then if GetWorld().IsVolcano() then local map = GetWorld().Map if map and map:IsTileGridValid() then local tx, ty = map:GetTileXYAtPoint(x, y, z) local dist = map:GetClosestTileDist(tx, ty, GROUND.VOLCANO_LAVA, 4) if dist <= 4 then delta = math.max(delta, -TUNING.SANITYAURA_TINY * (1 - (dist / 4))) end end end end return delta end In prefab function: inst.components.sanity.custom_rate_fn = sanityfn PS: Local function has to be before prefab function... Link to comment Share on other sites More sharing options...
SimasWat Posted August 13, 2019 Author Share Posted August 13, 2019 Yes, thank you very much I tried it right away and it worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.