Modding Help Trigger NPC behavior through status effect

Discussion in 'Starbound Modding' started by captainrumbarrels, Apr 29, 2018.

  1. captainrumbarrels

    captainrumbarrels Phantasmal Quasar

    Pretty self explanatory title.

    1. I have a ranged weapon, a clone of the water pistol, its associated projectiles and the wet status effect.

    2. This weapon applies the status effect - I use color filters or a duplicate of the glow effect as a visual proxy that tells me the effect is applied.

    3. When the effect via the weapon is applied I want the NPC to perform the "panic" dance and the "oooh" emote.

    The lua code is simple.
    npc.emote("oooh")
    npc.dance("panic")

    Problem:

    I discovered the NPC behaviors which reference the npc.lua scripts. I assume the possibility of creating an if statement that checks if my status effect is applied. if it is, then the npcs behave accordingly. For some reason beyond me it isn't working. Any ideas how to make it work?
     
  2. Zephyrhawk

    Zephyrhawk Void-Bound Voyager

    In /Starbound/doc/lua/npc.md it says

    Code:
    The `npc` table is for functions relating directly to the current npc. It is available only in NPC scripts.
    Sounds like you'd have to adjust NPC scripts, there might be a way for you to have your script talk to an npc script. Saw something about that briefly around here but not sure if it would fit this case, worth a look-see!

    edit: Think I might have misinterpreted at first, you've been putting the if statement into the npc.lua?
     
    Last edited: Apr 29, 2018
  3. captainrumbarrels

    captainrumbarrels Phantasmal Quasar

    Sorry, I shouldn't have been ambiguous. I haven't touched the npc.lua at all. so far what I'm trying to accomplish is through the weapon status effects which can be applied ver easily by setting the projectile:

    "damageTeam" : { "type" : "indiscriminate" },

    so I know the projectile hits and applies the status effect. I was saying if I were to incorporate it into a function within the npc.lua it would look something like (but not exactly):

    function npcreacttostatus()
    while status.stat("wet2") do
    npc.emote("oooh")
    npc.dance("panic")
    end
    end

    so far I'm just adding the functions to the status effect script, not the npc.lua. Hope this makes more sense.

    EDIT: If I can make my scripts talk, even if its by putting in say the "require/script" line then that would be great. The reason I would like to steer away from editing the npc scripts directly is for compatability.
     
  4. Zephyrhawk

    Zephyrhawk Void-Bound Voyager

    Maybe you could create a custom npcstatusreacttostatus.lua script for NPC's, and patch in the "script" : ["npcreacttostatus.lua"] into the .npctype JSON.

    Checkout vaultkeytrader.npctype and vaultkeytrader.lua

    Although not sure what "only available in NPC scripts" means for us, and if simply linking a lua script to a .npctype file will allow us to use those functions. Looking through the files right now to see the vanilla usage for npc.emote(), I'll update when I find something =]

    Edit: Looks like the function npc.emote() is used in the reaction.lua, which is linked in .behavior files. I'm going to guess that the npc's actions are hardcoded to follow the behavior files. What you're looking to do could have something to do with the reaction/behavior files or it could just be as simple as following the vaultkeytrader's vanilla files.
     
    Last edited: Apr 29, 2018
    captainrumbarrels likes this.
  5. captainrumbarrels

    captainrumbarrels Phantasmal Quasar

    well I did find in starboundassets/npc/base.npctype

    This looks like the template file for the reactions. If I have to start modding heaps of vanilla files the other option would be to investigate what will trigger the desired reaction and create an "aura" effect on myself that will trigger said reaction (if possible) when I'm in a certain range.

    To put things in context:

    [​IMG]

    I'm making a spray bottle that will make the npc scream and run away when the status effect is applied.
    [​IMG]
     
  6. captainrumbarrels

    captainrumbarrels Phantasmal Quasar

    Did a bit of reading up and looked at the vaultkeytrader.npctype

    Seems like they call on multiple scripts. so it could be as easy as patching the file and adding my script. if they can call on multiple scripts then it will be worth a shot making a custom script and then adding it to the base.npctype
     
    Zephyrhawk likes this.
  7. Zephyrhawk

    Zephyrhawk Void-Bound Voyager

    Seems like it should work, vaultkeytrader.lua uses the function npc.setOfferedQuests(), so npc.emote() should be fair game.
    Cheers! Sounds like an interesting project, good luck.
     
    captainrumbarrels likes this.
  8. pjaj

    pjaj Scruffy Nerf-Herder

    Did you have any luck with triggering a dance via status effect? Cause I'm in a similar situation... So far, google hasn't really helped...
     
  9. captainrumbarrels

    captainrumbarrels Phantasmal Quasar

    Unfortunately no :/
    It might only be possible to trigger reactions by editing the npc behaviour files themselves which is what I was trying to avoid. and I think I recall it would be meddling with the lua files which is a massive massive hassle.

    If I figure out anything I'll be sure to post the solution
     

Share This Page