Jump to content
  • Advertisement
Sign in to follow this  

Simple web-browser game

This topic is 4446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 http://thijsvanderschaeghe.no-ip.com/image.jpeg. (for a working example: click http://thijsvanderschaeghe.no-ip.com/start.php 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"
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


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.


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!