Jump to content

Recommended Posts

Hello, I am currently stumped on my woodie mod with allowing him to drop items in the werebeaver form, so far I can make him pick up stuff and have the inventory open, there are two sections in the woodie.lua prefab to give the werebeaver actions.

1st section:

local function GetBeaverAction(inst, target)
    for i, v in ipairs(BEAVER_LMB_ACTIONS) do
        if target:HasTag(v.."_workable")  then
            return not target:HasTag("sign") and ACTIONS[v]
end			
			if TUNING.SWITCH_MB_PICK_DIG_BEAVER == 2 and target:HasTag("DIG_workable")  
				then return ACTIONS.DIG
				end
			if TUNING.BEAVER_PICKUP_RENEWABLE_RESOURCES == 1 and target:HasTag("_inventoryitem") and not target:HasTag("heavy")
				then return ACTIONS.PICKUP
				end
			if target:HasTag("pickable") and TUNING.BEAVER_HARVEST_RENEWABLE_RESOURCES == 1 and TUNING.SWITCH_MB_PICK_DIG_BEAVER == 1 then
               return ACTIONS.PICK
			   end
			if inst.replica.inventory:GetActiveItem() ~= nil then
               return ACTIONS.DROP
			   end
			   			if target.prefab == "cave_entrance_open"  or target.prefab == "cave_exit"  then
               return ACTIONS.MIGRATE
			or nil
        end
    end
	
    if target:HasTag("walkingplank") and target:HasTag("interactable") then
        return (inst:HasTag("on_walkable_plank") and ACTIONS.ABANDON_SHIP) or
                (target:HasTag("plank_extended") and ACTIONS.MOUNT_PLANK) or
                ACTIONS.EXTEND_PLANK
    end
end

I added several parts including looking for a active item, currently being hold by the player and it returns the drop action.

2nd section.

local function BeaverLeftClickPicker(inst, target)
local useitem = inst.replica.inventory:GetActiveItem()
    if target ~= nil and target ~= inst then
        if inst.replica.combat:CanTarget(target) then
            return (not target:HasTag("player") or inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_ATTACK))
                and inst.components.playeractionpicker:SortActionList({ ACTIONS.ATTACK }, target, nil) 
                or nil
        end

        for i, v in ipairs(BEAVER_LMB_ACTIONS) do
            if target:HasTag(v.."_workable") then
                return not target:HasTag("sign")
                    and inst.components.playeractionpicker:SortActionList({ ACTIONS[v] }, target, nil)
elseif TUNING.SWITCH_MB_PICK_DIG_BEAVER == 2 and target:HasTag("DIG_workable")
		then return inst.components.playeractionpicker:SortActionList({ACTIONS.DIG }, target, nil)
                    elseif TUNING.BEAVER_PICKUP_RENEWABLE_RESOURCES == 1 and target:HasTag("_inventoryitem") and not target:HasTag("heavy")
		then return inst.components.playeractionpicker:SortActionList({ACTIONS.PICKUP }, target, nil)
                    elseif TUNING.BEAVER_HARVEST_RENEWABLE_RESOURCES == 1 and TUNING.SWITCH_MB_PICK_DIG_BEAVER == 1 and target:HasTag("pickable")
		then return inst.components.playeractionpicker:SortActionList({ACTIONS.PICK }, target, nil)
elseif target.prefab == "cave_entrance_open"  or target.prefab == "cave_exit" 
then return  inst.components.playeractionpicker:SortActionList({ ACTIONS.MIGRATE}, target, nil)	
			elseif useitem ~= nil
			then return inst.components.playeractionpicker:SortActionList({ACTIONS.DROP }, nil, target)
					or nil
            end
        end

        if target:HasTag("walkingplank") and target:HasTag("interactable") and target:HasTag("plank_extended") then
            return inst.components.playeractionpicker:SortActionList({ ACTIONS.MOUNT_PLANK }, target, nil)
        end
    end
end

In the second function, that works like the other one by targeting but by using the playeractionpicker instead, I switched the nil near the end of the component argument to target because it uses the useitem variable which also looks for an active item instead. 

While stuck did some digging with the key "playerfloater" since the difference between other actions is that this one is "INLIMBO" hovering over the player's inventory to drop/place on the ground.

Lastly I would like to add another feature such as a giving objects to other players while in the werebeaver form but I imagine I would have to look into the trader component or maybe Catcoons giving things to the player; Still having issues with items currently being held by the mouse button of the player and assigning actions. 

Any help would be appreciated. 

Link to comment
https://forums.kleientertainment.com/forums/topic/167641-drop-items-as-werebeaver/
Share on other sites

Holi, estoy seguro que hablas español así que no tiene caso que yo también escriba en inglés.

Veo que tienes acceso a la instancia de Inventory y a la instancia del objeto que quieres tirar ¿ya intentaste solo usar esto?:

Inventory:DropItem(item, wholestack, randomdir, pos, keepoverstacked)

Por lo que veo en el código del juego, el único parámetro indispensable es "item" (los demás no tengo ni idea de lo que pudiesen ser), así que podrías intentarlo y ver qué pasa.

Ok, lo intentare , tambien adjunto mi archivo zip del mod. Espero también que hayas entendido todo lo anterior, el juego pone restricciones para lo que puede hacer woodie en modo castor y luego le agrega libertades de acciones. 

woodie mod edit.zip

Mod on Steam workshop:

https://steamcommunity.com/sharedfiles/filedetails/?id=1532502411

Edited by ElMilojita
link to steam workshop mod
if inst.components.inventory:GetActiveItem() ~= nil and (target == inst)
then return inst.components.playeractionpicker:SortActionList({ ACTIONS.DROP }, inst, inst.components.inventory:GetActiveItem())
end

Easy, quick fix, because I couldn't actually target the ground I imagine because of the exclude tags, made it so selecting woodie would prompt the drop option on the item hovering over. 

										(   target:HasTag("trader") and 
										inst.components.inventory:GetActiveItem() ~= nil and 
                    inst.components.playeractionpicker:SortActionList({ ACTIONS.GIVE }, target, inst.components.inventory:GetActiveItem())
				)	
----if target:HasTag("trader") and inst.components.inventory:GetActiveItem() ~= nil 
---then return inst.components.playeractionpicker:SortActionList({ ACTIONS.GIVE }, target, inst.components.inventory:GetActiveItem())
-----end	
				or

también fácil, en vez de usar inventario, sigue utilizando el playeractionpicker para dar cosas y cómo " act.invobject " es la variable encontrado del argumento/función del componente 

inst.components.inventory:GetActiveItem()

lo que esta entre los parentesis es el objeto invisible sostenido por el jugador. 

Edited by ElMilojita

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
×
  • Create New...