Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/preferences/src/world_entities/npcs/npc.cc @ 6828

Last change on this file since 6828 was 6341, checked in by bensch, 19 years ago

orxonox/trunk: merged the network branche back to the trunk, so we do not get away from each other to fast

File size: 1.7 KB
Line 
1
2
3/*
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.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer:
16*/
17#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
18
19
20#include "npc.h"
21#include "obb_tree.h"
22
23#include "state.h"
24#include "stdlibincl.h"
25#include "power_ups/turret_power_up.h"
26#include "power_ups/laser_power_up.h"
27
28using namespace std;
29
30
31NPC::NPC()
32{
33  this->setClassID(CL_NPC, "NPC");
34  this->toList(OM_GROUP_00);
35}
36
37
38NPC::~NPC () {}
39
40
41void NPC::collidesWith(WorldEntity* entity, const Vector& location)
42{
43  if (entity->isA(CL_PROJECTILE) && entity != this->collider)
44  {
45//    PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z);
46//    this->applyForce(Vector(0,0,0)-location*1000);
47    if ((float)rand()/RAND_MAX < .3)
48    {
49      WorldEntity* powerUp = new TurretPowerUp();
50      powerUp->setAbsCoor(this->getAbsCoor());
51//      powerUp->toList(OM_COMMON);
52    }
53    else if ((float)rand()/RAND_MAX < .3)
54    {
55      WorldEntity* powerUp = new LaserPowerUp();
56      powerUp->setAbsCoor(this->getAbsCoor());
57      powerUp->toList(OM_COMMON);
58    }
59    this->toList(OM_DEAD);
60    this->removeNode();
61
62      this->collider = entity;
63  }
64  //  else if (entity->isA(CL_PLAYER))
65  //    this->applyForce(Vector(0,0,0)-location*100);
66  else if (entity->isA(CL_NPC))
67  {
68    this->setVisibiliy(false);
69    this->toList(OM_DEAD);
70    this->removeNode();
71  }
72}
Note: See TracBrowser for help on using the repository browser.