Jump to content

[Help] Help with my character


Mordekhay

Recommended Posts

Hello! This is my first topic here... Hopefully I didn't break any rules
 
I spent all night making my own character
 
http://i.imgur.com/tapSRwG.png

...And it was all fine, but I need a little help with some scripts D:

Can someone help me with this?

 

I just need a few things but I can't find how to write it, tell me if it's impossible to do:

-Rain damage him like WX78 but without sparkles and more damage (1).
-Take 100 points of damage and loss 50 sanity when eats any kind of meat

-Very slow health regeneration when stand near fire

 

 

Sorry for my awful english D:

Link to comment
Share on other sites

Hello! This is my first topic here... Hopefully I didn't break any rules

 

I spent all night making my own character

 

http://i.imgur.com/tapSRwG.png

...And it was all fine, but I need a little help with some scripts D:

Can someone help me with this?

 

I just need a few things but I can't find how to write it, tell me if it's impossible to do:

-Rain damage him like WX78 but without sparkles and more damage (1).

-Take 100 points of damage and loss 50 sanity when eats any kind of meat

-Very slow health regeneration when stand near fire

 

 

Sorry for my awful english D:

 

Here is WX's code for eating gears,

change 'gears' to 'meat' and then change the effects eg inst.components.health:DoDelta and same for sanity, and it should work.

local function oneat(inst, food)

    

    if food and food.components.edible and food.components.edible.foodtype == "GEARS" then

        --give an upgrade!

        inst.level = inst.level + 1

        applyupgrades(inst)    

        inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")

        inst.HUD.controls.status.heart:PulseGreen()

        inst.HUD.controls.status.stomach:PulseGreen()

        inst.HUD.controls.status.brain:PulseGreen()

        

        inst.HUD.controls.status.brain:ScaleTo(1.3,1,.7)

        inst.HUD.controls.status.heart:ScaleTo(1.3,1,.7)

        inst.HUD.controls.status.stomach:ScaleTo(1.3,1,.7)

    end

end

 

Here is WX's code for rain damage and spark

you will have to remove the sparks effects and change the value to the damage you want.

local function dorainsparks(inst, dt)

    if (inst.components.moisture and inst.components.moisture:GetMoisture() > 0) then

        inst.spark_time = inst.spark_time - dt

        if inst.spark_time <= 0 then

            

            --GetClock():DoLightningLighting()

            inst.spark_time = 3+math.random()*2

            local pos = Vector3(inst.Transform:GetWorldPosition())

            local damage = nil

            -- Raining, no moisture-giving equipment on head, and moisture is increasing. Pro-rate damage based on waterproofness.

            if GetSeasonManager():IsRaining() and inst.components.inventory:GetEquippedMoistureRate(EQUIPSLOTS.HEAD) <= 0 and inst.components.moisture:GetDelta() > 0 then

                local waterproofmult = (inst.components.moisture and inst.components.moisture.sheltered and inst.components.inventory) and (1 - (inst.components.inventory:GetWaterproofness() + inst.components.moisture.shelter_waterproofness)) or (inst.components.inventory and (1 - inst.components.inventory:GetWaterproofness()) or 1)

                damage = waterproofmult > 0 and math.min(TUNING.WX78_MIN_MOISTURE_DAMAGE, TUNING.WX78_MAX_MOISTURE_DAMAGE * waterproofmult) or 0

                inst.components.health:DoDelta(damage, false, "rain")

                pos.y = pos.y + 1 + math.random()*1.5

            else -- We have moisture-giving equipment on our head or it is not raining and we are just passively wet (but drying off). Do full damage.

                if inst.components.moisture:GetDelta() >= 0 then -- Moisture increasing (wearing something moisturizing)

                    inst.components.health:DoDelta(TUNING.WX78_MAX_MOISTURE_DAMAGE, false, "water")

                else -- Drying damage

                    inst.components.health:DoDelta(TUNING.WX78_MOISTURE_DRYING_DAMAGE, false, "water")

                end

                pos.y = pos.y + .25 + math.random()*2

            end

            

            if not damage or (damage and damage < 0) then

                local spark = SpawnPrefab("sparks")

                spark.Transform:SetPosition(pos:Get())

            end

        end

    end

end

 

Lastly, this is willow's sanity bonus from fire

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

    

    return delta

end

 

Im not sure how you could change it from a sanity boost to a health boost...

but taking a cue from WX's damage from rain might be a start, except apply a positive modifier.

eg. inst.components.health:DoDelta( X )

where X is the healing variable.

Link to comment
Share on other sites

Thank you! It didn't crash with the meat code :grin:

 

But the second one.. I don't know how to just remove something from the code without ruining it >.< , I don't know what I need to erase and what no

 

Well WX's gear eating code also permanently increases his health, so I assumed you removed that part of it.

=-=-

 

anyway

local function dorainsparks(inst, dt)

    if (inst.components.moisture and inst.components.moisture:GetMoisture() > 0) then

        inst.spark_time = inst.spark_time - dt

        if inst.spark_time <= 0 then

            

            --GetClock():DoLightningLighting()

            inst.spark_time = 3+math.random()*2

            local pos = Vector3(inst.Transform:GetWorldPosition())

            local damage = nil

            -- Raining, no moisture-giving equipment on head, and moisture is increasing. Pro-rate damage based on waterproofness.

            if GetSeasonManager():IsRaining() and inst.components.inventory:GetEquippedMoistureRate(EQUIPSLOTS.HEAD) <= 0 and inst.components.moisture:GetDelta() > 0 then

                local waterproofmult = (inst.components.moisture and inst.components.moisture.sheltered and inst.components.inventory) and (1 - (inst.components.inventory:GetWaterproofness() + inst.components.moisture.shelter_waterproofness)) or (inst.components.inventory and (1 - inst.components.inventory:GetWaterproofness()) or 1)

                damage = waterproofmult > 0 and math.min(TUNING.WX78_MIN_MOISTURE_DAMAGE, TUNING.WX78_MAX_MOISTURE_DAMAGE * waterproofmult) or 0

                inst.components.health:DoDelta(damage, false, "rain")

                pos.y = pos.y + 1 + math.random()*1.5

            else -- We have moisture-giving equipment on our head or it is not raining and we are just passively wet (but drying off). Do full damage.

                if inst.components.moisture:GetDelta() >= 0 then -- Moisture increasing (wearing something moisturizing)

                    inst.components.health:DoDelta(TUNING.WX78_MAX_MOISTURE_DAMAGE, false, "water")

                else -- Drying damage

                    inst.components.health:DoDelta(TUNING.WX78_MOISTURE_DRYING_DAMAGE, false, "water")

                end

                pos.y = pos.y + .25 + math.random()*2

            end

            

            if not damage or (damage and damage < 0) then

                local spark = SpawnPrefab("sparks")

                spark.Transform:SetPosition(pos:Get())

            end

        end

    end

end

The above _might_ work (remove highlighted parts)

 

It could be done simpler if you didnt care about waterproofness and just wated the character to take damage when it is raining (even if completely protected and dry)

Link to comment
Share on other sites

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.

×
  • Create New...