Game Development Community

dev|Pro Game Development Curriculum

Gibby's Greebles # 2: afxExplodo

by Gibby · 03/19/2014 (7:43 am) · 1 comments

Here's another Greeble [or should I call them 'stupid Torque Tricks?]:

I setup TGE-style team skins for some of my junk models. When the piece is added to the level, it will randomly choose a color, and be given a random amount of health and a %obj.explodo tag.

I then added this resource:
www.garagegames.com/community/resources/view/19301

If it's explodo tag is true, it will randomly cast 'Try Physical Zone' on itself, scattering it and any loose objects around it... During the game, any junk cars hit by projectiles could randomly explode!!!

//****************************************************************
// "Gibby's Greebles" 
// scrapyardGreeble.cs
// procedural generation of scrapyard placement
//****************************************************************

//echo("scrapyardGreeble.cs->exec'd here ->->->->->->->->->->->->->");

//****************************************************************
// scrapyard Datablocks
//****************************************************************

datablock StaticShapeData(junkCar1)
{
   //Mission editor category, this datablock will show up in the
   //specified category under the "shapes" root category.
   category = "GreebleMarker";
   isLadaCar =1;
   explodo = 1;
   class = "Junk";
   //Basic Item properties
   shapeFile = "art/shapes/props/scrapYard/lada1.dts";
};

datablock StaticShapeData(junkCar2)
{
   //Mission editor category, this datablock will show up in the
   //specified category under the "shapes" root category.
   category = "GreebleMarker";
   isLadaCar =1;
   class = "Junk";
   
   //Basic Item properties
   shapeFile = "art/shapes/props/scrapYard/lada2.dts";
};

datablock StaticShapeData(junkCar3)
{
   //Mission editor category, this datablock will show up in the
   //specified category under the "shapes" root category.
   category = "GreebleMarker";
   isLadaCar =1;
   explodo = 1;
   class = "Junk";
   
   //Basic Item properties
   shapeFile = "art/shapes/props/scrapYard/lada3.dts";
};

datablock StaticShapeData(ladabarrel)
{
   //Mission editor category, this datablock will show up in the
   //specified category under the "shapes" root category.
   category = "GreebleMarker";
   explodo = 1;
   class = "Junk";
   
   //Basic Item properties
   shapeFile = "art/shapes/props/scrapYard/ladabarrel.dts";
};

datablock StaticShapeData(junkTV)
{
   //Mission editor category, this datablock will show up in the
   //specified category under the "shapes" root category.
   category = "GreebleMarker";
   class = "Junk";
   
   //Basic Item properties
   shapeFile = "art/shapes/props/scrapYard/ladabarrel.dts";
};

//****************************************************************
// scrapyardMarker add/remove/initialize
//****************************************************************

function Junk::onAdd(%this, %obj)
{
   echo("weaponGreeble.cs->Junk::onAdd this: "@%this@" obj: "@%obj);
   //reset the object
   %obj.initialized = 0;   
   // Place into correct group
   if( !isObject(scrapyardMarkerGroup) )
   {
      echo("greebles.cs->generateGreebleMarkers creating scrapyardMarkerGroup");
      %grp = new SimGroup(scrapyardMarkerGroup);
      
      if(!isObject(MissionCleanup))
      {
         new SimGroup(MissionCleanup);
         
         // Make the MissionCleanup group the place where all new objects will automatically be added.
         $instantGroup = MissionCleanup;
      }
      MissionCleanup.add(%grp);
   }
   else
      scrapyardMarkerGroup.add(%obj);

}

function Junk::initializeObjective(%this, %obj)
{
      
   //Gibby ideally, this would be a list of weapons in a text string file that would be parsed
   //For now, we'll hard-wire them
   if(!isObject(%obj))
      return;
      
   if(%obj.getDataBlock().isLadaCar = 1)
   {
      //echo("whatever"); 
      %skinName = getRandom(1,8);
      if(%skinName < 7)
         %obj.setSkinName($Pref::Server::teamColor[%skinName]); 
      else if(%skinName == 7)
         %obj.setSkinName(burn);
      else
         %obj.setSkinName(burn2);
   }
   
   if(%obj.getDataBlock().explodo = 1)
   {
            
      %obj.damage = getRandom(10,100);
      
      %randomFactor = getRandom(1,10);
      
      if(%randomFactor > 6 && $pref::Server::Explodo $= "1")
      {      
         echo("greebles.cs->generateGreebleMarkers Boom, Boom, Yo!");
      
         %exp = new afxMagicSpell() 
         {
             datablock = TryPhysicalZoneSpell;
             caster = %obj;
             _castDur = 0;
             _anim = 0;
             _casterAnchor = 0;
             _ringDur = 3.1;
         };      
      }
   }
   
   
   
}

//****************************************************************
// scrapyardMarker collision/damage
//****************************************************************
// static shape damage code goes here...

#1
03/20/2014 (4:26 pm)
cool, don't suppose you have time for a quick video on this to see it in action?