Give buff to dino rider

I am trying to figure out how to give a buff to a dino rider. Basically i want it to only work on the player when he’s riding a specific dino.

ex.

Player mounts dino -> buff applied to player.
Player dismounts dino - > buff removed.

I honestly have no idea on how to pull this off.

Does anyone have an idea of how to pull this off?

Can you add the buff to the saddle?

If you want your mod to remain stackable, you’ll need to apply the buff to the rider directly from an equippable item, either a saddle or something else (eg: costume) that you equip to the dino.

[HR][/HR]

Your equippable item (eg: saddle, costume) blueprint:

First you’ll need to get a reference to the dino you can do this with the following:



Event Blueprint Equipped -> Get Owner Inventory(self) -> Get Owner() -> Set DinoChar


There isn’t an event for when a dino has a rider so you’ll need to check on tick to see if it does. Using the Event Equipped Blueprint Tick we can do this:



Event Equipped Blueprint Tick -> HasRider(DinoChar) -> Branch(True) -> GetRider(DinoChar) -> Set DinoRider -> HasBuff(DinoRider) -> Branch(False) -> StaticAddBuff(BuffClass, DinoRider, self) -> Set BuffActor -> BuffActor -> Use BPDeactivated(True)


The buff will now be applied once to the rider. The result of Has Buff on subsequent event ticks will be true, and we will not apply another buff.

Now for when the rider dismounts we need to expand the Event Equipped Blueprint Tick code above to handle when HasRider returns false and remove the buff from the DinoRider (the last known player to ride the dino)



Event Equipped Blueprint Tick -> HasRider(DinoChar) -> Branch(False) -> IsValid(DinoRider) -> Branch(True) -> HasBuff(DinoRider) -> Branch(True) -> BPDeactivate(BuffActor) -> Set DinoRider(None)


This will remove the buff from the dino rider once. Because we set the reference to DinoRider to None in the last call, subsequent calls to IsValid(DinoRider) will return false.

Finally lets clean up the references we set in our blueprint when the saddle is unequipped (this is good practice and helps the garbage collector to free up memory):



Event Blueprint Unequipped -> Set DinoChar(None) -> Set DinoRider(None) -> Set BuffActor(None)


[HR][/HR]

Finally you will want to implement what happens inside the buff’s Event BPDeactivated, if you only want to destroy the buff when BPDeactivate is called then the following will suffice:

Your Buff blueprint:



Event BPDeactivated -> DestroyActor(self)


[HR][/HR]

Hopefully this explanation helps. Sometimes you just have to look at the problem differently.

I was able to pull it off; For anyone curious or searches this thread somewhere down the line; here is the code.

I simply added “RiderBuff” as a variable so i could set it to whatever i wanted within the defaults tab.

Ah I forgot that BPNotify was added in later versions of the dev kit, obviously a much simpler way of doing it than what I suggested (which I guess is the old school method now :P)