Jump to content

I need help making a personal summoning staff for a character


Recommended Posts

I've been using the Yae Sakura mod and I wanted to add an item to it.

Her ears looked like bunny ears to me so it seemed like a great idea to make a staff that summons bunny followers for her, but I have very little modding knowledge.

So far I've only been able to tweak stats and that was about it.

I know very little about making a completely knew item

When the staff is used I want it to summon 3 bunnymen that also include the abilities of maxwell's minions besides the mining (fighting, tree cutting, stump digging). I've tried looking for the code for maxwell's minions to see how it worked, but haven't been able to find it.

The mod also has an item that has a skill that goes on a 5 day cooldown on use with an unlimited durability.

I want to try to implement it on this item with a 3 day cooldown on use that also has an unlimited durability.

So far I've tried adding 2 line for the recipe at the bottom of modmain

Spoiler

*PrefabFiles = {
    "sakura",
    "sakurasword",
    "sakuramark",
    "sakura_fx",
    "sakurapet", 
    } 
Assets = {  
    Asset("IMAGE", "images/inventoryimages/critter_sakurapet_builder.tex"),
    Asset("ATLAS", "images/inventoryimages/critter_sakurapet_builder.xml"), 
    }
AddMinimapAtlas("images/map_icons/sakura.xml") 
AddModCharacter("sakura", "FEMALE")  

TUNING.SAKURA_CD = 480*5 
TUNING.SAKURA_RANGE = 15 
TUNING.SAKURA_SUPERTIME = 10  
TUNING.SAKURA_SKILL_DAMAGE = 100 
TUNING.SAKURA_SKILL_HUNGER = 50 
TUNING.SAKURA_SKILL_SANITY = 5  
TUNING.SAKURA_RATE = 0.1 
TUNING.SAKURA_FLASH_DELTA = 2 
TUNING.SAKURA_FLASH_DAMAGE = 10 
TUNING.SAKURA_ATTACK_DELTA = 1  
local STRINGS = GLOBAL.STRINGS 
local require = GLOBAL.require  
local mylanguage = GetModConfigData("language") 
if mylanguage == 2 
then STRINGS.CHARACTER_TITLES.sakura= "逆神巫女" 
STRINGS.CHARACTER_NAMES.sakura= "八重樱"
STRINGS.CHARACTER_DESCRIPTIONS.sakura= "*带来了八重村的小可爱\n*利用刃返打出伤害\n*BOSS猎杀者" 
STRINGS.CHARACTER_QUOTES.sakura= "舰长补给全保底,舰长副本零掉落" 
STRINGS.CHARACTERS.SAKURA= require "speech_sakura" 
STRINGS.NAMES.SAKURA = "八重樱" 
STRINGS.NAMES.SAKURASWORD= "灵刀·樱吹雪" 
STRINGS.CHARACTERS.GENERIC.DESCRIBE.SAKURASWORD= "我可是最强巫女啊。" 
STRINGS.NAMES.CRITTER_SAKURAPET= "绯玉丸" 
STRINGS.NAMES.CRITTER_SAKURAPET_BUILDER= "绯玉丸" 
STRINGS.RECIPE_DESC.CRITTER_SAKURAPET_BUILDER = "小绯玉丸。" 
STRINGS.CHARACTERS.GENERIC.DESCRIBE.CRITTER_SAKURAPET= "你好,绯玉丸。" 
STRINGS.SAKURA_DONT_ATTACK = "我不想伤害伙伴。" 
STRINGS.ACTIONS.CASTSPELL.SAKURAFLASH = "一闪" 
STRINGS.ACTIONS.CASTSPELL.SAKURASKILL = "绯炎地狱" else 
STRINGS.CHARACTER_TITLES.sakura= "Yae Sakura" 
STRINGS.CHARACTER_NAMES.sakura= "Yae Sakura" 
STRINGS.CHARACTER_DESCRIPTIONS.sakura= "*Bring her own pet.\n*Fight is a art.\n*epic monster killer." 
STRINGS.CHARACTER_QUOTES.sakura= "Character from Honkai Impact 3rd." 
STRINGS.CHARACTERS.SAKURA= require "speech_sakura" 
STRINGS.NAMES.SAKURA = "Yae Sakura" STRINGS.NAMES.SAKURASWORD= "Sakura Sword" 
STRINGS.CHARACTERS.GENERIC.DESCRIBE.SAKURASWORD= "Fight is an art." 
STRINGS.NAMES.CRITTER_SAKURAPET= "绯玉丸" 
STRINGS.NAMES.CRITTER_SAKURAPET_BUILDER= "绯玉丸" 
STRINGS.RECIPE_DESC.CRITTER_SAKURAPET_BUILDER = "小绯玉丸。" 
STRINGS.CHARACTERS.GENERIC.DESCRIBE.CRITTER_SAKURAPET= "Hello,绯玉丸。" 
STRINGS.SAKURA_DONT_ATTACK = "I don't want to hurt my friends." 
STRINGS.ACTIONS.CASTSPELL.SAKURAFLASH = "flash" 
STRINGS.ACTIONS.CASTSPELL.SAKURASKILL = "use skill" end  
RECIPETABS = GLOBAL.RECIPETABS Recipe = GLOBAL.Recipe Ingredient = GLOBAL.Ingredient TECH = GLOBAL.TECH  
local critter_sakurapet_builder = Recipe("critter_sakurapet_builder", {Ingredient("fishsticks", 2), Ingredient("petals", 20)}, RECIPETABS.ORPHANAGE, TECH.ORPHANAGE_ONE, nil, nil, true, nil, "sakura") critter_sakurapet_builder.atlas = "images/inventoryimages/critter_sakurapet_builder.xml"   local oldspellstrfn = GLOBAL.ACTIONS.CASTSPELL.strfn   GLOBAL.ACTIONS.CASTSPELL.strfn = function(act)  if act.invobject:HasTag("sakurasword") and act.target == nil then  return "SAKURASKILL"  else  return oldspellstrfn(act)  end  end

