Kamikaze_Badger Posted November 25, 2004 Posted November 25, 2004 Well, I'm working on some AI for The Redwall Strategic Game or whatever it's called. Problem is: How in HELL do I get everything to work out right? What I want to do is set it up so it dosn't do anything unless the player comes within it's range of sight. Here's what I've got so far: /* ** Current rough draft of the enemy AI. This assumes that the player has armor ** and health ** Some code (c) Sam Tootell unless otherwise noted */ #include <iostream> #include <string> // Ok, so we're going to assume that the player has 50 armor and 100 health // later on in this source file int nPlayerArmor; int nPlayerHealth; // We'll also assume that the player has a weapon that does N amount of damage // per attack. The enemy will have 25 HP and 0 Armor later on in the 'rithm int nEnemyArmor; int nEnemyHealth; // Now we'll get the amount of damage done by each weapon. We'll assume that // it deals out 10 damage, 6/10ths of that will be absorbed by armor int nEnemyWeaponPower = 10; // That's it for the armor and health. Now onto perimeters // We'll assume that the enemy has a sight of 5 whatever: int nEnemySightPerimeterFront = 5; int nEnemySightPerimeterLeftDiag = 3; int nEnemySightPerimeterRightDiag = 3; // The directional ones are for diagonal sight // Onto hearing, we'll assume that the enemy can here twice as much as he can // see. Walls will be only slightly more complicated. Tell me if you want them // involved as well int nEnemyHearPerimeterFront = 10; int nEnemyHearPerimeterLeft = 6; int nEnemyHearPerimeterRight = 6; int nEnemyHearPerimeterBehind = 4; // If you're wondering why there's only left and right and no diagonal, it's // to simplify things a bit // For locations: float flEnemyLocation float flPlayerLocation // The . in the floats will be used to differentiate between the x and y axis. // Now, onto the actual stuff... int main(void) { do { /* nothing */ } while ( flPlayerLocation != flEnemyLocation ) } Quote Share this post Link to post Share on other sites More sharing options...
LobbDogg Posted November 25, 2004 Posted November 25, 2004 Did you actually code that yourself or just copy it out of a book or something? Because all you have so far is just declared some variables and started a do while loop. I for one have no idea what game you are talking about. Maybe help us out a little with some background info about the game or whatever it is so we might be able to try and help. But in the mean time, really you have nothing for code so will be very very difficult for us to help you out. You are asking the plain generic question. "How do I program?" Its like looking for a needle in a haystack. Quote Share this post Link to post Share on other sites More sharing options...
Kamikaze_Badger Posted November 25, 2004 Posted November 25, 2004 I did write it all myself. And I'm asking how to set it up so it dosn't do anything UNTILL a certain event happens. Quote Share this post Link to post Share on other sites More sharing options...
markiemrboo Posted November 25, 2004 Posted November 25, 2004 what event? it does seem like a bit of a ... uh.. vague question? I mean, what you seem to have now is a loop that loops until one player is on top of another. What kinda game is this? Quote Share this post Link to post Share on other sites More sharing options...
Frankie_CWRU Posted November 25, 2004 Posted November 25, 2004 a good place to start is to incorporate movement first. If your control to break out of the loop is for the player to move into the compouters range, and neither player can move, then you will loop forever. It would be a much better idea to get some other craptions put together before you start working on the loop variables. Quote Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.