Planeshift

combatmanager.h

Go to the documentation of this file.
00001 /*
00002  * combatmanager.h
00003  *
00004  * Copyright (C) 2001-2002 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef __COMBATMANAGER_H__
00021 #define __COMBATMANAGER_H__
00022 
00023 //=============================================================================
00024 // Local Includes
00025 //=============================================================================
00026 #include "msgmanager.h"
00027 
00028 
00029 #define SECONDS_BEFORE_SPARING_DEFEATED 30
00030 
00031 class psCombatGameEvent;
00032 struct Stance;
00033 
00034 enum COMBATMANAGER_ATTACKTYPE
00035 {
00036     ATTACK_NOTCALCULATED = -1,
00037     ATTACK_DAMAGE,
00038     ATTACK_DODGED,
00039     ATTACK_BLOCKED,
00040     ATTACK_MISSED,
00041     ATTACK_OUTOFRANGE,
00042     ATTACK_BADANGLE,
00043     ATTACK_OUTOFAMMO
00044 };
00045 
00046 class LocationType;
00047 class MathScriptEngine;
00048 class MathScript;
00049 
00055 class CombatManager: public MessageManager<CombatManager>
00056 {
00057 public:
00058 
00059     CombatManager(CacheManager* cachemanager, EntityManager* entitymanager);
00060     bool InitializePVP();
00061 
00062     virtual ~CombatManager();
00063 
00065     bool AttackSomeone(gemActor* attacker, gemActor* target, const Stance& stance);
00066 
00068     void StopAttack(gemActor* attacker);
00069 
00070     bool InPVPRegion(csVector3 &pos, iSector* sector);
00071 
00080     static const Stance &GetStance(CacheManager* cachemanager, csString name);
00081 
00090     static const Stance &GetRaisedActorStance(CacheManager* cachemanager, gemActor* attacker);
00091 
00100     static const Stance &GetLoweredActorStance(CacheManager* cachemanager, gemActor* attacker);
00101 
00102     EntityManager* GetEntityManager()
00103     {
00104         return entityManager;
00105     };
00106 
00107     csArray<INVENTORY_SLOT_NUMBER> targetLocations;
00108     void SetCombat(gemActor* combatant, const Stance& stance);
00109     void NotifyTarget(gemActor* attacker, gemObject* target);
00110     void sendAttackList(MsgEntry* me, Client* client);
00111     void sendAttackQueue(MsgEntry* me, Client* client);
00112     void sendAttackQueue(psCharacter* character);
00113 private:
00114     csRandomGen* randomgen;
00115     LocationType* pvp_region;
00116     CacheManager* cacheManager;
00117     EntityManager* entityManager;
00118 
00119 
00120     void HandleDeathEvent(MsgEntry* me,Client* client);
00121 
00122 };
00123 
00124 class psSpareDefeatedEvent: public psGameEvent
00125 {
00126 public:
00127     psSpareDefeatedEvent(gemActor* losr);
00128     void Trigger();
00129 
00130 protected:
00131     csWeakRef<Client> loser;
00132 
00133 };
00134 
00135 #endif