Jump to content

Need help with Character Mod


Recommended Posts

I need help to make a script does this: When the sanity of the character is below 20,the character will tranform (change to another form/anim),and cause sleep in a radius of 10 m around him/her ,forcing enemies (players only if pvp is on) that can sleep, to a "sleep mode" that has a duration of 3 minutes. Also,when in this form ,the character drains sanity from players like the ghost form does in Survival Mode.

PS: I will gradually post another scripts that i will need for this mod in another topics. And for those who want credit in the case i upload in public,just PM me about it.

Link to comment
Share on other sites

@Veyghard,

inst:ListenForEvent("sanitydelta",  function(inst) if inst.components.sanity.current<20 and inst.lastsanity and inst.lastsanity>=20 then --change build and stuff here local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10)--range    for k,v in pairs(ents) do		if v ~= inst then		   (TheNet:GetPVPEnabled() or not v:HasTag("player")) and        not (v.components.freezable ~= nil and v.components.freezable:IsFrozen()) and        not (v.components.pinnable ~= nil and v.components.pinnable:IsStuck()) then        if v.components.sleeper ~= nil then            v.components.sleeper:AddSleepiness(10, 60*3)--the first value is the sleepiness, some enemies have some resistance and u have to add enough sleepiness to actually put them to sleep.														--the 2nd value is the time, didn't test if its actually seconds        elseif v.components.grogginess ~= nil then            v.components.grogginess:AddGrogginess(10, 60*3)--same as above        else            v:PushEvent("knockedout")        end		end    end        end if inst.components.sanity.current>=20 and inst.lastsanity and inst.lastsanity<20 then  --change build and stuff back here  end inst.lastsanity=inst.components.sanity.current end )
didnt test it though, so it might have synthaxerrors. also, u will probably want to save and load whether u have been in that special state. and 3min seems imbalanced long, especially against players, u might want to at least make an exception so players dont sleep that long. Edited by Seiai
Link to comment
Share on other sites

@Veyghard,

 

inst:ListenForEvent("sanitydelta",  function(inst) if inst.components.sanity.current<20 and inst.lastsanity and inst.lastsanity>=20 then --change build and stuff here local pos = Vector3(inst.Transform:GetWorldPosition()) local ents = TheSim:FindEntities(pos.x,pos.y,pos.z, 10)--range    for k,v in pairs(ents) do		if v ~= inst then		   (TheNet:GetPVPEnabled() or not v:HasTag("player")) and        not (v.components.freezable ~= nil and v.components.freezable:IsFrozen()) and        not (v.components.pinnable ~= nil and v.components.pinnable:IsStuck()) then        if v.components.sleeper ~= nil then            v.components.sleeper:AddSleepiness(10, 60*3)--the first value is the sleepiness, some enemies have some resistance and u have to add enough sleepiness to actually put them to sleep.														--the 2nd value is the time, didn't test if its actually seconds        elseif v.components.grogginess ~= nil then            v.components.grogginess:AddGrogginess(10, 60*3)--same as above        else            v:PushEvent("knockedout")        end		end    end        end if inst.components.sanity.current>=20 and inst.lastsanity and inst.lastsanity<20 then  --change build and stuff back here  end inst.lastsanity=inst.components.sanity.current end )
didnt test it though, so it might have synthaxerrors. also, u will probably want to save and load whether u have been in that special state. and 3min seems imbalanced long, especially against players, u might want to at least make an exception so players dont sleep that long.

 

 

Thx for the reply,and i agree with you about the 3m for players,but i also forget to add some additions of "cons" about this sanity tranformation: The character while in this form cannot attack (thats why the sleepness),but can interact with anything,and he is immune to sleep or other debuffs like that while in this form.

And i am having problem to know where to put this script,i tried the prefab folder and hook it with the prefabs on the "modmain.lua",but every time i initialize the game with the mod applied ,it freezes.

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...