Making a spawn point

Discussion in 'Tutorials' started by TurtleMonkey, Jul 9, 2010.

  1. TurtleMonkey Private

    Contributions:
    0
    Processing:
    Graphics:
    Not written by me, because i am to tired to explain all (40 degrees here).I mostly use this script, for editing custom zombie maps (example is bots in co op zombies).Info:
    treyarch.com

    There are a number of ways to spawn a number of entities from script, chief among them being the aptly named spawn() function, which takes as input the classname for the desired entity (the string that identifies the specific type of entity, such as trigger_multiple or info_player_start), and the position at which you would like the new entity to be created at.
    One of the most common uses of spawn() is the creation of a "script_origin", a versatile and lightweight entity. These are used to do brief simple things like play a sound or effect at a particular or random position, or we can link another entity to it to control that entity:
    level.player freezeControls(true);
    level.player shellshock("default", 5);

    org = spawn("script_origin",level.player.origin);
    level.player linkto( org );
    org rotateYaw(75, .01);
    wait (.5);
    org rotateYaw(-90, 6);

    wait (4);
    iprintlnbold( "We need him alive Bond." );
    level.player unlink();
    level.player freezeControls(false);
    org delete();
    Here the player's is linked to the newly created script_origin, and because the player's controls have been frozen this affords us control over how the player faces, letting us force him to look at what we want him to. Having shown the player what he needed to see, we unfreeze the controls and unlink from the script_origin. Finally note now that we are finished using the script_origin, we delete it, freeing up that entity slot for possible later use by some other spawned entity.
    There are other more specific spawning functions, like the self-explanatory spawnVehicle() and spawnTurret(), but now we'll look at how we can go about spawning AIs (because an empty map with no friendly or enemy NPCs to interact with is typically not all that interesting) with the two functions that use a spawner entity to create actors at runtime, dospawn() and stalingradspawn().
    First of all, what exactly is a spawner? A spawner acts as a template for spawning a new AI. Rather than litter the map in radiant with instances of every copy of an actor you might need, you can simply create one instance of each type of actor you'd like to use, set up all the key-value pairs to your liking, and check the spawner checkbox in the entity window. Now you have an actor template accessible to you in script in the form of a spawner.
    Each of our two actor spawning functions, dospawn() and stalingradspawn(), are virtually identical as they both run on a spawner entity, and each takes as input the desired value for the targetname key of the newly spawned actor. There is one critical difference, however. stalingradspawn() will always succeed in spawning the new actor, but dospawn() will fail if spawning would create a telefrag or if the player is currently looking at the spawn point. (As a historical aside, the reason it is called stalingradspawn() is because the function was created expressly for use on the stalingrad level of Call of Duty.)
    spawner = getent( "enemy_spawner", "targetname" );
    enemy1 = spawner stalingradspawn( "enemy1" );
    enemy2 = spawner dospawn( "enemy2" );
    if ( spawnfailed( enemy2 ) )
    {
    return;
    }

    Notice the check on enemy2 using spawnfailed(), so we can determine whether dospawn() failed, and if so cease operating on that actor.

Share This Page