Modding Help W.I.P R.P.G REVAMP(HELP!)

Discussion in 'Starbound Modding' started by CTFJERK, Aug 24, 2017.

  1. CTFJERK

    CTFJERK Intergalactic Tourist

    Hello!
    So I'm new to modding Starbound.
    The ultimatum of the mod is to make crew NPC utilization more of an RPG mechanic.
    This will involve changing the default crew weapons, adding more "abilities", adding custom commands and behaviors. Reminiscent to games like StarOcean except 2D. Already got a little sheet of the design planed out.

    So to start things out, I attempted to make crew NPC's display a dialog when you speak to them.
    After a vast hierarchy of failure, I finally got a bloody result that didn't inadvertently kill off an entire village.
    by just adding the following script snippet into the npc/crew/crewmember.npctype file:

    "crew" : {
    "recruitable" : true,

    "recruitInteractAction" : {
    "messageType" : "recruits.offerRecruit",
    "messageArgs" : []
    },
    "interactAction" : "ShowPopup",
    "interactData" : {
    "config" : "/interface/windowconfig/Popup.config",
    "message" : "*%#@ you"
    },

    ...
    (i'd show the output, but picture won't upload)

    --THE PROBLEM--
    Yea, i got what i wanted buuut, Now the npc only does that and does not follow me like it means it or something lol.
    All i did was add something, but it seems to have removed the "following" functionality to do it.
    This rings a lot of false-positive gongs with me. Can anyone explain why/how this happens and how to fix it? The only file in the mod is the modified crewmember.npctype file in it respective directory.
    I think it would go a long way in my understanding of the concepts.
    -Many thanks in advance.
     
    Last edited: Aug 24, 2017
  2. projectmayhem

    projectmayhem Spaceman Spiff

    I'm only guessing, but maybe it has something to do with

    Code:
     "scriptConfig" : {
        "behavior" : "crewmember",
        "behaviorConfig" : {
          "emptyHands" : false,
    
          // Wander behavior config
          "wanderTime" : 1,
          "idleTime" : 10,
          "outerHomeRange" : 20,
          "innerHomeRange" : 15,
    
          "hostileDamageTeam" : {"type" : "friendly", "team" : 1}
        },
    Maybe the behavior tells it to follow/unfollow on interact, and you are adding a new interact that is conflicting with it?

    EDIT -- check out the recruitable.lua I think my guess is right...
    local interactAction = config.getParameter("crew.interactAction")
     
    Last edited: Aug 24, 2017
  3. CTFJERK

    CTFJERK Intergalactic Tourist

    Thank you so much for answering.
    based on the code below that i found from searching the statement you gave me, i found out that an if-statement checks if there is an interactAction/interactData paremeter incase that the
    npc is a tailor which do not follow in the first place.

    Code:
    function recruitable.interact(sourceEntityId)
      if recruitable.isRecruitable() then
        return recruitable.generateRecruitInteractAction()
      end
    
      local sourceUniqueId = world.entityUniqueId(sourceEntityId)
      if sourceUniqueId and sourceUniqueId == recruitable.ownerUuid() then
    
        local interactAction = config.getParameter("crew.interactAction")
        if interactAction then
          -- Tailor, etc. offer to update your uniform instead of following you
          -- around.
          local data = config.getParameter("crew.interactData", {})
          data.messageArgs = data.messageArgs or {}
          table.insert(data.messageArgs, recruitable.recruitUuid())
          table.insert(data.messageArgs, entity.id())
          return { interactAction, data }
        else
    
       
          -- No role-specific behavior, so just follow/unfollow the player
          if storage.behaviorFollowing then
            if world.getProperty("ephemeral") then
              recruitable.confirmUnfollowBehavior()
              return { "None", {} }
            else
              return recruitable.generateUnfollowInteractAction()      //I'll replace this with a function to generate the popup
            end
          else
            return recruitable.generateFollowInteractAction()
          end
        end
      end
    end
    alot is much clearer now.

    what ill do is keep the interaction to follow default.
    then I'll set code to create the interactActions for the popup dynamically(instead of in the json script) or just use another parameter name and reference those, when the player interacts with an already following npc.
    Then ill set the "dismiss" button click to release a "recruits.requestUnfollow" message.

    atleast thats the plan.
    Thank you so much for pointing that out.

    I'll post again if I have any more glaring questions.
     

Share This Page