Cutting Trees (Efficient use of Switches)

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
Hey guys, wondering if someone will be able to be able to provide some insight/suggestions for me.  I'm currently working on a survival game and cutting down trees for wood is something the player will likely do a lot (wood is just so useful afterall)  Thing is I'm trying to find the most effective way to have this system take place.

Here's my setup:

Find a tree



Cut it down (activating one of the 15 or so switches related to tree cutting)



Cut that into smaller and smaller pieces as needed (activating another series of switches)

Thing is that can take a LOT of switches if you have a couple hundred trees in the game.

My goal is to...

-Use as little switches as possible

-Avoid limiting the player

-Avoid scenarios where cutting down one tree activates switches that cause other trees to become cut or spawn logs prematurely

At first my idea was to have trees require one or two switches making it so that ten switches could technically give you a hundred possible combinations.  (Switch 1/Switch 2, Switch 3/Switch 7, etc.)  But of course once those switches are cut on they can effect other trees.

For example if you cut down a tree that uses switch 5 and then another that uses switch 7, another tree that requires switch 5 AND 7 will automatically cut itself down.

TL;DR How can I use switches better or should I use something other than switches for this?  THANK YOU!

PS: Ignore her wearing a dress in the cold snow or the repetitive and boring ground, they're placeholders.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,577
Reaction score
6,895
First Language
German
Primarily Uses
RMMV
Such mechanics are the reason why the self-switches exist in addition to the general switches.


If your design requires more data, then I suggest looking up PK8's self data suite and using those scripts.
 

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
Such mechanics are the reason why the self-switches exist in addition to the general switches.

If your design requires more data, then I suggest looking up PK8's self data suite and using those scripts.
I wasn't too clear on that, my apologies.  The tree breaks into multiple events (the stump, the large chunk, and the smaller pieces for about 5 events) so I'm not sure how self switches help beyond the part where the tree changes itself into a stump and so forth.  am I missing something?

EDIT:  Thanks for the suggestion of PK8's script.  Not sure if it will help but it could be useful. Problem is though the link to the script on their post has a 404 error.
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,577
Reaction score
6,895
First Language
German
Primarily Uses
RMMV
Problem is though the link to the script on their post has a 404 error.
Search for posts by PK8 - he provided an updated link in another post (where someone asked for the script), but I don't have that updated link myself.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,203
Reaction score
1,259
First Language
English
Primarily Uses
RMXP
Is the cutting always halving in size?

I.e. can the three only be cut up in the way you depict?

Because then only the last two cuts are split-up, before that the cutting is linear, so you can do it with a variable and two switches.

Do you have a more general tree cutting scenario? Multiple trees of varying length and more freedom in cutting?

I.e. what sort of possible outcomes are there? Can the tree once lying down by cut at any given tile position it takes up?

*hugs*

 - Zeriab
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,350
Reaction score
332
First Language
German
Primarily Uses
RMMV
You are Aware that 400 is the Most Events you can have on a Map without too much Lag and with Mog Hunter anti Animation Lag Script installed?

Would be cool to know how many Trees there can be on one Map.

And how those Trees respawn? (Whith Mapreload while Teleporting between 2 Maps? Or with some kind of fancy Timer? Or never?)

Maybe some kind of Tile Swap Script could Help you to maniplate the Map without using Events. (Only suitible for 32x32Tiles and your reference Picture ws different from that) so hmmm?
 
Last edited by a moderator:

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,203
Reaction score
1,259
First Language
English
Primarily Uses
RMXP
Whether or not the game lags is much more complicated than that. Would be nice if it was so easy though.

For example In RPG Maker XP I had 10k events on a map running smoothly.

As a procedure I highly recommend first figure out how we want the tree cutting to work. Afterwards we can discuss implementation details.
 
  • Like
Reactions: Bex

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
Is the cutting always halving in size?

I.e. can the three only be cut up in the way you depict?

Because then only the last two cuts are split-up, before that the cutting is linear, so you can do it with a variable and two switches.

Do you have a more general tree cutting scenario? Multiple trees of varying length and more freedom in cutting?

I.e. what sort of possible outcomes are there? Can the tree once lying down by cut at any given tile position it takes up?

*hugs*

 - Zeriab
Pretty much it's being chopped in half each time not counting the original cut which just separates the trunk and the majority of the tree.  It's based on the resources I have below.

 
 
 


Timber>Big log>Small log>wood

 
 
 


Dead Timber>Dead big log>Dead small log>firewood
Basically one tree and all its parts, and then a dead version and all its parts.  I don't plan on adding more than that one type of tree as I don't feel it's necessary and I have to pay an artist to make these and the whole point of this game is to make a good game with a much smaller budget than my original concept of a massive, open world, rpg.

