(12-18-2013, 08:53 PM)fr33xgames Wrote: 1) Is there a way to just make an action happen once? For example, if i want john to heal when his dim red health exists. I created an AI for it but he spams the heal skill till the dim red is gone.
My best bet would be to find out where ever the value that stores whether you are being healed is. It isprobably somewhere in an Object structure, which can be accessed by using
game.objects[target.num]. There isn't any actual documentation for these files, but if you download the source the structures are stored in "sgame.h" (in pure C structures).
Just simply print out every single unkwn value and see if any of them changes when you activate self heal, and if you find an answer be sure to let me know so I can implement it in the actual DLL.
In a few days I'll be done with school (because christmas holidays wohooo), so if you haven't solved it by then, I'll try to look into it myself.
(12-18-2013, 08:53 PM)fr33xgames Wrote: 2) Can someone show me a template AI of how self.xxx can approach target.xxx? And how to find the distance of an object id()?
I think the id you are referencing is the id (as in identification) and not the id (as in the ego and the id (Freud)/basic ai function). The was this is usually done is by subtracting the position of one from the other (
int distancex = target.x-self.x;). If the value is bigger than 0 then
target is at the right side of
self, and otherwise he is at the left side (or right on top of him :o). If you want the actual distance you'd use the
abs() function (
abs(distancex) or
abs(target.x-self.x)). Same thing goes for distance is y and z direction. If you want the actual distance (as in a line that isn't necessarily parallel to any axis), then I think good old Pythagoras has you covered.
You should be able to do something like:
C++-Code:
//something like this should work:
int distance = sqrt(xdistance*xdistance+zdistance*zdistance);
//and now that we are at it we may as well go 3d:
int distance = sqrt(xdistance*xdistance+ydistance*ydistance+zdistance*zdistance);
//also there could be some problems with doubles and ints, so if the above doesn't work try using double instead of int
|
I'm beginning to regret calling the AI function for id... probably shouldn't have done that :D
Also Pythagoras may or may not have actually been so good: http://www.youtube.com/watch?v=X1E7I7_r3Cw
(12-18-2013, 08:53 PM)fr33xgames Wrote: 3) How do you break out of an if statement with Angel Script? break; doesn't work.
You don't, just as you don't in C++ (and most other languages).
C++-Code:
//if you want to do something like the following:
void id(){
if(something){
//some code
if(somethingElse) break;
//more code
}
//rest of code code
}
//then you can do this instead:
void id(){
if(something){
//some code
if(!somethingElse){
//more code
}
}
//rest of code code
}
//or if you don't mind using a hack:
void id(){
if(something) do {
//some code
if(somethingElse) break;
//more code
}while(false);
//rest of code code
}
|
The reason for why it doesn't just work is the same as in C++. If it did you be unable to break a for/do/while/switch-statement from within an if-statement, as the language wouldn't know whether or not you want to break the if-statement or the loop.
Age ratings for movies and games (and similar) have never been a good idea.
One can learn a lot from reinventing wheels.
An unsound argument is not the same as an invalid one.
volatile in C++ does not mean thread-safe.
Do not make APIs unnecessarily asynchronous.
Make C++ operator > again
Trump is an idiot.