The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: kenth21v on August 19, 2011, 12:00:28 PM

Title: [XP] How to change an ITEM's common event. any time in the game? [solved]
Post by: kenth21v on August 19, 2011, 12:00:28 PM
Originally my plan is to create another menu for QUEST. but it is lot of scipting and I can't find something like that.
so i used an ITEM name QUEST BALL.
What I want is when the player  talk to an NPC, he'll get a quest from it. And if the player want to see his quest, he can always look at the QUEST BALL to see what is the goal of the quest. here is an example:

NPC: Get me 3 pcs of feather from the forest.
so that's the quest, and if the player want to see again what he should do he can use QUEST BALL from his menu and this will display:
"Get 3 PCS of feather from the forest"

and when the quest is finished and the player gets another quest. the common event of the QUEST BALL will be change for example:
"Quest2: Kill 10 orcs"

Like that guys. I'ts pretty simple but I'm a noobie. so please help me.  :lol:
Thanks in advance!
Title: Re: [XP] How to change an ITEM's common event. any time in the game?
Post by: dricc on August 19, 2011, 02:46:07 PM
Forget ...

The problem is that items are not saved in the savefile . So , even if you can find a way to change the common event programatically , the next time you save/load the game , the modification will be voided .

use a variable and a lot of "if" in your common event instead .
Title: Re: [XP] How to change an ITEM's common event. any time in the game?
Post by: kenth21v on August 20, 2011, 01:37:52 PM
Quote from: dricc on August 19, 2011, 02:46:07 PM
Forget ...

The problem is that items are not saved in the savefile . So , even if you can find a way to change the common event programatically , the next time you save/load the game , the modification will be voided .

use a variable and a lot of "if" in your common event instead .
i don't really get what you said, "items are not saved in the savefile". then how can the items in the game will be collected? well, don't need to asnwer that. your idea is cool. I'll just gonna use variable for the common event and quest.
thanks mate !  :)
Title: Re: [XP] How to change an ITEM's common event. any time in the game? [solved]
Post by: modern algebra on August 20, 2011, 02:07:33 PM
What he means is that they aren't saved as individual instances, but instead how many you own of an item is simply saved as a number in a hash. However, the stats of all those items are the same since it doesn't save each item's individual data and instead just loads it from the data file everytime you start the game. Therefore you can't change the common event ID of the item and expect it to be saved and carried over to the next time you load the game.

That said, it wouldn't actually be hard to do this with a script since you don't need them to be individualized. All you'd have to do is make a Table in Game_System (or some other class that's saved) with each value being the common_event_id of the corresponding item id. Then you would overwrite the common_event_id method in RPG::UsableItem and just have it return the value from that table instead.

However, the variable and conditional branches dricc recommended is the far superior solution.
Title: Re: [XP] How to change an ITEM's common event. any time in the game? [solved]
Post by: pacdiggity on August 21, 2011, 11:05:16 AM
You could make a method in Game_System that changes the common eventdef change_item_ce(type, id, common_event)
  $data_skills[id].common_event = common_event if type == :skill
  $data_items[id].common_event = common_event if type == :item
end
but I'm not in the state to test stuff right now. I don't even have VX or XP open. I really don't think that would work anyway.
But if it's solved, then it doesn't matter. Using variables is a good idea.
Title: Re: [XP] How to change an ITEM's common event. any time in the game? [solved]
Post by: modern algebra on August 21, 2011, 12:05:41 PM
It wouldn't work for the reason dricc identified.
Title: Re: [XP] How to change an ITEM's common event. any time in the game? [solved]
Post by: pacdiggity on August 21, 2011, 12:17:40 PM
:awareofthis: