From 4258aa872b2767607076632336b86ce2bf48af91 Mon Sep 17 00:00:00 2001 From: ineed bots Date: Sun, 8 May 2022 19:41:25 -0600 Subject: [PATCH] Chat events --- main_shared/maps/mp/bots/_bot.gsc | 8 ++ main_shared/maps/mp/bots/_bot_internal.gsc | 25 +++- main_shared/maps/mp/bots/_bot_script.gsc | 150 +++++++++++++++++++++ main_shared/maps/mp/bots/_bot_utility.gsc | 8 ++ 4 files changed, 186 insertions(+), 5 deletions(-) diff --git a/main_shared/maps/mp/bots/_bot.gsc b/main_shared/maps/mp/bots/_bot.gsc index cc820d5..986ce81 100644 --- a/main_shared/maps/mp/bots/_bot.gsc +++ b/main_shared/maps/mp/bots/_bot.gsc @@ -232,6 +232,14 @@ onPlayerKilled( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sH self maps\mp\bots\_bot_script::onKilled( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration ); } + self.lastAttacker = eAttacker; + + if ( isDefined( eAttacker ) ) + { + eAttacker.lastKilledPlayer = self; + eAttacker notify( "killed_enemy" ); + } + self [[level.prevCallbackPlayerKilled]]( eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration ); } diff --git a/main_shared/maps/mp/bots/_bot_internal.gsc b/main_shared/maps/mp/bots/_bot_internal.gsc index dae195e..9e4c59f 100644 --- a/main_shared/maps/mp/bots/_bot_internal.gsc +++ b/main_shared/maps/mp/bots/_bot_internal.gsc @@ -174,15 +174,30 @@ bot_skip_killcam() for ( ;; ) { - wait 1; + self waittill( "begin_killcam" ); - if ( isDefined( self.killcam ) ) - { - self notify( "end_killcam" ); - } + self thread doKillcamStuff(); } } +/* + bots use copy cat and skip killcams +*/ +doKillcamStuff() +{ + self endon( "disconnect" ); + + self BotNotifyBotEvent( "killcam", "start" ); + + wait 0.5 + randomInt( 3 ); + + wait 0.1; + + self notify( "end_killcam" ); + + self BotNotifyBotEvent( "killcam", "stop" ); +} + /* When the bot spawns. */ diff --git a/main_shared/maps/mp/bots/_bot_script.gsc b/main_shared/maps/mp/bots/_bot_script.gsc index b6dcdc3..3083b5e 100644 --- a/main_shared/maps/mp/bots/_bot_script.gsc +++ b/main_shared/maps/mp/bots/_bot_script.gsc @@ -1624,6 +1624,8 @@ bot_revive_think_loop() if ( !isDefined( revivePlayer ) ) return; + self BotNotifyBotEvent( "revive", "go", revivePlayer ); + self.bot_lock_goal = true; self SetScriptGoal( revivePlayer.origin, 1 ); @@ -1641,12 +1643,16 @@ bot_revive_think_loop() return; } + self BotNotifyBotEvent( "revive", "start", revivePlayer ); + self SetScriptGoal( self.origin, 64 ); self bot_use_revive_thread( revivePlayer ); wait 1; self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "revive", "stop", revivePlayer ); } /* @@ -2036,6 +2042,8 @@ bot_use_tube_think_loop( data ) } else { + self BotNotifyBotEvent( "tube", "go", tubeWp, tube ); + self SetScriptGoal( tubeWp.origin, 16 ); ret = self waittill_any_return( "new_goal", "goal", "bad_path" ); @@ -2059,6 +2067,8 @@ bot_use_tube_think_loop( data ) if ( !isDefined( loc ) ) return; + self BotNotifyBotEvent( "tube", "start", loc, tube ); + self SetScriptAimPos( loc ); self BotStopMoving( true ); wait 1; @@ -2159,6 +2169,8 @@ bot_use_equipment_think_loop( data ) } else { + self BotNotifyBotEvent( "equ", "go", clayWp, nade ); + self SetScriptGoal( clayWp.origin, 16 ); ret = self waittill_any_return( "new_goal", "goal", "bad_path" ); @@ -2182,6 +2194,8 @@ bot_use_equipment_think_loop( data ) if ( !isDefined( loc ) ) return; + self BotNotifyBotEvent( "equ", "start", loc, nade ); + self SetScriptAimPos( loc ); self BotStopMoving( true ); wait 1; @@ -2288,6 +2302,8 @@ bot_use_grenade_think_loop( data ) } else { + self BotNotifyBotEvent( "nade", "go", nadeWp, nade ); + self SetScriptGoal( nadeWp.origin, 16 ); ret = self waittill_any_return( "new_goal", "goal", "bad_path" ); @@ -2311,6 +2327,8 @@ bot_use_grenade_think_loop( data ) if ( !isDefined( loc ) ) return; + self BotNotifyBotEvent( "nade", "start", loc, nade ); + self SetScriptAimPos( loc ); self BotStopMoving( true ); wait 1; @@ -2357,11 +2375,15 @@ follow_target_loop() if ( randomInt( 100 ) > self.pers["bots"]["behavior"]["follow"] * 5 ) return; + self BotNotifyBotEvent( "follow_threat", "start", threat ); + self SetScriptGoal( threat.origin, 64 ); self thread stop_go_target_on_death( threat ); if ( self waittill_any_return( "new_goal", "goal", "bad_path" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "follow_threat", "stop", threat ); } /* @@ -2434,6 +2456,8 @@ bot_listen_to_steps_loop() if ( !IsDefined( heard ) ) return; + self BotNotifyBotEvent( "heard_target", "start", heard ); + if ( bulletTracePassed( self getEyePos(), heard getTagOrigin( "j_spineupper" ), false, heard ) ) { self setAttacker( heard ); @@ -2447,6 +2471,8 @@ bot_listen_to_steps_loop() if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "heard_target", "stop", heard ); } /* @@ -2502,10 +2528,14 @@ bot_revenge_think() if ( randomint( 100 ) < 75 ) return; + self BotNotifyBotEvent( "revenge", "start", loc, self.lastKiller ); + self SetScriptGoal( loc, 64 ); if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "revenge", "stop", loc, self.lastKiller ); } } @@ -2817,6 +2847,8 @@ bot_killstreak_think_loop() if ( self.pers["hardPointItem"] == "artillery_mp" && !isAirstrikePos ) return; + self BotNotifyBotEvent( "killstreak", "call", targetPos ); + self BotStopMoving( true ); if ( self changeToWeapon( self.pers["hardPointItem"] ) ) @@ -2905,6 +2937,8 @@ bot_uav_think_loop() if ( ( !isSubStr( player getCurrentWeapon(), "_silenced_" ) && !isSubStr( player getCurrentWeapon(), "_flash_" ) && player.bots_firing ) || ( self.bot_radar && !player hasPerk( "specialty_gpsjammer" ) ) ) { + self BotNotifyBotEvent( "uav_target", "start", player ); + distSq = self.pers["bots"]["skill"]["help_dist"] * self.pers["bots"]["skill"]["help_dist"]; if ( distFromPlayer < distSq && bulletTracePassed( self getEyePos(), player getTagOrigin( "j_spineupper" ), false, player ) ) @@ -2919,6 +2953,8 @@ bot_uav_think_loop() if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "uav_target", "stop", player ); } break; @@ -2988,9 +3024,13 @@ bot_target_vehicle_loop() if ( !isDefined( target ) ) return; + self BotNotifyBotEvent( "attack_vehicle", "start", target ); + self SetScriptEnemy( target, ( 0, 0, 5 ) ); self bot_vehicle_attack( target ); self ClearScriptEnemy(); + + self BotNotifyBotEvent( "attack_vehicle", "stop", target ); } /* @@ -3076,9 +3116,13 @@ bot_kill_dog_think_loop() if ( !isDefined( targetDog ) ) return; + self BotNotifyBotEvent( "attack_dog", "start", targetDog ); + self SetScriptEnemy( targetDog, ( 0, 0, 5 ) ); self bot_dog_attack( targetDog ); self ClearScriptEnemy(); + + self BotNotifyBotEvent( "attack_dog", "stop", targetDog ); } /* @@ -3175,9 +3219,13 @@ bot_equipment_kill_think_loop() if ( isDefined( target ) ) { + self BotNotifyBotEvent( "attack_equ", "start", target ); + self SetScriptEnemy( target, ( 0, 0, 0 ) ); self bot_equipment_attack( target ); self ClearScriptEnemy(); + + self BotNotifyBotEvent( "attack_equ", "stop", target ); } } @@ -3386,12 +3434,16 @@ bot_dom_spawn_kill_think_loop() if ( DistanceSquared( self.origin, flag.origin ) < 2048 * 2048 ) return; + self BotNotifyBotEvent( "dom", "start", "spawnkill", flag ); + self SetScriptGoal( flag.origin, 1024 ); self thread bot_dom_watch_flags( myFlagCount, myTeam ); if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "dom", "stop", "spawnkill", flag ); } /* @@ -3464,6 +3516,8 @@ bot_dom_def_think_loop() if ( !isDefined( flag ) ) return; + self BotNotifyBotEvent( "dom", "start", "defend", flag ); + self SetScriptGoal( flag.origin, 128 ); self thread bot_dom_watch_for_flashing( flag, myTeam ); @@ -3471,6 +3525,8 @@ bot_dom_def_think_loop() if ( self waittill_any_return( "goal", "bad_path", "new_goal" ) != "new_goal" ) self ClearScriptGoal(); + + self BotNotifyBotEvent( "dom", "stop", "defend", flag ); } /* @@ -3584,6 +3640,8 @@ bot_dom_cap_think_loop() if ( !isDefined( flag ) ) return; + self BotNotifyBotEvent( "dom", "go", "cap", flag ); + self.bot_lock_goal = true; self SetScriptGoal( flag.origin, 64 ); @@ -3600,6 +3658,8 @@ bot_dom_cap_think_loop() return; } + self BotNotifyBotEvent( "dom", "start", "cap", flag ); + self SetScriptGoal( self.origin, 64 ); while ( flag maps\mp\gametypes\dom::getFlagTeam() != myTeam && self isTouching( flag ) ) @@ -3613,6 +3673,8 @@ bot_dom_cap_think_loop() self thread bot_do_random_action_for_objective( flag ); } + self BotNotifyBotEvent( "dom", "stop", "cap", flag ); + self ClearScriptGoal(); self.bot_lock_goal = false; @@ -3709,6 +3771,8 @@ bot_hq_loop() //capture it + self BotNotifyBotEvent( "hq", "go", "cap" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); self thread bot_hq_go_cap( gameobj, radio ); @@ -3730,6 +3794,8 @@ bot_hq_loop() return; } + self BotNotifyBotEvent( "hq", "start", "cap" ); + self SetScriptGoal( self.origin, 64 ); while ( self isTouching( gameobj.trigger ) && gameobj.ownerTeam != myTeam && level.radio == radio ) @@ -3745,11 +3811,15 @@ bot_hq_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "hq", "stop", "cap" ); } else//we own it { if ( gameobj.objPoints[myteam].isFlashing ) //underattack { + self BotNotifyBotEvent( "hq", "start", "defend" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); self thread bot_hq_watch_flashing( gameobj, radio ); @@ -3758,6 +3828,8 @@ bot_hq_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "hq", "stop", "defend" ); return; } @@ -3890,6 +3962,8 @@ bot_sab_loop() // kill defuser if ( site isInUse() ) //somebody is defusing our bomb we planted { + self BotNotifyBotEvent( "sab", "start", "defuser" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); @@ -3899,6 +3973,8 @@ bot_sab_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sab", "stop", "defuser" ); return; } @@ -3943,6 +4019,8 @@ bot_sab_loop() if ( timepassed < 120 && timeleft >= 90 && randomInt( 100 ) < 98 ) return; + self BotNotifyBotEvent( "sab", "go", "plant" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 1 ); @@ -3958,6 +4036,8 @@ bot_sab_loop() return; } + self BotNotifyBotEvent( "sab", "start", "plant" ); + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); @@ -3966,6 +4046,8 @@ bot_sab_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sab", "stop", "plant" ); } else if ( bombteam == otherTeam ) // the bomb is theirs, we are on the defense { @@ -4004,6 +4086,8 @@ bot_sab_loop() if ( site isInUse() ) //somebody is planting { + self BotNotifyBotEvent( "sab", "start", "planter" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); self thread bot_inc_bots( site ); @@ -4014,6 +4098,8 @@ bot_sab_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sab", "stop", "planter" ); return; } @@ -4059,6 +4145,8 @@ bot_sab_loop() } // lets go defuse + self BotNotifyBotEvent( "sab", "go", "defuse" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 1 ); @@ -4076,6 +4164,8 @@ bot_sab_loop() return; } + self BotNotifyBotEvent( "sab", "start", "defuse" ); + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); @@ -4084,11 +4174,15 @@ bot_sab_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sab", "stop", "defuse" ); } else // we need to go get the bomb! { origin = ( bomb.curorigin[0], bomb.curorigin[1], bomb.curorigin[2] + 5 ); + self BotNotifyBotEvent( "sab", "start", "bomb" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); @@ -4098,6 +4192,8 @@ bot_sab_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sab", "stop", "bomb" ); return; } } @@ -4206,6 +4302,8 @@ bot_sd_defenders_loop( data ) if ( site isInUse() ) //somebody is planting { + self BotNotifyBotEvent( "sd", "start", "planter", site ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); @@ -4215,6 +4313,8 @@ bot_sd_defenders_loop( data ) self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sd", "stop", "planter", site ); return; } @@ -4262,6 +4362,8 @@ bot_sd_defenders_loop( data ) } // lets defuse + self BotNotifyBotEvent( "sd", "go", "defuse" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 1 ); self thread bot_inc_bots( defuse ); @@ -4278,6 +4380,8 @@ bot_sd_defenders_loop( data ) return; } + self BotNotifyBotEvent( "sd", "start", "defuse" ); + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); @@ -4285,6 +4389,8 @@ bot_sd_defenders_loop( data ) wait 1; self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sd", "stop", "defuse" ); } /* @@ -4351,6 +4457,8 @@ bot_sd_attackers_loop( data ) if ( site IsInUse() ) //somebody is defusing { + self BotNotifyBotEvent( "sd", "start", "defuser" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); @@ -4361,6 +4469,8 @@ bot_sd_attackers_loop( data ) self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sd", "stop", "defuser" ); return; } @@ -4436,6 +4546,8 @@ bot_sd_attackers_loop( data ) } // go get the bomb + self BotNotifyBotEvent( "sd", "start", "bomb" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 64 ); self thread bot_inc_bots( bomb ); @@ -4445,6 +4557,8 @@ bot_sd_attackers_loop( data ) self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sd", "stop", "bomb" ); return; } @@ -4475,6 +4589,8 @@ bot_sd_attackers_loop( data ) origin = ( plant.curorigin[0] + 50, plant.curorigin[1] + 50, plant.curorigin[2] + 5 ); + self BotNotifyBotEvent( "sd", "go", "plant", plant ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 1 ); self thread bot_go_plant( plant ); @@ -4490,6 +4606,8 @@ bot_sd_attackers_loop( data ) return; } + self BotNotifyBotEvent( "sd", "start", "plant", plant ); + self BotRandomStance(); self SetScriptGoal( self.origin, 64 ); @@ -4498,6 +4616,8 @@ bot_sd_attackers_loop( data ) self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "sd", "stop", "plant", plant ); } /* @@ -4546,10 +4666,22 @@ bot_cap_loop() if ( !isDefined( carrier ) ) //someone doesnt has our flag { if ( !isDefined( theirflag.carrier ) && DistanceSquared( self.origin, theirflag.curorigin ) < DistanceSquared( self.origin, myflag.curorigin ) ) //no one has their flag and its closer + { + self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); + self bot_cap_get_flag( theirflag ); + + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); + } else//go get it + { + self BotNotifyBotEvent( "cap", "start", "my_flag", myflag ); + self bot_cap_get_flag( myflag ); + self BotNotifyBotEvent( "cap", "stop", "my_flag", myflag ); + } + return; } else @@ -4557,7 +4689,11 @@ bot_cap_loop() if ( !theirflag maps\mp\gametypes\_gameobjects::isObjectAwayFromHome() && randomint( 100 ) < 50 ) { //take their flag + self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); + self bot_cap_get_flag( theirflag ); + + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); } else { @@ -4613,6 +4749,8 @@ bot_cap_loop() //go cap origin = myzone.curorigin; + self BotNotifyBotEvent( "cap", "start", "cap" ); + self.bot_lock_goal = true; self SetScriptGoal( origin, 32 ); @@ -4625,6 +4763,8 @@ bot_cap_loop() self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "cap", "stop", "cap" ); return; } @@ -4632,7 +4772,11 @@ bot_cap_loop() if ( !isDefined( carrier ) ) //if no one has enemy flag { + self BotNotifyBotEvent( "cap", "start", "their_flag", theirflag ); + self bot_cap_get_flag( theirflag ); + + self BotNotifyBotEvent( "cap", "stop", "their_flag", theirflag ); return; } @@ -4771,6 +4915,8 @@ bot_war_loop( data ) flag.useObj.numTouching[otherTeam] > flag.useObj.numTouching[myTeam] || data.rand > 90 || ourFlags < theirFlags ) { + self BotNotifyBotEvent( "twar", "go", "cap" ); + self.bot_lock_goal = true; self SetScriptGoal( flag.origin, 1 ); @@ -4786,6 +4932,8 @@ bot_war_loop( data ) return; } + self BotNotifyBotEvent( "twar", "start", "cap" ); + self SetScriptGoal( self.origin, 64 ); while ( flag maps\mp\gametypes\twar::GetFlagTeam() == "neutral" && self isTouching( flag ) ) @@ -4802,6 +4950,8 @@ bot_war_loop( data ) self ClearScriptGoal(); self.bot_lock_goal = false; + + self BotNotifyBotEvent( "twar", "stop", "cap" ); } else { diff --git a/main_shared/maps/mp/bots/_bot_utility.gsc b/main_shared/maps/mp/bots/_bot_utility.gsc index ab48aac..9ee8e0a 100644 --- a/main_shared/maps/mp/bots/_bot_utility.gsc +++ b/main_shared/maps/mp/bots/_bot_utility.gsc @@ -501,6 +501,14 @@ isSecondaryGrenade( gnade ) return ( gnade == "tabun_gas_mp" || gnade == "m8_white_smoke_mp" || gnade == "signal_flare_mp" ); } +/* + CoD4 +*/ +getBaseWeaponName( weap ) +{ + return strtok( weap, "_" )[0]; +} + /* Returns if the given weapon is full auto. */