[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_test.h" |
---|
[1853] | 21 | |
---|
[9947] | 22 | |
---|
[4984] | 23 | #include "state.h" |
---|
[5511] | 24 | #include "debug.h" |
---|
[4984] | 25 | |
---|
[9235] | 26 | #include "loading/factory.h" |
---|
| 27 | #include "loading/load_param.h" |
---|
[5511] | 28 | |
---|
[9947] | 29 | #include "md2/md2Model.h" |
---|
| 30 | #include "player.h" |
---|
| 31 | #include "playable.h" |
---|
[1853] | 32 | |
---|
[9869] | 33 | #include "class_id_DEPRECATED.h" |
---|
[10041] | 34 | |
---|
[9869] | 35 | ObjectListDefinitionID(NPC2, CL_NPC_TEST2); |
---|
| 36 | CREATE_FACTORY(NPC2); |
---|
[1858] | 37 | |
---|
[9947] | 38 | |
---|
[9235] | 39 | NPC2::NPC2(const TiXmlElement* root) |
---|
[8724] | 40 | : NPC(NULL) |
---|
[1931] | 41 | { |
---|
[9869] | 42 | this->registerObject(this, NPC2::_objectList); |
---|
[4976] | 43 | |
---|
[5621] | 44 | |
---|
[10041] | 45 | if (root != NULL)this->loadParams(root); |
---|
| 46 | |
---|
| 47 | addToTeam(0); |
---|
[1931] | 48 | } |
---|
[1853] | 49 | |
---|
[5034] | 50 | |
---|
[5267] | 51 | NPC2::~NPC2 () |
---|
[9869] | 52 | {} |
---|
[1853] | 53 | |
---|
[5267] | 54 | |
---|
[9235] | 55 | void NPC2::loadParams(const TiXmlElement* root) |
---|
| 56 | { |
---|
| 57 | NPC::loadParams(root); |
---|
[1931] | 58 | |
---|
[9235] | 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
[9947] | 62 | |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | void NPC2::tick(float dt) |
---|
[9235] | 66 | { |
---|
[10041] | 67 | |
---|
| 68 | |
---|
[9947] | 69 | // animating the md2 model (uninteressant) |
---|
| 70 | if( likely(this->getModel(0) != NULL)) |
---|
| 71 | ((MD2Model*)this->getModel(0))->tick(dt); |
---|
[9235] | 72 | |
---|
[10041] | 73 | return; |
---|
| 74 | //this things will now be managed by the AI modules....///// |
---|
[9235] | 75 | |
---|
[9947] | 76 | PRINTF(0)("====================\n"); |
---|
| 77 | PRINTF(0)("NPC2::tick(%f)\n", dt); |
---|
[9235] | 78 | |
---|
[9947] | 79 | // information gathering |
---|
[9235] | 80 | |
---|
[9947] | 81 | Vector absPosition = this->getAbsCoor(); |
---|
[9235] | 82 | |
---|
[9947] | 83 | PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z); |
---|
[9235] | 84 | |
---|
[9947] | 85 | Player* pl = State::getPlayer(); |
---|
| 86 | Vector playerAbsPos = pl->getPlayable()->getAbsCoor(); |
---|
[9235] | 87 | |
---|
[9947] | 88 | PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z); |
---|
[9235] | 89 | |
---|
[5266] | 90 | |
---|
[9947] | 91 | // intelligent reaction |
---|
[5266] | 92 | |
---|
[9947] | 93 | Vector distanceVector = playerAbsPos - absPosition; |
---|
| 94 | distanceVector.normalize(); |
---|
[2036] | 95 | |
---|
[9947] | 96 | float speed = 10.0f; |
---|
[4986] | 97 | |
---|
[9947] | 98 | this->shiftCoor( distanceVector * speed * dt); |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | |
---|
[4984] | 102 | } |
---|
| 103 | |
---|
| 104 | |
---|
[5033] | 105 | |
---|