Author Topic: Creepers.  (Read 10680 times)

YEY

THE SUGGESTION HAS COME

/support -snip-
Can you snip that  please?

Model = easy
Getting textures into game = Hard.

the look like green smiley snake's or peni or something

the look like green smiley snake's or peni or something
Only friends think the creeper looks like a snake.

Guys..
We needs these green guys!


Asdf U guys!
what does that mean /ontopic dude you can make dem but amades have the good events here is my try onbottouched-->bot-->spawnexplode-->vieclhfinalexplode

what does that mean /ontopic dude you can make dem but amades have the good events here is my try onbottouched-->bot-->spawnexplode-->vieclhfinalexplode

May I slap you?

I made a Creeper type for Realcraft (blockland remake of Minecraft):

Code: [Select]
registerBotType(
   "mob",
   creeper,
   "Creeper",
   "runForce: 3000; maxForwardSpeed: 4;",
   "%this.loadCreeper(%obj);",
   0
);

function RC_Bot_Creeper::loadCreeper(%this,%obj)
{
   %obj.setFaceName("asciiTerror");
   %obj.unHideNode("skirtHip");
   %obj.setNodeColor("skirtHip","0 1 0 1");
   %obj.setNodeColor("headskin","0 1 0 1");
   %obj.setNodeColor("chest","0 1 0 1");
   %obj.setNodeColor("larm","0 1 0 1");
   %obj.setNodeColor("rarm","0 1 0 1");
   %obj.setNodeColor("lhand","0 1 0 1");
   %obj.setNodeColor("rhand","0 1 0 1");
   %obj.setNodeColor("lshoe","0 1 0 1");
   %obj.setNodeColor("rshoe","0 1 0 1");
   %obj.setNodeColor("pants","0 1 0 1");
}

function RC_Bot_Creeper::onCollision(%this, %obj, %col, %thing, %other)
{
   if(%col.getClassName() !$= Player)
      return;
   if(%obj.getState() $= Dead)
      return;
   if(%col.getState() $= Dead)
      return;
   
   if(%obj.ss_touched)
      return;   
   
   %obj.ss_touched = 1;
   %cl = %col.client;
   centerPrint(%cl,"\c6SSSSSSsss..",1.5);
   %obj.schedule(1500,spawnExplosion, rocketLauncherProjectile, 1.3, %col.client);
   %obj.schedule(1550,kill);
}

Oh, I completely forgot the registering script.

Code: [Select]
deleteVariables("$BOT::*");
$BOT::TotalBots = 0;

function registerBotType(%team,%id,%ui,%flags,%apflags,%sl,%canJump)
{
      %n = $BOT::TotalBots;
      echo("    [BOTS] Registering "@%ui SPC %team@" ("@%id@")");
      $BOT::TotalBots++;
      $BOT::ID[%n] = %id;
      $BOT::UI[%n] = %ui;
      $BOT::TM[%n] = %team;
      if(!isObject("RC_Bot_"@%id))
      {
         %flags = strReplace(%flags,": ","=");
         %str = "datablock PlayerData(RC_Bot_"@%id@" : PlayerNoJet) { jumper=\""@%canJump@"\"; uiName = \"[RC] Bot: "@%ui@"\"; "@%flags@"};";
         echo("        Registering DATABLOCK and FLAGS...");
         eval(%str);
      }
      echo("        Registering APPEARANCE and FUNCTIONS...");
      %str = "function RC_Bot_"@%id@"::onRemove(%this,%obj) { if(isObject(%obj.emptyshape)) %obj.emptyshape.delete(); } ";
      eval(%str);
      %str = "function RC_Bot_"@%id@"::onAdd(%this,%obj) { "@(%sl ? "%obj.setScale(\"1 1 1.5\");" : "") SPC %apflags@"}";
      eval(%str);
}

package RC_Bots_onAttacked
{
   function swordPRojectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
   {
      //if(%col.getClassName() $= AIPlayer && %obj.client.miniGame $= RC_Minigame)
      if(%col.getClassName() $= AIPlayer)
      {
         if(isFunction(%col.getDataBlock().getName()@"_onAttack"))
         {
            call(%col.getDataBlock().getName()@"_onAttack",%col,%obj.client);
         }
         else
         {
            %col.addHealth(-(%this.directDamage / 3));
            %col.target = %obj.client.player;
         }
      }
      else if(%col.getClassName() !$= Player)
         Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
   }
};
activatePackage(RC_Bots_onAttacked);

And the thinking script.

