Posts: 11
Threads: 1
Joined: Jan 2010
I'm working on an action/shooter type game in RMXP. So far you can use a few differant guns and take down a couple of test dummies, run/strafe/melee, all that jazz.. My question is about creating some kind of cover system, or basicly make certain objects (such as walls/trees/people) stop the "bullet" so if you shoot at an enemy who's behind cover he won't get hit.
For anyone who hasn't worked on something exactly like this, I just have conditional events for the direction your facing and set the X and Y coordinates of the player and enemy events to seperate variables so I can compare them. If you're facing right the enemy's Y coordinate must be equal to yours and their X coordinate must be greater than yours in order to hit them, and so on for the other directions. This works fine in the open, but I can't think of a functional and practical way to create "solid" objects. Currently all the basic actions and such are pretty much functional except for the fact that you can shoot through absolutely anything to hit your target.. so I'd really like to fix this
I hope I was able to explain my situation and my problem properly. I was up all night working on it so now I'm like"Duuuuuuh." I should probably go catch some Zs but if anyone has any tips/suggestions/words of wisdom please feel free to share. If I need to go into any more detail or anything just let me know, I'll check back after my power nap and hopefully some cool dude will have solved this little riddle for me already. ;)
Posts: 11,235
Threads: 650
Joined: May 2009
Can you test for tile passability? Perhaps see if it is a 'counter' tile (used for things like desks and tables).
Posts: 1,664
Threads: 391
Joined: May 2009
You could also try using terrain tags to tag certain "solid objects" and pull something off with it. :)
Posts: 11
Threads: 1
Joined: Jan 2010
Hmm... Well, I could tag all the solid objects on the tileset, but the way my system works it would still need to know an X and Y for a solid object. Which would mean I would need an event updating the X and Y for every single wall or tree or what-have-you on the map, and that's just silly. Or is there some kind of way I could check if any tagged terain was in the players direct line of sight? My other idea was to have a call event for the projectile and have it spawn in front of the player, move forward till it hits something, then disapear, but then you would have to wait for the bullet to hit something before you could shoot again right? Unless you could call multiple instances of the same event? Otherwise I'd need to make a "bullet 1" and a "bullet 2" all the way up to "bullet 30" or something (since this is an action game and there will be enemies firing back at you, too) so you could fire multiple projectiles simultaniously.
If I can get it to work, I know my current system would be 10 times better than that, but this last speed bump is really slowing me down. I really appreciate the responces so far, as they've given me something to think about, and if anyone cares to make another suggestion or point me in the right direction at least that'd be greeeeat!
Posts: 110
Threads: 8
Joined: Jul 2009
You'd only need to terrain tag a piece of floor that's on the ground behind the object to, say, 3. Then, one parallel process event checks if the terrain tag of the shooter is lower than the terrain tag of target and flips a switch. If the switch is flipped, no shooting happens or "miss" graphic pops up. You can even make it easier on yourself and the player by having a visual reminder of the tagged areas.
Posts: 11
Threads: 1
Joined: Jan 2010
Hmmmmm, that's a pretty good idea, but it would only work if you're right next to the solid object. I'd have to tag all the terrain in a whole room if I wanted to make a wall or anything that covered you from more than a square away right? So I'd basically have to divide every map into separate quadrants (terrain tag 1/2/3/etc) and then make sure you and the enemy have the same terrain tag w/ a conditional event. Also if I wanted to make a tree or something I'd have to tag the squares below it, to the right of it, and to the left and above it, so like a cross shape basically. And then if I was below it and the enemy shot at me from my right our terrain tags would be different so he couldn't hit me, even though there isn't really anything obstructing his shot. It would work, but it would work under limited conditions.
Thanks a ton though, I feel like I'm making progress! I've almost got my arms around this thing. Anyone have any ideas how I could do this please let me know, I'll keep messing with it and check back later.
Posts: 110
Threads: 8
Joined: Jul 2009
It could be a check in addition to the system you already have going. You could probably build it into your shooting system as an extra conditional branch. Like "same x axis, same direction, same terrain tag" thing.
On a side note, you might have an easier time using a script. Not saying that it can't be done with events, so it's your call. :)
Posts: 11
Threads: 1
Joined: Jan 2010
I don't know much at all about RGSS. I know enough to kind of understand other people's, but I couldn't begin to start working on something like this probably.
There's gotta be a way to do this.. I just can't think how to make this thing work. Like, I could probably make working walls right now, but i couldn't really do a solid object in the middle of a map that would cover in four directions..
Posts: 110
Threads: 8
Joined: Jul 2009
I know I've seen a view range script here and there. I think it was by Near Fantastica (or a similar name, anyway). People have used it for guard mini-games where you need to sneak around and not be spotted by guards. Perhaps you could check that out and see how it's set up :)
Also, have you tried a "solid object" event? Conditional branch checking to see if the x/y of the event is between x/y of the shooter and x/y of the player. It might work.
Problem is, eventing gets increasingly more complicated to event as your maps get more detailed and complicated. You need to add more conditional branches and so on. That's what makes me wonder if a script might help more. I'm not a scripter myself, but I don't think it would be too complicated to write a script that just checks if there's an obstacle event and turns on the "no shooting" switch if that's the case. There might even be a script like this out there. Or you could see about striking a trade with someone :)
Posts: 11
Threads: 1
Joined: Jan 2010
I've been looking over a few different scripts, but I'll see if I can find a view range one as well cuz that could be useful.
I was thinking the same thing about checking the x/y of the solid events and the shooter and the player, and yea that would be a bitch to do. I think MAYBE it wouldn't be so bad to use the terrain id "quadrent" idea for walls, and then for other solid objects just do an x/y check. There won't be TOO many things that block your shot in the middle of a room, just things like pillars or whatever. So that might not be too painful. Otherwise I'll break down and try to get a script going for it.
I'll give it a "shot" though.. If you'll excuse the pun :)
Edit: Dude, that view range script is pretty kickass. I can check to see if an event is within view of the player and vice versa, and it can be set so they can't see through impassible tiles... That's perfect. Thanks everybody who helped me out, and thanks Lunarea for bringing that script to my attention. I'm almost done with all the basic systems and crap so soon I can start making the actual game itself. If I run into anymore snags I'll let you guys know