I am really fed up with th AI in my games just walking and beating each other up. I really have the problem of getting the AI to stand still and attack lets say a building then when a player approches the begin walking up to the palyer to attack the.
Any help would be appreciated
ID:149977
Jan 13 2002, 2:52 am
|
|
Jan 15 2002, 8:11 am
|
|
Sorry about bumping my post; but it's been over 48 hours and this is the last dumb, annoying problem will have for a while.
|
In response to Gojira
|
|
Gojira wrote:
Sorry about bumping my post; but it's been over 48 hours and this is the last dumb, annoying problem will have for a while. That's nice of you to say so, but I highly doubt you'll be the last dumb, annoying problem we'll have for a while... Players likely have several characteristics that differentiate them from monsters. They have a value stored in the variables "key" and "client", and they're probably a specialized type of mob. If you tell the monsters to only look for/attack that type of mobs, or mobs who have .key or .client, they'll go after only players. |
In response to Lesbian Assassin
|
|
Yes and i can get them to do that, but i want them to have two roles.
|
In response to Gojira
|
|
So, make them check for players... if no players, go on to checking for cities.
|
In response to Lesbian Assassin
|
|
you mean checking for obj's right?
|
In response to Gojira
|
|
You tell me... I don't know what a city is in your game. Whatever it is, have them attack it, the same way you have them attack players.
|
In response to Lesbian Assassin
|
|
Lesbian Assassin wrote:
That's nice of you to say so, but I highly doubt you'll be the last dumb, annoying problem we'll have for a while... Nicely said, I learn from you everyday in the art of newbie managment. |
In response to Lesbian Assassin
|
|
Well, thanks lexy.
Nadrew in "newbie management" are you reffering to me? |
In response to Gojira
|
|
Well, yes she keeps you from roaming free, and if you get out of hand she'll cut you down so far it would hurt, Lexy's my role model.
|
In response to Nadrew
|
|
Roaming free?
::Smashes Head repeatedly into desk trying to figure out the statement:: |
In response to Gojira
|
|
Gojira wrote:
Roaming free? Yes. As in free range newbies. Tasty. --Tarmas. |
In response to Gojira
|
|
Better make an area/
like: area/cityspace You can add in strength etc. as variables under this. Then just have the mobs check the areas in its view, if it finded area cityspace, attack whatever is in that space. Objs, buildings, bridges, whatever. Then when u have a cityspace and nothing is there to attack move on. LJR |
In response to Tarmas
|
|
You can lead a newbie to answers, but you can't make them think...
|
In response to Xooxer
|
|
This A.I code does not work for some bizzare reason, it used to.
mob/npc/attackers /*this will only effect the mobs defined as mob/npc/"name"*/ var think_delay = 10 /*this is a default think delay*/ New() ..() spawn(rand(1,think_delay)) AILoop() proc/AILoop() var/obj/M /*this monster attacks mobs only*/ for(M as obj in oview(src)) break /*this is done to the mob closest*/ if(!M) spawn(think_delay) AILoop() return if(get_dist(src,M) > 1) step_towards(src,M) spawn(think_delay) AILoop() /*this means, that if the opponent is more then a block away, the mob will walk toward him*/ else flick("attack",src) M.HP -= 10 /*again, this just takes hp from the opponent*/ M.DeathCheck() /*again this insures that the deathcheck proc is in effect*/ spawn(think_delay) AILoop() /*this means that the mob will wait its think_delay until attacking again*/ Any insight on what might ne wrong? |
In response to Gojira
|
|
Gojira wrote:
This A.I code does not work for some bizzare reason, it used to. Shouldn't those be mobs?? |
In response to Xooxer
|
|
no i am getting them to attack and destroy buildings. Why dont they even walk though?
|
In response to Gojira
|
|
Because they're busy attacking the first object they see. This is probably a nearby turf.
That's a bit of trouble with you attacking cities/mobs, so here's my opinion. For simplicity and realism, monsters should only be able to attack one turf at a time. You're sort of right with the whole looping through what it sees bit, but there's just one problem, as I said above. It's attacking any object, as long as it's the closest one. So, you should have it look for things that have a hit point variable. Doing that will not only allow monsters to attack building, but players to attack and destroy buildings as well. >:D Looking for the nearest thing in its view that has a hit point variable is probably easiest if you write a proc that returns oview() minus everything that doesn't have hit points, then using that proc instead of oview(). (Hint: I suggest using a proc that does damage on damagables, so you can use hascall(). Otherwise it's something I can't roll off the top of my head. I still don't know the finer points of DM. A for loop will probably come in handy as well. Along with +=ing to a list that is then returned at the end of the proc.) Once it locates the nearest damagable thing, it walks to it if it can, and starts bashing away. Hopefully not subtracting hit points but calling a damage function on it. Whee. It's clean, and allows for both your monsters and your players to blow buildings (and each other) up. --Tarmas. |
In response to Tarmas
|
|
There's just one problem with your one problem... it's not attacking the first object, it's attacking the first obj, which is guaranteed to not be a turf.
Rather than checking for a hp variable, he ought to just define obj/building, and make sure that obj/building has all the appropriate variables and procs for something that can be attacked and destroyed... and then redo his variable as var/obj/building/M, and his loop as for (M in oview()) This doesn't, of course, explain why his monsters aren't moving. |
In response to Lesbian Assassin
|
|
Bleh, you're right.
But.. I think it would be better to just check for a hp variable. The way you suggest really only allows it to attack buildings.. players and anything else should be counted as well. Er.. We may have different definitions of city, though. I'm talking about a monster wandering around on a map, destroying anything that it can destroy. Cities would really just be objects shaped like walls to form buildings. This way it'll nicely bash at walls until they explode, turn to custard, crumble and whatever. Okay, I think it's not moving, though, it because it is attacking the nearest obj. Players are mobs, so it won't attack them.. turfs are turfs, so it doesn't go near them. It may simply not be seeing any objs it can attack. Of course, I may be completely wrong and unaware of the fact that a mob also counts as an obj.. But, if turfs aren't objs I at least have a semi-logical reason. --Tarmas. |