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 | |
---|
18 | |
---|
19 | #include "npc.h" |
---|
20 | #include "obb_tree.h" |
---|
21 | |
---|
22 | #include "state.h" |
---|
23 | #include "list.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | |
---|
28 | NPC::NPC() |
---|
29 | { |
---|
30 | this->setClassID(CL_NPC, "NPC"); |
---|
31 | |
---|
32 | this->loadModelWithScale("models/ships/bolido.obj", 2); |
---|
33 | |
---|
34 | this->randomRotAxis = VECTOR_RAND(1); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | NPC::~NPC () {} |
---|
39 | |
---|
40 | |
---|
41 | void NPC::collidesWith(WorldEntity* entity, const Vector& location) |
---|
42 | { |
---|
43 | if (entity->isA(CL_PROJECTILE)) |
---|
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 | } |
---|
48 | else if (entity->isA(CL_PLAYER)) |
---|
49 | this->applyForce(Vector(0,0,0)-location*100); |
---|
50 | else |
---|
51 | { |
---|
52 | this->setVisibiliy(false); |
---|
53 | State::getWorldEntityList()->remove(this); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | void NPC::tick(float dt) |
---|
59 | { |
---|
60 | // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor()); |
---|
61 | |
---|
62 | //if (directin.len() < 100) |
---|
63 | // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0)); |
---|
64 | this->shiftDir(Quaternion(dt, this->randomRotAxis)); |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | |
---|