Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualScourage

Posted 11 December 2012 - 12:53 PM

What I think you are talking about is parameter driven models (or components). If you want to have a bunch of zombies each with different health values, they all have a health capability, just with different initial values. Same thing with size, speed, aggression, etc.

My system (also a zombie game) uses this approach. In my entity definitions (which are lua scripts) I allow for functions to be used for initialization data, which then return randomized values (within a valid range) each time a zombie is created. This gives various types of zombies, some harder to kill than others with the same game object model and initialization script.

Here's my initialization script for a zombie:

[source lang="cpp"]ENTITY{ type="zombie"; inherits="baseEntity"; attributes= { type={type="string", value="zombie"}; state={type="string", value="wander"}; }; behaviors= { RenderBehavior = { model="../data/models/zombie/zombie.ms3d"; texture="../data/models/zombie/zombie.jpg"; scale={0.2, 0.2, 0.2}; --scale={1.0, 1.0, 1.0}; translate={0.0, 0.0, 0.0}; rotate={0.0, 0.0, 0.0}; animated=true; }; AnimationBehavior= { animations={ {name="walk1", start=2, finish=20, fps=24, loop=true}, {name="walk2", start=22, finish=36, fps=24, loop=true}, {name="damage1", start=38, finish=47, fps=24, loop=false}, {name="damage2", start=48, finish=57, fps=24, loop=false}, {name="fall", start=59, finish=75, fps=24, loop=false}, {name="prone", start=78, finish=88, fps=24, loop=false}, {name="die", start=91, finish=103, fps=24, loop=false}, {name="kick", start=106, finish=115, fps=24, loop=false}, {name="punch", start=116, finish=128, fps=24, loop=false}, {name="headbutt", start=129, finish=136, fps=24, loop=false}, {name="idle1", start=137, finish=169, fps=24, loop=true}, {name="idel2", start=170, finish=200, fps=24, loop=true} } }; CollisionBehavior= { radius=1.0; }; ScriptBehavior= { script="zombieAI.cs" }; AudioBehavior= { sounds={"../data/audio/zombie-brains1.wav", "../data/audio/zombie-brains2.wav", "../data/audio/zombie-brains3.wav", "../data/audio/zombie-moan.wav", "../data/audio/zombie-gurgle.wav"}, period=10 }; SenseBehavior= { range=function() return math.random(200,500) end; acceptTypes={"player"}; }; DamageBehavior= { health=function() return math.random(25,75); end; }; }; reflected= { "RenderBehavior", "AudioBehavior", "AnimationBehavior", };}[/SOURCE]

#1Scourage

Posted 11 December 2012 - 12:50 PM

What I think you are talking about is parameter driven models (or components). If you want to have a bunch of zombies each with different health values, they all have a health capability, just with different initial values. Same thing with size, speed, aggression, etc.

My system (also a zombie game) uses this approach. In my entity definitions (which are lua scripts) I allow for functions to be used for initialization data, which then return randomized values (within a valid range) each time a zombie is created. This gives various types of zombies, some harder to kill than others with the same game object model and initialization script.

Here's my initialization script for a zombie:

ENTITY
{
   type="zombie";
   inherits="baseEntity";
   attributes=
   {
  type={type="string", value="zombie"};
  state={type="string", value="wander"};
   };
   behaviors=
   {
	  RenderBehavior =
	  {
		 model="../data/models/zombie/zombie.ms3d";
   texture="../data/models/zombie/zombie.jpg";
   scale={0.2, 0.2, 0.2};
   --scale={1.0, 1.0, 1.0};
   translate={0.0, 0.0, 0.0};
   rotate={0.0, 0.0, 0.0};
		 animated=true;
	  };
	  AnimationBehavior=
	  {
  animations={
   {name="walk1", start=2, finish=20, fps=24, loop=true},
   {name="walk2", start=22, finish=36, fps=24, loop=true},
   {name="damage1", start=38, finish=47, fps=24, loop=false},
   {name="damage2", start=48, finish=57, fps=24, loop=false},
   {name="fall", start=59, finish=75, fps=24, loop=false},
   {name="prone", start=78, finish=88, fps=24, loop=false},
   {name="die", start=91, finish=103, fps=24, loop=false},
   {name="kick", start=106, finish=115, fps=24, loop=false},
   {name="punch", start=116, finish=128, fps=24, loop=false},
   {name="headbutt", start=129, finish=136, fps=24, loop=false},
   {name="idle1", start=137, finish=169, fps=24, loop=true},
   {name="idel2", start=170, finish=200, fps=24, loop=true}
  }
	  };
	  CollisionBehavior=
   {
	   radius=1.0;
   };
  
   ScriptBehavior=
	  {
		 script="zombieAI.cs"
	  };
 
   AudioBehavior=
   {
  sounds={"../data/audio/zombie-brains1.wav",
		  "../data/audio/zombie-brains2.wav",
    "../data/audio/zombie-brains3.wav",
    "../data/audio/zombie-moan.wav",
    "../data/audio/zombie-gurgle.wav"},
  period=10
   };
   SenseBehavior=
   {
  range=function() return math.random(200,500) end;
  acceptTypes={"player"};
   };
   DamageBehavior=
   {
  health=function() return math.random(25,75); end;
   };
   };
   reflected=
   {
  "RenderBehavior",
  "AudioBehavior",
  "AnimationBehavior",
   };
}

PARTNERS