12#ifndef TT_INCLUDE__DEFENSEOBJECTCLASS_H
13#define TT_INCLUDE__DEFENSEOBJECTCLASS_H
15#include "ReferencerClass.h"
17class OffenseObjectClass;
19class DamageableGameObj;
20class DefenseObjectDefClass;
22typedef unsigned int ArmorType;
23typedef unsigned int WarheadType;
24typedef safe_unsigned_int SafeArmorType;
25typedef safe_unsigned_int SafeWarheadType;
26class DefenseObjectClass {
27#define DEFAULT_HEALTH 100.0f
29 DefenseObjectClass(
float health = DEFAULT_HEALTH, ArmorType skin = 0 ) :
30 Health( health ), HealthMax( health ), Skin( skin ), ShieldStrength( 0 ), ShieldStrengthMax( 0 ), ShieldType( 0 ), CanObjectDie( true ) {};
32 ~DefenseObjectClass() {};
33 void Init(
const DefenseObjectDefClass & def, DamageableGameObj * owner);
34 bool Save( ChunkSaveClass & csave );
35 bool Load( ChunkLoadClass & cload );
36 void Set_Owner( DamageableGameObj *owner ) { Owner = (ScriptableGameObj *)owner; }
37 DamageableGameObj *Get_Owner(
void )
const {
return (DamageableGameObj *)Owner.Get_Ptr(); }
38 void Set_Skin( ArmorType skin ) { Skin = skin; }
39 ArmorType Get_Skin(
void )
const {
return Skin; }
40 enum {MAX_MAX_HEALTH = 2000};
41 enum {MAX_MAX_SHIELD_STRENGTH = 2000};
42 enum {MAX_MAX_HEALTH_NEW = 10000};
43 enum {MAX_MAX_SHIELD_STRENGTH_NEW = 10000};
44 void Set_Health(
float health);
45 void Add_Health(
float add_health);
46 float SCRIPTS_API Get_Health(
void)
const ;
47 void SCRIPTS_API Set_Health_Max(
float health);
48 float SCRIPTS_API Get_Health_Max(
void)
const ;
49 void Set_Shield_Strength(
float str);
50 void Add_Shield_Strength(
float str);
51 float SCRIPTS_API Get_Shield_Strength(
void)
const ;
52 void SCRIPTS_API Set_Shield_Strength_Max(
float str);
53 float SCRIPTS_API Get_Shield_Strength_Max(
void)
const ;
54 void SCRIPTS_API Set_Shield_Type( ArmorType type );
55 unsigned long Get_Shield_Type(
void )
const {
return ShieldType; }
56 float Apply_Damage(
const OffenseObjectClass & offense,
float scale = 1.0f,
int alternate_skin = -1 );
57 float Do_Damage(
const OffenseObjectClass & offense,
float scale = 1.0f,
int alternate_skin = -1 );
58 void Request_Damage(
const OffenseObjectClass & offense,
float scale = 1.0f );
59 bool Is_Repair(
const OffenseObjectClass & offense,
float scale = 1.0f );
60 bool Would_Damage(
const OffenseObjectClass & offense,
float scale = 1.0f );
62 void Set_Can_Object_Die(
bool onoff ) { CanObjectDie = onoff; }
63 virtual void Import( BitStreamClass & packet );
64 virtual void Export( BitStreamClass & packet );
65 static void Set_Precision(
void);
66 float Get_Damage_Points(
void)
const {
return DamagePoints; }
67 float Get_Death_Points(
void)
const {
return DeathPoints; }
68 bool Can_Trust_Client_Damage (SmartGameObj* damager)
const;
69 void SCRIPTS_API Mark_Owner_Dirty(
void );
70 void Set_Damage_Points(
float points) {DamagePoints = points;}
71 void Set_Death_Points(
float points) {DeathPoints = points;}
76 safe_float ShieldStrength;
77 safe_float ShieldStrengthMax;
78 SafeArmorType ShieldType;
79 safe_float DamagePoints;
80 safe_float DeathPoints;
82 ReferencerClass Owner;