mirror of
https://github.com/ineedbots/iw3_bot_warfare.git
synced 2025-04-22 18:25:44 +00:00
funcs and docs, update to date with mw2
This commit is contained in:
parent
c220c36cf8
commit
a1ae78401e
@ -981,33 +981,6 @@ doSemiTime()
|
|||||||
self.bot.semi_time = false;
|
self.bot.semi_time = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Returns a random grenade in the bot's inventory.
|
|
||||||
*/
|
|
||||||
getValidGrenade()
|
|
||||||
{
|
|
||||||
grenadeTypes = [];
|
|
||||||
grenadeTypes[grenadeTypes.size] = "frag_grenade_mp";
|
|
||||||
grenadeTypes[grenadeTypes.size] = "smoke_grenade_mp";
|
|
||||||
grenadeTypes[grenadeTypes.size] = "flash_grenade_mp";
|
|
||||||
grenadeTypes[grenadeTypes.size] = "concussion_grenade_mp";
|
|
||||||
|
|
||||||
possibles = [];
|
|
||||||
|
|
||||||
for(i = 0; i < grenadeTypes.size; i++)
|
|
||||||
{
|
|
||||||
if ( !self hasWeapon( grenadeTypes[i] ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if ( !self getAmmoCount( grenadeTypes[i] ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
possibles[possibles.size] = grenadeTypes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return random(possibles);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns true if the bot can fire their current weapon.
|
Returns true if the bot can fire their current weapon.
|
||||||
*/
|
*/
|
||||||
|
@ -2,11 +2,17 @@
|
|||||||
#include maps\mp\_utility;
|
#include maps\mp\_utility;
|
||||||
#include maps\mp\gametypes\_hud_util;
|
#include maps\mp\gametypes\_hud_util;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns if player is the host
|
||||||
|
*/
|
||||||
is_host()
|
is_host()
|
||||||
{
|
{
|
||||||
return (isDefined(self.pers["bot_host"]) && self.pers["bot_host"]);
|
return (isDefined(self.pers["bot_host"]) && self.pers["bot_host"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Setups the host variable on the player
|
||||||
|
*/
|
||||||
doHostCheck()
|
doHostCheck()
|
||||||
{
|
{
|
||||||
self.pers["bot_host"] = false;
|
self.pers["bot_host"] = false;
|
||||||
@ -57,6 +63,9 @@ BotGetRandom()
|
|||||||
return self.bot.rand;
|
return self.bot.rand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a random number thats different everytime it changes target
|
||||||
|
*/
|
||||||
BotGetTargetRandom()
|
BotGetTargetRandom()
|
||||||
{
|
{
|
||||||
if (!isDefined(self.bot.target))
|
if (!isDefined(self.bot.target))
|
||||||
@ -73,16 +82,70 @@ BotPressADS(time)
|
|||||||
self maps\mp\bots\_bot_internal::pressADS(time);
|
self maps\mp\bots\_bot_internal::pressADS(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bot presses the frag button for time.
|
||||||
|
*/
|
||||||
BotPressFrag(time)
|
BotPressFrag(time)
|
||||||
{
|
{
|
||||||
self maps\mp\bots\_bot_internal::frag(time);
|
self maps\mp\bots\_bot_internal::frag(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bot presses the smoke button for time.
|
||||||
|
*/
|
||||||
BotPressSmoke(time)
|
BotPressSmoke(time)
|
||||||
{
|
{
|
||||||
self maps\mp\bots\_bot_internal::smoke(time);
|
self maps\mp\bots\_bot_internal::smoke(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a valid grenade launcher weapon
|
||||||
|
*/
|
||||||
|
getValidTube()
|
||||||
|
{
|
||||||
|
weaps = self getweaponslist();
|
||||||
|
|
||||||
|
for (i = 0; i < weaps.size; i++)
|
||||||
|
{
|
||||||
|
weap = weaps[i];
|
||||||
|
|
||||||
|
if(!self getAmmoCount(weap))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (isSubStr(weap, "gl_") && !isSubStr(weap, "_gl_"))
|
||||||
|
return weap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a random grenade in the bot's inventory.
|
||||||
|
*/
|
||||||
|
getValidGrenade()
|
||||||
|
{
|
||||||
|
grenadeTypes = [];
|
||||||
|
grenadeTypes[grenadeTypes.size] = "frag_grenade_mp";
|
||||||
|
grenadeTypes[grenadeTypes.size] = "smoke_grenade_mp";
|
||||||
|
grenadeTypes[grenadeTypes.size] = "flash_grenade_mp";
|
||||||
|
grenadeTypes[grenadeTypes.size] = "concussion_grenade_mp";
|
||||||
|
|
||||||
|
possibles = [];
|
||||||
|
|
||||||
|
for(i = 0; i < grenadeTypes.size; i++)
|
||||||
|
{
|
||||||
|
if ( !self hasWeapon( grenadeTypes[i] ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( !self getAmmoCount( grenadeTypes[i] ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
possibles[possibles.size] = grenadeTypes[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return random(possibles);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Returns if the bot is fragging.
|
Returns if the bot is fragging.
|
||||||
*/
|
*/
|
||||||
@ -150,6 +213,9 @@ HasScriptGoal()
|
|||||||
return (isDefined(self GetScriptGoal()));
|
return (isDefined(self GetScriptGoal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the pos of the bot's goal
|
||||||
|
*/
|
||||||
GetScriptGoal()
|
GetScriptGoal()
|
||||||
{
|
{
|
||||||
return self.bot.script_goal;
|
return self.bot.script_goal;
|
||||||
@ -177,16 +243,38 @@ ClearScriptGoal()
|
|||||||
self SetScriptGoal(undefined, 0);
|
self SetScriptGoal(undefined, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sets the aim position of the bot
|
||||||
|
*/
|
||||||
SetScriptAimPos(pos)
|
SetScriptAimPos(pos)
|
||||||
{
|
{
|
||||||
self.bot.script_aimpos = pos;
|
self.bot.script_aimpos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Clears the aim position of the bot
|
||||||
|
*/
|
||||||
ClearScriptAimPos()
|
ClearScriptAimPos()
|
||||||
{
|
{
|
||||||
self SetScriptAimPos(undefined);
|
self SetScriptAimPos(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the aim position of the bot
|
||||||
|
*/
|
||||||
|
GetScriptAimPos()
|
||||||
|
{
|
||||||
|
return self.bot.script_aimpos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns if the bot has a aim pos
|
||||||
|
*/
|
||||||
|
HasScriptAimPos()
|
||||||
|
{
|
||||||
|
return isDefined(self GetScriptAimPos());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Sets the script enemy for a bot.
|
Sets the script enemy for a bot.
|
||||||
*/
|
*/
|
||||||
@ -225,6 +313,9 @@ WeaponIsFullAuto(weap)
|
|||||||
return isDefined(weaptoks[0]) && isString(weaptoks[0]) && isdefined(level.bots_fullautoguns[weaptoks[0]]);
|
return isDefined(weaptoks[0]) && isString(weaptoks[0]) && isdefined(level.bots_fullautoguns[weaptoks[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Bot will stop moving
|
||||||
|
*/
|
||||||
BotStopMoving(what)
|
BotStopMoving(what)
|
||||||
{
|
{
|
||||||
self.bot.stop_move = what;
|
self.bot.stop_move = what;
|
||||||
@ -386,21 +477,33 @@ isItemUnlocked(what, lvl)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the weapon is allowed to be dropped
|
||||||
|
*/
|
||||||
isWeaponDroppable(weap)
|
isWeaponDroppable(weap)
|
||||||
{
|
{
|
||||||
return (maps\mp\gametypes\_weapons::mayDropWeapon(weap));
|
return (maps\mp\gametypes\_weapons::mayDropWeapon(weap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the player is defusing
|
||||||
|
*/
|
||||||
IsDefusing()
|
IsDefusing()
|
||||||
{
|
{
|
||||||
return (isDefined(self.isDefusing) && self.isDefusing);
|
return (isDefined(self.isDefusing) && self.isDefusing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the play is planting
|
||||||
|
*/
|
||||||
isPlanting()
|
isPlanting()
|
||||||
{
|
{
|
||||||
return (isDefined(self.isPlanting) && self.isPlanting);
|
return (isDefined(self.isPlanting) && self.isPlanting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
If the player is in laststand
|
||||||
|
*/
|
||||||
inLastStand()
|
inLastStand()
|
||||||
{
|
{
|
||||||
return (isDefined(self.lastStand) && self.lastStand);
|
return (isDefined(self.lastStand) && self.lastStand);
|
||||||
@ -508,6 +611,9 @@ getConeDot(to, from, dir)
|
|||||||
return vectordot(dirToTarget, forward);
|
return vectordot(dirToTarget, forward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the distance squared in a 2d space
|
||||||
|
*/
|
||||||
DistanceSquared2D(to, from)
|
DistanceSquared2D(to, from)
|
||||||
{
|
{
|
||||||
to = (to[0], to[1], 0);
|
to = (to[0], to[1], 0);
|
||||||
@ -630,6 +736,9 @@ cac_init_patch()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Tokenizes a string (strtok has limits...) (only one char tok)
|
||||||
|
*/
|
||||||
tokenizeLine(line, tok)
|
tokenizeLine(line, tok)
|
||||||
{
|
{
|
||||||
tokens = [];
|
tokens = [];
|
||||||
@ -653,6 +762,9 @@ tokenizeLine(line, tok)
|
|||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Parses tokens into a waypoint obj
|
||||||
|
*/
|
||||||
parseTokensIntoWaypoint(tokens)
|
parseTokensIntoWaypoint(tokens)
|
||||||
{
|
{
|
||||||
waypoint = spawnStruct();
|
waypoint = spawnStruct();
|
||||||
@ -681,6 +793,9 @@ parseTokensIntoWaypoint(tokens)
|
|||||||
return waypoint;
|
return waypoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns a bot's name to be used. Reads from botnames.txt
|
||||||
|
*/
|
||||||
getABotName()
|
getABotName()
|
||||||
{
|
{
|
||||||
if (!isDefined(level.bot_names))
|
if (!isDefined(level.bot_names))
|
||||||
@ -715,6 +830,9 @@ getABotName()
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Read from file a csv, and returns an array of waypoints
|
||||||
|
*/
|
||||||
readWpsFromFile(mapname)
|
readWpsFromFile(mapname)
|
||||||
{
|
{
|
||||||
waypoints = [];
|
waypoints = [];
|
||||||
@ -925,6 +1043,9 @@ getGoodMapAmount()
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the friendly user name for a given map's codename
|
||||||
|
*/
|
||||||
getMapName(map)
|
getMapName(map)
|
||||||
{
|
{
|
||||||
switch(map)
|
switch(map)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user