BTW, are you aware that something got screwed up with the aiming script? Thety just glumly stare at the ground and fire now.
hmm. it was cause mine wasn't recompiling. got some patched code that oughta work though. lemme test it out.
well, its still behaving strangely, but they are shooting at things other than the ground now, and this is 0 console flooding. take a crack at it and see what you can figure out.
Code:
Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez
$botlist[0] = "DUMMY";
$numbots = 0;
function blist(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
echo(%bot SPC %bot.getName());
}
}
function clearthebots(){
MessageBoxYesNo( "Bot Genocide", "Do you really want to kill all the robobots?", "clearbotstwo();", "");
}
function clearbotstwo(){
MessageBoxYesNo( "You are a horrible person!", "Even the really cute ones?", "clearbots();", "");
}
//clearbots() server command
function serverCmdcB()
{
clearbots();
}
function clearbots(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
if(isobject(%bot)){
echo("killing " SPC %bot.getshapename()@"...");
%bot.kill();
}
}
$botlist = "";
$numbots = 0;
echo("killing follow bots...");
delbots();
}
function serverCmdcFA(%client,%wep,%number,%color)
{
createFighterArmy(%client,%wep,%number,%color);
}
function serverCmdrVB(%client,%numred,%numblue)
{
createRandomFighterArmy(%numred,"red");
createRandomFighterArmy(%numblue,"blue");
}
function serverCmdcRFA(%client,%number,%color)
{
createRandomFighterArmy(%number,%color);
}
function createFighterArmy(%client,%wep,%number,%color)
{
createFighterBot(%wep,%client.namebase,%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createFighterArmy,%client,%wep,%number,%color);
}
}
function createRandomFighterArmy(%number,%color)
{
cfb(%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createRandomFighterArmy,%number,%color);
}
}
function randomWeapon(){
%weapons[0] = "grenadelauncher";
%weapons[1] = "missilelauncher";
%weapons[2] = "flamethrower";
%weapons[3] = "acidgun";
return %weapons[getRandom(3)];
}
function randomPlayer(){
%index = getRandom(ClientGroup.getCount() - 1);
return ClientGroup.getObject(%index);
}
function cfb(%army){
%randomplayer = ClientGroup.getObject(getRandom(ClientGroup.getCount() - 1));
createFighterBot(randomWeapon(),%randomplayer.namebase,%army);
}
function createFighterBot(%wep,%targetName,%armyName)
{
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
if(%wep $= "") %wep = "sword";
%wep = %wep@"Image";
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%who.setTransform(pickSpawnPoint());
%who.setEnergyLevel(60);
%name = %targetname SPC "Bot" SPC %armyName;
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(%wep),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,mybotreaim,%who,%name);
}
function mybotreaim(%who,%name)
{
if(isobject(%who)){
%target = findClosestEnemy(%who);
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
}
if (isobject(%target))
{
%targetlocation = getWords(%target.getTransform(),0,2);
%who.setShapeName(%name);
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
%who.setMoveDestination(%targetlocation);
if ( %whoz < %targetz)
{
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel + 17));
}
if (inWater(%who) != 0){
%who.playThread(0,crouch);
if(%whoz > %targetz){
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel - 20));
}
} else{
%who.stopThread(0);
}
}
if(isobject(%who)){
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,mybotreaim,%who);
}
}
function getPlayerByName(%playername){
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++) {
%victim = ClientGroup.getObject( %clientIndex );
if (%victim.namebase $= %playername) return %victim;
}
return 0;
}
function getArmy(%who){
return getWord( %who.getShapeName(), 2);
}
//finds the closest member of a non-friendly army
function findClosestEnemy(%bot){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(!(getarmy(%next) $= getarmy(%bot))) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function listplayers(){
%center = "0 0 0";
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
echo("ID:" SPC %next SPC "NAME:" SPC %next.getshapename());
echo(" "@getarmy(%next));
%next = containerSearchNext();
}
}
function inWater(%bot){
if(isObject(%bot)){
%bt = %bot.getTransform();
%center = getWords(%bt, 0 ,2);
initContainerRadiusSearch(%center,1.0,$TypeMasks::WaterObjectType);
return containerSearchNext();
}
return 0;
}
function servercmdAddfbot(%client){
addbot(%client);
}
function servercmdSetTeam(%client,%color){
%firstword = getword(%client.player.getshapename(),0);
if(%firstword $= "") %firstword = "namelesswonder";
%client.player.setshapename(%firstword SPC "army" SPC %color);
}
What exactly is happening strangely? I'm going to load it up on C-0, but I'm interested to hear what you come up with.
They seem to be shooting at random things....load it and see for yourself. I cant figure out what they are shooting at.
[edit]
at each other, everytime a mybotreaim call is scheduled, before the call actually happens, the bot it is scheduled on get its name cleared
[edit]
fixed
Code:
[edit]
at each other, everytime a mybotreaim call is scheduled, before the call actually happens, the bot it is scheduled on get its name cleared
[edit]
fixed
Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez
$botlist[0] = "DUMMY";
$numbots = 0;
function blist(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
echo(%bot SPC %bot.getName());
}
}
function clearthebots(){
MessageBoxYesNo( "Bot Genocide", "Do you really want to kill all the robobots?", "clearbotstwo();", "");
}
function clearbotstwo(){
MessageBoxYesNo( "You are a horrible person!", "Even the really cute ones?", "clearbots();", "");
}
//clearbots() server command
function serverCmdcB()
{
clearbots();
}
function clearbots(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
if(isobject(%bot)){
echo("killing " SPC %bot.getshapename()@"...");
%bot.kill();
}
}
$botlist = "";
$numbots = 0;
echo("killing follow bots...");
delbots();
}
function serverCmdcFA(%client,%wep,%number,%color)
{
createFighterArmy(%client,%wep,%number,%color);
}
function serverCmdrVB(%client,%numred,%numblue)
{
createRandomFighterArmy(%numred,"red");
createRandomFighterArmy(%numblue,"blue");
}
function serverCmdcRFA(%client,%number,%color)
{
createRandomFighterArmy(%number,%color);
}
function createFighterArmy(%client,%wep,%number,%color)
{
createFighterBot(%wep,%client.namebase,%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createFighterArmy,%client,%wep,%number,%color);
}
}
function createRandomFighterArmy(%number,%color)
{
cfb(%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createRandomFighterArmy,%number,%color);
}
}
function randomWeapon(){
%weapons[0] = "grenadelauncher";
%weapons[1] = "missilelauncher";
%weapons[2] = "flamethrower";
%weapons[3] = "acidgun";
return %weapons[getRandom(3)];
}
function randomPlayer(){
%index = getRandom(ClientGroup.getCount() - 1);
return ClientGroup.getObject(%index);
}
function cfb(%army){
%randomplayer = ClientGroup.getObject(getRandom(ClientGroup.getCount() - 1));
createFighterBot(randomWeapon(),%randomplayer.namebase,%army);
}
function createFighterBot(%wep,%targetName,%armyName)
{
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
if(%wep $= "") %wep = "sword";
%wep = %wep@"Image";
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%who.setTransform(pickSpawnPoint());
%who.setEnergyLevel(60);
%name = %targetname SPC "Bot" SPC %armyName;
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(%wep),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,mybotreaim,%who,%name);
}
function mybotreaim(%who,%name)
{
if(isobject(%who)){
%target = findClosestEnemy(%who);
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
}
if (isobject(%target))
{
%targetlocation = getWords(%target.getTransform(),0,2);
%who.setShapeName(%name);
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
%who.setMoveDestination(%targetlocation);
if ( %whoz < %targetz)
{
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel + 17));
}
if (inWater(%who) != 0){
%who.playThread(0,crouch);
if(%whoz > %targetz){
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel - 20));
}
} else{
%who.stopThread(0);
}
}
if(isobject(%who)){
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,mybotreaim,%who,%name);
}
}
function getPlayerByName(%playername){
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++) {
%victim = ClientGroup.getObject( %clientIndex );
if (%victim.namebase $= %playername) return %victim;
}
return 0;
}
function getArmy(%who){
return getWord( %who.getShapeName(), 2);
}
//finds the closest member of a non-friendly army
function findClosestEnemy(%bot){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(!(getarmy(%next) $= getarmy(%bot))) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function listplayers(){
%center = "0 0 0";
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
echo("ID:" SPC %next SPC "NAME:" SPC %next.getshapename());
echo(" "@getarmy(%next));
%next = containerSearchNext();
}
}
function inWater(%bot){
if(isObject(%bot)){
%bt = %bot.getTransform();
%center = getWords(%bt, 0 ,2);
initContainerRadiusSearch(%center,1.0,$TypeMasks::WaterObjectType);
return containerSearchNext();
}
return 0;
}
function servercmdAddfbot(%client){
addbot(%client);
}
function servercmdSetTeam(%client,%color){
%firstword = getword(%client.player.getshapename(),0);
if(%firstword $= "") %firstword = "namelesswonder";
%client.player.setshapename(%firstword SPC "army" SPC %color);
}
thanks.
alright, check out this bad boy.
Code:
alright, check out this bad boy.
Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez
$botlist[0] = "DUMMY";
$numbots = 0;
function blist(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
echo(%bot SPC %bot.getName());
}
}
function clearthebots(){
MessageBoxYesNo( "Bot Genocide", "Do you really want to kill all the robobots?", "clearbotstwo();", "");
}
function clearbotstwo(){
MessageBoxYesNo( "You are a horrible person!", "Even the really cute ones?", "clearbots();", "");
}
//clearbots() server command
function serverCmdcB()
{
clearbots();
}
function clearbots(){
$gdelbots = 1;
echo("killing bots...");
}
function serverCmdcFA(%client,%wep,%number,%color)
{
createFighterArmy(%client,%wep,%number,%color);
}
function serverCmdrVB(%client,%numred,%numblue)
{
createRandomFighterArmy(%numred,"red");
createRandomFighterArmy(%numblue,"blue");
}
function serverCmdcRFA(%client,%number,%color)
{
createRandomFighterArmy(%number,%color);
}
function createFighterArmy(%client,%wep,%number,%color)
{
createFighterBot(%wep,%client.namebase,%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createFighterArmy,%client,%wep,%number,%color);
}
}
function createRandomFighterArmy(%number,%color)
{
cfb(%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createRandomFighterArmy,%number,%color);
}
}
function randomWeapon(){
%weapons[0] = "grenadelauncher";
%weapons[1] = "missilelauncher";
%weapons[2] = "flamethrower";
%weapons[3] = "acidgun";
return %weapons[getRandom(3)];
}
function randomPlayer(){
%index = getRandom(ClientGroup.getCount() - 1);
return ClientGroup.getObject(%index);
}
function cfb(%army){
%randomplayer = ClientGroup.getObject(getRandom(ClientGroup.getCount() - 1));
createFighterBot(randomWeapon(),%randomplayer.namebase,%army);
}
function createFighterBot(%wep,%targetName,%armyName)
{
$gdelbots = 0;
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
if(%wep $= "") %wep = "sword";
%wep = %wep@"Image";
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%who.setTransform(pickSpawnPoint());
%who.setEnergyLevel(60);
%name = %targetname SPC "Bot" SPC %armyName;
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(%wep),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,mybotreaim,%who,%name);
}
function mybotreaim(%who,%name)
{
if(isobject(%who)){
if($gdelbots == 1){
%who.kill();
return;
}
%target = findClosestEnemy(%who);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
if (isobject(%target))
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%targetlocation = getWords(%target.getTransform(),0,2);
} else{
%who.clearaim();
%whox = %whox + getrandom(2) - 1;
%whoy = %whox + getrandom(2) - 1;
%targetlocation = %whox SPC %whoy SPC %whoz;
}
%who.setShapeName(%name);
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%who.setMoveDestination(%targetlocation);
if ( %whoz < %targetz)
{
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel + 17));
}
if (inWater(%who) != 0){
%who.playThread(0,crouch);
if(%whoz > %targetz){
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel - 20));
}
} else{
%who.stopThread(0);
}
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,mybotreaim,%who,%name);
}
}
function getPlayerByName(%playername){
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++) {
%victim = ClientGroup.getObject( %clientIndex );
if (%victim.namebase $= %playername) return %victim;
}
return 0;
}
function getArmy(%who){
return getWord( %who.getShapeName(), 2);
}
//finds the closest member of a non-friendly army
function findClosestEnemy(%bot){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(!(getarmy(%next) $= getarmy(%bot))) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function listplayers(){
%center = "0 0 0";
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
echo("ID:" SPC %next SPC "NAME:" SPC %next.getshapename());
echo(" "@getarmy(%next));
%next = containerSearchNext();
}
}
function inWater(%bot){
if(isObject(%bot)){
%bt = %bot.getTransform();
%center = getWords(%bt, 0 ,2);
initContainerRadiusSearch(%center,1.0,$TypeMasks::WaterObjectType);
return containerSearchNext();
}
return 0;
}
function servercmdAddfbot(%client){
addbot(%client);
}
function servercmdSetTeam(%client,%color){
%firstword = getword(%client.player.getshapename(),0);
if(%firstword $= "") %firstword = "namelesswonder";
%client.player.setshapename(%firstword SPC "army" SPC %color);
}
its easier now, I split up into sections.
This version adds bodyguards, which aren't finished, but they are functional.
also, the camera code doesn't do anything, yet....
Code:
This version adds bodyguards, which aren't finished, but they are functional.
also, the camera code doesn't do anything, yet....
Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez
///////////
///general
///////////
$botlist[0] = "DUMMY";
$numbots = 0;
function blist(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
echo(%bot SPC %bot.getName());
}
}
function clearthebots(){
MessageBoxYesNo( "Bot Genocide", "Do you really want to kill all the robobots?", "clearbotstwo();", "");
}
function clearbotstwo(){
MessageBoxYesNo( "You are a horrible person!", "Even the really cute ones?", "clearbots();", "");
}
//clearbots() server command
function serverCmdcB()
{
clearbots();
}
function clearbots(){
$gdelbots = 1;
$botlist[0] = "DUMMY";
$numbots = 0;
echo("killing bots...");
}
function randomWeapon(){
%weapons[0] = "grenadelauncher";
%weapons[1] = "missilelauncher";
%weapons[2] = "flamethrower";
%weapons[3] = "acidgun";
return %weapons[getRandom(3)];
}
function randomPlayer(){
%index = getRandom(ClientGroup.getCount() - 1);
return ClientGroup.getObject(%index);
}
function move(%who,%targetlocation){
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%whox = getWord( %who.getTransform(), 0);
%whoy = getWord( %who.getTransform(), 1);
%whoz = getWord( %who.getTransform(), 2);
%who.setMoveDestination(%targetlocation);
if ( %whoz < %targetz)
{
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel + 17));
}
if (inWater(%who) != 0){
%who.playThread(0,crouch);
if(%whoz > %targetz){
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel - 20));
}
} else{
%who.stopThread(0);
}
}
function listplayers(){
%center = "0 0 0";
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
echo("ID:" SPC %next SPC "NAME:" SPC %next.getshapename());
echo(" "@getarmy(%next));
%next = containerSearchNext();
}
}
function inWater(%bot){
if(isObject(%bot)){
%bt = %bot.getTransform();
%center = getWords(%bt, 0 ,2);
initContainerRadiusSearch(%center,1.0,$TypeMasks::WaterObjectType);
return containerSearchNext();
}
return 0;
}
///////////
///end of general
///////////
////////////////////////////////
/// team stuff
///////////////////////////////
function serverCmdcFA(%client,%wep,%number,%color)
{
createFighterArmy(%client,%wep,%number,%color);
}
function serverCmdrVB(%client,%numred,%numblue)
{
createRandomFighterArmy(%numred,"red");
createRandomFighterArmy(%numblue,"blue");
}
function serverCmdcRFA(%client,%number,%color)
{
createRandomFighterArmy(%number,%color);
}
function createFighterArmy(%client,%wep,%number,%color)
{
createFighterBot(%wep,%client.namebase,%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createFighterArmy,%client,%wep,%number,%color);
}
}
function createRandomFighterArmy(%number,%color)
{
cfb(%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createRandomFighterArmy,%number,%color);
}
}
function cfb(%army){
%randomplayer = ClientGroup.getObject(getRandom(ClientGroup.getCount() - 1));
createFighterBot(randomWeapon(),%randomplayer.namebase,%army);
}
function createFighterBot(%wep,%targetName,%armyName)
{
$gdelbots = 0;
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
if(%wep $= "") %wep = "sword";
%wep = %wep@"Image";
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%who.setTransform(pickSpawnPoint());
%who.setEnergyLevel(60);
%name = getWord(%targetname,0) SPC "Bot" SPC %armyName;
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(%wep),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,mybotreaim,%who,%name);
}
function mybotreaim(%who,%name)
{
if(isobject(%who)){
if($gdelbots == 1){
%who.kill();
return;
}
%target = findClosestEnemy(%who);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
if (isobject(%target) && getarmy(%bot) !$= getarmy(%target))
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%targetlocation = getWords(%target.getTransform(),0,2);
} else{
%who.clearaim();
%whox = %whox + getrandom(2) - 1;
%whoy = %whox + getrandom(2) - 1;
%targetlocation = %whox SPC %whoy SPC %whoz;
}
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%who.setShapeName(%name);
move(%who,%targetlocation);
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,mybotreaim,%who,%name);
}
}
function getPlayerByName(%playername){
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++) {
%victim = ClientGroup.getObject( %clientIndex );
if (%victim.namebase $= %playername) return %victim;
}
return 0;
}
function getArmy(%who){
return getWord( %who.getShapeName(), 2);
}
//finds the closest member of a non-friendly army
function findClosestEnemy(%bot){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(!(getarmy(%next) $= getarmy(%bot))) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function servercmdAddfbot(%client){
addbot(%client);
}
function servercmdSetTeam(%client,%color){
%firstword = getword(%client.player.getshapename(),0);
if(%firstword $= "") %firstword = "namelesswonder";
%client.player.setshapename(%firstword SPC "army" SPC %color);
}
/////////////////////////////////////////
///end of team stuff
/////////////////////////////////////////
////////////////////////////////////////
////begin camera stuff
////////////////////////////////////////
function addCamera(){
%newcam = new Observer(){
dataBlock = CameraData;
};
}
/////////////////////////////////////////
///end of camera stuff
/////////////////////////////////////////
////////////////////////////////////////
////begin bodyguard stuff
////////////////////////////////////////
function createBodyGuard(%targetName)
{
if(!isobject(getPlayerByName(%targetname))) return 0;
$gdelbots = 0;
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%tt = %target.player.getTransform();
%who.setTransform((getwords(%tt,0) + 3) SPC getwords(%t,1) SPC getwords(%tt,2));
%who.setEnergyLevel(60);
%name = getWord(%targetname,0)@"'s bodyguard" SPC getarmy(%target.player);
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(flamethrowerimage),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,bodyguardreaim,%who,%target.player);
}
function bodyguardreaim(%who,%owner)
{
if(isobject(%who)){
if($gdelbots == 1){
%who.kill();
return;
}
if(isobject(%owner)){
%target = findThreat(%who,%owner);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
if (isobject(%target) && isValidTarget(%bot,%owner,%target))
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%targetlocation = %target.getTransform();
} else{
%who.clearaim();
%whox = %whox + getrandom(2) - 1;
%whoy = %whox + getrandom(2) - 1;
%targetlocation = %whox SPC %whoy SPC %whoz;
}
%who.setShapeName(getword(%owner.getshapename(),0)@"'s bodyguard" SPC getarmy(%owner));
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
move(%who,%owner.getTransform());
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,bodyguardreaim,%who,%owner);
} else {%who.kill();}
}
}
function findThreat(%bot,%owner){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(isValidTarget(%bot,%owner,%next)) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function isValidTarget(%bot,%owner,%next){
return (%next != %owner) && (%next.getshapename() !$= %bot.getshapename()) && ((getarmy(%bot) !$= getarmy(%next) && getarmy(%owner) !$= "") || (getarmy(%owner) $= ""));
}
Idea: Once the bots are within a certain (close) distance of their target, have them circle the target while still firing at them rather than charging up close like an idiot.
Idea: Send messages to the message area (that players see) when a bot is killed/dies.
Idea: Send messages to the message area (that players see) when a bot is killed/dies.
jpez wrote:
Idea: Once the bots are within a certain (close) distance of their target, have them circle the target while still firing at them rather than charging up close like an idiot.
Idea: Send messages to the message area (that players see) when a bot is killed/dies.
Idea: Send messages to the message area (that players see) when a bot is killed/dies.
both of those are good ideas
[edit]
after checking out the weapon scripts, they all seem to have an explosion, damageRadius, and radiusdamage, so I can't figure out why the other weapons won't work.
[edit2]
the non-bot-damaging ones seem to have a damage radius of 0.5 as well as occasionally a radiusdamage of 0.
[edit3]
here's the real reason:
onCollision of a bot damaging projectile:
Code:
function blackholeGunProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
}
here's the onCollision of a non bot damaging one:
function
Code:
MissileLauncherProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
tbmcollison(%this,%obj,%col,%fade,%pos,%normal);
tbmradiusDamage
(%obj, VectorAdd(%pos, VectorScale(%normal, 0.01)),
%this.damageRadius,%this.radiusDamage,%this.damageType,1000);
}
notice how
1) it calls tbmcollision twice
2) it calls tbmradiusDamage (the big issue).
bots can be damaged by any weapons. haven't finished the reverse yet, but i did add conrifle to their repertoire since that also has an explosion.
Code:
Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez
///////////
///general
///////////
$botlist[0] = "DUMMY";
$numbots = 0;
function blist(){
for(%i = 0; %i < $numbots; %i++){
%bot = $botlist[%i];
echo(%bot SPC %bot.getName());
}
}
function clearthebots(){
MessageBoxYesNo( "Bot Genocide", "Do you really want to kill all the robobots?", "clearbotstwo();", "");
}
function clearbotstwo(){
MessageBoxYesNo( "You are a horrible person!", "Even the really cute ones?", "clearbots();", "");
}
//clearbots() server command
function serverCmdcB()
{
clearbots();
}
function clearbots(){
$gdelbots = 1;
$botlist[0] = "DUMMY";
$numbots = 0;
echo("killing bots...");
}
function randomWeapon(){
%weapons[0] = "grenadelauncher";
%weapons[1] = "missilelauncher";
%weapons[2] = "flamethrower";
%weapons[3] = "acidgun";
%weapons[4] = "conrifle";
return %weapons[getRandom(4)];
}
function randomPlayer(){
%index = getRandom(ClientGroup.getCount() - 1);
return ClientGroup.getObject(%index);
}
function move(%who,%targetlocation){
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%whox = getWord( %who.getTransform(), 0);
%whoy = getWord( %who.getTransform(), 1);
%whoz = getWord( %who.getTransform(), 2);
%who.setMoveDestination(%targetlocation);
if ( %whoz < %targetz)
{
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel + 17));
}
if (inWater(%who) != 0){
%who.playThread(0,crouch);
if(%whoz > %targetz){
%bvel = %who.getVelocity();
%xvel = getWord(%bvel, 0);
%yvel = getWord(%bvel, 0);
%zvel = getWord(%bvel, 0);
%who.setVelocity(%xvel SPC %yvel SPC (%zvel - 20));
}
} else{
%who.stopThread(0);
}
}
function listplayers(){
%center = "0 0 0";
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
echo("ID:" SPC %next SPC "NAME:" SPC %next.getshapename());
echo(" "@getarmy(%next));
%next = containerSearchNext();
}
}
function inWater(%bot){
if(isObject(%bot)){
%bt = %bot.getTransform();
%center = getWords(%bt, 0 ,2);
initContainerRadiusSearch(%center,1.0,$TypeMasks::WaterObjectType);
return containerSearchNext();
}
return 0;
}
///////////
///end of general
///////////
////////////////////////////////
/// team stuff
///////////////////////////////
function serverCmdcFA(%client,%wep,%number,%color)
{
createFighterArmy(%client,%wep,%number,%color);
}
function serverCmdrVB(%client,%numred,%numblue)
{
createRandomFighterArmy(%numred,"red");
createRandomFighterArmy(%numblue,"blue");
}
function serverCmdcRFA(%client,%number,%color)
{
createRandomFighterArmy(%number,%color);
}
function createFighterArmy(%client,%wep,%number,%color)
{
createFighterBot(%wep,%client.namebase,%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createFighterArmy,%client,%wep,%number,%color);
}
}
function createRandomFighterArmy(%number,%color)
{
cfb(%color);
%number--;
if (%number > 0)
{
schedule(2000,0,createRandomFighterArmy,%number,%color);
}
}
function cfb(%army){
%randomplayer = ClientGroup.getObject(getRandom(ClientGroup.getCount() - 1));
createFighterBot(randomWeapon(),%randomplayer.namebase,%army);
}
function createFighterBot(%wep,%targetName,%armyName)
{
$gdelbots = 0;
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
if(%wep $= "") %wep = "sword";
%wep = %wep@"Image";
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%who.setTransform(pickSpawnPoint());
%who.setEnergyLevel(60);
%name = getWord(%targetname,0) SPC "Bot" SPC %armyName;
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(%wep),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,mybotreaim,%who,%name);
}
function mybotreaim(%who,%name)
{
if(isobject(%who)){
if($gdelbots == 1){
%who.kill();
return;
}
%target = findClosestEnemy(%who);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
if (isobject(%target) && getarmy(%bot) !$= getarmy(%target))
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%targetlocation = getWords(%target.getTransform(),0,2);
} else{
%who.clearaim();
%whox = %whox + getrandom(2) - 1;
%whoy = %whox + getrandom(2) - 1;
%targetlocation = %whox SPC %whoy SPC %whoz;
}
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
%who.setShapeName(%name);
move(%who,%targetlocation);
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,mybotreaim,%who,%name);
}
}
function getPlayerByName(%playername){
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++) {
%victim = ClientGroup.getObject( %clientIndex );
if (%victim.namebase $= %playername) return %victim;
}
return 0;
}
function getArmy(%who){
if(isobject(%who)){
return getWord( %who.getShapeName(), 2);
}
return "";
}
//finds the closest member of a non-friendly army
function findClosestEnemy(%bot){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(getarmy(%next) !$= getarmy(%bot)) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function servercmdAddfbot(%client){
addbot(%client);
}
function servercmdSetTeam(%client,%color){
%firstword = getword(%client.player.getshapename(),0);
if(%firstword $= "") %firstword = "namelesswonder";
%client.player.setshapename(%firstword SPC "army" SPC %color);
}
/////////////////////////////////////////
///end of team stuff
/////////////////////////////////////////
////////////////////////////////////////
////begin camera stuff
////////////////////////////////////////
function addCamera(){
%newcam = new Observer(){
dataBlock = CameraData;
};
}
/////////////////////////////////////////
///end of camera stuff
/////////////////////////////////////////
////////////////////////////////////////
////begin bodyguard stuff
////////////////////////////////////////
function createBodyGuard(%targetName)
{
if(!isobject(getPlayerByName(%targetname))) return 0;
$gdelbots = 0;
%who = new AIPlayer() {
dataBlock = LightMaleHumanArmor;
aiPlayer = true;
};
%target = getPlayerByName(%targetName);
MissionCleanup.add(%who);
echo("ID :"@%who);
// Player setup
%who.setMoveSpeed(1);
%tt = %target.player.getTransform();
%who.setTransform((getwords(%tt,0) + 3) SPC getwords(%t,1) SPC getwords(%tt,2));
%who.setEnergyLevel(60);
%name = getWord(%targetname,0)@"'s bodyguard" SPC getarmy(%target.player);
echo(%name);
%who.setName(%name);
%who.setshapename(%name);
%who.setSkinName(%armyName); //bots wear their army color
%who.mountImage(%target.headCode, $headSlot, 1, %target.headCodeColor);
%who.mountImage(%target.visorCode, $visorSlot, 1, %target.visorCodeColor);
%who.mountImage(%target.backCode, $backSlot, 1, %target.backCodeColor);
%who.mountImage(%target.leftHandCode, $leftHandSlot, 1, %target.leftHandCodeColor);
%who.mountImage(%target.chestCode, $chestSlot, 1, %target.chestdecalcode);
%who.mountImage(%target.faceCode, $faceSlot, 1, %target.facedecalcode);
%who.mountImage(nametoid(flamethrowerimage),$rightHandSlot);
$botlist[$numbots] = %who;
$numbots++;
schedule(1000,0,bodyguardreaim,%who,%target.player);
}
function bodyguardreaim(%who,%owner)
{
if(isobject(%who)){
if($gdelbots == 1){
%who.kill();
return;
}
if(isobject(%owner)){
%target = findThreat(%who,%owner);
%whox = getWord( %who.getTransform(), 0 );
%whoy = getWord( %who.getTransform(), 1 );
%whoz = getWord( %who.getTransform(), 2 );
if (isobject(%target) && isValidTarget(%bot,%owner,%target))
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%targetlocation = %target.getTransform();
} else{
%who.clearaim();
%whox = %whox + getrandom(2) - 1;
%whoy = %whox + getrandom(2) - 1;
%targetlocation = %whox SPC %whoy SPC %whoz;
}
%who.setShapeName(getword(%owner.getshapename(),0)@"'s bodyguard" SPC getarmy(%owner));
%targetx = getWord( %targetlocation, 0);
%targety = getWord( %targetlocation, 1);
%targetz = getWord( %targetlocation, 2);
move(%who,%owner.getTransform());
%who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
schedule(1000,0,bodyguardreaim,%who,%owner);
} else {%who.kill();}
}
}
function findThreat(%bot,%owner){
if(isobject(%bot)){
%center = getwords(%bot.getTransform(),0,2);
initContainerRadiusSearch(%center,1000000000.0,$TypeMasks::PlayerObjectType);
%next = containerSearchNext();
while(isObject(%next)){
if(isValidTarget(%bot,%owner,%next)) return %next;
%next = containerSearchNext();
}
}
return 0;
}
function isValidTarget(%bot,%owner,%next){
return (%next != %owner) && (%next.getshapename() !$= %bot.getshapename()) && ((getarmy(%bot) !$= getarmy(%next) && getarmy(%owner) !$= "") || (getarmy(%owner) $= ""));
}
//////////////////
//overrides
//////////////////
function tbmcollison(%tbmthis,%tbmobj,%tbmcol,%tbmfade,%tbmpos,%tbmnormal) {
%player = %tbmobj.client.player;
%client = %player.client;
if(!%player || %col.client.poon)
return 0;
if (%tbmcol.getClassName() !$= "Player" && %tbmcol.getClassName() !$= "AIplayer")
return;
%colData = %tbmcol.getDataBlock();
%colDataClass = %colData.classname;
if ( %tbmcol.getClassName() $= "AIPlayer") {
%tbmcol.damage(%tbmobj,%tbmpos,%tbmthis.directDamage,%tbmobj.getdatablock().damagemsg);
return;
}
if (%tbmcol.getClassName() $= "Player" ) {
%dmg = %tbmthis.directDamage;
%dmg = %tbmcol.client.DMShield? 0 : (%tbmcol.client.DMArmor == 1? 0.25 * %dmg : %dmg);
%tbmcol.damage(%tbmobj,%tbmpos,%dmg,%tbmobj.getdatablock().damagemsg);
return;
}
}
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
Page 9 of 12
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement