Page 2 of 2

Posted: Sun May 27, 2007 4:40 pm
by Mightywayne
I can see your point of view (and this surely won't be easy either way, I'm sure of it) but the game is not really in Flash that much. It's browser-based. I try to spice things up in the browser window by adding Flash elements, like when you "fly" to a town, it shows a cute little Flash of you flying. But really, the battle system is like... You enter battle! Then, you choose an attacking style. Does it. I've pretty much got the psuedo-code done out in my head. I'm really not that bad with PHP anymore, it's just the freakin' SPECIAL things you gotta do, like this. :(

I'll see if someone else has a suggestion for the background thing. I just couldn't imagine doing it all in Flash.

Posted: Sun May 27, 2007 4:45 pm
by superdezign
Okay then.

Out of curiosity, what do you do about the user pressing the "Back" button on the browser?

Posted: Sun May 27, 2007 4:51 pm
by Mightywayne
You mean if they get a random encounter and they don't want to fight it, so they Back out? When you get into the battle, it initializes your character in the battle, stuck, until you finish it. This stops Backing out, and also allows someone to leave off at the turn they did. Monsters don't have MP or anything, so it's easy to keep track of their current HP along with the mob's current HP. It's a bit harsh on the server, I know... but it's not like I'm not investing my moneys into this. It's going to be a nice little dedi to start with, but I'd assume I'll eventually have to move up sooner than I expect. ._.;

Posted: Sun May 27, 2007 5:01 pm
by superdezign
I mean with anything that they ever do in the game. Considering PHP is a server-side programming language, Everything is another page. So... what if they press the back button?

It's combattable with sessions, but what if they close the browser and end the session?

There's a lot of shortcomings, and it's a lot easier to hack. Client-side, you can edit GET and POST data, you can edit HTML, and you can alter/disable JavaScript.

You can do a lot to stop this (mostly just banning cheaters), but you have to put it all into consideration.

Posted: Sun May 27, 2007 5:06 pm
by Mightywayne
There are certain precautions you can take to stop people from doing things. No matter what, they cannot change the .php file they're sending whatever the information is to. So you put in stupid precautions that will never happen unless they hack. I'll try to find one now.

Here we go.

Code: Select all

$chosenmonster = $_POST["choice"];
 
	 if (empty($chosenmonster))
	 die("<img src='npc/caretaker.png' align='right'>Erm, you should probably pick the egg you'd like first. ");
To get to the page normally, you'd always input a monster you want. But putting in that precaution stops people from just entering the page like that. And database injection is aided with mysql_real_escape and htmlidentities();

I also try to use GET as least as possible.

Posted: Sun May 27, 2007 5:15 pm
by superdezign
Well, I'd suggest you have some sort of validation in your posted data as well. At any point, you can change POST data as it's being posted. The people you want to stop ARE hackers, so you should look into what it is that we can do.

Posted: Sun May 27, 2007 5:28 pm
by Mightywayne
You can change it BEFORE it's even posted. o.o; I consider that too. Okay, so what are they going to change? Let's say they input their monster type to like... I dunno... "banana". The game's not going to function correctly, it won't allow them to continue with banana type. Eventually I'm going to spend like a whole day tying up the plain silly ones, but all the ones that could so far cause problems have been taken of.

I understand what you're saying, dez, but really I've got most of the game already completed. xD It's not like I can say "Oh you know he's got a point!" and just drop 6 months of work.

I'm still here for the AJAX question. =o Uhm. xD Yes, back to waiting for someone else....... right?

Posted: Sun May 27, 2007 5:42 pm
by superdezign
Lol, I was trying to convince you to switch over to Flash, but I had no idea you'd already gotten so far. I figured you just started.

If you want everyone to see one another as they walk around and such, and for it to happen live (as in, not just when one person moves), then you could have a time interval to obtain everyone's positions from the database, and to send the user's movement to the database. Whether or not the user moves as they press the movement keys/buttons, or as you retrieve the new position, is up to you.

