File: combat.h

package info (click to toggle)
exult 1.2-15
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze
  • size: 8,640 kB
  • ctags: 10,524
  • sloc: cpp: 99,373; sh: 7,324; ansic: 4,659; makefile: 985; yacc: 769; lex: 313; xml: 19
file content (106 lines) | stat: -rw-r--r-- 3,660 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 *	combat.h - Combat scheduling.
 *
 *  Copyright (C) 2000-2001  The Exult Team
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef COMBAT_H
#define COMBAT_H	1

#include "schedule.h"
#include "lists.h"

class Actor;
class Spellbook_object;

/*
 *	Combat schedule:
 */
class Combat_schedule : public Schedule
	{
protected:
	static unsigned long battle_time;// Time when battle started.
	static unsigned long battle_end_time;	// And when it ended.
	enum Phase			// We'll be a finite-state-machine.
		{
		initial = 0,		// Just constructed.
		approach = 1,		// Approaching a foe to attack.
		retreat = 2,		// Avoiding a foe.
		flee = 3,		// Run away!
		strike = 4,		// In the process of striking.
		fire = 5,		// In process of firing range weapon.
		parry = 6,		// In the process of parrying a blow.
		stunned = 7,		// Just been hit.
		wait_return = 8		// Wait for boomerang.
		} state;
	Schedule_types prev_schedule;	// Before going into combat.
	Actor_queue opponents;		// Possible opponents.
	Game_object *practice_target;	// Only for duel schedule.
	int weapon_shape;		// Weapon's shape in shapes.vga.
	int ammo_shape;			// If required, else 0.
	int projectile_shape;		// For shooting, else 0.
	Spellbook_object *spellbook;	// If readied.
					// Ranges in tiles.  
					//   0 means not applicable.
	unsigned char strike_range, projectile_range, max_range;
	bool is_thrown;			// Daggers, etc.
	bool returns;			// Boomerang, magic axe.
	bool no_blocking;		// Weapon/ammo goes through walls.
	unsigned char yelled;		// Yell when first opponent targeted.
	bool started_battle;		// 1st opponent targeted.
	unsigned char fleed;		// Incremented when fleeing.
	bool can_yell;
	int failures;			// # failures to find opponent.
	unsigned int teleport_time;	// Next time we can teleport.
	void start_battle();		// Play music at start of battle.
	bool teleport();		// For monsters that can.
	virtual void find_opponents();
	Actor *find_protected_attacker();// Find attacker of protected member.
	Game_object *find_foe(int mode);// Find a new opponent.
	Game_object *find_foe();
	void approach_foe();		// Approach foe.
	void start_strike();
	void run_away();
	Spellbook_object *readied_spellbook();
public:
	Combat_schedule(Actor *n, Schedule_types prev_sched);
	static void monster_died();	// Checks for victory.
	virtual void now_what();	// Npc calls this when it's done
	virtual void im_dormant();	// Npc calls this when it goes dormant.
	virtual void ending(int newtype);// Switching to another schedule.
	virtual void set_weapon();	// Set weapon info.
	bool has_started_battle() const
		{ return started_battle; }
	};

/*
 *	Dueling is like combat, but nobody gets hurt.
 */

class Duel_schedule : public Combat_schedule
	{
	Tile_coord start;		// Starting position.
	int attacks;			// Count strikes.
	virtual void find_opponents();
public:
	Duel_schedule(Actor *n);
	virtual void now_what();
	};

bool In_ammo_family(int shnum, int family);// Yow, a global function.

#endif