Modding Help How can i make an npc interact with an object?

Discussion in 'Starbound Modding' started by Chofranc, Feb 20, 2017.

  1. Chofranc

    Chofranc Pangalactic Porcupine

    Hi, i want to made that an npc interact with an object like when you press E on an object, i don't know how to do that.
    Precisely i don't know very well how the influence value works.
     
  2. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    I remember seeing something like npc interactions, somewhere, perhaps it was at :
    /assets/_unpacked/stats/effects/npcreactions may help.

    Not sure, will keep looking.
     
  3. ImHereForTheMods

    ImHereForTheMods Cosmic Narwhal

    Ah yes, /assets/_unpacked/scripts/npcToyObject

    Referencing that may help.
     
  4. Kawa

    Kawa Tiy's Beard

    NPCs can't "E" an object the way a player can, and a player can't mess with an object the way an NPC can.

    That is, if an NPC were to find an arcadestarbound object, they may play with it, with their hands at the controls. If they approach a smallwallswitch object, they may play a little "flip it" animation. If a player presses "E" on a smallwallswitch, there is no "flip it" animation and the switch is actually flipped regardless, because players can activate objects outside of arms reach. Somehow.

    So the first part you wrote,
    is already quite a problem.

    Do you still want/need to learn how npcToys work?
     
  5. Chofranc

    Chofranc Pangalactic Porcupine

    So NPCs can't trigger the OnInteraction() function of an object? thats sad :'(.
     
  6. Kawa

    Kawa Tiy's Beard

    Pasting all this here for relevance:
    Code:
    <Chofranc> So NPCs can't trigger the OnInteraction() function of an object?
    <Kawa> No.
    <Kawa> Touchplates and proximity sensors work on NPCs because they themselves scan for nearby people.
    <Kawa> which includes PCs and NPCs alike.
    <Chofranc> but they can use doors like the pc
    <Kawa> NPCs don't "press E".
    <Kawa> Their scripts can and do toggle switches and such, so the pathfinder script for example opens doors.
    <Kawa> And Nuru throws a gate's switch.
    <Kawa> They're coded for that.
    <Kawa> NPCToys, like where an NPC can approach a DDR machine and dance on it, are a separate thing.
    <Kawa> You'll notice players can't dance.
    <Kawa> Or warm their hands.
    <Kawa> Or throw up.
    <Chofranc> so the npctoy only make them play animations only right?
    <Kawa> Basically!
    <Kawa> (those are called dances, btw)
    <Kawa> (it's a development leftover)
    <Kawa> PCs can only dance through things like vehicles.
    <Kawa> That's how they steer.
    <Chofranc> the thing is that i did a short range teleport that teleports you from ObjectA to B in the ship onInteraction function and i wanted that the npc could use it too
    <Kawa> Ahahaha
    <Kawa> I see.
    <Kawa> The outpost has random visitors spawned in by the 2-Stop Teleshop, and those visitors eventually self-destruct with a teleport animation.
    <Kawa> But tbh I doubt that'd be too much help.
    <Kawa> If only because those random visitors are themselves specially scripted to do so.
    <Kawa> Unless you mean -specific- NPCs of your own design instead of -any- NPC that would respond to toys... I'm afraid you can't do it.
    <Chofranc> at least my character could have an isolated room only for himself xD
    <Kawa> Hm.
     
  7. bk3k

    bk3k Oxygen Tank

    NPCs can however "sit" on objects that have that feature.
    "objectType" : "loungeable"
    tells them they can sit on it. And by "sit" that includes beds too. They will get the "sitStatusEffects" the object provides. Between "sitPosition", "sitOrientation", and "sitAngle" you could make them appear to be standing in front of it still while the game considers them to be "sitting."

    This might be more involved than you where intending but one could use LUA to learn that an NPC was the one using that object and react accordingly. Say you wanted to trigger something. Obviously that involves learning LUA. You could even have something happen only when a "Felin" NPC "sits" on it. It could be a fake button with a real wire output that opens a dungeon door for only a specific custom race(or specific set of them). A hylotl dungeon could have a "no florans" door that way.
     

Share This Page