Or, you could go completely PHP and, every time they move, it refreshes the page and gets all of the information from the database. This wouldn't be AS bandwidth intensive.

If you use AJAX, you'd update the screen by moving like, a div with the users into their respective positions. In PHP, you could use the GD library to generate the image and have everyone see the same thing.

Posted: Sun May 27, 2007 5:47 pm
by Mightywayne
Oh god no! xD Oh man that's nuts. Dude not for nothing, but I'm like pouring my heart and soul into this game. Sometimes I dream there's a giant monster made of 1's and 0's and he's going to eat me, so I have to type faster and faster and my fingers just aren't fast enough and...!

Well no, not really. But there's no way I'm showing people "live". The game is meant to resemble a single player game the moment you hit the battle field. YOU are the hero, YOU are the one doing quests and such. To show other people would annihilate my server's resources, on top of <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> me off greatly whilst coding.

http://www.dreamincode.net/code/snippet183.htm I'm looking into that, and if it's kinda sorta maybe as easy as what it looks, I can consider doing this without my brains exploding. But this is the last thing I'm adding to the game before it's done, the exploration system. Political's nearing completion (damn taxes...) and I'm going to start splicing things soon. So hopefully I'll have enough time to think about exactly what is need after-all.

Posted: Sun May 27, 2007 5:57 pm
by superdezign
Interesting. If you plan to make money with this in the future, I'd be more than happy to help program it. ^_^

Just remember that the more you make client-side, the more vulnerable you are to cheaters... However, the script there is very simple, but generally solid. I'm not to sure how it'd stand up against cheaters though.

Posted: Wed Jun 06, 2007 9:35 am
by InterHat
I'm not sure if this helps, but here's how I did it for my senior project. I wrote the basis of a graphical Master of Orion 2 style game in PHP using AJAX. I can send you a link with an account if you want to take a look, it is live. There's a scheduled task that runs on the server with a set interval of 1 minute right now. The client side reloads(using AJAX as to not disrupt the interface) every minute showing which other users are within its ships' sensor range.

What happens is the player has a number of ships, the scheduled task process loops through them and finds the distance to all other ships in the same solar system, and if they're in range it formats them as JS objects, passing them to the client via Ajax. While there's a lot of data coming from the server to the client, doing this eliminates the need to do anything more complicated to pass game objects to the client.

I'm guessing your game has something like fog of war. Why black out the map entirely except for what the client can see? If absolutely necessary, do that client side. Pass game objects dynamically based on what the player can see when he moves to a new location and load them 'over' the map. (I can walk you through how to do this and show you an example if you want to PM me) This way you're only updating with a small amount of data and in smaller bits. You also won't have to worry as much about cheating.

If you want you can load game data from a square or two out based on where the player can move, preloading the game objects before the player does the movement. You can then use a interval-based loading scheme rather than an event driven one. This is similar enough to what many actual RPGs do to load data on a client. Unfortunately, there is some room to cheat, but not as much as loading ALL of the data on the client. It'd be similar to a 'radar' in an mmo if someone were to cheat with this.

As far as updating the server, just do that the event driven way. When the client side is updated, update the server using Ajax. How fast do the players need to be move? If it's not an absurd amount, it's not going to be that intensive. Our game runs fine on a VPSland $20some dollar a month cruddy Windows VPS with 20+ simultaneous users and we're using Propel for ease so it's not even remotely the most efficient way of querying the database.

Posted: Wed Jun 06, 2007 3:33 pm
by Mightywayne
Well definitely thank you for your words, you actually even gave me a good idea if I was to show where players were on the map at one point. (parsing as JS or something)

I actually don't have a fog of war - I want people to see all available. My friend gave me a cute little tutorial on how to use AJAX for what I want, so I can handle that fine.

The rest I'll PM you.