This commit is contained in:
Your Name 2020-08-11 19:58:48 -06:00
parent 3f6c81b6a7
commit 617612e7bd
2 changed files with 189 additions and 73 deletions

View File

@ -90,6 +90,8 @@ init()
level.bots_nonfullautoguns["dragunov"] = true; level.bots_nonfullautoguns["dragunov"] = true;
level.bots_bloodfx = loadfx("impacts/flesh_hit_body_fatal_exit"); level.bots_bloodfx = loadfx("impacts/flesh_hit_body_fatal_exit");
PrecacheMpAnim("pb_combatrun_forward_loop");
PrecacheMpAnim("pt_stand_core_pullout");
level thread fixGamemodes(); level thread fixGamemodes();

View File

@ -55,6 +55,7 @@ connected()
self thread onPlayerSpawned(); self thread onPlayerSpawned();
self thread onDisconnected(); self thread onDisconnected();
self thread onGameEnded();
} }
/* /*
@ -73,6 +74,14 @@ onDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint
{ {
} }
onGameEnded()
{
self endon("disconnect");
level waittill("game_ended");
self botsDeleteFakeAnim();
}
onDisconnected() onDisconnected()
{ {
self waittill("disconnect"); self waittill("disconnect");
@ -142,66 +151,6 @@ resetBotVars()
self.bot.knifing = false; self.bot.knifing = false;
} }
makeFakeAnim()
{
if(isDefined(self.bot_anim))
return;
self.bot_anim = spawn("script_model", self.origin);
self.bot_anim setModel(self.model);
self.bot_anim LinkTo(self, "tag_origin", (0, 0, 0), (0, 0, 0));
self.bot_anim.headmodel = spawn( "script_model", self.bot_anim getTagOrigin( "j_spine4" ));
self.bot_anim.headmodel setModel(self.headmodel);
self.bot_anim.headmodel.angles = (270, 0, 270);
self.bot_anim.headmodel linkto( self.bot_anim, "j_spine4" );
if(isDefined(self))
{
self thread maps\mp\gametypes\_weapons::detach_all_weapons();
self botHideParts();
}
}
botsDeleteFakeAnim()
{
if(!isDefined(self.bot_anim))
return;
self.bot_anim.headmodel delete();
self.bot_anim.headmodel = undefined;
self.bot_anim delete();
self.bot_anim = undefined;
if(isDefined(self))
{
self botShowParts();
self thread maps\mp\gametypes\_weapons::stowedWeaponsRefresh();
}
}
botHideParts()
{
//hideallparts
self hidepart("j_ankle_le");//this is the only place where bot cannot be shot at...
self hidepart("j_hiptwist_le");
self hidepart("j_head");
self hidepart("j_helmet");
self hidepart("j_eyeball_le");
self hidepart("j_clavicle_le");
}
botShowParts()
{
self showpart("j_ankle_le");
self showpart("j_hiptwist_le");
self showpart("j_head");
self showpart("j_helmet");
self showpart("j_eyeball_le");
self showpart("j_clavicle_le");
//showallparts
}
/* /*
When the bot spawns. When the bot spawns.
*/ */
@ -794,25 +743,27 @@ onWeaponChange()
if(isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != "none") if(isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != "none")
self setSpawnWeapon(self.lastDroppableWeapon); self setSpawnWeapon(self.lastDroppableWeapon);
break; break;
case "ac130_105mm_mp":
case "ac130_40mm_mp":
case "ac130_25mm_mp":
case "heli_remote_mp":
break;
default: default:
self thread doSwitch(); self thread doSwitch(newWeapon);
break; break;
} }
} }
} }
doSwitch() doSwitch(newWeapon)
{ {
self endon("disconnect"); self endon("disconnect");
self endon("death"); self endon("death");
self notify("bot_weapon_change"); self notify("bot_weapon_change");
self endon("bot_weapon_change"); self endon("bot_weapon_change");
if (self.bot.climbing)
return;
if (isDefined(self.lastDroppableWeapon) && self.lastDroppableWeapon != newWeapon)
return;
self thread botDoAnim("pt_stand_core_pullout", 0.5, true);
self.bot.isswitching = true; self.bot.isswitching = true;
wait 1; // fast pullout? wait 1; // fast pullout?
@ -967,8 +918,6 @@ spawned()
self thread onNewEnemy(); self thread onNewEnemy();
self thread walk(); self thread walk();
self makeFakeAnim();
self notify("bot_spawned"); self notify("bot_spawned");
} }
@ -2039,27 +1988,60 @@ knife(ent, knifeDist)
curWeap = self GetCurrentWeapon(); curWeap = self GetCurrentWeapon();
usedRiot = self.hasRiotShieldEquipped; usedRiot = self.hasRiotShieldEquipped;
distsq = DistanceSquared(self.origin, ent.origin); distsq = DistanceSquared(self.origin, ent.origin);
inLastStand = isDefined(self.lastStand);
stance = self getStance();
damage = 135; damage = 135;
if (usedRiot) if (usedRiot)
damage = 52; damage = 52;
botAnim = "";
botAnimTime = 0;
lastWeap = self GetCurrentWeapon();
hasC4 = self HasWeapon("c4_mp");
if (!hasC4)
self giveWeapon("c4_mp");
self setSpawnWeapon("c4_mp");
// play sound // play sound
if (usedRiot) if (usedRiot)
{ {
self playSound("melee_riotshield_swing"); self playSound("melee_riotshield_swing");
botAnim = "pt_melee_shield";
botAnimTime = 1;
} }
else else
{ {
if ((distsq / knifeDist) < 0.3333333) if ((distsq / knifeDist) < 0.3333333)
{ {
self playSound("melee_swing_small"); self playSound("melee_swing_small");
if (stance != "prone")
{
botAnim = "pt_melee_pistol_1";
botAnimTime = 1;
}
else
{
botAnim = "pt_melee_prone_pistol";
botAnimTime = 1;
}
} }
else else
{ {
self playSound("melee_swing_ps_large"); self playSound("melee_swing_ps_large");
botAnim = "pt_melee_pistol_2";
botAnimTime = 1.5;
} }
} }
if (inLastStand)
{
botAnim = "pt_laststand_melee";
botAnimTime = 1.5;
}
self thread botDoAnim(botAnim, botAnimTime, true);
wait 0.15; wait 0.15;
if (isDefined(ent) && isAlive(ent) && randomInt(20)) // 5percent chance of missing if (isDefined(ent) && isAlive(ent) && randomInt(20)) // 5percent chance of missing
@ -2067,10 +2049,13 @@ knife(ent, knifeDist)
if (isplay) if (isplay)
{ {
// teleport to target // teleport to target
pushOutDir = VectorNormalize((self.origin[0], self.origin[1], 0)-(ent.origin[0], ent.origin[1], 0)); if (!inLastStand)
pushoutPos = self.origin + (pushOutDir * (60-distance(ent.origin,self.origin))); {
self SetOrigin((pushoutPos[0], pushoutPos[1], ent.origin[2])); pushOutDir = VectorNormalize((self.origin[0], self.origin[1], 0)-(ent.origin[0], ent.origin[1], 0));
self notify("kill_goal"); pushoutPos = self.origin + (pushOutDir * (60-distance(ent.origin,self.origin)));
self SetOrigin((pushoutPos[0], pushoutPos[1], ent.origin[2]));
self notify("kill_goal");
}
for (;;) for (;;)
{ {
@ -2118,6 +2103,10 @@ knife(ent, knifeDist)
else else
wait 2; wait 2;
if (!hasC4)
self takeWeapon("c4_mp");
self setSpawnWeapon(lastWeap);
self.bot.knifing = false; self.bot.knifing = false;
} }
@ -2326,3 +2315,128 @@ bot_lookat(pos, time)
wait 0.05; wait 0.05;
} }
} }
botDoingAnim(animName)
{
if (!isDefined(self.bot_anim))
return false;
return (self.bot_anim.animation == animName);
}
botDoAnim(animName, time, isActiveAnim)
{
self endon("death");
self endon("disconnect");
if(!isDefined(self.bot_anim))
self makeFakeAnim();
if (!isDefined(isActiveAnim))
isActiveAnim = false;
if (!isActiveAnim && self.bot_anim.inActiveAnim)
return;
self notify("bot_kill_anim");
self endon("bot_kill_anim");
self.bot_anim.inActiveAnim = isActiveAnim;
self.bot_anim.animation = animName;
self.bot_anim scriptModelPlayAnim(animName);
if (isDefined(time))
wait time;
self.bot_anim.inActiveAnim = false;
}
makeFakeAnim()
{
if(isDefined(self.bot_anim))
return;
self.bot_anim = spawn("script_model", self.origin);
self.bot_anim setModel(self.model);
self.bot_anim LinkTo(self, "tag_origin", (0, 0, 0), (0, 0, 0));
self.bot_anim notsolid();
self.bot_anim.headmodel = spawn( "script_model", self.bot_anim getTagOrigin( "j_spine4" ));
self.bot_anim.headmodel setModel(self.headmodel);
self.bot_anim.headmodel.angles = (270, 0, 270);
self.bot_anim.headmodel linkto( self.bot_anim, "j_spine4" );
self.bot_anim.headmodel notsolid();
self.bot_anim.animation = undefined;
self.bot_anim.inActiveAnim = false;
self showFakeAnim();
}
botsDeleteFakeAnim()
{
if(!isDefined(self.bot_anim))
return;
self hideFakeAnim();
self notify("bot_kill_anim");
self.bot_anim.headmodel delete();
self.bot_anim.headmodel = undefined;
self.bot_anim delete();
self.bot_anim = undefined;
}
showFakeAnim()
{
if(isDefined(self))
{
self thread maps\mp\gametypes\_weapons::detach_all_weapons();
self botHideParts();
}
if(!isDefined(self.bot_anim))
return;
self.bot_anim show();
self.bot_anim.hidden = false;
self.bot_anim.headmodel show();
}
hideFakeAnim()
{
if(isDefined(self))
{
self botShowParts();
self thread maps\mp\gametypes\_weapons::stowedWeaponsRefresh();
}
if(!isDefined(self.bot_anim))
return;
self.bot_anim hide();
self.bot_anim.hidden = true;
self.bot_anim.headmodel hide();
}
botHideParts()
{
//hideallparts
self hidepart("j_ankle_le");//this is the only place where bot cannot be shot at...
self hidepart("j_hiptwist_le");
self hidepart("j_head");
self hidepart("j_helmet");
self hidepart("j_eyeball_le");
self hidepart("j_clavicle_le");
}
botShowParts()
{
self showpart("j_ankle_le");
self showpart("j_hiptwist_le");
self showpart("j_head");
self showpart("j_helmet");
self showpart("j_eyeball_le");
self showpart("j_clavicle_le");
//showallparts
}