Jump to content

Recommended Posts

I'm trying to get these butterflies to attack but they only go to the target and do no damage

also as of right now you've gotta manually set them as followers, like with the too many items mod

littleshadowbrain.lualittleshadow.lua

Edited by Player_056

This is a shot in the dark, but did you already add the attack state to the stategraph? It could be that this is preventing them from really attacking.

State{
        name = "attack",
        tags = {"attack", "busy"},

        onenter = function(inst, target)
            inst.Physics:Stop()
            inst.components.combat:StartAttack()
            inst.AnimState:PlayAnimation("atk")
            inst.sg.statemem.target = target
        end,

        timeline=
        {
            TimeEvent(10*FRAMES, function(inst) inst.SoundEmitter:PlaySound(SoundPath(inst, "Attack")) end),
            TimeEvent(10*FRAMES, function(inst) inst.SoundEmitter:PlaySound(SoundPath(inst, "attack_grunt")) end),
            TimeEvent(25*FRAMES, function(inst) inst.components.combat:DoAttack(inst.sg.statemem.target) end),
        },

        events=
        {
            EventHandler("animover", function(inst) inst.sg:GoToState("idle") end),
        },
    },

This is  from SGspider, as you can see the DoAttack function is called in the timeline.

  • Like 1

i haven't done anything with stategraphs yet so that might be my problem exactly, i'll try that

YES MUAHAHAHAHA

Thanks!

Spoiler

--added

    EventHandler("doattack", function(inst)
        if not (inst.sg:HasStateTag("busy") or inst.components.health:IsDead()) then
            inst.sg:GoToState("attack")
        end
    end),

--and

    State{
        name = "attack",
        tags = { "attack" },

        onenter = function(inst, cb)
            inst.Physics:Stop()
            inst.components.combat:StartAttack()
            inst.AnimState:PlayAnimation("flight_cycle")
        end,

        timeline =
        {
            TimeEvent(15 * FRAMES, function(inst)
                inst.components.combat:DoAttack()
            end),
        },

        events =
        {
            EventHandler("animover", function(inst)
                inst.sg:GoToState("idle")
            end),
        },
    },

 

ok looks like this might be a good reference so here's the fixed up files

littleshadowbrain.lua

littleshadow.lua

SGlittleshadow.lua

(should be all) the modmain stuff (except images)

Spoiler

PrefabFiles = {"littleshadow"}

local require = GLOBAL.require
local STRINGS = GLOBAL.STRINGS
local RECIPETABS = GLOBAL.RECIPETABS
local CUSTOM_RECIPETABS = GLOBAL.CUSTOM_RECIPETABS
local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient

AddRecipe("littleshadow",
{Ingredient("nightmarefuel", 1), Ingredient("butterflywings", 1), Ingredient(GLOBAL.CHARACTER_INGREDIENT.SANITY, 5)},
RECIPETABS.MAGIC, 
TECH.NONE).sortkey = -1

GLOBAL.STRINGS.RECIPE_DESC.LITTLESHADOW = "Swarm your foes in darkness."
GLOBAL.STRINGS.NAMES.LITTLESHADOW = "Shadowfly"

 

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