C-Code:
bool is_attacking(int j){ if( !is_object(j) || target.id == 999 ){ return false; } int x = target.state; int i = 0; do{ x /= 10; i++; }while( x > 0); x = 1; for( i; i > 1; --i ){ x *= 10; } return ( target.team != self.team && ( ( target.type == 0 && frame(j,60,99) ) || target.state/x == 3 || target.state == 18 || target.state == 19 || target.state == 1002 || target.state == 2000 ) ) ? true : false; } |
If that's not the case, in the last line I return true if the object is attacking. The easiest option is: return true if the target is on a different team and in state 3, the attacking state. But this will only recognize characters doing basic attacks because all projectiles use attacking states like 3000, 3005 and 3006. Also some character attacks use state 301. I did not want to check for all of these separately, so I simply checked whether the state begins with a 3. For that the code in between determines the length of the state and creates a 1 with trailing zeros to have the same amount of digits (1 for state 3, 100 for 301, 1000 for 3000/3001/etc). If dividing the target state by this number equals 3 then the state starts off with 3. There are also other attacking states such as the light and heavy throwing weapon states and the fire states 19 and 18 (I now notice I did not take into consideration that team mates with state 18 are attacking you too).
Now this function is anything but perfect, because there was no way to truly check for itrs yet. Version 3.0 will allow me to simply check whether the target is on a different team and has a damaging itr in its current frame. That will be a lot simpler and much more efficient than this.
C-Code:
int square_distance(int s, int t){ loadTarget(s); int sx = target.x; int sy = target.y; int sz = target.z; loadTarget(t); int tx = target.x; int ty = target.y; int tz = target.z; return (sx-tx)*(sx-tx) + (sy-ty)*(sy-ty) + (sz-tz)*(sz-tz); } |
next: the hit time function and an updated is attacking function
favorite dcing techniques: wpoint | double key inputs | holding back | alternate basic moves