What I am wondering is, is there an easier way to deal with side-scrolling AI (mainly jumping) without needing to take every single situation into consideration, which the situation is determined by variables (not var, I mean imaginary variables.). Or if you do, what is the best approach to use when taking every different situation into consideration?
Here are the problem variables I have to deal with:
Closeness of platform above you to your head
Closeness of ends of platforms
If there is somewhere to land on the other side of a drop
How far up in the air you are
If the space below you ends up in an abyssal drop (resulting in death), or if it is a platform
If there is somewhere to land below other platforms after an abyssal drop
Where your enemy is
The closest path using side-scrolling controls to get there
I am sure there is more but that is all I can think of. When you combine those together, then need different scenarios for when some are false and some are true, it begins to get overwelming.
ID:153678
May 14 2003, 4:08 pm
|
|
hmmm o.o
You COULD go through all the trouble of fiddling with pages and pages and pages and pages and pages of AI code to get something like that done o.o to scan the surroundings, to find the opponent (or whatever) etc etc etc etc etc o.o But why? o.o; Thats how -we- as humans work, but not nessicarily effective in a game format for a non-pc character. IMHO a -much- easier way to do it would be to have the turf the mob is currently standing on carry a lot of the information that you'd need to scan the surroundings for. Perhaps also include some basic instructions on the turf itself on how the mob should handle -basic- situations. Depending on how complex you make your maps, yea, this could be a pain in the rear to go through.. but a lot of basic tile types could be simplified so you dont need a whole pile of unique ones. Short example. Say the NPC is standing on a platform. To the left the platform continues on, and to the right there is a pit that is jumpable. You could give the tile itself basic instructions like: If the opponent is within 1 space, then goto AI code. If NPC HP > 50% then goto AI code. If the opponent is right, then jump the pit. If the opponent is left, then walk left. Then for the NPC specic code you could include things that need to be scanned. Like say its hp is low (see above example) then it could scan its surroundings, find something thatd heal it, and make that its target, then go back to the tile code to figure out how to get there o.o; Hope this idea is of any help ^_^ And sorry its so long @_@;;;; Elorien |
The first thing I'd do is just set up a rudimentary way for the mob to walk to that desired target... This system should just assume a flat course with no drop offs... A plain old walk_to type of thing (of course, using only East and West movement)
Then, add in a way for it to check for edges of platforms ahead of itself at every step... (a simple check to see if the next tile they'll step on is non-dense will work just fine...because that means it'll be a drop...)
Once it comes to an edge, have it check in a certain radius for other platforms... A simple, universal radius should be fine for all instances (jumping up, jumping sideways, or falling down to a lower platform)... If the distance is above the desired radius, then the jump or fall is too great and the mob has no other option than to walk back the way they came... Or, if the destination is on the same platform (behind them), disregard it... If it finds a suitable target, make it jump to that location...and then start walking again... Rinse, repeat...
If it happens to find multiple reachable targets (a platform above and a platform across a small chasm, etc), then have it weigh each of them to pick the best one... For instance, if the target is higher than they are, then jumping up to a higher platform would be more desirable than jumping to a lower one (if both were within range)... And so it would pick the higher destination...
Perhaps to spruce things up a bit more, you could have it check for reachable platforms with each step... That way, if you have a flat ground level with no pits, it won't end up just walking back and forth...lol It will look for platforms to jump up to if its target is higher up than it is...
Basically, the trick here is that it really doesn't need to be that compicated to work nicely... Don't overthink it...lol The whole thing can be accomplished with one generic set of rules that applies to all situations, instead of having to hardcode an effect for every different situation, and a system of recognizing every possible situation...