Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/npcs/npc_test.cc

Last change on this file was 10376, checked in by patrick, 17 years ago

merged branche ai to trunk

File size: 2.8 KB
RevLine 
[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"
[10376]21#include <stdio.h>
[1853]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
[10376]29#include "md2/md2Model.h"
30#include "player.h"
31#include "playable.h"
[1853]32
[10376]33#include "weapons/test_gun.h"
34#include "weapons/turret.h"
35#include "weapons/cannon.h"
[10114]36
[10376]37
[10114]38ObjectListDefinition(NPC2);
[9869]39CREATE_FACTORY(NPC2);
[1858]40
[10376]41
[9235]42NPC2::NPC2(const TiXmlElement* root)
[1931]43{
[9869]44  this->registerObject(this, NPC2::_objectList);
[4976]45
[10376]46  if (root != NULL)
47    this->loadParams(root);
[5621]48
[9235]49
[10376]50  // create the weapons and their manager
[9235]51
52
[10376]53  this->getWeaponManager().changeWeaponConfig(1);
54  Weapon* wpRight = new TestGun(0);
55  wpRight->setName("testGun Right");
56  Weapon* wpLeft = new TestGun(1);
57  wpLeft->setName("testGun Left");
[5059]58
[10376]59  this->addWeapon(wpLeft, 1, 0);
60  this->addWeapon(wpRight,1 ,1);
[5266]61
[10376]62  this->setHealthMax(100);
63  this->setHealth(80);
[1853]64
[10376]65  this->getWeaponManager().setSlotCount(7);
[5034]66
[10376]67  this->getWeaponManager().setSlotPosition(0, Vector(-2.6, .1, -3.0));
68  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[1853]69
[10376]70  this->getWeaponManager().setSlotPosition(1, Vector(-2.6, .1, 3.0));
71  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
[5267]72
[10376]73  this->getWeaponManager().setSlotPosition(2, Vector(-1.5, .5, -.5));
74  this->getWeaponManager().setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
[1931]75
[10376]76  this->getWeaponManager().setSlotPosition(3, Vector(-1.5, .5, .5));
77  this->getWeaponManager().setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
78
79  this->getWeaponManager().setSlotPosition(4, Vector(-1.5, -.5, .5));
80  this->getWeaponManager().setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
81
82  this->getWeaponManager().setSlotPosition(5, Vector(-1.5, -.5, -.5));
83  this->getWeaponManager().setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
84
85  this->getWeaponManager().setSlotPosition(6, Vector(-1, 0.0, 0));
86  this->getWeaponManager().setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
87
88  this->getWeaponManager().getFixedTarget()->setParent(this);
89  this->getWeaponManager().getFixedTarget()->setRelCoor(100000,0,0);
90
[9235]91}
92
[10376]93NPC2::~NPC2()
94{
95}
[9235]96
[10376]97void NPC2::loadParams(const TiXmlElement* root)
[9235]98{
[10376]99  NPC::loadParams(root);
[9235]100
101}
102
103
104
[5266]105void NPC2::tick(float dt)
106{
[2036]107
[4986]108
[10376]109
110
111  // animating the md2 model
112  if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(MD2Model::staticClassID()))
113    ((MD2Model*)this->getModel(0))->tick(dt);
[4984]114}
115
116
[5033]117
Note: See TracBrowser for help on using the repository browser.