PDA

View Full Version : Revival of the few zombie during the reboot.



Moczulak
11th February 2013, 19:37
Hey all.
I don't know how to make to the restart there was more than one zombie, I would like to do to the amount of zombies grow depending on the number of hunters, as well as the NoDL.
The second problem is that when join the second player when you type in console,, kill'' is the restart round. I tried to do so by attaching the second player to the game, there was a restart. But to no avail... :confused:

Please help me.



checkRestart(zombie)
{
numonteam["allies"] = 0;
numonteam["axis"] = 0;

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isDefined(player.pers["team"]) || player.pers["team"] == "spectator" || (isPlayer(self) && self.sessionstate == "playing"))
continue;

numonteam[player.pers["team"]]++;
}

if(numonteam["allies"] == 0 && (numonteam["axis"] != 0 && numonteam["axis"] != 1)) // Restart the round if the server has more than one zombies
{
if(isDefined(zombie) && isPlayer(zombie))
{
axisPlayer = zombie;
}
else
{
axisPlayer = players[randomint(players.size)];
}

for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isDefined(player.pers["team"]) || player.pers["team"] == "spectator")
continue;

player thread showText(&"ZOM_ROUND_RESTART");


if (player == axisPlayer)
{
player thread movePlayer("axis", 2);
}
else
{
player thread movePlayer("allies", 4);
}
}
return true;
}
else
{
return false;
}
}

IzNoGoD
11th February 2013, 21:49
who is self.
what is zombie.

Moczulak
11th February 2013, 21:56
who is self.
what is zombie.

zombie = self;

kung foo man
11th February 2013, 23:05
The last few hunters will be the new zombies. So you need to:
- save the time of hunter-deaths: if (player.pers["team"] == "allies") player.lastDeath = getTime()
- on roundrestart, sort the players-array by player.lastDeath
- calculate the number of new zombies, e.g. n=1+int(players.size/4)
- make first n elements of the sorted array zombies, the other ones hunters

Moczulak
12th February 2013, 00:13
The last few hunters will be the new zombies. So you need to:
- save the time of hunter-deaths: if (player.pers["team"] == "allies") player.lastDeath = getTime()
- on roundrestart, sort the players-array by player.lastDeath
- calculate the number of new zombies, e.g. n=1+int(players.size/4)
- make first n elements of the sorted array zombies, the other ones hunters

What is the function check: if (player.pers["team"] == "allies") player.lastDeath = getTime() ?? Why is this necessary ?

kung foo man
12th February 2013, 00:19
Because you need to know which hunters died last (so you can make them zombies).

Moczulak
12th February 2013, 00:21
Because you need to know which hunters died last (so you can make them zombies).

I have no idea how to do it, could you help me write it? I do not demand from you a finished script, but directing in the right direction.

Moczulak
12th February 2013, 10:56
He sat a little with the script at night and I wrote something like this:



checkRestart(zombie,axisPlayer)
{
numonteam["allies"] = 0;
numonteam["axis"] = 0;

players = getentarray("player", "classname");
for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isDefined(player.pers["team"]) || player.pers["team"] == "spectator" || (isPlayer(self) && self.sessionstate == "playing") && (isPlayer(self) && self.pers["team"] == "spectator"))
continue;

numonteam[player.pers["team"]]++;
}

if ((numonteam["allies"] == 0) && (numonteam["axis"] > 1))
{
if(isDefined(zombie) && isPlayer(zombie))
{
j = 0;
if (players.size%2 == 0)
{
j = int((players.size/2)-1);
iprintlnbold("Wynik = "+j);
}
else
{
j = int((players.size/2));
iprintlnbold("Wynik2 = "+j);
}

for(i=j; i; i--)
{
//axisPlayer = zombie;
axisPlayer = players[randomint(players.size)];
//iprintlnbold("Last Death Allies: "+self.lastDeath);
//iprintlnbold("Wynik3 = "+randomint(players.size));
}
}
else
{
axisPlayer = players[randomint(players.size)];
}

for(i = 0; i < players.size; i++)
{
player = players[i];

if(!isDefined(player.pers["team"]) || player.pers["team"] == "spectator")
continue;

player thread showText(&"ZOM_ROUND_RESTART");

if (player == axisPlayer)
{
player thread movePlayer("axis", 2);
}
else
{
player thread movePlayer("allies", 4);
}
}
return true;
}
else
{
return false;
}
}


In Callback_PlayerKilled i add:

if (self.pers["team"] == "allies") self.lastDeath = getTime();

