(08-19-2012, 03:34 PM)Alblaka Wrote: Important feature: Jan/John/Sorcerer actively seeking out and healing teammates with low hp, but sufficient dark hp.yes i am planning to include loading the teammate that requires healing most (or the group need in general)
it can be used for healing moves later but as silva said this does not directly belong to writing a new basic ai
i want to first use it to help out the weakest character or call the team together - i added it to the list
@silva: please spoiler your cup duck
thank you
Moving on with the get_objects function, it will return an array of object numbers that we can later base all decisions on.
C-Code:
int[] get_objects(){ array<int>o = {-1,-1,-1,-1}; for ( int i = 0; i < 400; ++i ){ if( is_object(i) && target.team != self.team ){ //get attack that will hit first if( hits_sooner_than(i,o[0]) ){ o[0] = i; } //get closest opponent if( is_opponent(i) && ( ( closer_than(i,o[1]) && is_opponent(o[1]) ) || !is_object(o[1]) ) ){ o[1] = i; } //get second closest opponent else if( is_opponent(i) && ( ( closer_than(i,o[2]) && is_opponent(o[2]) ) || !is_object(o[2]) ) ){ o[2] = i; } //get closest item if( is_item(i) && ( ( closer_than(i,o[3]) && is_item(o[3]) ) || !is_object(o[3]) ) ){ o[3] = i; } } } return o; } |
As usual with finding certain objects I have a for loop that goes through all 400 objects there are. Before that I create and fill the array that will be used to store the object numbers with -1 values, which will remain in case objects for a certain category are not found.
In case the currently loaded number inside the loop belongs to an existing object that is on another team it is further checked whether it is a dangerous attack, an opponent or an item.
//get attack that will hit first
If the object will hit the character sooner than the previously loaded object its number will be written to o[0] (slot 0).
This can be an attack, opponent or item. Anything really.
//get closest opponent
If the object is an opponent and closer than the previously loaded opponent (or the first opponent loaded) its number will be written to o[1] (slot 1).
//get second closest opponent
If the object is an opponent and not closer than the so far closest opponent but closer than the previously second closest one its number will be written to o[2]. (If I will ever load more opponents sorted by their distance I will try to combine these two into an internal for loop.)
//get closest item
Same as the two above except for items. I have yet to think up a way to rank items by more than just their distance (preferring a farther bottle over another weapon if it is needed). If you have a good script idea write it down.
The conditions for the closest objects are a little long - maybe i can simplify them later.
As you can see I have added an is_object(int i) function I will use for better readability inside the id function as well:
updated id function (Click to View)
favorite dcing techniques: wpoint | double key inputs | holding back | alternate basic moves