Jump to content

Help with dodelta on character goes insane to other characters...


Recommended Posts

Helloo, I need someones help to me a kind of code that would inst.components.sanity:DoDelta(-50) any players in a med range of my character upon going insane, since I got my character to roar upon going insane now I just need help with lowering other's sanity by 50 points :)! Please I beg of the coding gods here on Klei Forums, please, please, please help I really need this for make my character :D!!!! I thank you for everything you all done for me, 100% credit to you :D:D:D!!!!!

Link to comment
Share on other sites

In your event of going insane callback:

local theCharacter = <event callback data for going insane for your player's inst>
if(theCharacter.Transform)
then
    local x, y, z = theCharacter.Transform:GetWorldPosition()
    local players = FindPlayersInRange(x, y, z, (range here), true)
    for _, v in pairs(players)
    do
        if(v~=theCharacter)
        then
            if(v.components and v.components.sanity)
            then
                v.components.sanity:DoDelta(-50)
            end
        end
    end
end

 

Link to comment
Share on other sites

Please help I did this and it crashed 

local theCharacter = <"goinsane" for "goinsane" for "adam">
if(theCharacter.Transform)
then
local x, y, z = theCharacter.Transform:GetWorldPosition()
local players = FindPlayersInRange(x, y, z, (range here), true)
for _, v in pairs(players)
do
if(v~=theCharacter)
then
if(v.components and v.components.sanity)
then
v.components.sanity:DoDelta(-50)
end
end
end
end

So close!!!! Please CarlZalph help :D:D:D!!!!!!!!!!!!!!!!!

Link to comment
Share on other sites

3 minutes ago, SuperDavid said:

Please help I did this and it crashed

So close!!!! Please CarlZalph help :D:D:D!!!!!!!!!!!!!!!!!

Of course it crashed, you need to shove it into your event callback for going insane.

Ala:

inst:ListenForEvent("goinsane",
    function(inst)
        --The big code block above
        local theCharacter = inst
    end
)

Then change (range here) into some real floating point number for your range you want.

Link to comment
Share on other sites

I did this

inst:ListenForEvent("goinsane", function(inst, data)
local theCharacter = <"goinsane" for "goinsane" for "adam"> --line 293
if(theCharacter.Transform)
then
local x, y, z = theCharacter.Transform:GetWorldPosition()
local players = FindPlayersInRange(x, y, z, (1), true)
for _, v in pairs(players)
do
if(v~=theCharacter)
then
if(v.components and v.components.sanity)
then
v.components.sanity:DoDelta(-50)
end
end
end
end
local theCharacter = inst
end)

but it says ":293: unexpected symbol near '<'" please help :(:D!!!

Edited by SuperDavid
Link to comment
Share on other sites

9 minutes ago, SuperDavid said:

I did this but it says ":293: unexpected symbol near '<'" please help :(:D!!!

Lol.

inst:ListenForEvent("goinsane",
    function(inst, data)
        if(inst.Transform)
        then
            local x, y, z = inst.Transform:GetWorldPosition()
            local players = FindPlayersInRange(x, y, z, (range here), true)
            for _, v in pairs(players)
            do
                if(v~=inst)
                then
                    if(v.components and v.components.sanity)
                    then
                        v.components.sanity:DoDelta(-50)
                    end
                end
            end
        end
    end
)

Put it in your character's master postinit function callback or after the pristine state/TheWorld.ismastersim check.

Though you should have already have an event listener for your character's roar sound on going insane.

My snippets generally need some minor work to get it into your code portion.

 

Also a range of 1.0 is the size of 1/4th of a turf square.

Edited by CarlZalph
Link to comment
Share on other sites

Thank you, thank you, thank you SO MUCH!!!!!!! Now I have nice roar, really thanks so much I never could do this without you definitely give you all credit for roar of my character :D:D!!!!!! Really thanks again :D!! 

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...