Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
weapon_xml.h
Go to the documentation of this file.
1 #ifndef _CMD_WEAPON_XML_H_
2 #define _CMD_WEAPON_XML_H_
3 #include <string>
4 #include "gfx/vec.h"
5 
6 namespace BeamXML
7 {
8 void beginElement( void *userData, const char *name, const char **atts );
9 }
10 
12 {
13  friend void BeamXML::beginElement( void *userData, const char *name, const char **atts );
15  {
21  }
22  type;
24  {
25  NOWEAP=0x0, LIGHT=0x1, MEDIUM=0x2, HEAVY=0x4, CAPSHIPLIGHT=0x8, CAPSHIPHEAVY=0x10, SPECIAL=0x20,
27  0x400,
29  }
30  size;
32  int role_bits;
33  int sound;
34  float r, g, b, a;
38  float Refire() const;
40  std::string file;
41  std::string weapon_name;
42  mutable class Mesh *gun; //requres nonconst to add to orig drawing queue when drawing
43  mutable class Mesh *gun1; //requres nonconst to add to orig drawing queue when drawing
44  void init()
45  {
46  gun = gun1 = NULL;
47  TextureStretch = 1;
48  role_bits = 0;
49  offset = Vector( 0, 0, 0 );
50  size = NOWEAP;
51  r = g = b = a = 127;
52  Length = 5;
53  Speed = 10;
54  PulseSpeed = 15;
55  RadialSpeed = 1;
56  Range = 100;
57  Radius = .5;
58  Damage = 1.8;
59  PhaseDamage = 0;
60  Stability = 60;
61  Longrange = .5;
62  LockTime = 0;
63  EnergyRate = 18;
64  RefireRate = .2;
65  sound = -1;
66  volume = 0;
67  }
68  void Type( enum WEAPON_TYPE typ )
69  {
70  type = typ;
71  switch (typ)
72  {
73  case BOLT:
74  file = std::string( "" );
75  break;
76  case BEAM:
77  file = std::string( "beamtexture.bmp" );
78  break;
79  case BALL:
80  file = std::string( "ball.ani" );
81  break;
82  case PROJECTILE:
83  file = std::string( "missile.bfxm" );
84  break;
85  default:
86  break;
87  }
88  }
89  void MntSize( enum MOUNT_SIZE size )
90  {
91  this->size = size;
92  }
94  {
95  init();
96  Type( typ );
97  }
98  weapon_info( const weapon_info &tmp )
99  {
100  *this = tmp;
101  }
102  void netswap();
103 private:
104  float RefireRate;
105 };
106 weapon_info getWeaponInfoFromBuffer( char *netbuf, int &size );
107 void setWeaponInfoToBuffer( weapon_info wi, char *netbuf, int &bufsize ); //WARNING : ALLOCATES A CHAR * BUFFER SO IT MUST BE DELETED AFTER THAT CALL
108 
109 enum weapon_info::MOUNT_SIZE lookupMountSize( const char *str );
110 std::string lookupMountSize( int size );
111 void LoadWeapons( const char *filename );
112 weapon_info * getTemplate( const std::string &key );
113 
114 #endif
115