The smaller log and wood can be picked up by the player and carried so it can be cut elsewhere but the larger wood (big log and timber) isn't carryable.  I do plan on making it where you can drag it but I haven't implemented that yet (involves a lot of work for the sprite to look like she's really holding onto it and no weird issues if you drag it through other objects)

Would be cool to know how many Trees there can be on one Map.

And how those Trees respawn? (Whith Mapreload while Teleporting between 2 Maps? Or with some kind of fancy Timer? Or never?)

Maybe some kind of Tile Swap Script could Help you to maniplate the Map without using Events. (Only suitible for 32x32Tiles and your reference Picture ws different from that) so hmmm?
Trees don't respawn, one you don't craft too many things like in Minecraft so you don't need that much wood, two I'm trying to be a bit more realistic.  For example you can only burn dry wood so the tree shown since it was alive would not be able to be used for fires as its wood would contain too much water.
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,203
Reaction score
1,259
First Language
English
Primarily Uses
RMXP
So the following?

1 Tree > 1 Timber
1 Timber > 2 Big log
1 Big log > 2 Small log
1 Small log > 1 wood
 

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
1 small log>2 wood  but other then that yes you're correct
 

Zeriab

Huggins!
Veteran
Joined
Mar 20, 2012
Messages
1,203
Reaction score
1,259
First Language
English
Primarily Uses
RMXP
In other words a tree contains

  • 8 wood
  • 4 small logs
  • 2 big logs
  • 1 timber
So a timber takes up 8 event tiles? Or does it take fewer event tiles and then spread out more as you chop?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,733
Reaction score
13,140
First Language
English
Primarily Uses
RMVXA
Cut tree, turn on self switch A.

If A is on, show timber. Cut that, turn on self switch B

If self switch B on, show big logs, cut that, turn on self swtich C

If self switch C on, show small logs, if cut that, turn on self switch D

If self switch D on, show wood. Actually, you should probably just auto-collet the wood, as D is as far as you can with out a script or something to add more self switches.\

No extra switches needed.
 

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
In other words a tree contains

  • 8 wood
  • 4 small logs
  • 2 big logs
  • 1 timber
So a timber takes up 8 event tiles? Or does it take fewer event tiles and then spread out more as you chop?
Just double checked both in engine and photoshop, it does indeed take up 8 tiles.  (In engine you're able to walk through all of it but the point where the 32x32 event in placed...it's an issue I'll solve later)

 

Cut tree, turn on self switch A.

If A is on, show timber. Cut that, turn on self switch B

If self switch B on, show big logs, cut that, turn on self swtich C

If self switch C on, show small logs, if cut that, turn on self switch D

If self switch D on, show wood. Actually, you should probably just auto-collet the wood, as D is as far as you can with out a script or something to add more self switches.\

No extra switches needed.
 

Actually since the log, wood, etc is moveable and thus their own events that doesn't work.  But thanks for the usggestion I wish it was that easy.  Also you bring up a good point with wood being added to an inventory system.  I've considered this as a fail safe but I much rather it have a physical representation in the world you play in.



EDIT: Here's a picture of it in engine,



The tree (left side) becomes a trunk.  The timber is in the center (the blank one) it becomes nothing after being chopped into the two big logs.  The two big logs become small logs after that as well as two more events which are just more small logs.  (After this they would become wood but since that is something that would happen back at the cabin they're not evented yet)
 
Last edited by a moderator:

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,255
Reaction score
612
First Language
English
Primarily Uses
Hm... is it necessary for the wood pieces to stay on map when the tree has been cut? By that I mean if you leave the map after you fell the tree, do you need those pieces to be on the ground?

I've thought up the best way of doing this. The first scenario is easier in which the pieces disappear if you leave the map without collecting them. The second scenario is more complicated but will leave the pieces on the map. The only difference is that in scenario two, you'll be using a few variables to keep track of where there are pieces to be spawned.

These two scenarios require you to be able to spawn events on demand~ which can be done using a script or by hand via script call (i believe)

Scenario 1:

Fell the tree --> change tree to cut stump, spawn large Timber.

cut Timber --> timberevent.erase, spawn 2 big logs.

... ... etc ... ...

harvest wood -->add wood to inventory, erase wood

because the events were spawned after the fact and are not set in map, they will disappear if you leave and re-enter the map, only the stump will remain.

Scenario 2:

Map Tree Variable [@map_id][Type of Item to Spawn]

Map Tree item X [@map_id][X location of item to Spawn]

Map Tree item Y[@map_id][Y location of item to Spawn]

Timber = 1

Big Log = 2

Small Log = 3

Wood = 4

Fell the tree --> change tree to cut stump, spawn large Timber.

     Set type of item, X location and Y location like so:
        $game_variables[MTV][@map_id].push(1)
        $game_variables[MTiX][@map_id].push(this.x + 4)
        $game_variables[MTiY][@map_id].push(this.y)

cut Timber --> timberevent.erase, spawn 2 big logs.

     Set type of item, X location and Y location like so:
        $game_variables[MTV][@map_id].push(2)
        $game_variables[MTiX][@map_id].push(this.x + 2)
        $game_variables[MTiY][@map_id].push(this.y)
        $game_variables[MTV][@map_id].push(2)
        $game_variables[MTiX][@map_id].push(this.x + 4)
        $game_variables[MTiY][@map_id].push(this.y)

     Delete the Timber from the arrays:
        $game_variables[MTC][@map_id].delete_at(this.id - 100)
        $game_variables[MTiX][@map_id].delete_at(this.id - 100)
        $game_variables[MTiY][@map_id].delete_at(this.id - 100)

... ... etc ... ...

harvest wood --> add wood to inventory, erase wood

Now once you enter the map, there will be a single process that loops through  Map Tree Variable, Map Tree item X, Map Tree item Y, and spawns those based on the location of these items. It should spawn each one and add 100 to the ID number.

The trick here is to use the entry number of the 2D array as the event ID, then add 100 to id (in case you have 100 other events on the map. If you need more space to be safe, make it 200).

EDIT: I forgot to mention. For both scenarios, you'll only have to do all of this processing once. The Timber, Big Log, Small Log, Wood will all have a single event with those processes in it, coming from a (spawn items) map. The Tree/Stump will call a common event that starts the process.

Then, the autorun at the beginning of the map will spawn all of the items depending on the 2D Array. All you would really have to do, in theory, is place the trees.
 
Last edited by a moderator:

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
@seita Oh boy t's nice to see you here! We were just chatting on twitter like yesterday and now you're already helping me.

I'm just about ready to mark that as solved but a couple things I want to note.

1)  The game should consist of one large map (currently 8,000x8,000 pixels)  I will increase this as needed (if more gameplay area needs to be added) or decrease it (if the game begins to lag) but the game is meant to have no loading screens and keep you immersed without menus as well.  (Even walking into the cabin uses a script that pulls data from another map of the interior and displays it on the main map as if it were a part of it...don't ask me how, Vlue does magic script work for me)

2)  Say wood is added to inventory, I should be able to create a system where the wood can be placed back in physical form at a storage location right?  (That way you could have a place to store wood without the game being unreal and having you carry 30 pieces of wood in your backpack)

Thank you for the feedback and I appreciate your valuable time being put towards helping others.  I checked your recruitment thread and if you're still in need of a sprite artist/animator I can get you in touch with my guy who does my work.  I'll dm you details to keep this thread on topic.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,255
Reaction score
612
First Language
English
Primarily Uses
Ah okay. The first point is interesting, though I've never noticed loading screens to lose immersion, unless you're thinking of other games like minecraft. For your second point, I don't think anyone's ever complained about holding 30 wood on them as unrealistic. They've brought it up in webcomics and such, but it doesn't seem like a huge issue. It seems like it'd become very tedious if the player could only hold one or a few at a time, and would probably detract overall from the fun factor. Otherwise, I don't see why making that system would be a problem.
 

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
Ah okay. The first point is interesting, though I've never noticed loading screens to lose immersion, unless you're thinking of other games like minecraft. For your second point, I don't think anyone's ever complained about holding 30 wood on them as unrealistic. They've brought it up in webcomics and such, but it doesn't seem like a huge issue. It seems like it'd become very tedious if the player could only hold one or a few at a time, and would probably detract overall from the fun factor. Otherwise, I don't see why making that system would be a problem.
I'm a very critical person when it comes to games and especially if I'm the one making them.  My goal is to have people feel like they're in the world and enjoy the experience.

As for carrying wood in any form I plan to add a large sled you can drag along with you on large pathways (having to abandon it when going off trail) this would be something you could dump the wood on and carry back home.  That way you could technically carry four or so large logs without Val carrying these herself.

PS: I saw your edit and I think it's the best solution.  I just need to wrap my head around it.  I haven't used common events to spawn items on the map.  I'll need to figure this out so I can implement your suggestion.  Also the ability to pickup items comes from a script call, would I be able to attach that to the spawned items?
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,255
Reaction score
612
First Language
English
Primarily Uses
The sled bit is a nice solution~ will be nice to see it in action.

The spawned items will simply copy the event from another map and create a copy of it in the new map. All of the event commands, pages etc will remain intact. So if the original spawn item calls the common event, then it shouldn't be a problem~
 

Dream3r

90% Dreamer, 100% Dedicated
Veteran
Joined
Jun 13, 2013
Messages
530
Reaction score
375
First Language
English
Primarily Uses
So basically I would follow Yanfly's instructions here to do what you suggested?  Anything else I should note?

To everyone else thank you SO much for all the help.  Glad we could figure this out...sort of
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,255
Reaction score
612
First Language
English
Primarily Uses
Yes basically, that's the gist of it. Which scenario are you going with? In the 1st one, the spawned events will disappear if you save and close the map as well.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

The new intro Logo for my videos.

I speed it up, the one I use to use was to long.
The workweek is now over. Now I can work on my GamZzzzzZzzzzZzzzZzzZz....
Just watched Onward with the family. One of the best movies I've ever seen. <3
2 hours & 20 minutes remaining. :D
...trying to hurry finish up all commissions before I never put the controller down again ;)

Forum statistics

Threads
95,822
Messages
932,185
Members
126,254
Latest member
YKJordan
Top