Jump to content

Help blacklist an action?


Recommended Posts

I am making a captain character and I want this character to refuse to abandon ship (by refusing to walk the plank).

Considering that Abandoning ship is an Action, is there away to blacklist a character from performing specific actions?

Any help is appreciated.

Link to comment
Share on other sites

my implement,

local actions = {"MINE", "CHOP", "HAMMER", "DIG", "TERRAFORM"}
local function BanAction_Client(inst, b)
  local oldval = inst._actionbanned
  if oldval ~= b then
    inst._actionbanned = b
    for i, v in ipairs(actions) do
      local a = ACTIONS[v]
      if a then
        if b then
          a._oldex = a.ghost_exclusive
          a.ghost_exclusive = true
        else
          a.ghost_exclusive = a._oldex
          a._oldex = nil
        end
      end
    end
  end
end
if not inst:HasTag("playerghost") then
      BanAction_Client(inst, true)
    else
      BanAction_Client(inst, false)
    end
local function onperform(inst, data)
  local a = data and data.action
  local act = a and a.action
  act = act and act.id
  if act and table.contains(actions, act) then
    if inst:IsDrained() then
      a.Do = function()
        a:Fail()
        return false, "drained"
      end
    end
  end
end
local function BanAction_Server(inst) inst:ListenForEvent("performaction", onperform) end
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...