Jump to content

Recommended Posts

For a whiterabbit wonderland themed character.

He's gonna have a pocketwatch that logs anything he causes a countdown for, and he'll loose sanity till he reaches it, Repeating "I'm late" till he does.

•He heals sanity when finishing tasks he sets timers for

•He takes more damage from hounds

•He gains carrot seeds from picking carrots out of the ground, and fills up faster from carrot based dishes

•He moves a bit faster than normal characters

•He cannot attack bunnies or bunny men

And he cannot use traps.

 

Heres the modmain.lua

PrefabFiles = {
    "whiterabbit", 
    "handwatch",   
}

Assets = {
    Asset("ANIM", "anim/whiterabbit.zip"),
    Asset("ANIM", "anim/ghost_whiterabbit_build.zip"),
    Asset("ATLAS", "images/map_icons/whiterabbit.xml"),
    Asset("IMAGE", "images/map_icons/whiterabbit.tex"),
}

----------------------------------------------------------------
-- STRINGS / QUOTES
----------------------------------------------------------------
STRINGS.CHARACTERS.WHITERABBIT = require "speech_whiterabbit"

STRINGS.CHARACTERS.WHITERABBIT.DESCRIBE.FLOWER   = "These flowers are much nicer than the ones in Wonderland"
STRINGS.CHARACTERS.WHITERABBIT.DESCRIBE.WORMHOLE = "I think I just saw a girl fall in"
STRINGS.CHARACTERS.WHITERABBIT.DESCRIBE.TRAP     = "Awful contraptions"
STRINGS.CHARACTERS.WHITERABBIT.ANNOUNCE_TIMER_DONE = "I'm late!"

AddMinimapAtlas("images/map_icons/whiterabbit.xml")

----------------------------------------------------------------
-- PLAYER MODS
----------------------------------------------------------------
local function onload(inst)

    ----------------------------------------------------------------
    -- Movement speed boost
    if inst.components.locomotor then
        inst.components.locomotor:SetExternalSpeedMultiplier(inst, "whiterabbit_speed", 1.1) -- 10% faster
    end

    ----------------------------------------------------------------
    -- Double damage from hounds
    local old_GetAttacked = inst.components.combat.GetAttacked
    inst.components.combat.GetAttacked = function(self, attacker, damage, weapon, ...)
        if attacker and attacker:HasTag("hound") then
            damage = damage * 2
        end
        return old_GetAttacked(self, attacker, damage, weapon, ...)
    end

    ----------------------------------------------------------------
    -- Rabbits & Bunnymen ignore White Rabbit (and cannot be harmed)
    inst:AddTag("rabbitfriend")

    inst:DoTaskInTime(0, function()
        AddPrefabPostInit("rabbit", function(r)
            if r.components.combat then r:RemoveComponent("combat") end
        end)
        AddPrefabPostInit("bunnyman", function(r)
            if r.components.combat then r:RemoveComponent("combat") end
        end)
    end)

    -- Prevent attacking rabbits/bunnymen
    inst:ListenForEvent("onattackother", function(inst, data)
        if data and data.target and (data.target.prefab == "rabbit" or data.target.prefab == "bunnyman") then
            inst.components.talker:Say("I can't hurt them!")
            if data.target.components.combat then
                data.target.components.combat:DropTarget()
            end
        end
    end)

    ----------------------------------------------------------------
    -- Carrot healing boost
    local old_Eat = inst.components.eater.Eat
    inst.components.eater.Eat = function(self, food, ...)
        if food and food.prefab and string.find(food.prefab, "carrot") then
            if food.components.edible then
                local oldval = food.components.edible.healthvalue
                food.components.edible.healthvalue = oldval * 1.5
                local ret = old_Eat(self, food, ...)
                food.components.edible.healthvalue = oldval -- reset to normal
                return ret
            end
        end
        return old_Eat(self, food, ...)
    end

    ----------------------------------------------------------------
    -- Gain carrot seeds from picking carrots
    inst:ListenForEvent("picksomething", function(inst, data)
        if data and data.object and data.object.prefab == "carrot" then
            local seed = SpawnPrefab("carrot_seeds")
            if seed then
                inst.components.inventory:GiveItem(seed)
            end
        end
    end)

    ----------------------------------------------------------------
    -- Only sanity from harvesting edible plants/cooked meals
    inst:ListenForEvent("harvested", function(inst, data)
        if data and data.object then
            if data.object:HasTag("stewer") or data.object:HasTag("farm_plant") then
                inst.components.sanity:DoDelta(10)
            end
        end
    end)

    ----------------------------------------------------------------
    -- Watch sanity check (sanity drains quickly if lost)
    inst:DoPeriodicTask(5, function()
        if not inst.components.inventory:FindItem(function(item) return item.prefab == "handwatch" end) then
            inst.components.sanity:DoDelta(-2) -- sanity drain w/o watch
        end
    end)

end

AddPlayerPostInit(onload)
 

 

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
×
  • Create New...