Code: [Select]
function RC_Bots_think(%this)
{
   // Realcraft Bots, version 1.5
   
   // Target Finding, Following and Checking   
   
   cancel(%this.think); // Cancel any double-runs.
   if(!isObject(%this))
      return;
   for(%i=0;%i<%this.getCount();%i++) // Do a loop on all bots.
   {
      %b=%this.getObject(%i); // Get the bot object.
      if(%b.getState() $= Dead) // We don't want to control dead bots.
         continue;
      %t=%b.target; // Get the target.
      if(isObject(%t) && %t.getState() !$= Dead) // Do we have a target?
      {
         // Yes! Get distance to target.
         %dist = vectorSub(%b.getPosition(),%t.getPosition());
         %dist = getWord(%dist,0) + getWord(%dist,1) + getWord(%dist,2);
         if(%dist >= 45 || %dist <= -45) // Has target escaped?
         {
            // Damn, abandon target.
            %b.target = 0;
            continue;
         }
         // Find height distance
         %hdif = getWord(%t.getPosition(),2) - getWord(%b.getPosition(),2);
         if(%hdif >= 1 && %b.getDataBlock().jumper) // Is target above us, and can we jump?
         {
            %b.playThread(1,jump); // Play Jump Animation
            %b.addVelocity("0 0 12.5"); // Jump!
         }
         while(isEventPending(%b.wanderloop))
            cancel(%b.wanderloop); // We don't want it to wander if we have a 100% good target.
         %b.setMoveDestination(%t.getPosition()); // Go to the target!
      }
      else // So, we DONT have a target?
      {
         // Seems that there is no target, find one.
         for(%i=0;%i<ClientGroup.getCount();%i++) // Search for targets on all clients
         // NOTE FOR ABOVE: Might change this to container raycast sometime.
         {
            %cl = ClientGroup.getObject(%i); // Get the client we found
            if(!isObject(%cl.player)) // We don't want to inspect dead people
               continue;
           
            %bpos=%b.getPosition(); // Save our position
%pos[%cnt++]=%cl.player.getPosition(); // Save their position
%ID[%cnt]=%cl.player; // Save their object
         }
         %shortDist=""; // Reset shortest distance.
         for(%i=1;%i<=%cnt;%i++) // Loop through all saved data.
         {
            %dist=vectorSub(%bpos,%pos[%i]); // Find distance
            if(getSubStr(%dist,0,1) $= "-") // Negative numbers dont matter
               %dist = getSubStr(%dist,1,strLen(%dist));
            if(%dist >= 15) // Damn, its too far away.
               continue;
            if(%shortDist$=""||%dist<%shortDist) // Is this the closest we've found yet?
            {
               %shortDist=%dist; // Sure is, save shortest distance.
               %target=%ID[%i]; // And save the object as the closest.
            }
         }
         if(isObject(%target)) // Did we find anything in range?
         {
            // We did! Set it as target.
            %b.target = %target;
         }
         else if(!isEventPending(%bot.wanderloop))
         {
            // We didn't, begin wandering and search next time.
            %b.wander(50);
         }
      }
   }
   %this.think = schedule(500,0,RC_Bots_think,%this);
}

function Player::wander(%this, %radius)
{
if(isObject(%this))
{
if(%this.getClassName() $= "AIplayer")
{
if(%radius < 1)
{
%radius = 25;
}
         %this.setMoveSpeed(1);
%tpos = %this.getPosition();
%ranV = getRandom(-25, 25) SPC getRandom(-25, 25) SPC 0;
%dest = vectorAdd(%tpos, %ranV);
while(isObject(firstWord(containerRaycast(%tpos, %dest, $TypeMasks::FxBrickAlwaysObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::VehicleBlockerObjectType))))
{
%ranV = getRandom(-25, 25) SPC getRandom(-25, 25) SPC 0;
%dest = vectorAdd(%tpos, %ranV);
if(%i++ > 10) //So the server doesn't crash if it's encased in something
{
break;
}
}
if(vectorDist(%dest, %this.spawnPosition) > %radius)
{
%dest = %this.spawnPosition;
jumpToZ(%this, getWord(2, %this.spawnPosition));
}
         %this.setMoveDestination(%dest, false);
%this.wanderloop = %this.schedule(5000, wander, %radius);
}
}
}
function jumpToZ(%obj, %z)
{
if(isObject(%obj) && strLen(getWord(%dest = %obj.spawnPosition, 2)) > 0)
{
if(%obj.getClassName() $= "AIplayer")
{
%pos = %obj.getPosition();
%obj.setMoveX(0);
if(getRandom() > 0.5)
{
%obj.setMoveX(getRandom(-1,1));
}
if(getWord(%pos, 2) < %z)
{
%obj.botjump();
%obj.jumpsched = %obj.schedule(1000, jumpToZ, %z);
}
}
}
}

Aaand spawning.

Code: [Select]
function RC_SpawnBot(%id,%pos,%ss)
{
   if(!isObject("RC_Bot_"@%id)) return;
   if(!isObject(RC_Bots)) new SimSet(RC_Bots);
   %bot = new AIPlayer()
   {
      position = %pos;
      datablock = nametoid("RC_Bot_"@%id);
      type = %id;
   };
   if(strLen(%ss) < 1) %ss = 1;
   if(%id $= slime)
      %bot.slimeSize = %ss;
   RC_Bots.add(%bot);
   cancel(RC_Bots.think);
   RC_Bots_think(RC_Bots);
   return %bot;
}


This would be a cool AI

I already posted a huge creeper AI above.