require \
require \
Action = Class(function(self, priority, instant, rmb, distance) self.priority = priority or 0
self.fn = function() return false end self.strfn = nil self.testfn = nil
self.instant = instant or false self.rmb = rmb or nil
self.distance = distance or nil end)
ACTIONS= { REPAIR = Action(), READ = Action(), DROP = Action(-1), TRAVEL = Action(), CHOP = Action(),
ATTACK = Action(2, true),
FORCEATTACK = Action(2, true), EAT = Action(), PICK = Action(), PICKUP = Action(1), MINE = Action(),
DIG = Action(nil, nil, true), GIVE = Action(), COOK = Action(), DRY = Action(),
ADDFUEL = Action(), LIGHT = Action(-4),
EXTINGUISH = Action(0), LOOKAT = Action(-3, true), TALKTO = Action(3, true), WALKTO = Action(-4), BAIT = Action(),
CHECKTRAP = Action(2), BUILD = Action(), PLANT = Action(), HARVEST = Action(), GOHOME = Action(), SLEEPIN = Action(),
EQUIP = Action(0,true), UNEQUIP = Action(-2,true), --OPEN_SHOP = Action(), SHAVE = Action(), STORE = Action(),
RUMMAGE = Action(-1), DEPLOY = Action(), PLAY = Action(), NET = Action(3),
CATCH = Action(3, true), FISH = Action(),
REEL = Action(0, true), POLLINATE = Action(), FERTILIZE = Action(), LAYEGG = Action(), HAMMER = Action(3), TERRAFORM = Action(), JUMPIN = Action(), RESETMINE = Action(3), ACTIVATE = Action(), MURDER = Action(0), HEAL = Action(),
INVESTIGATE = Action(), UNLOCK = Action(), TEACH = Action(), TURNON = Action(2), TURNOFF = Action(2), SEW = Action(), STEAL = Action(),
USEITEM = Action(1, true), TAKEITEM = Action(),
MAKEBALLOON = Action(),
CASTSPELL = Action(0, false, true, 20), BLINK = Action(10, false, true, 36), COMBINESTACK = Action(),
TOGGLE_DEPLOY_MODE = Action(1), }
for k,v in pairs(ACTIONS) do
v.str = STRINGS.ACTIONS[k] or \ v.id = k end
----set up the action functions!
ACTIONS.EAT.fn = function(act)
local obj = act.target or act.invobject
if act.doer.components.eater and obj and obj.components.edible then return act.doer.components.eater:Eat(obj) end end
ACTIONS.STEAL.fn = function(act) local obj = act.target local attack = false
if act.attack then attack = act.attack end
if (obj.components.inventoryitem and obj.components.inventoryitem:IsHeld()) then
return act.doer.components.thief:StealItem(obj.components.inventoryitem.owner, obj, attack) end end
ACTIONS.MAKEBALLOON.fn = function(act)
if act.doer and act.invobject and act.invobject.components.balloonmaker then if act.doer.components.sanity then
act.doer.components.sanity:DoDelta(-TUNING.SANITY_TINY) end
local x,y,z = act.doer.Transform:GetWorldPosition()
local angle = TheCamera.headingtarget + math.random()*10*DEGREES-5*DEGREES x = x + .5*math.cos(angle) z = z + .5*math.sin(angle)
act.invobject.components.balloonmaker:MakeBalloon(x,y,z) end
return true end
ACTIONS.EQUIP.fn = function(act)
if act.doer.components.inventory then
return act.doer.components.inventory:Equip(act.invobject) end end
ACTIONS.UNEQUIP.fn = function(act) if act.doer.components.inventory and act.invobject and act.invobject.components.inventoryitem.cangoincontainer then act.doer.components.inventory:GiveItem(act.invobject)
--return act.doer.components.inventory:Unequip(act.invobject) return true elseif act.doer.components.inventory and act.invobject and not act.invobject.components.inventoryitem.cangoincontainer then
act.doer.components.inventory:DropItem(act.invobject, true, true) return true end end
ACTIONS.PICKUP.fn = function(act)
if act.doer.components.inventory and act.target and act.target.components.inventoryitem and not act.target:IsInLimbo() then act.doer:PushEvent(\
--special case for trying to carry two backpacks if not act.target.components.inventoryitem.cangoincontainer and act.target.components.equippable and act.doer.components.inventory:GetEquippedItem(act.target.components.equippable.equipslot) then
local item = act.doer.components.inventory:GetEquippedItem(act.target.components.equippable.equipslot) if item.components.inventoryitem and item.components.inventoryitem.cangoincontainer then
--act.doer.components.inventory:SelectActiveItemFromEquipSlot(act.target.components.equippable.equipslot)
act.doer.components.inventory:GiveItem(act.doer.components.inventory:Unequip(act.target.components.equippable.equipslot)) else
act.doer.components.inventory:DropItem(act.doer.components.inventory:GetEquippedItem(act.target.components.equippable.equipslot)) end
act.doer.components.inventory:Equip(act.target) return true end
if act.doer:HasTag(\and act.target.components.equippable and not act.doer.components.inventory:GetEquippedItem(act.target.components.equippable.equipslot) then
act.doer.components.inventory:Equip(act.target) else
act.doer.components.inventory:GiveItem(act.target,
Vector3(TheSim:GetScreenPos(act.target.Transform:GetWorldPosition()))) end
return true end end
ACTIONS.REPAIR.fn = function(act) if act.target and act.target.components.repairable and act.invobject act.invobject.components.repairer then return act.target.components.repairable:Repair(act.doer, act.invobject) end end
ACTIONS.SEW.fn = function(act) if act.target and act.target.components.fueled and act.invobject act.invobject.components.sewing then return act.invobject.components.sewing:DoSewing(act.target, act.doer) end end
ACTIONS.RUMMAGE.fn = function(act) local targ = act.target or act.invobject
if act.doer.HUD and targ.components.container then if targ.components.container:IsOpen() then targ.components.container:Close(act.doer) else targ.components.container:Open(act.doer) end
return true end end
ACTIONS.RUMMAGE.strfn = function(act) local targ = act.target or act.invobject
if targ and targ.components.container and targ.components.container:IsOpen() then return \ end end
nil,
and
and