From 5e621953ca00e202f8c9a3ab0f35e6a6f7f9e695 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 7 Aug 2011 17:27:57 +0200 Subject: [PATCH] bots now can handle paths through warpzones --- qcsrc/server/sv_main.qc | 17 +++++++++++++++++ qcsrc/server/t_teleporters.qc | 5 +---- qcsrc/warpzonelib/server.qc | 1 + qcsrc/warpzonelib/server.qh | 2 ++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index d11a7e3fd..15f43ad9e 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -389,3 +389,20 @@ void SV_OnEntityPreSpawnFunction() return; } } + +void WarpZone_PostInitialize_Callback(void) +{ + // create waypoint links for warpzones + entity e; + for(e = world; (e = find(e, classname, "trigger_warpzone")); ) + { + vector src, dst; + src = (e.absmin + e.absmax) * 0.5; + makevectors(e.warpzone_angles); + src = src + ((e.warpzone_origin - src) * v_forward) * v_forward + 16 * v_right; + dst = (e.enemy.absmin + e.enemy.absmax) * 0.5; + makevectors(e.enemy.warpzone_angles); + dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right; + waypoint_spawnforteleporter_v(e, src, dst, 0); + } +} diff --git a/qcsrc/server/t_teleporters.qc b/qcsrc/server/t_teleporters.qc index 003fcbc05..0adbd5196 100644 --- a/qcsrc/server/t_teleporters.qc +++ b/qcsrc/server/t_teleporters.qc @@ -251,14 +251,12 @@ void teleport_findtarget (void) entity e; float n; - RandomSelection_Init(); n = 0; for(e = world; (e = find(e, targetname, self.target)); ) { ++n; - waypoint_spawnforteleporter(self, e.origin, 0); if(e.movetype == MOVETYPE_NONE) - RandomSelection_Add(e, 0, string_null, 1, 1); + waypoint_spawnforteleporter(self, e.origin, 0); if(e.classname != "info_teleport_destination") print("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n"); } @@ -273,7 +271,6 @@ void teleport_findtarget (void) { // exactly one dest - bots love that self.enemy = find(e, targetname, self.target); - self.dest = self.enemy.origin; } else { diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 94209205b..4d44fe84e 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -770,6 +770,7 @@ void WarpZone_StartFrame() WarpZone_InitStep_UpdateTransform(); self = e; WarpZones_Reconnect(); + WarpZone_PostInitialize_Callback(); } if(warpzone_warpzones_exist) diff --git a/qcsrc/warpzonelib/server.qh b/qcsrc/warpzonelib/server.qh index 621e0f951..7a301a8b8 100644 --- a/qcsrc/warpzonelib/server.qh +++ b/qcsrc/warpzonelib/server.qh @@ -10,3 +10,5 @@ const float ENT_CLIENT_WARPZONE; const float ENT_CLIENT_WARPZONE_CAMERA; void WarpZone_PlayerPhysics_FixVAngle(void); + +void WarpZone_PostInitialize_Callback(void); -- 2.39.2