roh/conf/area/
roh/game/talk/
roh/help/
roh/monsters/ocean/
roh/objects/ocean/
roh/player/
roh/rooms/area/1/
roh/rooms/misc/
roh/rooms/ocean/
roh/src-2.44b/
/*
 * effects.h
 *   effects on creatures
 *   ____            _
 *  |  _ \ ___  __ _| |_ __ ___  ___
 *  | |_) / _ \/ _` | | '_ ` _ \/ __|
 *  |  _ <  __/ (_| | | | | | | \__ \
 *  |_| \_\___|\__,_|_|_| |_| |_|___/
 *
 * Permission to use, modify and distribute is granted via the
 *  Creative Commons - Attribution - Non Commercial - Share Alike 3.0 License
 *    http://creativecommons.org/licenses/by-nc-sa/3.0/
 *
 * 	Copyright (C) 2007-2009 Jason Mitchell, Randi Mitchell
 * 	   Contributions by Tim Callahan, Jonathan Hseu
 *  Based on Mordor (C) Brooke Paul, Brett J. Vickers, John P. Freeman
 *
 */

#ifndef EFFECTS_H_
#define EFFECTS_H_

#define EFFECT_MAX_DURATION	10800
#define EFFECT_MAX_STRENGTH	5000

#include <iostream>

// Actions to be taken by the effect function
enum EffectType {
	NO_EFFECT_TYPE,

	GOOD_EFFECT,
	NEUTRAL_EFFECT,
	BAD_EFFECT,

	MAX_EFFECT_TYPE
};

// Forward Delcaration
class Creature;

// Typedefs
typedef bool(*EffectFn)(EffectInfo* effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);

typedef struct {
	bstring name;
	bstring display;

	bstring oppositeEffect;

	bstring selfStrAdd;
	bstring roomStrAdd;
	bstring selfStrDel;
	bstring roomStrDel;

	EffectFn effFn;

	bool needsPulse;	// Does this effect need to be pulsed?

	EffectType type;
} EffectList, *effectPtr;

// Effects that are conferred from spells or items
class ConferredEffect {
private:
	bstring name;	// Name of the effect
	int strength;	// Strength of the effect
	int duration;	// How long this effect will last
};

// Information about an effect on a creature
class EffectInfo
{
private:
	bstring name; 		// Which effect is this
	bstring pOwner;		// Who cast this effect (player)
	time_t	lastMod;	// When did we last update duration
	long	duration;	// How much longer will this effect last
	int		strength;	// How strong is this effect (for overwriting effects)
	int		extra;		// Extra info
	effectPtr myEffect;	// Pointer to the effect listing

	Creature* parentCreature; // Who are we effecting
	BaseRoom* parentRoom;
	Exit* parentExit;

public:
	EffectInfo();
	EffectInfo(bstring pName, time_t pLastMod, long pDuration, int pStrength, Creature* cParent=0, BaseRoom* rParent=0, Exit* xParent=0, const Creature* owner=0);
	EffectInfo(xmlNodePtr rootNode, EffectParentType type);
	virtual ~EffectInfo();

	bool compute(void* applier, ApplyFrom aFrom);
	bool add(void);
	bool apply(void);

	bool willOverWrite(EffectInfo* existingEffect) const;

	friend std::ostream& operator<<(std::ostream& out, const EffectInfo& eff);

	void setParentCreature(Creature* parent);
	void setParentRoom(BaseRoom* parent);
	void setParentExit(Exit* parent);

	const bstring& getName() const;
	bstring getDisplayName() const;
	const bstring& getOwner() const;
	bool isOwner(const Creature* owner) const;
	time_t getLastMod() const;
	long getDuration() const;
	int getStrength() const;
	int getExtra() const;
	Creature* getParentCreature() const;
	BaseRoom* getParentRoom() const;
	Exit* getParentExit() const;
	BaseRoom* getRoom() const;

	effectPtr getEffect() const;
	bool isPermanent() const;

	bool updateLastMod(time_t t);
	bool pulse(time_t t);
	bool remove(bool show = true);

	void setOwner(const Creature* owner);
	void setStrength(int pStrength);
	void setExtra(int pExtra);
	void setDuration(long pDuration);

	void save(xmlNodePtr rootNode) const;
	bool isCurse() const;
	bool isDisease() const;
	bool isPoison() const;
};

effectPtr findEffect(const bstring& effect, EffectParentType type);
EffectFn findEffectFn(const bstring& effect, EffectParentType type);

bool effectPoison(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectDisease(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectCurse(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectVisibility(EffectInfo* effect, Creature* target, EffectAction action,  void* applier, ApplyFrom aFrom);
bool effectBeneficial(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectShield(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectDetect(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectDarkInfra(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectLanguages(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectGravity(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectResist(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectVuln(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectImmune(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectNatural(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectStatRaise(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectStatLower(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectGeneric(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectWall(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);
bool effectRoomDoT(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);

// Weapon Resist, Vuln, Immune
bool effectWeaponRVI(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);

// Death Sickness!
bool effectDeathSickness(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);

// Petrify, hold person, etc
bool effectDisable(EffectInfo *effect, Creature* target, EffectAction action, void* applier, ApplyFrom aFrom);

#endif /*EFFECTS_H_*/