local Bunnymanstaff = AddRecipe("Bunnymanstaff", {Ingredient("carrot", 3), Ingredient("livinglog", 2), Ingredient("manrabbit_tail", 6)}, RECIPETABS.MAGIC, TECH.MAGIC_THREE  nil, nil, nil, "sakura") 
Bunnymanstaff.atlas = "images/inventoryimages/bunnymanstaff.xml"

I tested it and so far the recipe shows, but the image of it is the lazy deserter for some reason.

I added 2 prefab files for the bunnyman entity and the staff entity

I have no idea how to make the staff summon the bunnypet but this is what i tried to do

Spoiler

local assets =
{
    Asset("ANIM", "anim/staffs.zip"),
    Asset("ANIM", "anim/swap_staffs.zip"),
}


local function SpawnBunnymanPet
    inst.components.leader:AddFollower(bunnymanpet)
    inst.components.leader:AddFollower(bunnymanpet)
    inst.components.leader:AddFollower(bunnymanpet)
    
    return inst
end

This is my attempt of the bunnyman entity but most of it was copy and pasted from the in game bunnyman

Spoiler

local assets =
{
    Asset("ANIM", "anim/manrabbit_basic.zip"),
    Asset("ANIM", "anim/manrabbit_actions.zip"),
    Asset("ANIM", "anim/manrabbit_attacks.zip"),
    Asset("ANIM", "anim/manrabbit_build.zip"),
    Asset("SOUND", "sound/bunnyman.fsb"),
}

local prefabs =
{
    "meat",
    "monstermeat",
    "manrabbit_tail",
    "carrot",
}

local regularloot = { "carrot", "carrot" }

local brain = require("brains/bunnymanpetbrain")

local function OnGetItemFromPlayer(inst, giver, item)

    --I wear hats
    if item.components.equippable ~= nil and item.components.equippable.equipslot == EQUIPSLOTS.HEAD then
        local current = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
        if current ~= nil then
            inst.components.inventory:DropItem(current)
        end
        inst.components.inventory:Equip(item)
        inst.AnimState:Show("hat")
    end
end

