.float teleport_antispam;
-// waypoint sprites
-.entity bot_basewaypoint; // generator waypointsprite
-
.bool isgenneighbor[17];
.bool iscpneighbor[17];
float ons_notification_time[17];
void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius);
void havocbot_goalrating_waypoints(entity this, float ratingscale, vector org, float sradius);
+.entity bot_basewaypoint;
+.bool navigation_dynamicgoal;
+void navigation_dynamicgoal_init(entity this, bool initially_static);
+void navigation_dynamicgoal_set(entity this);
+void navigation_dynamicgoal_unset(entity this);
entity navigation_findnearestwaypoint(entity ent, float walkfromwp);
void navigation_goalrating_end(entity this);
void navigation_goalrating_start(entity this);
.float speed;
+void navigation_dynamicgoal_init(entity this, bool initially_static)
+{
+ this.navigation_dynamicgoal = true;
+ this.bot_basewaypoint = this.nearestwaypoint;
+ if(initially_static)
+ this.nearestwaypointtimeout = time + 1000000000;
+ else
+ this.nearestwaypointtimeout = time;
+}
+
+void navigation_dynamicgoal_set(entity this)
+{
+ this.nearestwaypointtimeout = time;
+}
+
+void navigation_dynamicgoal_unset(entity this)
+{
+ if(this.bot_basewaypoint)
+ this.nearestwaypoint = this.bot_basewaypoint;
+ this.nearestwaypointtimeout = time + 1000000000;
+}
+
// rough simulation of walking from one point to another to test if a path
// can be traveled, used for waypoint linking and havocbot
}
else
{
- bool search = true;
-
- if((e.flags & FL_ITEM) && e.nearestwaypoint)
- {
- if (e.flags & FL_WEAPON)
- {
- if(e.classname != "droppedweapon")
- search = false;
- }
- else
- search = false;
- }
-
- if(search)
- if (time > e.nearestwaypointtimeout)
+ if ((!e.nearestwaypoint || e.navigation_dynamicgoal) && time > e.nearestwaypointtimeout)
{
nwp = navigation_findnearestwaypoint(e, true);
if(nwp)
{
LOG_DEBUG("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e));
- if(e.flags & FL_ITEM)
- {
- if (e.flags & FL_WEAPON)
- {
- if(e.classname != "droppedweapon")
- e.blacklisted = true;
- }
- else
- e.blacklisted = true;
- }
+ if(!e.navigation_dynamicgoal)
+ e.blacklisted = true;
if(e.blacklisted)
{
}
}
- // TODO: Cleaner solution, probably handling this timeout from ctf.qc
- if(e.classname=="item_flag_team")
+ if(e.navigation_dynamicgoal)
e.nearestwaypointtimeout = time + 2;
- else
- e.nearestwaypointtimeout = time + random() * 3 + 5;
}
nwp = e.nearestwaypoint;
}
entity bot_waypoint_queue_bestgoal;
float bot_waypoint_queue_bestgoalrating;
+.entity bot_basewaypoint;
+.bool navigation_dynamicgoal;
+void navigation_dynamicgoal_init(entity this, bool initially_static);
+void navigation_dynamicgoal_set(entity this);
+void navigation_dynamicgoal_unset(entity this);
+
+
/*
* Functions
*/
IL_PUSH(g_bot_targets, this);
this.bot_attack = true;
this.monster_attack = true;
+ navigation_dynamicgoal_init(this, false);
PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_JUMP(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
flag.solid = SOLID_TRIGGER;
flag.ctf_dropper = player;
flag.ctf_droptime = time;
+ navigation_dynamicgoal_set(flag);
flag.flags = FL_ITEM | FL_NOTARGET; // clear FL_ONGROUND for MOVETYPE_TOSS
flag.ctf_pickuptime = 0;
flag.ctf_droptime = 0;
flag.ctf_flagdamaged_byworld = false;
+ navigation_dynamicgoal_unset(flag);
ctf_CheckStalemate();
}
{
// bot waypoints
waypoint_spawnforitem_force(this, this.origin);
- this.nearestwaypointtimeout = 0; // activate waypointing again
- this.bot_basewaypoint = this.nearestwaypoint;
+ navigation_dynamicgoal_init(this, true);
// waypointsprites
entity basename;
.entity ctf_staleflagnext;
// waypoint sprites
-.entity bot_basewaypoint; // flag waypointsprite
.entity wps_helpme;
.entity wps_flagbase;
.entity wps_flagcarrier;
}
void ka_TouchEvent(entity this, entity toucher);
-void ka_RespawnBall(entity this);
void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
{
if(game_stopped) return;
settouch(this, ka_TouchEvent);
setthink(this, ka_RespawnBall);
this.nextthink = time + autocvar_g_keepawayball_respawntime;
+ navigation_dynamicgoal_set(this);
Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
Send_Effect(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 1);
setthink(this, ka_TimeScoring);
this.nextthink = time + autocvar_g_keepaway_score_timeinterval;
this.takedamage = DAMAGE_NO;
+ navigation_dynamicgoal_unset(this);
// apply effects to player
toucher.glow_color = autocvar_g_keepawayball_trail_color;
ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
ball.owner.ballcarried = world; // I hope nothing checks to see if the world has the ball in the rest of my code :P
ball.owner = NULL;
+ navigation_dynamicgoal_set(ball);
// reset the player effects
plyr.glow_trail = false;
settouch(e, ka_TouchEvent);
e.owner = NULL;
ka_ball = e;
+ navigation_dynamicgoal_init(ka_ball, false);
InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So.
}
key.damageforcescale = 0;
key.takedamage = DAMAGE_NO;
key.modelindex = kh_key_carried;
+ navigation_dynamicgoal_unset(key);
}
void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs several times times when all the keys are captured
key.takedamage = DAMAGE_YES;
// let key.team stay
key.modelindex = kh_key_dropped;
+ navigation_dynamicgoal_set(key);
key.kh_previous_owner = key.owner;
key.kh_previous_owner_playerid = key.owner.playerid;
}
setsize(key, KH_KEY_MIN, KH_KEY_MAX);
key.colormod = Team_ColorRGB(initial_owner.team) * KH_KEY_BRIGHTNESS;
key.reset = key_reset;
+ navigation_dynamicgoal_init(key, false);
switch(initial_owner.team)
{
wep.flags |= FL_TOSSED;
wep.colormap = own.colormap;
wep.glowmod = weaponentity_glowmod(info, own, own.clientcolors, own.(weaponentity));
+ navigation_dynamicgoal_init(wep, false);
W_DropEvent(wr_drop,own,wpn,wep,weaponentity);