But i don't know how use self.lastDeath...

kung foo man
12th February 2013, 12:19
Now you just need to sort player.lastDeath (in my script i named it different) and spawn the sorted players:




players = getActivePlayers(); // axis/allies
sorted = sort(players, ::isPlayerAlongerHunterAsB); // the first entries are the players was most hunters (=new start zombies)

// example:
// players: 10
// numberOfNewZombies = 1 + int(10/4) = 3
// hunters: for (i=numbersOfNewZombies; i<sorted.size; i++)


// spawn the hunters FIRST...
for (i=numberOfNewZombies; i<sorted.size; i++)
{
hunter = sorted[i];
hunter roundRestart("allies");
}

// spawn the zombies (near the hunters then)...
for (i=0; i<numberOfNewZombies; i++)
{
zombie = sorted[i];
zombie roundRestart("axis", " ^7"+(i+1)+"^1/^7"+numberOfNewZombies);
}



isPlayerAlongerHunterAsB(a, b)
{
if (a.lastTimeOfDeathAsHunter > b.lastTimeOfDeathAsHunter)
return 1;
else
return 0;
}

// sample-function for sort()
a_bigger_b(a, b)
{
if (a > b)
return 1;
else
return 0;
}

// slow, but works... cba for quicksort now
sort(elements, isAbiggerB)
{
for (i=0; i<elements.size; i++)
{
for (j=i+1; j<elements.size; j++)
{
//if (elements[i] < elements[j])
if (
! // big to small...
[[isAbiggerB]](elements[i], elements[j])
)
{
// swap
tmp = elements[j];
elements[j] = elements[i];
elements[i] = tmp;
}
}
}

return elements;
}

getActivePlayers()
{
players = getentarray("player", "classname");
tmp = [];
for (i=0; i<players.size; i++)
{
player = players[i];
if (player.pers["team"] == "axis" || player.pers["team"] == "allies")
tmp[tmp.size] = player;
}
return tmp;
}

Tally
12th February 2013, 13:13
Get the Last Man Standing gametype from the AWE mod for COD2. There is a very simple method in there for checking for the last player alive.

Tally
12th February 2013, 14:38
Back in 2006 I did an "infected" gametype called Hitman for COD2. Basically, the gametype starts with 1 hitman, 1 commander, and the rest are guards who are supposed to protect the commander. As the hitman kills the guards, they turn into hitmen. Change the name "Hitman" to "infected" and you have the same thing: as the "infected" (= hitman) kills the guards, they become infected themselves. So, the gametype uses a method to increase the size of hitmen/infected exponentially. Which is what you were looking for.

Download Hitman gametype for COD2 here:

http://callofduty.filefront.com/file/CoD2_Hitman_Gametype;68302

Moczulak
12th February 2013, 18:08
******* script runtime error *******
pair 'undefined' and 'undefined' has unmatching types 'undefined' and 'undefined': (file 'files/zom.gsc', line 2107)
if (a.lastTimeOfDeathAsHunter > b.lastTimeOfDeathAsHunter)
*


I have error.. idk why... ;/

kung foo man
12th February 2013, 18:20
Instead of player.lastDeath write now:



if (player.pers["team"] == "allies")
player.lastTimeOfDeathAsHunter = getTime();


BTW dont forget to set player.lastTimeOfDeathAsHunter = 0 in callback_playerconnect(), otherwise it will crash with undefined-int-unmatching-type-error.

Moczulak
12th February 2013, 18:44
Add to Callback_PlayerConnect:



if (player.pers["team"] == "allies")
player.lastTimeOfDeathAsHunter = getTime();

??

kung foo man
12th February 2013, 18:51
No, that goes to Callback_PlayerKilled().




Callback_PlayerConnect: player.lastTimeOfDeathAsHunter = 0;

Moczulak
12th February 2013, 19:04
I kill the last hunter, do i not turn into the hunter ;/
The last hunter is killed, the team moved ,, axis'', then after a while ,,allies''.

How to repair ?

kung foo man
12th February 2013, 19:12
Did you commented your old hunter-becomes-zombie-logic out?

Moczulak
12th February 2013, 19:14
How do I comment on this?

kung foo man
12th February 2013, 19:31
Its different for every zombie-mod, most ppl put the logic directly in Callback_PlayerKilled (who wrote that part for your mod?).

Tally
13th February 2013, 09:04
I hate to rain on anyone's parade, but if you can't script, or are very new to it, you should not be attempting to write a whole zombie gametype script. You should learn to walk before you try to run. Gametypes are for the very advanced only.