Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Revival of the few zombie during the reboot.

  1. #1
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts

    Revival of the few zombie during the reboot.

    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...

    Please help me.

    PHP Code:
    checkRestart(zombie)
    {
        
    numonteam["allies"] = 0;
        
    numonteam["axis"] = 0;
        
        
    players getentarray("player""classname");
        for(
    0players.sizei++)
        {
            
    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"] == && (numonteam["axis"] != && 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(
    0players.sizei++)
            {
                
    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;
        }


  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    who is self.
    what is zombie.

  3. #3
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Quote Originally Posted by IzNoGoD View Post
    who is self.
    what is zombie.
    zombie = self;

  4. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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
    timescale 0.01

  5. #5
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Quote Originally Posted by kung foo man View Post
    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 ?

  6. #6
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Because you need to know which hunters died last (so you can make them zombies).
    timescale 0.01

  7. #7
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    Quote Originally Posted by kung foo man View Post
    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.

  8. #8
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    He sat a little with the script at night and I wrote something like this:

    PHP Code:
    checkRestart(zombie,axisPlayer)
    {
        
    numonteam["allies"] = 0;
        
    numonteam["axis"] = 0;
        
        
    players getentarray("player""classname");
        for(
    0players.sizei++)
        {
            
    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))
            {
                
    0;
                if (
    players.size%== 0)
                {
                    
    int((players.size/2)-1);
                    
    iprintlnbold("Wynik = "+j);
                } 
                else
                {
                    
    int((players.size/2));
                    
    iprintlnbold("Wynik2 = "+j);
                }
                
                for(
    i=jii--)
                {
                    
    //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(
    0players.sizei++)
            {
                
    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...

  9. #9
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Now you just need to sort player.lastDeath (in my script i named it different) and spawn the sorted players:

    PHP Code:

                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=numberOfNewZombiesi<sorted.sizei++)
                {
                    
    hunter sorted[i];
                    
    hunter roundRestart("allies");
                }

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

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

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

    // slow, but works... cba for quicksort now
    sort(elementsisAbiggerB)
    {
        for (
    i=0i<elements.sizei++)
        {
            for (
    j=i+1j<elements.sizej++)
            {
                
    //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=0i<players.sizei++)
        {
            
    player players[i];
            if (
    player.pers["team"] == "axis" || player.pers["team"] == "allies")
                
    tmp[tmp.size] = player;
        }
        return 
    tmp;

    timescale 0.01

  10. #10
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •