nope.

as of right now the weapons I know of that bots can do damage with are:

Con Rifle
Acid Gun
Flame thrower
grenade launcher
missile launcher
nuke (not one of the random weapon options in the script for obvious reasons)

I have not tested bot vs bot with the other weapons, but I do know that people can now attack bots with any weapon which has been the biggest complaint (aka no sniper practice = waaaahhhh)
I was bored today in nerd camp and wrote up this little laundry list of stuff:
    *Replace spaces in names to avoid messing up the word count, which will be used for more advanced stuff later on. (i.e. if the bot modeled on Kerm Martian, it should be named Kerm_Martian Bot).
    *Fix console-spamming on bot death: use object scheduling (%who.schedule(mybotreaim...)) rather than schedule(mybotreaim,%who...).
    *Fix "stuck on human" bug. I'm not sure what the cause of this is.
    *Rewrite AIPlayer:: functions
    *Research built-in function to find closest object
    *Fix flying - make it intelligent, more human-like

And an idea:
General Bot
-Makes strategic descions for his army
-Spawns as first member of give army
--Name: General_<color>
--Admiral Hat & Cape
--Check to see whether the army exists before assigning gneral status
-Issues orders via 4th word of name
--Member army bots check general's name for orders, then execute them.
--General can have much more intense, centralized planning
---Saves processing time
---Individual bots can be issued orders, or the army as a whole can be issued orders
----Example: "Attack" applies to all bots - default mode
----Example: "1.attack.jpez|2.attack.Kerm" could mean 1 bot should attack jpez and 2 bots should attack Kerm
---This allows for traditional centralized decision making or decentralized intelligent swarming
    *Replace spaces in names to avoid messing up the word count, which will be used for more advanced stuff later on. (i.e. if the bot modeled on Kerm Martian, it should be named Kerm_Martian Bot). done, just takes the first word of the name
    *Fix console-spamming on bot death: use object scheduling (%who.schedule(mybotreaim...)) rather than schedule(mybotreaim,%who...). done, it just does a check to see if the bot still exists before calling reaim. also clearbots() is more efficient now, and kills them quicker
    *Fix "stuck on human" bug. I'm not sure what the cause of this is. can you describe it?
    *Rewrite AIPlayer:: functions why?
    *Research built-in function to find closest object already done
    *Fix flying - make it intelligent, more human-like any ideas on how?
To shed a little light on the intelligent flying: one of the things I've noticed about the bots is that they seem to fly in jerks due to the frequency with which their overseer script is called. In order to resolve this, I think perhaps they should have their stuff rescheduled more often while flying and less often while on the ground or in water - what do you think? Either that, or the velocity coefficients could be tweaked a bit.
water I want to leave how it is for a bit, but I like that idea.
this just pwns. bodyguards become regular soldiers when the person they are protecting dies. bots can now use any weapons.


Code:
//----------------------------------------AI PLAYER SCRIPT
//written by members of Cemetech.net including Kerm Martian, elfprince13, & jpez

///////////////////
/// server commands
///////////////////
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 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);
}

function serverCmdCbg(%client){
   createBodyGuard(%client.namebase);   
}


///////////////////
///end of server commands
///////////////////

///////////
///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 robots?", "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(){
   %index = getRandom(41) + 1;
   %index = ($weapon[%index].getname() $= 'nuke' || $weapon[%index].getname() $= 'flashlight')? 41 : %index;
   return $weapon[%index].getname();
}

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 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;
}

/////////////////////////////////////////
///end of team 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) && isobject(%owner) && 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;
          }
          if(isobject(%owner) && isobject(%who)){
               %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);
          }
       }   
    }
    if(!isObject(%owner)){
       %army = getarmy(%who) $= "" ? "red" : getarmy(%who);
       %name = "exbodyguard bot" SPC %army;
       schedule(1000,0,mybotreaim,%who,%name);
    }
}

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){
   if(isobject(%bot) && isobject(%bot) && isobject(%next)) return (%next != %owner) && (%next.getshapename() !$= %bot.getshapename()) && ((getarmy(%bot) !$= getarmy(%next) && getarmy(%owner) !$= "") || (getarmy(%owner) $= ""));
   return 0;
}
////////////////////////////////////////
////end bodyguard stuff
////////////////////////////////////////


//////////////////
//overrides
//////////////////
function tbmcollison(%tbmthis,%tbmobj,%tbmcol,%tbmfade,%tbmpos,%tbmnormal) {
  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;
   }
   return;
 
}
No worky. Can you please document your code more thoroughly so I know what's going on when you make changes?
jpez wrote:
No worky. Can you please document your code more thoroughly so I know what's going on when you make changes?


what doesn't work?
Bots using any weapon does not work.
Hmm, I'll look through the code some more. I don't see anything obvious though.
jpez wrote:
Bots using any weapon does not work.


yes, it does. I got slaughtered repeatedly for half an hour.
You can clearly see in this screenshot (click to expand) that the bots congregated in a pile where they are not hurting each other:


Again, I'm BEGGING you to properly document the code line-by-line as necessary so we can tell what exactly you are doing and find bugs much more easily.
jpez wrote:
You can clearly see in this screenshot (click to expand) that the bots congregated in a pile where they are not hurting each other:
what server command did you use, and have you tried deleting the .dso? it works fine on all 3 computers Ive tested it on.

jpez wrote:
Again, I'm BEGGING you to properly document the code line-by-line as necessary so we can tell what exactly you are doing and find bugs much more easily.


bah, comments are for asm programs Wink
anywho, Ill try to document it better, but, its hard to break a habit of 5 years.
Jpez, it looks to me like the problem there is that a red and a blue bot spawned inside one another, hence the problem.
ok i can post here now to btw Smile
so im making the AI Bot Control GUI for tbm
which when u press a certain keybind (non as of now) will open the window
and allow users to easily spwan and control the bots

i have finished the functions and buttons needed for 3 functions
i have 2 or 3 left once i figure out what they do Smile
i will post a pic soon
Awesome, thanks Thermoman! I hope that it comes out well. A GUI would be an excellent addition to our script imho.
i am going to post screenshots later of the gui in game once i set up the keybinds and "hack" our files in
How about Alt+B?
*checks* not used for anything yet. Go for it.

the cmd has to be set by the player on first run
and i also found a bug that keeps spwaning the bots
idk if its in my code or the one posted above
we def. need to fix it
  
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
» Goto page Previous  1, 2, 3 ... 9, 10, 11, 12  Next
» View previous topic :: View next topic  
Page 10 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

 

Advertisement