[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 | |
---|
[5682] | 20 | #include "npc_test1.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] | 29 | using namespace std; |
---|
[1853] | 30 | |
---|
[1858] | 31 | |
---|
[5682] | 32 | NPCTest1::NPCTest1() |
---|
[1931] | 33 | { |
---|
[5682] | 34 | this->setClassID(CL_NPC, "NPCTest1"); |
---|
[4976] | 35 | |
---|
[5621] | 36 | if ((float)rand()/RAND_MAX > .5f) |
---|
| 37 | this->loadModel("models/ships/bolido.obj", 2); |
---|
| 38 | else |
---|
| 39 | this->loadModel("models/ships/gobblin.obj", 2); |
---|
[5059] | 40 | |
---|
[5427] | 41 | this->randomRotAxis = VECTOR_RAND(1); |
---|
[1931] | 42 | } |
---|
[1853] | 43 | |
---|
[5034] | 44 | |
---|
[5682] | 45 | NPCTest1::~NPCTest1 () {} |
---|
[1853] | 46 | |
---|
| 47 | |
---|
[5682] | 48 | void NPCTest1::collidesWith(WorldEntity* entity, const Vector& location) |
---|
[5029] | 49 | { |
---|
[5451] | 50 | if (entity->isA(CL_PROJECTILE) && entity != this->collider) |
---|
[5258] | 51 | { |
---|
[5451] | 52 | // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getName(), entity->getName(), location.x, location.y, location.z); |
---|
| 53 | // this->applyForce(Vector(0,0,0)-location*1000); |
---|
| 54 | if ((float)rand()/RAND_MAX < .3) |
---|
| 55 | { |
---|
| 56 | WorldEntity* powerUp = new TurretPowerUp(); |
---|
| 57 | powerUp->setAbsCoor(this->getAbsCoor()); |
---|
| 58 | State::getWorldEntityList()->add(powerUp); |
---|
| 59 | } |
---|
[5458] | 60 | else if ((float)rand()/RAND_MAX < .3) |
---|
| 61 | { |
---|
| 62 | WorldEntity* powerUp = new LaserPowerUp(); |
---|
| 63 | powerUp->setAbsCoor(this->getAbsCoor()); |
---|
| 64 | State::getWorldEntityList()->add(powerUp); |
---|
| 65 | } |
---|
[5451] | 66 | State::getWorldEntityList()->remove(this); |
---|
| 67 | |
---|
| 68 | this->collider = entity; |
---|
[5258] | 69 | } |
---|
[5259] | 70 | else if (entity->isA(CL_PLAYER)) |
---|
| 71 | this->applyForce(Vector(0,0,0)-location*100); |
---|
[5451] | 72 | else if (entity->isA(CL_NPC)) |
---|
[5258] | 73 | { |
---|
| 74 | this->setVisibiliy(false); |
---|
[5451] | 75 | State::getWorldEntityList()->remove(this); |
---|
[5258] | 76 | } |
---|
[1931] | 77 | } |
---|
| 78 | |
---|
[5029] | 79 | |
---|
[5682] | 80 | void NPCTest1::tick(float dt) |
---|
[4984] | 81 | { |
---|
[5257] | 82 | // Vector direction = (State::getCameraTarget()->getAbsCoor() - this->getAbsCoor()); |
---|
[2036] | 83 | |
---|
[4986] | 84 | //if (directin.len() < 100) |
---|
[5257] | 85 | // this->shiftCoor(direction *dt * 5 * exp(-direction.len() / 30.0)); |
---|
[5060] | 86 | this->shiftDir(Quaternion(dt, this->randomRotAxis)); |
---|
[4986] | 87 | |
---|
[4984] | 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
[5033] | 91 | |
---|