Author Topic: Slower Zombie Player  (Read 1228 times)

My problem here is that i want the endless zombies AI to be slower but i dont know where can i change that or how to add code that makes it slower,please help me.
Code: [Select]
//########## Zombie AI

function AIPlayer::addKills(%this) { return; }
function AIPlayer::incScore(%this) { return; }
function AIPlayer::getTeam(%this) { return -1; }
function AIPlayer::onDeath(%this) { return; }

function AIPlayer::EZM_SetAim(%this,%obj)
{
  if(%this.getState() $= "Dead") return;
  if(!isObject(%obj)) return;
  %o = (%this.intelligence / 100) * VectorDist(%this.getPosition(),%obj.getPosition());
  %this.setAimObject(%obj,getRandom(-%o,%o) SPC getRandom(-%o,%o) SPC getRandom(-%o,%o));
}

function AIPlayer::EZM_Attack(%this)
{
  if(%this.getState() $= "Dead") return;
  %this.setImageTrigger(0,1);
  %this.schedule(50,"setImageTrigger",0,0);
  if(!getRandom(20)) serverPlay3D(EZM_ZombiePainSound,%this.getTransform());
}

function AIPlayer::EZM_Wander(%this)
{
  %this.setMoveDestination(VectorAdd(%this.getPosition(),getRandom(-10,10) SPC getRandom(-10,10) SPC 0));
}

function AIPlayer::EZM_CanSeeObject(%this,%obj)
{
  if(%this.getState() $= "Dead") return 0;
  if(!isObject(%obj)) return 0;
  %pos1 = %this.getEyePoint();
  %pos2 = %obj.getPosition();
  %dist = vectorDist(%pos1,%pos2);
  if(getMinigameFromObject(%obj).EZM_ZombieSuperIntelligence) return %dist;
  if(%dist > %this.sightRange) return 0;
  %ray = containerRayCast(%pos1,%pos2,$TypeMasks::FxBrickObjectType,%this);
  if(isObject(%ray)) return 0;
  return %dist;
}

function AIPlayer::EZM_Idle(%this)
{
  if(%this.getState() $= "Dead") return;
  cancel(%this.moveSchedule);
  if(!getRandom(20)) serverPlay3D(EZM_ZombieDeathSound,%this.getTransform());
  if(isObject(%this.getMoveObject())) { %this.clearAim(); %this.setMoveObject(0); }

  if(getMinigameFromObject(%this).EZM_ZombieSuperIntelligence)
  {
    %mini = getMinigameFromObject(%this);
    for(%i=0;%i<%mini.numMembers;%i++)
    {
      if(!isObject(%target = %mini.member[%i].player)) continue;
      %dist = VectorDist(%this.getEyePoint(),%target.getPosition());
      if(%currdist !$= "" && %dist > %currdist) continue;
      if(getMinigameFromObject(%this) != getMinigameFromObject(%target)) continue;
      %currdist = %dist;
      %currobj = %target;
    }
  }
  else
  {
    InitContainerRadiusSearch(%this.getPosition(),%this.sightRange,$TypeMasks::PlayerObjectType);
    for(%i=0;%i<15;%i++)
    {
      %target = containerSearchNext();
      if(!isObject(%target)) continue;
      if(%target == %this) continue;
      if(%target.EZMisZombie) continue;
      if(%target.getState() $= "Dead") continue;
      if(!(%dist = %this.EZM_CanSeeObject(%target))) continue;
      if(%currdist !$= "" && %dist > %currdist) continue;
      if(getMinigameFromObject(%this) != getMinigameFromObject(%target)) continue;
      %currdist = %dist;
      %currobj = %target;
    }
  }
  if(isObject(%currobj)) %this.EZM_Chase(%currobj);
  else
  {
    %this.EZM_Wander();
    %this.moveSchedule = %this.schedule(getRandom(2000,3000),"EZM_Idle");
  }
}

function AIPlayer::EZM_Chase(%this,%obj)
{
  if(%this.getState() $= "Dead") return;
  cancel(%this.moveSchedule);
  if(!isObject(%obj) || %obj.EZMisZombie) { %this.moveSchedule = %this.schedule(2000 - %this.intelligence * 10,"EZM_Idle"); return; }
  if(%obj.getState() $= "Dead") { %this.moveSchedule = %this.schedule(2000 - %this.intelligence * 10,"EZM_Idle"); return; }
  if(!getRandom(20)) serverPlay3D(EZM_ZombieDeathSound,%this.getTransform());
  if(getWord(%this.getPosition(),2) - getWord(%dest,2) < -5) %this.EZM_Jump();
  %ray = containerRayCast(VectorSub(VectorAdd(%this.getPosition(),%this.getForwardVector()),"0 0" SPC getWord(%this.getScale(),2)),VectorAdd(VectorAdd(%this.getPosition(),%this.getForwardVector()),"0 0" SPC getWord(%this.getScale(),2)),$TypeMasks::FxBrickObjectType | $TypeMasks::VehicleObjectType | $TypeMasks::PlayerObjectType,%this);
  if(isObject(firstWord(%ray)))
  {
    if(getRandom(1)) %this.EZM_Jump();
    else
      %this.EZM_Crouch();
  }
  if(!getRandom(5))
  {
    if(getRandom(1)) %this.EZM_Jump();
    else
      %this.EZM_Crouch();
  }
  if(!getRandom(5)) %this.EZM_Strafe();
  if(VectorDist(%this.getPosition(),%obj.getPosition()) < %this.attackRange) %this.EZM_Attack();
  if(%this.EZM_CanSeeObject(%obj)) { %this.setAimObject(%obj); %this.setMoveObject(%obj); }
  %this.moveSchedule = %this.schedule(2000 - %this.intelligence * 15,"EZM_Chase",%obj);
}

What you're going to want to do is open up the file, 'zombies.cs.' This file is where the actual zombie datablocks are placed, and where you can edit the speed.

You're looking for this-
Quote
//### Player Datablocks
Underneath that is some text that looks like this. . .
Quote
datablock PlayerData(EZM_FastPlayer : PlayerStandardArmor)
{
  uiName = "";
  maxDamage = 50;
  jumpForce = 1000;
  maxForwardSpeed = 10;
  maxBackwardSpeed = 6;
  maxSideSpeed = 8;
  maxForwardCrouchSpeed = 5;
  maxBackwardCrouchSpeed = 3;
  maxSideCrouchSpeed = 3;

  canJet = false;
};

The bolded text is the numbers you would probably like to change to a lower value.

Keep in mind, there are multiple zombies you'll have to do this with, as there are (as you know) multiple zombie types. There should be a bunch of similar-looking blocks of text under it. Do the same thing for those as well.

( that is, if you mean, physically slower. . . )

What you're going to want to do is open up the file, 'zombies.cs.' This file is where the actual zombie datablocks are placed, and where you can edit the speed.

You're looking for this- Underneath that is some text that looks like this. . .The bolded text is the numbers you would probably like to change to a lower value.

Keep in mind, there are multiple zombies you'll have to do this with, as there are (as you know) multiple zombie types. There should be a bunch of similar-looking blocks of text under it. Do the same thing for those as well.

( that is, if you mean, physically slower. . . )
Thank you so much!
I am working at a actual good cod zombies gamemode with cod guns and stuff.