pawn Код:
public zombieAtaca()
{
new Float:pX,Float:pY,Float:pZ,Float:angle,Float:PEPE,Float:PIPO,Float:AA1,Float:AA2,Float:H;
new vehicleStatus;
if (NOFZombies<1 && !apocalipsis)
{
if (TimerAPO!=-1){KillTimer(TimerAPO);}
if (TimerAtaca!=-1){KillTimer(TimerAtaca);}
}
HoldingFire();
for (new j=0;j<TOTALZombies;j++)
{
for(new a=0; a<MAX_PLAYERS; a++) //para definir la "a"
{
if(EnEvento[a] == 1) //esto hara que solo ataquen a los "EnEvento" bueno depende de que variable tengan o algo asi xD
{
if(zombie[j][undead]&&IsPlayerConnected(zombie[j][target]) && GetPlayerInterior(zombie[j][target])==0)
{
vehicleStatus = IsPlayerInAnyVehicle(zombie[j][target]);
GetPlayerPos(zombie[j][target],pX,pY,pZ);
pZ+=0.7;
GetObjectPos(zombie[j][head],X,Y,Z);
angle = 180.0-atan2(X-pX,Y-pY);
angle+=vaiven;
vaiven*=-1;
PEPE = floatsin((angle*3.14159/180.0));
PIPO = floatcos((angle*3.14159/180.0));
zombie[j][angulo]=angle;
if(floatabs(zombie[j][ArmAngle])>10.0){zombie[j][ArmStatus]*=-1;}
zombie[j][ArmAngle]+=zombie[j][ArmStatus];
zombie[j][LegsH]=!zombie[j][LegsH];
AA1 = floatcos(zombie[j][ArmAngle]*3.14159/180.0);
AA2 = floatsin(zombie[j][ArmAngle]*3.14159/180.0);
if ((pZ-Z)>3.0)
{
Z+=1.0;
}
else if((pZ-Z)<-3.0)
{
Z-=1.0;
}
//we destroy the old zombi
DestroyObject(zombie[j][torso]);
DestroyObject(zombie[j][head]);
if (zombie[j][pedazos] & brazo1) DestroyObject(zombie[j][rArm]);
if (zombie[j][pedazos] & brazo2) DestroyObject(zombie[j][lArm]);
if (zombie[j][pedazos] & pierna1) DestroyObject(zombie[j][rLeg]);
if (zombie[j][pedazos] & pierna2) DestroyObject(zombie[j][lLeg]);
//we recreate the zombie
zombie[j][head]=CreateObject(z1[headZ][partModel],X,Y,pZ,z1[headZ][RelrX],z1[headZ][RelrY],angle+vaiven);
zombie[j][torso]=CreateObject(z1[torsoZ][partModel],X+z1[torsoZ][RelX]*PIPO+PEPE*z2[torsoZ][RelX],Y+z1[torsoZ][RelY]*PIPO+PEPE*z2[torsoZ][RelY],pZ+z1[torsoZ][RelZ],z1[torsoZ][RelrX],z1[torsoZ][RelrY],angle);
if (zombie[j][pedazos] & brazo1)
zombie[j][rArm]=CreateObject(z1[rArmZ][partModel],X+z1[rArmZ][RelX]*PIPO+PEPE*z2[rArmZ][RelX],Y+z1[rArmZ][RelY]*PIPO+PEPE*z2[rArmZ][RelY],pZ+A1[der][AZ]*AA1+AA2*A2[der][AZ],(-1)*zombie[j][ArmAngle],z1[rArmZ][RelrY],angle);
if (zombie[j][pedazos] & brazo2)
zombie[j][lArm]=CreateObject(z1[lArmZ][partModel],X+z1[lArmZ][RelX]*PIPO+PEPE*z2[lArmZ][RelX],Y+z1[lArmZ][RelY]*PIPO+PEPE*z2[lArmZ][RelY],pZ+A1[izq][AZ]*AA1-AA2*A2[izq][AZ],zombie[j][ArmAngle],z1[lArmZ][RelrY],angle);
if (zombie[j][pedazos] & pierna1)
zombie[j][rLeg]=CreateObject(z1[rLegZ][partModel],X+z1[rLegZ][RelX]*PIPO+PEPE*z2[rLegZ][RelX],Y+z1[rLegZ][RelY]*PIPO+PEPE*z2[rLegZ][RelY],pZ+z1[rLegZ][RelZ]+float(zombie[j][LegsH])*0.2,z1[rLegZ][RelrX],z1[rLegZ][RelrY],angle);
if (zombie[j][pedazos] & pierna2)
zombie[j][lLeg]=CreateObject(z1[lLegZ][partModel],X+z1[lLegZ][RelX]*PIPO+PEPE*z2[lLegZ][RelX],Y+z1[lLegZ][RelY]*PIPO+PEPE*z2[lLegZ][RelY],pZ+z1[lLegZ][RelZ]+float(!zombie[j][LegsH])*0.2,z1[lLegZ][RelrX],z1[lLegZ][RelrY],angle);
if ( (floatabs(pX-X) + floatabs(pY-Y) + floatabs(pZ-Z) )>(2.0+6.0*vehicleStatus))//The zombie will move to your position to eat you because if you are too far away
{
MoveObject(zombie[j][head],pX,pY,pZ,zombie[j][speed]*0.01*Zspeed);
MoveObject(zombie[j][torso],pX+z1[torsoZ][RelX]*PIPO+PEPE*z2[torsoZ][RelX],pY+z1[torsoZ][RelY]*PIPO+PEPE*z2[torsoZ][RelY],pZ+z1[torsoZ][RelZ],zombie[j][speed]*0.01*Zspeed);
if (zombie[j][pedazos] & brazo1)
MoveObject(zombie[j][rArm],pX+z1[rArmZ][RelX]*PIPO+PEPE*z2[rArmZ][RelX],pY+z1[rArmZ][RelY]*PIPO+PEPE*z2[rArmZ][RelY],pZ+A1[der][AZ]*AA1+AA2*A2[der][AZ],zombie[j][speed]*0.01*Zspeed);
if (zombie[j][pedazos] & brazo2)
MoveObject(zombie[j][lArm],pX+z1[lArmZ][RelX]*PIPO+PEPE*z2[lArmZ][RelX],pY+z1[lArmZ][RelY]*PIPO+PEPE*z2[lArmZ][RelY],pZ+A1[izq][AZ]*AA1-AA2*A2[izq][AZ],zombie[j][speed]*0.01*Zspeed);
if (zombie[j][pedazos] & pierna1)
MoveObject(zombie[j][rLeg],pX+z1[rLegZ][RelX]*PIPO+PEPE*z2[rLegZ][RelX],pY+z1[rLegZ][RelY]*PIPO+PEPE*z2[rLegZ][RelY],pZ+z1[rLegZ][RelZ]+float(zombie[j][LegsH])*0.2,zombie[j][speed]*0.01*Zspeed);
if (zombie[j][pedazos] & pierna2)
MoveObject(zombie[j][lLeg],pX+z1[lLegZ][RelX]*PIPO+PEPE*z2[lLegZ][RelX],pY+z1[lLegZ][RelY]*PIPO+PEPE*z2[lLegZ][RelY],pZ+z1[lLegZ][RelZ]+float(!zombie[j][LegsH])*0.2,zombie[j][speed]*0.01*Zspeed);
}
else//the zombie EATS you unless you are in a vehicle or you are alredy dead
{
StopObject(zombie[j][head]);
StopObject(zombie[j][torso]);
StopObject(zombie[j][rArm]);
StopObject(zombie[j][lArm]);
StopObject(zombie[j][rLeg]);
StopObject(zombie[j][lLeg]);
GetPlayerHealth(zombie[j][target],H);
if ( !vehicleStatus && !PlayerDeath[zombie[j][target]])
{
SetPlayerHealth(zombie[j][target],H-5.0);
}
}
}
}
}
}
return 1;
}