local function LootSetupFunction(lootdropper)
    local guy = lootdropper.inst.causeofdeath
        -- regular loot
        lootdropper:SetLoot(regularloot)
        lootdropper:AddRandomLoot("carrot", 1)
    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddDynamicShadow()
    inst.entity:AddLightWatcher()
    inst.entity:AddNetwork()

    inst.AnimState:SetBuild("manrabbit_build")

    MakeCharacterPhysics(inst, 50, .5)

    inst.DynamicShadow:SetSize(1.5, .75)

    inst:AddTag("cavedweller")
    inst:AddTag("character")
    inst:AddTag("pig")
    inst:AddTag("manrabbit")
    inst:AddTag("scarytoprey")

    inst.AnimState:SetBank("manrabbit")
    inst.AnimState:PlayAnimation("idle_loop", true)
    inst.AnimState:Hide("hat")

    inst.AnimState:SetClientsideBuildOverride("insane", "manrabbit_build")

    --trader (from trader component) added to pristine state for optimization
    inst:AddTag("trader")

    --Sneak these into pristine state for optimization
    inst:AddTag("_named")

    inst:AddComponent("talker")
    inst.components.talker.fontsize = 24
    inst.components.talker.font = TALKINGFONT
    inst.components.talker.offset = Vector3(0, -500, 0)
    inst.components.talker:MakeChatter()

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

    --Remove these tags so that they can be added properly when replicating components below
    inst:RemoveTag("_named")

    inst.components.talker.ontalk = ontalk

    inst:AddComponent("locomotor") -- locomotor must be constructed before the stategraph
    inst.components.locomotor.runspeed = TUNING.PIG_RUN_SPEED * 2.2 -- account for them being stopped for part of their anim
    inst.components.locomotor.walkspeed = TUNING.PIG_WALK_SPEED * 1.9 -- account for them being stopped for part of their anim

    inst:AddComponent("bloomer")

    ------------------------------------------
    inst:AddComponent("eater")
    inst.components.eater:SetDiet({ FOODTYPE.VEGGIE }, { FOODTYPE.VEGGIE })
    inst.components.eater:SetCanEatRaw()*

    ------------------------------------------
    inst:AddComponent("combat")
    inst.components.combat.hiteffectsymbol = "manrabbit_torso"
    inst.components.combat.panic_thresh = TUNING.BUNNYMAN_PANIC_THRESH

    inst.components.combat.GetBattleCryString = battlecry

    MakeMediumBurnableCharacter(inst, "manrabbit_torso")

    inst:AddComponent("named")
    inst.components.named.possiblenames = STRINGS.BUNNYMANNAMES
    inst.components.named:PickNewName()

    ------------------------------------------
    inst:AddComponent("follower")
    ------------------------------------------
    inst:AddComponent("health")
    inst.components.health:StartRegen(TUNING.BUNNYMAN_HEALTH_REGEN_AMOUNT, TUNING.BUNNYMAN_HEALTH_REGEN_PERIOD)

    ------------------------------------------

    inst:AddComponent("inventory")

    ------------------------------------------

    inst:AddComponent("lootdropper")
    inst.components.lootdropper:SetLootSetupFn(LootSetupFunction)
    LootSetupFunction(inst.components.lootdropper)

    ------------------------------------------

    inst:AddComponent("knownlocations")

    ------------------------------------------

    inst:AddComponent("trader")
    inst.components.trader:SetAcceptTest(ShouldAcceptItem)
    inst.components.trader.onaccept = OnGetItemFromPlayer
    inst.components.trader.onrefuse = OnRefuseItem
    inst.components.trader.deleteitemonaccept = false

    ------------------------------------------

    inst:AddComponent("sanityaura")
    inst.components.sanityaura.aurafn = CalcSanityAura

    ------------------------------------------

    inst:AddComponent("sleeper")

    ------------------------------------------
    MakeMediumFreezableCharacter(inst, "pig_torso")

    ------------------------------------------

    inst:AddComponent("inspectable")
    inst.components.inspectable.getstatus = GetStatus
    ------------------------------------------

    inst:ListenForEvent("attacked", OnAttacked)    
    inst:ListenForEvent("newcombattarget", OnNewTarget)

    inst.components.sleeper:SetResistance(2)
    inst.components.sleeper.sleeptestfn = NocturnalSleepTest
    inst.components.sleeper.waketestfn = NocturnalWakeTest

    inst.components.combat:SetDefaultDamage(TUNING.BUNNYMAN_DAMAGE)
    inst.components.combat:SetAttackPeriod(TUNING.BUNNYMAN_ATTACK_PERIOD)
    inst.components.combat:SetKeepTargetFunction(NormalKeepTargetFn)
    inst.components.combat:SetRetargetFunction(3, NormalRetargetFn)

    inst.components.locomotor.runspeed = 10
    inst.components.locomotor.walkspeed = 10

    inst.components.health:SetMaxHealth(250)

    MakeHauntablePanic(inst, 5, nil, 5)

    inst:SetBrain(brain)
    inst:SetStateGraph("SGbunnyman")

    return inst
end

return Prefab("bunnymanpet", fn, assets, prefabs)

I've change some stats and loot drops and attempted to remove the transformation from low sanity. Not sure if it is working.

I tried making the brain for the bunnyman but its practically non existent

Spoiler

require "behaviours/wander"
require "behaviours/follow"
require "behaviours/faceentity"
require "behaviours/chaseandattack"
require "behaviours/runaway"
require "behaviours/doaction"
--require "behaviours/choptree"
require "behaviours/findlight"
require "behaviours/panic"
require "behaviours/chattynode"
require "behaviours/leash"

local BunnymanpetBrain = Class(Brain, function(self, inst)
    Brain._ctor(self, inst)
end)


local function GetLeader(inst)
    return inst.components.follower.leader 
end

local BunnymanBrain = Class(Brain, function(self, inst)
    Brain._ctor(self, inst)
end)

return BunnymanpetBrain
 

So far no crashes

Edited by Rainbow Kitty
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...