Decoy question.

This is the development community to discuss tribes mod coding or to ask questions.

Moderator: Moderators

1 Sat Nov 30, 2013 2:21 pm

So im working on a spawning AI Decoy, all is going well except one thing.

When the decoy is spawned and set to the players team it prints in global chat "+]-[+Armageddon(bot) joined the so and so team"

How would i go about removing that, the decoy doesn't need to be announced to the server that kinda breaks it's purpose of fooling anyone.

GameBase::setTeam(%AIid,GameBase::getTeam(%player));

Thats what causes the join message and team assignment, removing this bit makes the bot team less which also doesn't work well.
User avatar
Armageddonv2
Ensign
Ensign
 
Posts: 51

2 Sun Dec 01, 2013 3:14 am

you first call client::setinitialTeam(%cl, %team), and then gamebase::setTeam(%pl, %team).
this avoids printing anything to global chat.

A good example is how the chameleon pack works in annihilation.

or here:
viewtopic.php?f=2&t=8333




... I can't believe I still remember this stuff
User avatar
C--
Sorry....
 
Posts: 3299

3 Sun Dec 01, 2013 12:41 pm

Awesome :)

Since i have the AI masters attention how does this look to you?

All this is to do is spawn a Bot that will target anything in range and attack it, nothing special.
It works up until i try to deploy another one while one is already active.
When i try to set the 2nd bot i get the error message saying i have one, but right after that the already spawned bot dies as if the schedule("Player::kill("@%AIid@");",25); time has been effected by trying to set another :?
Code: Select all
function ReconDecoy(%clientId, %player, %item) // called from Mine::onUse
{
   if (ReconDecoy::deployShape(%player,%item)) // call deployshape
   {
      //Player::decItemCount(%player,"Grenade"); Handled elsewhere
      //Player::decItemCount(%player,"Decoy");   Handled elsewhere
      $TeamItemCount[GameBase::getTeam(%player) @ "Decoy"]++; // add to count
   }
}

function ReconDecoy::deployShape(%player,%item)
{
   %team = GameBase::getTeam(%player); // get our team
   %client = Player::getClient(%player); // client is player
   %Name = Client::getName(%client); // get player name
   if($TeamItemCount[GameBase::getTeam(%player) @ "Decoy"] < $TeamItemMax[Decoy]) // count stuffs
   {
      if(GameBase::getLOSInfo(%player,3)) // deploy los range
      {
         %obj = getObjectType($los::object); // checking for things in los
         %Data = GameBase::getDataName($los::object);
         echo(%obj@", type: "@%Data);
         if(%obj == "SimTerrain" || %obj == "InteriorShape") // what it be yo, terrain / bases = OK start deploying
         {
            %LOS = $los::object;
            %num = $TeamItemCount[GameBase::getTeam(%player)@"Decoy"];
            %AIName = %Name@""; // AI takes players name
            if(Ai::spawn(%AIName,player::getarmor(%player),$los::position,"0 0 0") != "false")
            {
               %AIid = AI::getId(%AIName); // AIid = AIname
               %AIid.Owner = %player; // set owner
               %player.Owns = %AIid; // again
               playNextAnim(%AIid); // play ani
               GameBase::setRotation(%AIid,GameBase::getRotation(%client)); // make him face your current rot
               Client::setinitialTeam(%AIid, %team); // set team
               GameBase::setTeam(%AIid,GameBase::getTeam(%player));
               playSound(SoundPickupBackpack,$los::position); // some noise
               AI::SetVar(%AIName, pathtype, 2); //two way
               AI::SetVar(%AIName, triggerPct, 200); //pew pew
               AI::setVar(%AIName, iq, 5000); // Smart juice
               AI::setVar(%AIName, attackMode, 0); // leash like
               AI::setVar( %AIName, SpotDist, 200.0 ); // targeting range
               //AI::DirectiveTarget(%AIName, 2049, 100); // attacks you, for testing only
               AI::SetAutomaticTargets(%AIName); // hopefully acts like a zombie and tries to kill anything in range
               // Mount FX pack
               %AIPack = Player::getMountedItem(%client,1);   
               Player::setItemCount(%AIid, %AIPack, 1);   
               Player::mountItem(%AIid, %AIPack, 1);
               // Mount ID pack for turret targeting
               %AIPackID = Player::getMountedItem(%client,7);   
               Player::setItemCount(%AIid, %AIPackID, 1);   
               Player::mountItem(%AIid, %AIPackID, 7);
               // Mount Weapon that the player has equip durring deploy
               // Give ammo
               %AIWeapon = Player::getMountedItem(%client,0);   
               Player::setItemCount(%AIid, %AIWeapon, 1);   
               %AIAmmo = $WeaponAmmo[%AIWeapon];
               Player::setItemCount(%AIid,35,%AIAmmo);
               Player::mountItem(%AIid, %AIWeapon, 0);
               Player::trigger(%AIid,0,true); // Redundant i think?

               GameBase::startFadeOut(%player); // Fade the player out so decoy takes over
               Client::sendMessage(%client,0,"Your Decoy only has a 25 seconds."); // let player know how long decoy will live

               schedule("Player::kill("@%AIid@");",25); // 25 seconds later remove decoy, sloppy.. need a better way
               schedule("GameBase::startFadeIn("@%player@");",25); // return player from fade
               return true;
            }
            else
               Client::sendMessage(%client,0,"Could Not add Decoy, You already have one!"); // Players has one
         }
         else
            Client::sendMessage(%client,0,"Can only deploy on buildings or terrain"); // trying to dep on a static
      }
      else
         Client::sendMessage(%client,0,"Deploy position out of range"); // deploy out of los range
   }
   else
      Client::sendMessage(%client,0,"Deployable Item limit reached for " @ %item.description @ "s"); // deploy limit reached
   return false;
}


I normally don't mess with AI but since i'm copy/porting FireFall into mod i don't get to make the choice in what to make.
User avatar
Armageddonv2
Ensign
Ensign
 
Posts: 51

4 Sun Dec 01, 2013 5:02 pm

AI Names should be unique. Note that the AI name is not the player's name in the game, its a name that you use to address it (also using wildcards, like calling AI::Delete("bot*"); ).
Before taking any AI name you must make sure yourself that the name isn't taken. Otherwise, you may
remove the bot (with AI::Delete()) and reuse its name.

quick solution, assuming I know what you are trying to do:
Code: Select all
%AIName = %Name @ $armageddonv2bots++;


However I think you want the AI player's game name to be the same as your (hence decoy)
The player's name is the last parameter to AI::Spawn() which is missing in your code.
Code: Select all
AI::spawn( %aiName, %armorType, %spawnPos, %spawnRot, %__NAME__, "male2" )


last parameter is the voice pack. Doesn't do anything.
User avatar
C--
Sorry....
 
Posts: 3299

5 Mon Dec 02, 2013 11:15 pm

Thank you, that worked perfectly. My first time playing with AI i wasn't too sure what the params for them are. :|
User avatar
Armageddonv2
Ensign
Ensign
 
Posts: 51


Return to Coder's Hangout

Who is online

Users browsing this forum: No registered users and 2 guests

cron