javascript/features/death_match/death_match_manager.js
// We want to spawn the player at the right location with the right settings.
We want to spawn the player at the right location with the right settings.
We want to spawn the player at the right location with the right settings .
spawnPlayer(player, zone) {
        const location = DeathMatchLocation.getById(zone);
        const spawnPosition = this.findRandomSpawnPosition(location);
        player.activity = Player.PLAYER_ACTIVITY_JS_DM_ZONE;
        player.position = spawnPosition.position;
        player.rotation = spawnPosition.rotation;
        player.health = location.playerHealth;
        player.armour = location.playerArmour;
        player.weather = location.weather;
        player.time = [location.time, 0];
        if(!isNaN(location.gravity))
            player.gravity = location.gravity;
        if (this.playerTeam_.has(player)) {
            const team = this.playerTeam_.get(player).team;
            wait(1).then(() => player.color = team === RED_TEAM ? Color.RED : Color.BLUE);
            if (location.noTeamDamage)
                player.team = team;
        }
        wait(1).then(() => player.virtualWorld = location.world);
        player.interiorId = location.interiorId;
        wait(0).then(() => player.setWorldBoundaries(location.boundaries[0], location.boundaries[1],
            location.boundaries[2], location.boundaries[3]));
        player.resetWeapons();
        for (const weaponInfo of location.weapons) {
            player.giveWeapon(weaponInfo.weaponId, weaponInfo.ammo);
        }
    }
spawnPlayer ( player , zone ) { const location = DeathMatchLocation . getById ( zone ) ; const spawnPosition = this . findRandomSpawnPosition ( location ) ; player . activity = Player . PLAYER_ACTIVITY_JS_DM_ZONE ; player . position = spawnPosition . position ; player . rotation = spawnPosition . rotation ; player . health = location . playerHealth ; player . armour = location . playerArmour ; player . weather = location . weather ; player . time = [ location . time , 0 ] ; if ( ! isNaN ( location . gravity ) ) player . gravity = location . gravity ; if ( this . playerTeam_ . has ( player ) ) { const team = this . playerTeam_ . get ( player ) . team ; wait ( 1 ) . then ( ( ) => player . color = team === RED_TEAM ? Color . RED : Color . BLUE ) ; if ( location . noTeamDamage ) player . team = team ; } wait ( 1 ) . then ( ( ) => player . virtualWorld = location . world ) ; player . interiorId = location . interiorId ; wait ( 0 ) . then ( ( ) => player . setWorldBoundaries ( location . boundaries [ 0 ] , location . boundaries [ 1 ] , location . boundaries [ 2 ] , location . boundaries [ 3 ] ) ) ; player . resetWeapons ( ) ; for ( const weaponInfo of location . weapons ) { player . giveWeapon ( weaponInfo . weaponId , weaponInfo . ammo ) ; } }
We want to spawn the player at the right location with the right settings.
We want to spawn the player at the right location with the right settings .
// Make sure this world is set last. TODO: Fix without wait. (e.g. use game API) // Do it in a tiny delay to avoid the player receiving an out of bounds message.