Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ai/src/world_entities/npcs/npc_test.cc @ 10275

Last change on this file since 10275 was 10275, checked in by tfahrni, 17 years ago

npc can shoot

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