/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli co-programmer: */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "npc_test.h" #include "state.h" #include "debug.h" #include "loading/factory.h" #include "loading/load_param.h" #include "md2/md2Model.h" #include "player.h" #include "playable.h" #include "class_id_DEPRECATED.h" ObjectListDefinitionID(NPC2, CL_NPC_TEST2); CREATE_FACTORY(NPC2); NPC2::NPC2(const TiXmlElement* root) : NPC(NULL) { this->registerObject(this, NPC2::_objectList); if (root != NULL)this->loadParams(root); addToTeam(0); } NPC2::~NPC2 () {} void NPC2::loadParams(const TiXmlElement* root) { NPC::loadParams(root); } void NPC2::tick(float dt) { // animating the md2 model (uninteressant) if( likely(this->getModel(0) != NULL)) ((MD2Model*)this->getModel(0))->tick(dt); return; //this things will now be managed by the AI modules....///// PRINTF(0)("====================\n"); PRINTF(0)("NPC2::tick(%f)\n", dt); // information gathering Vector absPosition = this->getAbsCoor(); PRINTF(0)(" npc abs coor: %f, %f, %f\n", absPosition.x, absPosition.y, absPosition.z); Player* pl = State::getPlayer(); Vector playerAbsPos = pl->getPlayable()->getAbsCoor(); PRINTF(0)(" player abs coor: %f, %f, %f\n", playerAbsPos.x, playerAbsPos.y, playerAbsPos.z); // intelligent reaction Vector distanceVector = playerAbsPos - absPosition; distanceVector.normalize(); float speed = 10.0f; this->shiftCoor( distanceVector * speed * dt); }