MIDNIGHTANIMAL Posted July 16, 2016 Share Posted July 16, 2016 (edited) i am glad that u checked this topic, i am really sorry for asking that much, Its not like i didnt even tried,no, I gave this problem some time to be confident with things what i need, so the things what i begging for : First perk: I working on Female character. Its will be cool if when she is near Male characters she gain some sanity boost, and Female and Male characters around her lose sanity. Second perk: If someone(not ghost players) is staying near her ,she is neutral to all enemies(excluding boss, bees, shadows) untill provoke them. But when there is no one around her monsters acting normal to her. Thats it.I know its alot of work ,but i found some things that could be modified to fit my expectations. Here is code from Sanji character, i dont actually know what i should change here to make people around My character lose sanity local function isMan(name) for k, v in ipairs(GLOBAL.CHARACTER_GENDERS.MALE) do if v == name then return true end end return false end AddPlayerPostInit(function(inst) if isMan(inst.prefab) then if not inst.components.sanityaura then inst:AddComponent("sanityaura") end local old = inst.components.sanityaura.aurafn inst.components.sanityaura.aurafn = function(inst, observer) local ret = 0 if old ~= nil then ret = old(inst, observer) end if observer.prefab == "mycharacter" then return GLOBAL.TUNING.SANITYAURA_SMALL + ret end return ret end end end) Here is combined things i tried, to make My character neutral if she is not alone (I used codes from different topics This one and This ) local function getplayersnumber(inst) local x,y,z = inst.Transform:GetWorldPosition() local radius = 10--change the radius to whatever you want local players = TheSim:FindEntities(x, y, z, radius, {"player"}, {"playerghost"}) --get all players in radius, but not ghosts local playercount = #players - 1 -- remove your self from the player count if playercount >= 1 then local function PassiveUntilAttack(self) if self.inst:HasTag("shadow") then return end local _SetRetargetFunction = self.SetRetargetFunction self.SetRetargetFunction = function(self, period, fn) if fn then local _fn = fn fn = function(...) local _target = _fn(...) if _target and _target.prefab == "mycharacter" then return end return _target end end return _SetRetargetFunction(self, period, fn) end end AddComponentPostInit("combat", PassiveUntilAttack) local function ChangeSuggest(inst) if inst.components.combat then local self = inst.components.combat local _SuggestTarget = self.SuggestTarget self.SuggestTarget = function(self, target) if target and target.prefab == "mycharacter" and target.components.combat.target ~= self.inst then return end return _SuggestTarget(self, target) end end end AddPrefabPostInit("hound", ChangeSuggest) AddPrefabPostInit("firehound", ChangeSuggest) AddPrefabPostInit("icehound", ChangeSuggest) end end I will appreciate any help. Edited July 16, 2016 by MIDNIGHTANIMAL 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