Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7605


Ignore:
Timestamp:
Nov 2, 2010, 10:34:07 PM (14 years ago)
Author:
jo
Message:

Various successful changes. But the part I commented out in punishPlayer(PlayerInfo* player) causes crashes.

Location:
code/branches/lastmanstanding
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/lastmanstanding/data/levels/gametype_lastmanstanding.oxw

    r7603 r7605  
    66  include("templates/spaceship_assff.oxt")
    77  include("templates/spaceship_pirate.oxt")
     8  include("templates/pickup_representation_templates.oxt")
    89?>
    910
     
    2122    skybox       = "Orxonox/skypanoramagen1"
    2223  >
    23 <!----- Spawnpoints ----->
     24
     25    <?lua
     26      include("includes/pickups.oxi")
     27    ?>
     28
     29<!----- Spawnpoints
    2430    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    2531    <SpawnPoint team=0 position="-1150,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
    2834    <SpawnPoint team=0 position="700,0,-700" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    2935    <SpawnPoint team=0 position="0,0,-1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    30     <SpawnPoint team=0 position="0,0,1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     36    <SpawnPoint team=0 position="0,0,1150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /> ----->
    3137<Bot />
    3238
     
    4147      </collisionShapes>
    4248    </StaticEntity>
    43 <!--StaticEntity position="0,0,0" collisionType=static>
    44       <collisionShapes>
    45         <SphereCollisionShape radius="145" />
    46       </collisionShapes>
    47     </StaticEntity-->
     49
     50    <PickupSpawner position="-160,65,10" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg-->
     51      <pickup>
     52        <InvisiblePickup template=mediuminvisiblepickup />
     53      </pickup>
     54    </PickupSpawner>
     55    <PickupSpawner position="-160,60,17" triggerDistance="10" respawnTime="5" maxSpawnedItems="10"><!--EasterEgg-->
     56      <pickup>
     57        <InvisiblePickup template=hugeinvisiblepickup />
     58      </pickup>
     59    </PickupSpawner>
     60    <StaticEntity position="-160,60,28.4"><!--EasterEgg-Indicator-->
     61      <attached>
     62        <Model position="0,0,0" scale=1 mesh="sphere.mesh" />
     63      </attached>
     64    </StaticEntity>
    4865
    4966<!-- ---------------asteroid dome----------------- -->
     
    5471    y = math.sin(i/max*6)*750
    5572    z = math.cos(i/max*6)*750
    56     x = i*10
    5773    ?>
    5874<?lua
     
    6278?>
    6379
    64 
    65     <!--SpawnPoint team=0 position="<?lua print(y*1.4) ?>,0,<?lua print(z*1.4) ?>" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
     80    <SpawnPoint team=0 position="<?lua print(y*1.4+z*0.2) ?>,0,<?lua print(z*1.4-y*0.2) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    6681
    6782    <StaticEntity position="<?lua print(y) ?>,0,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     
    8398        <BoxCollisionShape    halfExtents="45,100,45" position = "0,0,0" />
    8499      </collisionShapes>
    85     </StaticEntity>#
     100    </StaticEntity>
    86101
    87102    <StaticEntity position="<?lua print(y) ?>,200,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     
    116131
    117132<!-- ---------Top Asteroid----------- -->
    118 
    119133    <StaticEntity position="<?lua print(y) ?>,300,<?lua print(z) ?>" scale=<?lua print(j * 2.1) ?> pitch="90" roll="180" yaw="<?lua print(-90+i*360/max) ?>" collisionType=static >
    120134      <attached>
     
    128142
    129143
    130 
    131144<?lua
    132145end
     
    134147<?lua end ?>
    135148
    136 
    137 
    138 
    139149  </Scene>
    140150</Level>
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.cc

    r7602 r7605  
    3535#include "core/ConfigValueIncludes.h"
    3636#include "util/Convert.h"
    37 //TODO: respawn delay
     37
    3838namespace orxonox
    3939{
     
    4848        this->timeRemaining=15.0f;
    4949        this->respawnDelay=4.0f;
     50        this->noPunishment=false;
     51        this->hardPunishment=false;
     52        this->punishDamageRate=0.4f;
    5053        this->setHUDTemplate("LastmanstandingHUD");
    5154    }
     
    8487        SetConfigValue(timeRemaining, 15.0f);
    8588        SetConfigValue(respawnDelay, 4.0f);
     89        SetConfigValue(noPunishment, false);
     90        SetConfigValue(hardPunishment, false);
    8691    }
    8792
     
    9196        {
    9297            this->timeToAct_[originator->getPlayer()]=timeRemaining;
     98
     99            std::map<PlayerInfo*, Player>::iterator it = this->players_.find(originator->getPlayer());
     100            if (it != this->players_.end())
     101            {
     102                if (it->first->getClientID()== CLIENTID_UNKNOWN)
     103                    return true;
     104                const std::string& message = ""; // set blank - erases Camper-Warning-message
     105                this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
     106            }   
    93107        }
    94108        return true;
     
    111125    }
    112126
     127    int LastManStanding::getMinLives()
     128    {
     129        int min=lives;
     130        for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
     131        {
     132            if (it->second<=0)
     133                continue;
     134            if (it->second<lives)
     135                min=it->second;
     136        }
     137        return min;
     138    }
     139
    113140    void LastManStanding::end()
    114141    {
     
    127154    }
    128155
     156
    129157    void LastManStanding::playerEntered(PlayerInfo* player)
    130158    {
     
    132160            return;
    133161        Deathmatch::playerEntered(player);
    134 
    135         playerLives_[player]=lives;
     162        if (playersAlive<=1)
     163            playerLives_[player]=lives;
     164        else
     165            playerLives_[player]=getMinLives();//new players only get minimum of lives
    136166        this->playersAlive++;
    137167        this->timeToAct_[player]=timeRemaining;
     
    154184        {
    155185            this->playersAlive--;
    156             //this->playerLives_[player].erase (player); not necessary?
     186            this->playerLives_.erase (player);
     187            this->playerDelayTime_.erase (player);
     188            this->inGame_.erase (player);
    157189            //Update: EachPlayer's "Players in Game"-HUD
    158190            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    207239    }
    208240
    209     void LastManStanding::killPlayer(PlayerInfo* player)
     241    void LastManStanding::punishPlayer(PlayerInfo* player)
    210242    {
    211243        if(!player)
     244            return;
     245        if(noPunishment)
    212246            return;
    213247        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
     
    215249        {
    216250            if(!player->getControllableEntity())
    217                 {return;}
     251                return;
    218252            Pawn* pawn = dynamic_cast<Pawn*>(player->getControllableEntity());
    219253            if(!pawn)
    220                 {return;}
    221             pawn->kill();
    222             this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
    223         }
    224     }
    225    
     254                return;
     255            if(hardPunishment)
     256            {
     257                pawn->kill();
     258                this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
     259            }
     260            /*else
     261            {
     262                float damage=pawn->getMaxHealth()*punishDamageRate*0.5;
     263                pawn->removeHealth(damage);
     264                this->timeToAct_[player]=timeRemaining;//reset timer
     265            }*/
     266        }
     267    }
     268
    226269    void LastManStanding::tick(float dt)
    227270    {
     
    231274            if ((this->hasStarted()&&(playersAlive<=1)))//last player remaining
    232275            {
    233             this->end();
     276                this->end();
    234277            }
    235278            for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
     
    243286                    if (playerDelayTime_[it->first]<=0)
    244287                    this->inGame_[it->first]=true;
     288
     289                    if (it->first->getClientID()== CLIENTID_UNKNOWN)
     290                        continue;
     291                    int output=1+playerDelayTime_[it->first];
     292                    const std::string& message = "Respawn in " +multi_cast<std::string>(output)+ " seconds." ;//Countdown
     293                    this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    245294                }
    246295                else if (it->second<0.0f)
     
    248297                    it->second=timeRemaining+3.0f;//reset punishment-timer
    249298                    if (playerGetLives(it->first)>0)
    250                         this->killPlayer(it->first);
    251                 }
    252                 else if (it->second<timeRemaining/6)//Warning message
     299                        this->punishPlayer(it->first);
     300                }
     301                else if (it->second<timeRemaining/5)//Warning message
    253302                {
    254303                    if (it->first->getClientID()== CLIENTID_UNKNOWN)
  • code/branches/lastmanstanding/src/orxonox/gametypes/LastManStanding.h

    r7596 r7605  
    5858            std::map<PlayerInfo*, float> playerDelayTime_; //!< Stores each Player's delay time.
    5959            std::map<PlayerInfo*, bool> inGame_; //!< Indicates each Player's state.
    60             virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn
     60            bool noPunishment;
     61            bool hardPunishment;
     62            float punishDamageRate;
     63            virtual void spawnDeadPlayersIfRequested(); //!< Prevents dead players to respawn.
     64            virtual int getMinLives(); //!< Returns minimum of each player's lives; players with 0 lives are skipped;
    6165
    6266        public:
     
    7579
    7680            const int playerGetLives(PlayerInfo* player); //!< getFunction for the map "playerLives_".
    77             void killPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
     81            void punishPlayer(PlayerInfo* player); //!< Function in order to kill a player. Punishment for hiding longer than "timeRemaining".
    7882            void tick (float dt); //!< used to end the game
    7983    };
Note: See TracChangeset for help on using the changeset viewer.