|
Post by mercenaryx on Jun 3, 2008 23:55:30 GMT -5
hey guys, im bringing back this thread only because at the time that this thread was made, the only reason for me needing to know how to make a working treasure chest was because when the game first starts, your put in a room and your only choice is to open a treasure box which triggers a cutscene, and exits the area. at the time, there was no real item inside the treasure chest and the player will never need to visit this area again, so there was no need to make another actual treasure chest until now, and now i'm running into problems.
since this threads solution, i've come a long way and i've learned quite a bit, and im not quite as stupid about rpgm2 as i used to be, but i'm still using a model for my chests similar to the first response in raithwalls model. so, the problem NOW is that the chests exist in areas that the player will be able to revisit. Once opened, they should always be opened every time they enter the area (before the area becomes visible when they zone in.) and the item inside should no longer be attainable, and the animation for the chest should be no longer workable.
i've currently got the problem solved, but i was just wondering what the most efficient solution you guys would use would be?
my current solution was to add 4 more lines (per chest) to my [Dungeon room 1: custom entrance] script including:
-----------------------------------------------------------------------
(script name: custom entrance for dungeon room)
if [flag for chest] : ON { event target -> specific chest event the flag corresponds to call script:[individual chest code] }Condition end (bunch of other preparation code) [fade into area]
------------------------------------------------------------------------
and the script for each chest is again, similar to raithwalls first model with a bit of tweaking and house cleaning i did, but recently i've added an extra 4 lines for when its already been opened
------------------------------------------------------------------------
(SCRIPT: Individual chest code)
if [chest flag]: ON{ script call:[already open] Force script end }condition end
script call:[common chest open] if [chest flag]: off{ [chest flag]: turn on party>possessions>add the item screen display:message:[" (name of item)."] }condition end event control: start off
--------------------------------------------------------------------------
(script name: common chest open)
event: change direction: face leader event: single action (disable motion after action) screen display:content:[player name input] screen display:message:[" received "]
--------------------------------------------------------------------------------
(script name: already open)
event:single action:(speed:999*) (disable motion after action)
--------------------------------------------------------------------------------
*to minimize the amount of time it takes for the camera to fade into the area so the player can continue their traveling
after seeing these four scripts, i just ask you guys, is there anything you can spot that would make this easier for me? or more memory efficient? because i'd like to see how you guys would switch this around to suit your needs, because i can tell these snippets of code are a huge waste of space in some way or another.
Old question: (already solved) what do i do to make a treasure chest do the following:
1: will only be affected if the player stands facing it 2: will only be activated if the player brings up their menu and selects the "look" option 3: animate the chest to open up 4: results from opening chest
can someone give me a generic script/event/event placement combo to make this work? i dont want abig complicated example, just something so i can understand.
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jun 4, 2008 12:27:44 GMT -5
The Basic Approach:
1. Set your chest Event to Examine 2. Begin with this Script:
Event: change direction - face leader Event: single action, disable motion after action. Condition: Chest Flag is off Turn Chest Flag on Party > Posessions > Add the item Condition end. Data > Item Info Load Get Item Name Screen display > content > Input > common name Screen display > text message " was found!" Event Control: Start Off
Works best when item 0 is called Nothing and you set the item number to 0 at the beginning of the script.
The Advanced Approach:
Instead of Putting the item in the partys bag we set the item number variable to the chest item, or more likely a random range of items. Then we use a merchant script with a Take Treasure item, store the item number in a temp variable, then change the item number variable to equal this temp variable between the display buy list command and buy item command.
This allows you to buy any item you find at 0% price, put the item where you want it, and all without any long script branches.
The Super Advanced Approach:
Here we handle hundreds of random treasures and do away with treasure flags completely to save memory.
1. Make a variable for each dungeon in the game and set it to the maximum number of treasure found in that dungeon. 2. Make a sort branch to sort your dungeon number or world number and reduce this variable by 1, and copy its contents to a temp variable. 3. Check to make sure the temp variable is 0 or higher. If it is call your random treasure script to handle rolling the item number. 4. Make a flag for each chest event. Have about 8-12 chest events. 5. Make a variable called last World. When last world is different then current world the chest flags are reset and last world becomes current world. 6. Branch any specific or special treasures by sorting world and flag. 7. Use the merchant script to again buy the item
Result: you create a set amount of treasure per dungeon, and turn off the chest flags, but to turn them back on the player must go to a new dungeon and return to this one. An unlikely effort on his part and one that be more of a hassle then simply continuing to explore the current dungeon, especially since there could be non random treasures hidden deeper within.
The Condensed Super Advanced Approach
This only applies if the player is running dungeons in a set order. You make a variable and increase it through quest progress and make it so you can never find more treasure then this variable, which increases throughout the game.
This can do away with sorting the world number and dungeon variables.
The Ultra Mega Condensed Approach
Each dungeon must be one map only. When you leave the map you cannot ever come back to it. Use the event control: Start Off after giving a random item.
By doing this you can put the same chest in every dungeon over and over again, and only have a little tiny script and the special merchant script.
I will provide some detailed scripts for this soon.
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jun 4, 2008 12:47:53 GMT -5
flags: 1 for each chest event and a few temp flags for any chest.
Variables: 1 for every dungeon that begins at the max number of chests in that dungeon. 1 temp variable for the calculation of whether there are treasures left to find. 1 last world variable to organize when chest flags are reset.
Scripts: 1 for each chest event. 1 to sort the world, reduce each dungeons variable, give the ok for treasure 1 random treasure script that sets up the item number 1 called script that resets all flags. (or just use the command in each enter map) 1 chest options script that distributes the treasure 1 chest closing chest script called in each chest script. 1 special merchant script designed for treasures
Events: 1 for each chest.
Script: random chest
temp variable = -1 Sort: world number apply if 1 dungeon 1 = dungeon 1 - 1 temp variable = dungeon 1 to end (other branches) branch end Condition: temp variable is 0 or higher script call: random treasure Condition end
script: random treasure
Treasure = 1 ? 1000 Condition: Treasure is higher then 980 item number 1 ? 10 (item numbers of rare treasures) force script to end condition end Condition: treasure is higher then 700 item number 20 ? 30 (item numbers of good treasures) force script to end condition end (other conditions like these two) item number 50 ? 80 (common items)
Script: Chest 1 (and another for each chest)
item number = 0 sound effects event: change direction leader event single action (chest opening)
sort: world number (for specific chests found in that dungeon) apply if conditon: specific flag is off specific flag turns on item number = specific treasure conditon end to end apply if conditon: room in dungeon = number. (for multiple uses of chest 1) conditon: specific flag is off specific flag turns on item number = specific treasure conditon end condition end to end branch end
Condition: item number is still 0 Conditon: chest 1 flag is off chest 1 flag turns on script call: random chest conditon end condition end
script call: chest options script call: closure event control: start off
Script: Chest options
merchant script: 4 items (uses special merchant script) wait for script to end (Trust me, use this command here)
script: chest closure
item info load get item name display common name text: was found.
Script: merchant script
Temp Variable = Item Number Display Buy list Repeat Branch - if Quantity is 2 or higher Display Buy List Condition end Item Number = Temp Variable Display Who List (branches for if member is carrying too many things) Buy Item
Thats the basic version of the merchant script. Mine sorts the items Take Treasure, give treasure, destroy chest, and nothing, as well as locked chests where these options come before the chest opened as well as after it.
This should be everything you need to organize all your treasures both specific and random. It may seem like a lot for work, but if you plan to have a lot of chests it will save massive amounts of memory in the long run.
|
|
|
Post by Dungeon Warden on Jun 4, 2008 18:30:44 GMT -5
The easiest way to make a treasure chest is to copy the existing chest event and script (script 253) (make sure you place your new script into the copied event). Change flag 250 (sample Flag 50) to an unused flag (flags 261 to 989 unless you've used some of these yourself) and change the item.
If you want a chest that has money, use script 254. Make sure to copy the event and replace the old script with the copy (unless you have the same amount of money in the chest).
You could just make one chest and have it give a random amount of money. Change line 8 to:
Data : Var 999 [temp 9] = 100 ? 1000 Data : Party Money = Party Money + Var 999 [temp 9]
This will cause the party to find a random amount of treasure between 100 and 1000 SP (or whatever you call your money).
|
|
|
Post by mercenaryx on Jun 4, 2008 19:28:56 GMT -5
Ok that all works and all, (i tried the first method) but theres only 2 problems now:
1.) how do i get the stupid treasure box to stay shut until its opened, instead of being caught in an infinate loop of being opened and shut over and over. (it stays open once you examine it)
2.) how do i put more than one treasure chest on the map while still being able to control what exactly is inside each chest?
again, i'd like the most basic approaches possible.
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jun 4, 2008 19:56:30 GMT -5
1. Closely examine the preset chest events. They have a motion script that sets the event motion to 0 speed. This type of script is used for chests, doors, and a few other things to.
2. If you dont want to make another chest event you need to sort the treasure somehow. I find the most efficient way is by sorting a variable that represents your current map or world number. If two chests are on the same map its best to make two events, but you could also use game info load and sort the partys XYZ coordinates.
3. In the basic approach, each chest will need a flag of its own to keep track of whether the treasure was taken or not.
The presets are a great learning tool when your just starting out, its too bad they did soo many things in such a tiresome and memory inefficient way.
|
|
|
Post by mercenaryx on Jun 5, 2008 10:22:47 GMT -5
I'm sorry, i appriciate your response but could you please use a response in a format similar to the first basic explanation i got? the preset information and code is far too complex and the network of calling from one script to another to see what each one does doesn't let me see what code is the stuff for the chest and what code is for other things in the game.
the first step by step explanation was excellent and i understood it fully, could you please explain it like that?
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jun 5, 2008 10:35:54 GMT -5
The script with motion settings goes in the slot right above where you set the event to examine.
the script must be type action and not content.
it only needs a single command: in event > effects > motion change set it to none and the speed to 0.
|
|
|
Post by mercenaryx on Jun 5, 2008 10:39:32 GMT -5
so what? do i put all this stuff into a new page in the event information for the chest? or do i create an entirely new identical event only without motion?
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jun 5, 2008 10:45:01 GMT -5
Nah, use a single page. Action scripts begin automatically when you enter the map. The bottom of your page should look like this:
no motion script Examine Treasure Chest script
The same format is true for every event you make. If its a villager you use a wander script here to make him walk around.
|
|
|
Post by mercenaryx on Jun 5, 2008 10:55:53 GMT -5
ah alright thank you so much !! ^^
|
|
|
Post by Dungeon Warden on Jun 6, 2008 18:09:55 GMT -5
Again, if you had just copied the treasure chest already in the game you could have saved yourself all these problems. Look at the chest event for more information on how to make one. (note the use of multiple pages to keep the chest closed for example).
|
|
|
Post by mercenaryx on Jul 21, 2008 12:34:11 GMT -5
bump (for a good reason, read the first post)
|
|
|
Post by dailycolbert on Jul 22, 2008 12:11:12 GMT -5
Here's what I do. It only takes 160 per treasure Script (that's not including the Action Script raithwall mentioned nor the Events).
Event "Treasure01" Page 1 Has an Action Script: default that keeps them still Has a Content Script: "Treasure01" Page 2 Action Script is the same, I think Content Script: None
Content Script "Treasure01" Script: Condition: "TreasureFlag01" On (check what Dungeon Warden said earlier in this thread) Event: Effect: Single Action Party: Possessions: Items (or Party: Possessions: Money) tell party what item was obtained* Condition End
*For me, I display a text box for 30 frames, make a sound effect, then close the text box. It's up to you how to do the visual/audio for this.
Total, each chest uses up one Script, one Event, and one Flag.
|
|
|
Post by mercenaryx on Jul 22, 2008 15:50:44 GMT -5
mine does too colbert.... well actually 2 scripts (one to keep the chest closed before opening)
and the other one is for opening, and it has a single event and a single flag.
but the question here is how much total memory is that for you?
|
|
|
Post by dailycolbert on Jul 23, 2008 3:24:07 GMT -5
I don't remember how much the keeping the chests open and keeping the chests closed scripts cost, but on top of those two each individual chest is an additional 160 mem consuming script, one event with two pages (I think about 350 for it), plus one Flag... so total it's about 510 mem per treasure for how I have it set-up. gl
|
|
|
Post by Dungeon Warden on Jul 23, 2008 13:31:17 GMT -5
Party: Possessions: Items (or Party: Possessions: Money) Note that the default script checks to see if the party already has 99 of an item in the bag (the maximum allowed). Also, you must activate the bag in order for this to work (no big deal but sometimes people don't want the player to have the bag until later in the game). The default script also gives the item to the party members first but if you always have a bag that's not needed. I put all the party receives an item commands into it's own script so that if the party gets an item from anywhere, I just call that script to see who gets it. The chest script really only needs a script that checks if the item has been taken and what that item is. The rest of the script can be called from other scripts (one that checks if the party can take the item and one that opens/ closes the chest. However, every chest will need a separate script to keep the chest open if the item has been taken.
|
|
|
Post by mercenaryx on Jul 24, 2008 15:17:59 GMT -5
yeah i know, i had the "leave chest open from this point on" thing working for awhile, and i was very pleased with it. The only thing i had to do was add one more conditional statement at the top of each script that contains the information thats executed when the player opens it. all it said was that if the flag for the item was turned on: force script end
that way im guarenteed that the player wont get something out of the same chest twice, then all i had to do was go to the customly made enter script for the area that the chest is located in, and add a preperation command for when the area becomes visable, once the screen fades in, by the time they're able to see it, the chest already has opened, (that is if the flag is turned on.)
but this took a lot more memory than necessary, i realized this later on, so instead of changing my mind later on into the game, and having to change all the friggin chests because i run out of memory space, i jumped on the problem right away, and made it much simpler. instead of showing the chests open when the player returns to check on it, i simply made it so that the event would no longer even be there when they return.
with a simple 4 bit "event>temporary removal" added into the areas custom enter script, it made it a slight bit less stressful, this way the chest is gone altogether.
|
|
raithwall
RPGM2 Helper
The World I know
Posts: 222
|
Post by raithwall on Jul 24, 2008 20:11:38 GMT -5
If you want the chests to always be open, you need an action script that sorts the world, room, and then if the flag for that chest is on you apply the single motion open. Start by using the chest closed no motion at the top of this script.
Memory wise these scripts will double the cost of every chest.
Note that everything you need to do can be done with a single event page and 2 scripts for each chest event you need which is slightly less memory then multiple event pages.
The action is applied when you enter the room, if the flag is on the chest will appear open. The content is applied when you examine. Its that simple.
If you use a memory efficient system of random chests and variables like the one I explained above then you can't keep them open if the party leaves that dungeon and finds a new one it is reset, of you could keep them open if that dungeons variable has no treasures left.
Only you can decide whether its important or not. I find it reasonable enough to conclude that monsters will close the lids of chests, or you could just have the party close it themselves after taking the treasure.
its a question of style. earlier rpgs without an open chest model just leave it alone and say its empty or make it disappear from the room.
|
|