I want to make a berry item when if the player eats the berry, put the user to sleep. But the same berry can be thrown at an enemy, causing the foe to fall asleep. Can this be done and if so how?
Thanks for reading.
Set the item's scope to enemy & ally.
Oops, sorry. I forgot that's just in MZ.
Here's a non-script solution, that assumes a berry would never be used on the party in battle.
Basically you create A "Berry" item and a "Throw: Berry" item in the database. Preferably right next to each other
Create a Battle event that'll run at the start of every battle
When Turn:0
If party has Berry
set Berry amount to variable
remove Berry by variable amount
add "throw:berry" by variable amount
turn switch "berry exchange" on.
Then create a common event, Trigger: Parallel Process, Switch: Berry Exchange
Same thing but reversed
if party has Throw:Berry
set Throw:Berry to variable
remove Throw:Berry by variable amount
add Berry by variable amount
turn switch "berry exchange" off.
So in-battle the berries get converted to throw:berries; outside of battle, any throw:berries get converted to berries automatically by the common event. The items should appear in the same place in the inventory so long as they're right next to each other in the database.
You can rename "throw:berry" to just "berry"; if you want. But Idk, I think if you're going to set it up like this you might as well communicate to the player that an item can be thrown in battle.
That's a great idea. It gives me an idea of my own.
Maybe a Common Event where the player is given an option to "eat berry" or "throw at enemy"?
And then I can make it where the berry item can only be used in battles only. But I still like to be able to eat the berry outside of battle and cause sleep. But that's okay if not.
Thanks for the cool suggestions everyone. ^_^
I've worked with this a little more and made a common event for the item. Looks good so far. But I had to set it to where the item can only be used in battle. The common event shows the choices "Eat" or "Throw at the enemy"
But I would like to be able to put a conditional script to check if the player is in battle or not. And if yes, the choices show. But if now, and the player is on the map, then no choices and they are just put asleep. Edit: And if a little HP was recovered.
Is this possible?
Edit: I've run into a problem with the Common Event. I can't have the enemy be selected so I chose at random. I'm unsure as to what to do.
Edit 2: I'll probably end up scrapping the idea. 😛