Author Topic: Zapt - Turn players into zombies on touch?  (Read 565 times)

For the ZAPT gamemode, I'm trying to make it so that when a zombie touches a non-zombie player, it instantly turns them into a zombie.
What i've tried to do is edit the oncollision function in package.cs to be this:
Code: [Select]
function Armor::onCollision(%this, %obj, %col, %pos, %vel)
{
%result = parent::onCollision(%this, %obj, %col, %pos, %vel);

%mini = getMiniGameFromObject(%obj);

if(zombieGameSetUpRight(%mini))
{
if(zombieBot(%obj) && zombieValidTarget(%obj, %col))
{
if(%col.getType() & $TypeMasks::VehicleObjectType)
{
if(%col.getMountedObjectCount() > 0)
{
if(!%obj.zombieHasTarget() || (%obj.target.getID() != %col.getID() && !%obj.target.zombieDistract))
{
%obj.zombieChase(%col);
}

%obj.zombieClaw();
}
else if(%obj.zombieHasTarget() && %obj.target.getID() == %col.getID() && !%col.zombieDistract)
{
%obj.zombieChase(-1);
}
}
else
{
if(!%obj.zombieHasTarget() || (%obj.target.getID() != %col.getID() && !%obj.target.zombieDistract))
{
%obj.zombieChase(%col);
}

%obj.zombieClaw();
}
}
else if(!%obj.isZombie && !%obj.zombieHelpless && !%obj.zombieSmoked && %obj.getState() !$= "Dead" &&
!%col.isZombie && %col.zombieSmoked && %col.getState() !$= "Dead")
{
if(isObject(%col.zombieSmokedBy.zombieSmokingWho) && %col.zombieSmokedBy.zombieSmokingWho.getID() == %col.getID())
{
if(!zombieBot(%col.zombieSmokedBy))
{
if(!zombieBot(%obj.client) && !zombieBot(%col.client))
{
messageClient(%col.zombieSmokedBy.client, '', "\c3" @ %obj.client.name @ "<color:ffaaaa> broke your strangle on \c3" @ %col.client.name @ "<color:ffaaaa>!");
}
else if(!zombieBot(%obj.client) && zombieBot(%col.client))
{
messageClient(%col.zombieSmokedBy.client, '', "\c3A survivor <color:ffaaaa>broke your strangle on \c3" @ %col.client.name @ "<color:ffaaaa>!");
}
else if(zombieBot(%obj.client) && !zombieBot(%col.client))
{
messageClient(%col.zombieSmokedBy.client, '', "\c3" @ %obj.client.name @ "<color:ffaaaa> broke your strangle on \c3another survivor<color:ffaaaa>!");
}
else
{
messageClient(%col.zombieSmokedBy.client, '', "\c3A survivor <color:ffaaaa>broke your strangle on \c3another survivor<color:ffaaaa>!");
}
}

if(isObject(%col.getMountedImage(2)) && %col.getMountedImage(2).getID() == ZombieSmokerConstrictImage.getID())
{
%col.unMountImage(2);
}

%col.zombieHelpless = false;
cancel(%col.zombieSmokedBy.zombieStrangleSched);
%col.zombieSmoked = false;
%col.zombieSmokedBy = "";

if(!zombieBot(%obj.client))
{
if(!zombieBot(%col.client))
{
messageClient(%obj.client, '', "<color:aaffaa>You rescued \c3" @ %col.client.name @ "<color:aaffaa>!");
}
else
{
messageClient(%obj.client, '', "<color:aaffaa>You rescued \c3a survivor<color:aaffaa>!");
}
}

if(!zombieBot(%col.client))
{
if(!zombieBot(%obj.client))
{
messageClient(%col.client, '', "<color:aaffaa>You were rescued by \c3" @ %obj.client.name @ "<color:aaffaa>!");
}
else
{
messageClient(%col.client, '', "<color:aaffaa>You were rescued<color:aaffaa>!");
}
}
}
}
else if(%obj.isZombie != %col.isZombie)
{
if(zombieGameSetUpRight(%mini))
{
if(%obj.isZombie)
%z = %obj;
else
%z = %col;
%z.zombieDiedAs = %z.isZombie;

if(!%z.isZombie)
{
%mini.zombieLastDeathTime = $sim::time;

if(%mini.getProperty("respawn"))
{
if(%mini.ZAPT_PlayerZombies)
{
%transformed = true;
%z.isZombie = true;
messageClient(%client, '', "<color:ffaaaa>You are now a Zombie.");
%z.setDatablock(ZombieStandardArmor);
}
}
else
{
%client.isDead = true;
messageClient(%client, '', "<color:ffaaaa>You are now Dead. There's no respawning in <color:ffffaa>" @ %mini.getProperty("uiName") @ "<color:ffaaaa>, so sit back.");
messageClient(%client, 'MsgYourSpawn');
%client.zombieCameraSched = %client.schedule(2000, "zombieAutoCameraTarget");
}
}
}
}
}

return %result;
}
All I did is near the end of that function I added in a part from the onDeath function, so that (in theory) it would set the non-zombie player's datablock to that of a zombie.

Why isn't this working?


I dont know what's in there by default and what you added. Plus, i honestly didn't think you'd need help with something so simple.

Well, first, elm, that was pretty uncalled for.

Second, I have never modified or played ZAPT so I don't really know what the variables mean, but my best guess is that the conditions !%obj.isZombie && !%obj.zombieHelpless && !%obj.zombieSmoked && %obj.getState() !$= "Dead" && !%col.isZombie && %col.zombieSmoked && %col.getState() !$= "Dead" and %obj.isZombie != %col.isZombie are both always true when the other is, thus causing your if code to never be run because it's in an else. It seems like it wouldn't break anything if you were to remove the "else" before that if, you wanted it to turn them into a zombie regardless of conditions (as long as they not a zombie), right? So just remove the else and it'll catch it every time it's true.
« Last Edit: January 20, 2013, 02:10:21 PM by !Trinick »

You should display some console output with echo so you can see what happens and what doesn't.