Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/npcs/npc.cc @ 6200

Last change on this file since 6200 was 6142, checked in by bensch, 19 years ago

orxonox/trunk: merge the ObjectManager to the trunk
merged with command:
svn merge -r6082:HEAD objectmanager/ ../trunk/

conflicts resolution was easy this time :)
but specially merged the world to network_world

File size: 1.7 KB
RevLine 
[1853]1
2
[4597]3/*
[1853]4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
[1855]12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer:
[1853]16*/
[5357]17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
[1853]18
19
20#include "npc.h"
[5033]21#include "obb_tree.h"
[1853]22
[4984]23#include "state.h"
[5064]24#include "list.h"
[5427]25#include "stdlibincl.h"
[5451]26#include "power_ups/turret_power_up.h"
[5458]27#include "power_ups/laser_power_up.h"
[4984]28
[1858]29using namespace std;
[1853]30
[1858]31
[4976]32NPC::NPC()
[1931]33{
[4597]34  this->setClassID(CL_NPC, "NPC");
[6142]35  this->toList(OM_GROUP_00);
[1931]36}
[1853]37
[5034]38
[1853]39NPC::~NPC () {}
40
41
[5029]42void NPC::collidesWith(WorldEntity* entity, const Vector& location)
43{
[5451]44  if (entity->isA(CL_PROJECTILE) && entity != this->collider)
[5258]45  {
[5451]46//    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
47//    this->applyForce(Vector(0,0,0)-location*1000);
48    if ((float)rand()/RAND_MAX < .3)
49    {
50      WorldEntity* powerUp = new TurretPowerUp();
51      powerUp->setAbsCoor(this->getAbsCoor());
[6142]52//      powerUp->toList(OM_COMMON);
[5451]53    }
[5458]54    else if ((float)rand()/RAND_MAX < .3)
55    {
56      WorldEntity* powerUp = new LaserPowerUp();
57      powerUp->setAbsCoor(this->getAbsCoor());
[6142]58      powerUp->toList(OM_COMMON);
[5458]59    }
[6142]60    this->toList(OM_DEAD);
[6054]61    this->removeNode();
[5451]62
63      this->collider = entity;
[5258]64  }
[5259]65  else if (entity->isA(CL_PLAYER))
66    this->applyForce(Vector(0,0,0)-location*100);
[5451]67  else if (entity->isA(CL_NPC))
[5258]68  {
69    this->setVisibiliy(false);
[6142]70    this->toList(OM_DEAD);
[6054]71    this->removeNode();
[5258]72  }
[1931]73}
Note: See TracBrowser for help on using the repository browser.