Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Collision Detection?

Neikko

Member

I have some great ideas for games, but they all come at a heavy price, which is being totally different from the default battle system.

I've always pondered these questions, but never knew how to ask. I want to start by saying I've used RMXP before, but never to any extremes. I know how to use variables, switches, stuff like that.

Now, here are my questions.

One of my ideas for a battle system, is using on-field fighting. Where you don't just switch to another screen and use a menu to fight, but where you can enter "attack mode" on the fly, hitting things around you. (think of any generic MMORPG, FF12, etc).

How would you script (even using old school ways of just using variables, switches, and etc) to make the game recgonize when a monster is too far away to attack? What if I want my character to be able to cast a spell on any NPC within a 5x5 square around my character? How would you be able to code something like that in? has anyone tried stuff like this? How do I even start, just to figure it out as I go along? I don't even know where to begin.

I can figure some things out, like creating a Custom menu system (I know how to but i've never sat down and done one, at least not a complete one).

Another thing that I've had in my head for a long time, how would you scirpt something like a item list? Most traditional RPGs have an Item menu (including the default menu in RMXP) that lists items downward as you get them. All I can figure out is how to do a Zelda'ish item menu, where the items only show up in one place on the menu if you have the item, or not if you dont have the item. I cant comprehend how to make it so the list grows as you get more or less items.

There are so many more questions, but I feel like Im already asking for too much explanation here. If anyone can point me in the right direction, or get me off on the right foot to start figuring these things out on my own, any help would be VERy appriciated! : )

Thanks.
 
Determining the distance of an event(monster) from a player is easy enough. You can even do it without scripting. Go to "control switches" on the event command page and in the 7th operand field assign the player's and an event's x and y coordinates to different variables. Then do the following:

Control Variable: [player x] -= [event x]
Control Variable: [player y] -= [event y]
if [player x] > 0
[distance] += [player x]
else
[distance] -= [player x]
end
if [player y] > 0
[distance] += [player y]
else
[distance] -= [player y]
end

After you run this, [distance] will be the exact number of tiles the event is from your character.

As for the item list, it isn't impossible to do without scripting. though if you are planning to make any custom systems it would be a lot easier to simply learn RGSS. (I am saying this in context as neither is an easy feat for a novice.) Though if you are stuck on the idea of doing it without scripting, you can do it like so:

let's say, for example, that you have 10 variables that each hold an item id:

Item1: 01
Item2: 02
Item3: 00
Item4: 01
Item5: 00
Item6: 00
Item7: 00
Item8: 00
Item9: 00
Item10: 02


The item ids each relate to a different type of item. like if it is 01 it could be an apple, or a biscuit, or whatever. item id 00 would be nothing. meaning you have a blank spot in your item list, which is what you're trying to get rid of. What you want to do is make everything that isn't id 00 go up on the list. and all the item slots with an id of 00 go down the list. So this is the logical procedure that you need to follow:

beginning
1. Go down the list checking each item slot if it's id is 00. If it's id is not 00 skip it. Stop when you come to the first item slot that has an id of 00 or until you reach the end of the list (in which case there would be no empty item slots). Store the index (The spot in the item list) of the first item slot with the id of 00, check the next item. If it is id: 00, go to the next item. keep checking each individual item slot after the first 00 id until you either reach the end of the list (in which case the item list is already in order) or find an item slot that ISN'T 00 id. if you find an item that isn't a 00 id, REPLACE the first item slot on your list with a 00 id with the slot that isnt a 00 id. After you do this start the entire procedure over from the beginning.


Now lets see what happens when you run this process on the fake item list I gave to you above.

Item1: 01 ... not 00, skip.
Item2: 02 ... not 00, skip.
Item3: 00 ... is 00, stop. now find the next item slot that doesnt have a 00 id
Item4: 01 ... not 00, switch this id with Item3 then start over.
Item5: 00
Item6: 00
Item7: 00
Item8: 00
Item9: 00
Item10: 02

start over

Item1: 01 ... not 00, skip.
Item2: 02 ... not 00, skip.
Item3: 01 ... not 00, skip.
Item4: 00 ... is 00, stop. now find the next item slot that doesnt have a 00 id
Item5: 00 ... is 00, skip
Item6: 00 ... is 00, skip
Item7: 00 ... is 00, skip
Item8: 00 ... is 00, skip
Item9: 00 ... is 00, skip
Item10: 02 ... not 00, switch this id with Item4 then start over.

start over

Item1: 01 ... not 00, skip.
Item2: 02 ... not 00, skip.
Item3: 01 ... not 00, skip.
Item4: 02 ... not 00, skip
Item5: 00 ... is 00, stop. now find the next item slot that doesnt have a 00 id.
Item6: 00 ... is 00, skip
Item7: 00 ... is 00, skip
Item8: 00 ... is 00, skip
Item9: 00 ... is 00, skip
Item10: 00 ... is 00, skip

end of list. items are now in order.

As you can see, once you run this procedure your item slots that have nothing in them (Id: 00) are at the bottom, and the items slots that do have items are at the top. These are the basics of sorting a list. Now once you actually do this with event commands, you're going to have a lot of pages worth of commands, but that's ok. You're not constantly running the commands and should only run this once you add or use an item in your list. so it shouldn't be much of a problem.

I hope that answers your questions.
 
Well, in general, when working on making complex scripts like this with RMXP, the first step is to fully understand all the default code very well. The comments are quite descriptive and help plenty with doing this.

That way, when you're looking for somewhere to start, you're able to pick the place that best suits your needs. There are many ways to approach making any script in RMXP. Since you're wanting to make a form of battle system, you'll probably want to start somewhere with Scene_Battle, and code ways to call damage calculation based on pressing the A or B buttons to attack, rather than entering the commands in a battle.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top