If i use 5 consumable items, i want an event to appear! How would i create a common event for that? For example if a party member consumes 3 rotten food items, i want event to be triggered, like a sick status! Does anyone know how i could create the script for this?
Event triggered by item usage
RPG Maker VXAce SupportI wouldn't use a script, it doesn't need it. Have the item call a common event which has a variable in it to track how many times it's been called. Then when variable equals 3 (or whatever number you want) it inflicts a state.
Do you mind giving an example on how to create the process? Sorry i am fairly new to this!
Create a new common event. Leave the trigger to None. In the event commands, add a Control Variables. Create a new variable, choose Add for the operation, and 1 for the constant value to add.
Then add a Conditional Branch that says if the variable you just created is equal to 3. Inside the conditional branch, add the state you want to add.
On your Item, add a new Effect. On the Other tab, choose Common event and select the common event you just created.
Now each time you consume that item, it will add 1 to the variable. After you consume 3 of them, the state will be added.
If you want the count to reset, so consuming 3 more of the item will add the state again, go back into the commands inside the conditional branch, and add another Control Variables. Select the same variable, and this time use the Set operation, and make the value 0.
Then add a Conditional Branch that says if the variable you just created is equal to 3. Inside the conditional branch, add the state you want to add.
On your Item, add a new Effect. On the Other tab, choose Common event and select the common event you just created.
Now each time you consume that item, it will add 1 to the variable. After you consume 3 of them, the state will be added.
If you want the count to reset, so consuming 3 more of the item will add the state again, go back into the commands inside the conditional branch, and add another Control Variables. Select the same variable, and this time use the Set operation, and make the value 0.
What if i wanted to add a waiting period between each item, like let's say the party member consumed 1 rotten food and then 5 minutes later text pops up saying something like "my stomach is feeling upset"! Also during the waiting time, i need my character to be able to move! Could i just change it to a parallel process?
Not exactly.
You need a parallel process for time controls (unless you want to use a single timer only), but not on the common event for the item.
You will need a second common event, set to parallel process and controlled by a switch.
On the item event, instead of applying the state it will control the switch, activating the parallel event.
Then on that event, you place a wait command at the beginning, apply the state after the wait and then control switch to switch the parallel event off again (otherwise it would loop and apply the state again after the second time waiting.
Oh i see now, thank you all so much! Your help is greatly appreciated! 🙂
Original thread: https://forums.rpgmakerweb.com/threads/event-triggered-by-item-usage.17278/