Jump to content

Throwing Giant Vegetables


Recommended Posts

I'm trying to make giant vegetables throwable, and I copied several functions from the waterbaloon prefab to test it out, however, when I equip one, the "toss" option doesn't appear. I think it has to do with the giant vege being a heavy item, but I checked the component actions for complexprojectiles and it seems that it shouldn't matter and that all the checks should go through... Does anyone have any clue why?

AddPrefabPostInitAny(function(inst)
	if not inst:HasTag"oversized_veggie" or not inst:HasTag"waxable" then return end 
    inst:AddComponent"reticule"
    inst.components.reticule.targetfn = ReticuleTargetFn
    inst.components.reticule.ease = true
    
    if not GLOBAL.TheWorld.ismastersim then return end

	inst:AddComponent"complexprojectile"
    inst.components.complexprojectile:SetHorizontalSpeed(15)
    inst.components.complexprojectile:SetGravity(-35)
    inst.components.complexprojectile:SetLaunchOffset(GLOBAL.Vector3(.25, 1, 0))
--    inst.components.complexprojectile:SetOnLaunch(onthrown)
    inst.components.complexprojectile:SetOnHit(OnHitWater)
end)

 

Link to comment
Share on other sites

@TheSkylarr is correct, EQUIPPED component actions are only called from the hand slot.

Spoiler

function PlayerActionPicker:GetLeftClickActions(position, target)
  ----
  local equipitem = self.inst.replica.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
  ----
	elseif equipitem ~= nil and equipitem:IsValid() then
		actions = self:GetEquippedItemActions(target, equipitem)
	end

 

As you can see, it checks for the equipped item in the handslot. You can either set the equipslot of the veggies to the handslot or you hook the PlayerActionPicker:GetLeftClickActions function and add the case of an equipped veggy.

  • Like 2
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...