Jump to content

Weaponizing Birds


Recommended Posts

Yeah you must alter the code to change into a weapon on pickup and change when dropped tho

inst.components.inventoryitem:SetOnDroppedFn(dropped)

inst.components.inventoryitem:SetOnPickupFn(get)

inst.components.inventoryitem:SetOnPutInInventoryFn(get)

 

    local function get(inst) --------------------------- this gives the item the equipable
        if inst.components.equippable == nil then
            inst:AddComponent("equippable")
            inst.components.equippable:SetOnEquip(onequip)
            inst.components.equippable:SetOnUnequip(onunequip)
        end
    end
    local function lost(inst) ------------------------- this removes the equipable 
        if inst.components.equippable ~= nil then
            inst:RemoveComponent("equippable")
        end
    end
    local function get(inst, owner) -------------------------makes / recognises if tt should be equipable or not 
        if owner ~= nil then
            if owner.prefab == "character" then
                get(inst)
            else
                inst:DoTaskInTime(0, lost)
            end
        end
    end
    local function dropped(inst) ----------------------------this removes the equipable when dropped so it's character specific
        inst:DoTaskInTime(0, lost)
    end

this is some basic bare bones code for it

Edited by thomas4845
Link to comment
Share on other sites

Good thing the birds all share the same file. Though I want it to be a character-specific thing. Isn't there a "if player is character" thing to go under local function get, next to if inst.components.equippable == nil?

 

Unless I interpreted the info wrong and have to put it in the character's LUA instead of the birds'?

Edited by icantevenname
Had a thought.
Link to comment
Share on other sites

if owner.prefab == "character" then 

this bit of code makes it so that it only become equitable if the character picks it up 

the only problems that should be recognized is that you need to change the anim to suit the bird when you equip the item

if you need any more help i'll try my best

Link to comment
Share on other sites

Haven't had the chance to work on this mod, but I've had some thoughts. Would it be better for the birds to die when hitting the target, or have them stunned?

And how about they have elemental effects? (Crow = Just damage, Robin = Fire + Less Damage, Winter Robin = Ice + Less Damage, Canary = Electric + Less Damage, Puffin = Water + Less Damage) Would that be too much?

Edited by icantevenname
Had another thought.
Link to comment
Share on other sites

I've been using Wilbur's poop file from SW as a reference. I've given Sky the ability to throw (currently invisible) birds. But there's two problems I can't figure out. The birds fly to the NW if the target isn't close enough or in the way. Also, if I load a game with birds in Sky's inventory, I get this error:

[string "../mods/Sky/scripts/prefabs/birds.lua"]:449: attempt to index a nil value
LUA ERROR stack traceback:
    ../mods/Sky/scripts/prefabs/birds.lua:449 in (field) fn (Lua) <285-454>
    scripts/mainfunctions.lua:258 in () ? (Lua) <247-289>
    =[C]:-1 in (method) SpawnPrefab (C) <-1--1>
    scripts/mainfunctions.lua:306 in () ? (Lua) <300-308>
    =(tail call):-1 in ()  (tail) <-1--1>
    scripts/mainfunctions.lua:312 in (global) SpawnSaveRecord (Lua) <310-352>
    scripts/gamelogic.lua:553 in (upvalue) PopulateWorld (Lua) <325-587>
    scripts/gamelogic.lua:803 in (upvalue) DoInitGame (Lua) <686-882>
    scripts/gamelogic.lua:916 in (local) cb (Lua) <910-917>
    scripts/saveindex.lua:312 in (upvalue) OnLoadSaveDataFile (Lua) <294-313>
    scripts/saveindex.lua:327 in () ? (Lua) <326-328>
    =[C]:-1 in (method) GetPersistentStringInClusterSlot (C) <-1--1>

 

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