Sign in to follow this  
Daedeloth

Simple web-browser game

Recommended Posts

Hello everyone, I've posted before, but not in this forum. Anyway, now I have a new problem: I'm making a RPG/RTS (combination) in PHP & javascript. I know it sounds odd, but it is possible to make something nice without java-applets :p Anyway here is my problem. The battle-system of the game is mainly massive-multiplayer, so no npc's. But I also wanted to make quests (where you slay monsters etc), a form of "traveling trough the wastelands and fighting random encounters" etc. My battleground is isometric and looks like [url]http://thijsvanderschaeghe.no-ip.com/image.jpeg[/url]. (for a working example: click [url]http://thijsvanderschaeghe.no-ip.com/start.php[/url] and login with guest / guest : search for the battlepit or the quest and enter it). I'll have to write some kind of AI-system for the NPC's. I've already made a script that runs every 2 seconds (which should be good enough) and the npc's actually hit everything that comes within 1 square of them at the moment. In other words: the engine is fine. The battlefield actually is a square raster and the image above is 15x15 tiles (to give you an idea). Now my question: How can I write a good working & nice AI-system? I figured that I should start with collecting all available data for the NPC's, so I made it all available (the map, creatures in range, enemies, etc). I also figured that I would have to set a target for each creature somehow, so it doesn't keep changing target and not attacking at all... It's actually kinda like an advanced chess-game with more possibilities. So could some one give me a little hint on how to start or what tutorials to read? Tnx :)

Share this post


Link to post
Share on other sites
What about each enemy unit having a "state machine"?
If you dont know what it is search for it, its a pretty simple concept.

You can have the unit states something like "attacking", "running", "chasing", "hiding", etc...

for each state you can write different logic

for example:

--- case state "attacking"
if (player-unit.hps>10% and this.hps<15%)
change state to "running"
if (distance>2) change state to "chasing"
attack
if (player died) change state to "chasing"

---- case state "running"
move oppsosite direction from nearest player unit
if (distance>4) change to "hiding"

---- case state "chasing"
move toward nearest player unit
if (distance<2) change state to "attacking"

--- case state "hiding"
if (this.hps > 70%) change state "chasing"
heal self



Iftah.

Share this post


Link to post
Share on other sites
Is that a screen shot from your game? :) Looks good. I like the style.

Using state machines is a good way to go.

While I can't really offer anything specific, you might want to google 'Rogue' or 'NetHack' programming. They're both older text based games, and have been very well documented.

Good luck, and please let me know when I can play your game.

Will

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this