Results 1 to 5 of 5

Thread: Revival of the close of the team hunters.

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

    Revival of the close of the team hunters.

    Hi all. I do not know how to rewrite the script so that the team of zombies appeared from 500 units hunters team, but at the same time so that a single player zombies appear close to zombie team. Please help me.

    This is my script:

    PHP Code:
    getSpawnpoint_NearTeam(spawnpoints)
    {
        if(!
    isdefined(spawnpoints))
            return 
    undefined;
        
        
    aliveplayers undefined;
        
        
    players getentarray("player""classname");
        for(
    0players.sizei++)
        {
            
    player players[i];
            
            if(
    player.sessionstate == "spectator" || player.sessionstate == "dead" || player == self)
            {
                continue;
            }

            
    aliveplayers add_to_array(aliveplayersplayer);
        }
        
        
    bestposition undefined;
        
        if(
    isdefined(aliveplayers))
        {
            
    distlargest = -33554432;

            for(
    0spawnpoints.sizei++)
            {
                if(
    positionWouldTelefrag(spawnpoints[i].origin))
                    continue;

                if(
    isdefined(self.lastspawnpoint) && self.lastspawnpoint == spawnpoints[i])
                    continue;
                    
                
    dist 0;

                for(
    0aliveplayers.sizej++)
                {
                    if(
    aliveplayers[j].pers["team"] == self.pers["team"])
                        
    dist dist - (distance(spawnpoints[i].originaliveplayers[j].origin) <= 100);
                    else
                        
    dist dist + (distance(spawnpoints[i].originaliveplayers[j].origin) >= 500);
                }

                if(
    dist distlargest)
                {
                    
    distlargest dist;
                    
    bestposition spawnpoints[i];
                }
            }

            
    spawnpoint bestposition;
        }
        else
        {
            
    spawnpoint getSpawnpoint_Random(spawnpoints);
        }
        
        
    self.lastspawnpoint spawnpoint;
        return 
    spawnpoint;


  2. #2
    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
    Hey Moczulak, got some old code for it. Once written for my NO-DL-Zombies-Mod:

    Code:
    getSpawnpoints()
    {
        spawnpoints = getentarray("mp_dm_spawn", "classname");
        spawns = [];
        for (i=0; i<spawnpoints.size; i++)
        {
            spawns[i] = spawnstruct();
            spawns[i].origin = spawnpoints[i].origin;
            spawns[i].angles = spawnpoints[i].angles;
        }
        spawnpoints = getentarray("mp_tdm_spawn", "classname");
        for (i=0; i<spawnpoints.size; i++)
        {
            spawns[i] = spawnstruct();
            spawns[i].origin = spawnpoints[i].origin;
            spawns[i].angles = spawnpoints[i].angles;
        }
        return spawns;
    }
    getActiveHunters()
    {
        hunters = getentarray("player", "classname");
        activeHunters = [];
        for (i=0; i<hunters.size; i++)
        {
            hunter = hunters[i];
            if (hunter.pers["team"] == "allies")
            if (hunter.sessionstate == "playing")
                activeHunters[activeHunters.size] = hunter;
        }
        return activeHunters;
    }
    findSpawnpoint()
    {
        spawnpoints = getSpawnpoints();
        activeHunters = getActiveHunters();
    
        if (activeHunters.size == 0)
        {
            // todo: pick random!
            spawnpoint = spawnpoints[0];
            return spawnpoint;
        }
    
        // find the nearest hunter for each spawnpoint
        for (i=0; i<spawnpoints.size; i++)
        {
            spawnpoint = spawnpoints[i];
            for (j=0; j<activeHunters.size; j++)
            {
                hunter = activeHunters[j];
                dist = distance(hunter.origin, spawnpoint.origin);
    
                if (!isDefined(spawnpoint.nearestHunter))
                {
                    spawnpoint.nearestHunter = dist;
                } else if (dist < spawnpoint.nearestHunter) {
                        spawnpoint.nearestHunter = dist;
                }
            }
        }
    
        bestSpawnpoint = spawnpoints[0];
        // first find the worst spawnpoint (furthest away)
        for (i=1; i<spawnpoints.size; i++)
        {
            spawnpoint = spawnpoints[i];
            if (spawnpoint.nearestHunter > bestSpawnpoint.nearestHunter)
                bestSpawnpoint = spawnpoint;
        }
        // now get better each iteration (further than 1000 units but nearer then the best)
        for (i=1; i<spawnpoints.size; i++)
        {
            spawnpoint = spawnpoints[i];
            if (spawnpoint.nearestHunter > 1000)
            if (spawnpoint.nearestHunter < bestSpawnpoint.nearestHunter)
                bestSpawnpoint = spawnpoint;
        }
        return bestSpawnpoint;
    }
    Ok, findSpawnpoint() is returning:
    - a struct with origin,angles
    - zombies is further away then 1000 (to give hunters a change)
    - spawnpoint is NEAREST to 1000 (so they dont need to walk to much -> action )

    I hope it helps you out.
    timescale 0.01

  3. #3
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    In the Zom :: spawnPlayer () I have the three lines:

    PHP Code:
        spawnpointname "mp_tdm_spawn";
        
    spawnpoints getentarray(spawnpointname"classname");
        
    spawnpoint files\maps\gametypes\_spawnlogic::getSpawnpoint_NearTeam(spawnpoints); 
    I swapped them for:

    PHP Code:
    files\maps\gametypes\_spawnlogic::findSpawnpoint(); 
    And not work ,show up in the air and fall, or show up out of the ground.

  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
    I call it like this:

    Code:
    zombieSpawn(position, angles)
    {
        player = self;
    
        player playsound("grenade_explode_dirt");
        playfx(level.fx["large_mud"], position);
    
        player spawn(position+(0,0,0/*-80*/),angles);
    }
    Code:
            spawnpoint = findSpawnpoint();
            //if (isDefined(spawnpoint.nearestHunter))
            //    iprintln("[DEBUG] spawnpoint.nearestHunter: " + spawnpoint.nearestHunter);
            //else
            //    iprintln("[DEBUG] spawnpoint.nearestHunter: not defined");
    
            self thread zombieSpawn(spawnpoint.origin, spawnpoint.angles);
    timescale 0.01

  5. The Following User Says Thank You to kung foo man For This Useful Post:

    Moczulak (19th October 2012)

  6. #5
    Private
    Join Date
    Aug 2012
    Posts
    78
    Thanks
    20
    Thanked 10 Times in 5 Posts
    It works ,very thanks man

Posting Permissions

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