From 21e59bca6fa14b9ae0cd0b4d943268e646b41866 Mon Sep 17 00:00:00 2001 From: zicodxx <> Date: Mon, 3 Nov 2008 11:39:56 +0000 Subject: [PATCH] Made move_towards_segment_center() use move_towards_vector() instead of just changing object position suddenly - smoother; Changed back the robot:controlcen collision back to original - the AI just relies to often on no-damage collisions, especially when our segment suddenly is a controlcen --- CHANGELOG.txt | 1 + main/ai2.c | 14 +++++++++++++- main/collide.c | 21 +++++++++------------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index adbe808d2..573784135 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D2X-Rebirth Changelog 20081103 -------- misc/args.c: Fixed Typo +main/ai2.c, main/collide.c: Made move_towards_segment_center() use move_towards_vector() instead of just changing object position suddenly - smoother; Changed back the robot:controlcen collision back to original - the AI just relies to often on no-damage collisions, especially when our segment suddenly is a controlcen 20081101 -------- diff --git a/main/ai2.c b/main/ai2.c index 97c391a34..cb1b29a59 100644 --- a/main/ai2.c +++ b/main/ai2.c @@ -1584,6 +1584,18 @@ void move_object_to_legal_spot(object *objp) // If segment center is nearer than 2 radii, move it to center. void move_towards_segment_center(object *objp) { +/* ZICO's change of 20081103: + Make move to segment center smoother by using move_towards vector. + Bot's should not jump around and maybe even intersect with each other! + In case it breaks something what I do not see, yet, old code is still there. */ +#if 1 + int segnum = objp->segnum; + vms_vector vec_to_center, segment_center; + + compute_segment_center(&segment_center, &Segments[segnum]); + vm_vec_normalized_dir_quick(&vec_to_center, &segment_center, &objp->pos); + move_towards_vector(objp, &vec_to_center, 1); +#else int segnum = objp->segnum; fix dist_to_center; vms_vector segment_center, goal_dir; @@ -1610,7 +1622,7 @@ void move_towards_segment_center(object *objp) move_object_to_legal_spot(objp); } } - +#endif } extern int Buddy_objnum; diff --git a/main/collide.c b/main/collide.c index f2094fbec..43723e20e 100644 --- a/main/collide.c +++ b/main/collide.c @@ -973,18 +973,15 @@ void collide_robot_and_robot( object * robot1, object * robot2, vms_vector *coll void collide_robot_and_controlcen( object * obj1, object * obj2, vms_vector *collision_point ) { - -// if (obj1->type == OBJ_ROBOT) { -// vms_vector hitvec; -// vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj2->pos, &obj1->pos)); -// bump_one_object(obj1, &hitvec, 0); -// } else { -// vms_vector hitvec; -// vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj1->pos, &obj2->pos)); -// bump_one_object(obj2, &hitvec, 0); -// } - if (!(Robot_info[obj1->id].companion || Robot_info[obj1->id].thief) && !(Robot_info[obj2->id].companion || Robot_info[obj2->id].thief)) - bump_two_objects(obj1, obj2, 0); + if (obj1->type == OBJ_ROBOT) { + vms_vector hitvec; + vm_vec_normalize(vm_vec_sub(&hitvec, &obj2->pos, &obj1->pos)); + bump_one_object(obj1, &hitvec, 0); + } else { + vms_vector hitvec; + vm_vec_normalize(vm_vec_sub(&hitvec, &obj1->pos, &obj2->pos)); + bump_one_object(obj2, &hitvec, 0); + } } //##void collide_robot_and_hostage( object * robot, object * hostage, vms_vector *collision_point ) {