// My new attack program. // Aiming and enemy seeking has been improved. // It works with all shooters (legged, winged, etc.) // against all enemy races (ant, wasp, etc.). // Because there is a bug with pitch value not being // recognized correctly while in 1st-person camera view, // I recommend switching camera view to 3rd-person for best // results. Happy Hunting! extern void object::Attack() { int cat[]; cat[0] = AlienAnt; cat[1] = AlienWorm; cat[2] = AlienWasp; cat[3] = AlienSpider; cat[4] = AlienEgg; while(true) { object enemy = radar(cat); if(enemy != null) moveAndDestroy(enemy); } } void object::moveAndDestroy(object target) { float dir; float dis; float dif; float ang; object infront = radar(target.category,0,45,0,45); if(infront != null) target = infront; dir = direction(target.position); dis = distance(position,target.position); if(dir > 45 and dis < 10) motor(-1,0); else if(dir < -45 and dis < 10) motor(0,-1); else motor(1-dir/22.5,1+dir/22.5); dis = distance(position,target.position); dif = target.position.z-position.z; ang = asin(dif/dis); jet(1-ang/-20); dir = direction(target.position); dis = distance(position,target.position); dif = target.position.z-position.z; ang = asin(dif/dis)-pitch; aim(ang); if(dis < 40 and -15 < dir and dir < 15 and -25 < ang and ang < 25) fire(0.1); }