Well, at present the Windows code for the actual game almost compiles. The current goal is to undo all the things that Ormus did to make this job difficult.

Basically, remove as many as possible of the dependencies of the source files in the tools and classes folders on source files not in those folders.
(With the exception that files in the classes folder may depend on files in the tools folder.)

In this commit, several changes were made.
- Project file modified, may need further modification.
- Many files renamed to match the Mac version.
- #include statements for system headers changed to use <> instead of "" (some already did, but many didn't).
- xxx.h headers replaced with cxxx headers where appropriate.
- Most sound-related variables moved from globvars.cpp to soundvars.cpp.
- The files originally named graphutil and gutils have been merged.
- Changed TRUE/FALSE to true/false.
- Changed exlsound to soundtool and mostly removed dependencies on the main game files; the exception is that it still uses mainPtr (which probably can't be helped)
  and print_nums (which should probably be incorporated into the MessageBox string).
- Possibly other things that were forgotten.

For some reason this commit also includes changes recently committed into the branch for osx.

git-svn-id: http://openexile.googlecode.com/svn/trunk@121 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
2009-08-03 19:00:23 +00:00
parent c6a5f5bacd
commit b02902770c
84 changed files with 2585 additions and 1392 deletions

View File

@@ -0,0 +1,167 @@
#include "location.h" // location
#include "exlsound.h" // play_sound
#include "boe.main.h" // out
#include "boe.text.h" // add_string_to_buf
#include "boe.locutils.h" // alter_space
#include "boe.items.h" // fancy_choice_dialog
#include "global.h"
#include "globvar.h"
location location::toGlobal()
{
//return local_to_global(*this);
location global = *this;
if (party.i_w_c.x == 1) global.x = global.x + 48;
if (party.i_w_c.y == 1) global.y = global.y + 48;
return global;
}
location location::toLocal()
{
// return global_to_local(*this);
location local = (*this);
if (party.i_w_c.x == 1) local.x = local.x - 48;
if (party.i_w_c.y == 1) local.y = local.y - 48;
return local;
}
short location::countWalls() const
{
unsigned char walls[31] = {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};
short answer = 0;
short k = 0;
for (k = 0; k < 31 ; k++)
{
if (out[x + 1][y] == walls[k]) answer++;
if (out[x - 1][y] == walls[k]) answer++;
if (out[x][y + 1] == walls[k]) answer++;
if (out[x][y - 1] == walls[k]) answer++;
}
return answer;
}
// 0 if no pull.
// 1 if in right position now.
// 2 if in left position
// levers should always start to left.
short location::handleLever()
{
if (FCD(1020,0) == 1) return 0;
play_sound(94);
alter_space(x,y,scenario.ter_types[t_d.terrain[x][y]].trans_to_what);
return 1;
}
void location::crumbleWall()
{
unsigned char ter;
if (loc_off_act_area(*this) == TRUE)
return;
ter = t_d.terrain[x][y];
if (scenario.ter_types[ter].special == 7) {
play_sound(60);
t_d.terrain[x][y] = scenario.ter_types[ter].flag1;
if(scenario.ter_types[scenario.ter_types[ter].flag1].special >= 16 && scenario.ter_types[scenario.ter_types[ter].flag1].special <=19)
belt_present = TRUE;
add_string_to_buf(" Barrier crumbles.");
}
}
bool location::isDoor() const
{
if ((scenario.ter_types[t_d.terrain[x][y]].special == 9) ||
(scenario.ter_types[t_d.terrain[x][y]].special == 1) ||
(scenario.ter_types[t_d.terrain[x][y]].special == 10))
return true;
return false;
}
//void pick_lock(location where,short pc_num)
void location::pickLock(short pc_num)
{
unsigned char terrain;
short r1,which_item;
Boolean will_break = FALSE;
short unlock_adjust;
terrain = t_d.terrain[x][y];
which_item = adven[pc_num].hasAbilEquip(161);
if (which_item == 24) {
add_string_to_buf(" Need lockpick equipped. ");
return;
}
r1 = get_ran(1,0,100) + adven[pc_num].items[which_item].ability_strength * 7;
if (r1 < 75)
will_break = TRUE;
r1 = get_ran(1,0,100) - 5 * adven[pc_num].statAdj(1) + c_town.difficulty * 7
- 5 * adven[pc_num].skills[15] - adven[pc_num].items[which_item].ability_strength * 7;
// Nimble?
if (adven[pc_num].traits[TRAIT_NIMBLE] == TRUE) r1 -= 8;
if (adven[pc_num].hasAbilEquip(42) < 24)
r1 = r1 - 12;
if ((scenario.ter_types[terrain].special < 9) || (scenario.ter_types[terrain].special > 10)) {
add_string_to_buf(" Wrong terrain type. ");
return;
}
unlock_adjust = scenario.ter_types[terrain].flag2;
if ((unlock_adjust >= 5) || (r1 > (unlock_adjust * 15 + 30))) {
add_string_to_buf(" Didn't work. ");
if (will_break == TRUE)
{
add_string_to_buf(" Pick breaks. ");
adven[pc_num].removeCharge(which_item);
}
play_sound(41);
}
else {
add_string_to_buf(" Door unlocked. ");
play_sound(9);
t_d.terrain[x][y] = scenario.ter_types[terrain].flag1;
if(scenario.ter_types[scenario.ter_types[terrain].flag1].special >= 16 && scenario.ter_types[scenario.ter_types[terrain].flag1].special <=19)
belt_present = TRUE;
}
}
//void bash_door(location where,short pc_num)
void location::bashDoor(short pc_num)
{
unsigned char terrain;
short r1,unlock_adjust;
terrain = t_d.terrain[x][y];
r1 = get_ran(1,0,100) - 15 * adven[pc_num].statAdj(0) + c_town.difficulty * 4;
if ((scenario.ter_types[terrain].special < 9) || (scenario.ter_types[terrain].special > 10))
{
add_string_to_buf(" Wrong terrain type. ");
return;
}
unlock_adjust = scenario.ter_types[terrain].flag2;
if ((unlock_adjust >= 5) || (r1 > (unlock_adjust * 15 + 40)) || (scenario.ter_types[terrain].special != 10))
{
add_string_to_buf(" Didn't work. ");
adven[pc_num].damage(get_ran(1,1,4),4,-1);
}
else
{
add_string_to_buf(" Lock breaks. ");
play_sound(9);
t_d.terrain[x][y] = scenario.ter_types[terrain].flag1;
if(scenario.ter_types[scenario.ter_types[terrain].flag1].special >= 16 && scenario.ter_types[scenario.ter_types[terrain].flag1].special <=19)
belt_present = TRUE;
}
}

View File

@@ -0,0 +1,24 @@
#ifndef _LOCATION_H
#define _LOCATION_H
struct location
{
char x, y;
/* functions */
location() : x(0), y(0) { }
location(int ix, int iy) { x = ix; y = iy; }
location toGlobal(); /* convert local coordinates to global*/
location toLocal(); /* convert global coordinates to local*/
location randomShift();
short countWalls() const; /* count number of walls around */
short handleLever(); /* call dialog and eventually pull lever */
void crumbleWall();
bool isDoor() const;
void pickLock(short pcNum);
void bashDoor(short pcNum);
};
#endif

View File

@@ -0,0 +1,983 @@
#include "pc.h" // party_record_type
#include "location.h" // location
//#include "boe.text.h" // add_string_to_buf
//#include "boe.main.h" // globals
#include "tools/soundtool.h" // play_sound
//#include "boe.combat.h" // hit_chance
//#include "boe.items.h" // place_item
//#include "boe.fields.h" // make_sfx
#include "tools/mathutil.h" // get_ran
//#include "boe.infodlg.h" // give_help
//#include "boe.party.h" // adjust_spell_menu
//#include "boe.itemdata.h" // return_dummy_item
//#include "boe.locutils.h" // is_container
//#include "globvar.h"
void pc_record_type::kill(short type)
{
short i = 24;
bool dummy, no_save = false;
location item_loc;
if (type >= 10)
{
type -= 10;
no_save = true;
}
if (type != 4)
i = hasAbilEquip(48); //check if has life saving items
else
i = hasAbilEquip(49); //check if has protection vs petrification items
short which_pc = getNum();
if ((no_save == false) && (type != 0) && (skills[SKILL_LUCK] > 0) &&
(get_ran(1,0,100) < hit_chance[skills[SKILL_LUCK]])) {
add_string_to_buf(" But you luck out! ");
cur_health = 0;
}
else if ((i == 24) || (type == 0)) {
if (combat_active_pc == which_pc)
combat_active_pc = 6;
for (i = 0; i < 24; i++)
equip[i] = false;
item_loc = (overall_mode >= MODE_COMBAT) ? pc_pos[which_pc] : c_town.p_loc;
if (type == 2)
make_sfx(item_loc.x,item_loc.y,3);
else if (type == 3)
make_sfx(item_loc.x,item_loc.y,6);
if (overall_mode != 0)
for (i = 0; i < 24; i++)
if (items[i].variety != 0) {
dummy = place_item(items[i],item_loc,true);
items[i].variety = 0;
}
if ((type == 2) || (type == 3))
play_sound(21);
if(type == 4){
play_sound(43);
sprintf ((char *) create_line, " %s is turned to stone. ",(char *) name);
add_string_to_buf((char *) create_line);
}
main_status = type;
pc_moves[which_pc] = 0;
}
else {
if (type == 4) {
sprintf ((char *) create_line, " %s is immune to petrification. ",(char *) name);
add_string_to_buf((char*) create_line); //inform of what has happened
}
else{
add_string_to_buf(" Life saved! ");
takeItem(i);
heal(200);
}
}
current_pc = first_active_pc();
if (current_pc > 5) {
for (i = 0; i < NUM_OF_PCS; i++)
if (adven[i].status > 0)
current_pc = i;
}
put_pc_screen();
set_stat_window(current_pc);
}
bool pc_record_type::runTrap(short trap_type, short trap_level, short diff)
{
short r1,skill,i,num_hits = 1,i_level;
short trap_odds[30] = {5,30,35,42,48, 55,63,69,75,77,
78,80,82,84,86, 88,90,92,94,96,98,99,99,99,99,99,99,99,99,99};
num_hits += trap_level;
if (trap_type == TRAP_RANDOM)
trap_type = get_ran(1,1,4);
/// ??? => no trap after all ;)
if (trap_type == 6)
return true;
i = statAdj(1);
if ((i_level = getProtLevel(42)) > 0)
i += i_level / 2;
skill = minmax(0, 20, skills[14] + skills[SKILL_LUCK] / 2 + 1 - c_town.difficulty + 2 * i);
r1 = get_ran(1,0,100) + diff;
// Nimble?
if (traits[TRAIT_NIMBLE] == true) r1 -= 6;
if (r1 < trap_odds[skill])
{
add_string_to_buf(" Trap disarmed. ");
return true;
}
else add_string_to_buf(" Disarm failed. ");
switch (trap_type)
{
case TRAP_BLADE:
for (i = 0; i < num_hits; i++)
{
add_string_to_buf(" A knife flies out! ");
damage(get_ran(2 + c_town.difficulty / 14,1,10),DAMAGE_WEAPON,-1);
}
break;
case TRAP_DART:
add_string_to_buf(" A dart flies out. ");
poison((3 + c_town.difficulty / 14) + (trap_level * 2));
break;
case TRAP_GAS:
add_string_to_buf(" Poison gas pours out. ");
adven.poison((2 + c_town.difficulty / 14) + trap_level * 2);
break;
case TRAP_EXPLOSION:
for (i = 0; i < num_hits; i++)
{
add_string_to_buf(" There is an explosion. ");
adven.damage(get_ran(3 + c_town.difficulty / 13,1,8), DAMAGE_FIRE);
}
break;
case TRAP_SLEEP_RAY:
add_string_to_buf(" A purple ray flies out. ");
sleep((200 + c_town.difficulty * 100) + (trap_level * 400),12,50);
break;
case TRAP_DRAIN_XP:
add_string_to_buf(" You feel weak. ");
experience = max(0, experience - (40 + trap_level * 30));
break;
case TRAP_ALERT:
add_string_to_buf(" An alarm goes off!!! ");
set_town_status(0);
break;
case TRAP_FLAMES:
add_string_to_buf(" Flames shoot from the walls. ");
adven.damage(get_ran(10 + trap_level * 5,1,8),DAMAGE_FIRE);
break;
case TRAP_DUMBFOUND:
add_string_to_buf(" You feel disoriented. ");
adven.dumbfound(2 + trap_level * 2);
break;
case TRAP_DISEASE:
add_string_to_buf(" You prick your finger. ");
disease((3 + c_town.difficulty / 14) + (trap_level * 2));
break;
case TRAP_DISEASE_ALL:
add_string_to_buf(" A foul substance sprays out.");
adven.disease((2 + c_town.difficulty / 14) + (trap_level * 2));
break;
default:
add_string_to_buf(" (ERROR: Unknown type of trap!)");
break;
}
put_pc_screen();
put_item_screen(stat_window,0);
return true;
}
short pc_record_type::statAdj(short which)
{
short tr;
tr = skill_bonus[skills[which]];
if (which == 2) {
if (traits[1] == true) tr++;
if (hasAbilEquip(40) < 24) tr++;
}
if (which == 0)
if (traits[8] == true) tr++;
if (hasAbilEquip(38) < 24)
tr++;
if (which == 1) {
if (hasAbilEquip(39) < 24)
tr++;
}
return tr;
}
void pc_record_type::giveXP(short amt)
{
short adjust,add_hp;
short xp_percent[30] = {150,120,100,90,80,70,60,50,50,50,
45,40,40,40,40,35,30,25,23,20,
15,15,15,15,15,15,15,15,15,15};
if (!isAlive()) return;
if (level > 49)
{
level = 50;
return;
}
if (amt > 200) { // debug
MessageBeep(MB_OK);
ASB("Oops! Too much xp!");
ASB("Report this!");
return;
}
if (amt < 0) { // debug
MessageBeep(MB_OK);
ASB("Oops! Negative xp!");
ASB("Report this!");
return;
}
if (level >= 40) adjust = 15;
else adjust = xp_percent[level / 2];
if ((amt > 0) && (level > 7))
{
if (get_ran(1,0,100) < xp_percent[level / 2]) amt--;
}
if (amt <= 0) return;
experience += (max(((amt * adjust) / 100), 0) * 100) / 100;
party.total_xp_gained += (max(((amt * adjust) / 100), 0) * 100) / 100;
if (experience < 0) {
MessageBeep(MB_OK);
ASB("Oops! Xp became negative somehow!");
ASB("Report this!");
experience = level * (get_tnl(this)) - 1;
return;
}
if (experience > 15000)
{
experience = 15000;
return;
}
while (experience >= (level * (get_tnl(this))))
{
play_sound(7);
level++;
sprintf ((char *) c_line, " %s is level %d! ",(char *) name, level);
add_string_to_buf((char *) c_line);
skill_pts += (level < 20) ? 5 : 4;
add_hp = (level < 26) ? get_ran(1,2,6) + skill_bonus[skills[0]]
: max (skill_bonus[skills[0]],0);
if (add_hp < 0) add_hp = 0;
max_health += add_hp;
if (max_health > 250) max_health = 250;
cur_health += add_hp;
if (cur_health > 250) cur_health = 250;
put_pc_screen();
}
}
void pc_record_type::drainXP(short how_much)
{
if (!isAlive()) return;
experience = max(experience - how_much, 0);
sprintf ((char *) c_line, " %s drained.",(char *) name);
add_string_to_buf((char *) c_line);
}
void pc_record_type::restoreSP(short amt)
{
if (!isAlive()) return;
if (cur_sp > max_sp) return;
cur_sp += amt;
if (cur_sp > max_sp) cur_sp = max_sp;
}
void pc_record_type::cure(short amt)
{
if (!isAlive()) return;
if (status[STATUS_POISON] <= amt)
status[STATUS_POISON] = 0;
else
status[STATUS_POISON] -= amt;
one_sound(51);
}
void pc_record_type::curse(short how_much)
{
if (!isAlive()) return;
status[STATUS_BLESS] = max(status[STATUS_BLESS] - how_much, -8);
sprintf ((char *) c_line, " %s cursed.",(char *) name);
add_string_to_buf((char *) c_line);
put_pc_screen();
give_help(59,0,0);
}
void pc_record_type::dumbfound(short how_much)
{
short r1;
if (!isAlive()) return;
r1 = get_ran(1,0,90);
if (hasAbilEquip(53) < 24) {
add_string_to_buf(" Ring of Will glows.");
r1 -= 10;
}
if (r1 < level)
how_much -= 2;
if (how_much <= 0) {
sprintf ((char *) c_line, " %s saved.",(char *) name);
add_string_to_buf((char *) c_line);
return;
}
status[STATUS_DUMB] = min(status[STATUS_DUMB] + how_much, 8);
sprintf ((char *) c_line, " %s dumbfounded.",(char *) name);
add_string_to_buf((char *) c_line);
one_sound(67);
put_pc_screen();
adjust_spell_menus();
give_help(28,0,0);
}
void pc_record_type::disease(short how_much)
{
short r1, tlevel;
if (!isAlive()) return;
r1 = get_ran(1,0,100);
if (r1 < level * 2)
how_much -= 2;
if (how_much <= 0)
{
sprintf ((char *) c_line, " %s saved.",(char *) name);
add_string_to_buf((char *) c_line);
return;
}
if ((tlevel = getProtLevel(62)) > 0)
how_much -= tlevel / 2;
if ((traits[12] == true) && (how_much > 1)) how_much++;
if ((traits[12] == true) && (how_much == 1) && (get_ran(1,0,1) == 0)) how_much++;
status[STATUS_DISEASE] = min(status[STATUS_DISEASE] + how_much,8);
sprintf ((char *) c_line, " %s diseased.",(char *) name);
add_string_to_buf((char *) c_line);
one_sound(66);
put_pc_screen();
give_help(29,0,0);
}
void pc_record_type::sleep(short how_much,short what_type,short adjust)
// higher adjust, less chance of saving
{
short r1, tlevel;
if (!isAlive()) return;
if (how_much == 0)
return;
if ((what_type == STATUS_ASLEEP) || (what_type == STATUS_PARALYZED)) { ////
if ((tlevel = getProtLevel(53)) > 0)
how_much -= tlevel / 2;
if ((tlevel = getProtLevel(54)) > 0)
how_much -= (what_type == STATUS_ASLEEP) ? tlevel : tlevel * 300;
}
r1 = get_ran(1,0,100) + adjust;
if (r1 < 30 + level * 2)
how_much = -1;
if ((what_type == STATUS_ASLEEP) && ((traits[7] > 0) || (status[STATUS_ASLEEP] < 0)))
how_much = -1;
if (how_much <= 0) {
sprintf ((char *) c_line, " %s resisted.",(char *) name);
add_string_to_buf((char *) c_line);
return;
}
if (isAlive()) {
status[what_type] = how_much;
if (what_type == STATUS_ASLEEP)
sprintf ((char *) c_line, " %s falls asleep.",(char *) name);
else sprintf ((char *) c_line, " %s paralyzed.",(char *) name);
if (what_type == STATUS_ASLEEP)
play_sound(96);
else play_sound(90);
add_string_to_buf((char *) c_line);
pc_moves[getNum()] = 0;
}
put_pc_screen();
if (what_type == STATUS_ASLEEP)
give_help(30,0,0);
else give_help(32,0,0);
}
void pc_record_type::slow(short how_much)
{
if (!isAlive()) return;
status[STATUS_HASTE] = minmax(-8,8,status[STATUS_HASTE] - how_much);
if (how_much < 0)
sprintf ((char *) c_line, " %s hasted.",(char *) name);
else sprintf ((char *) c_line, " %s slowed.",(char *) name);
add_string_to_buf((char *) c_line);
put_pc_screen();
if (how_much < 0)
give_help(35,0,0);
}
void pc_record_type::web(short how_much)
{
if (!isAlive()) return;
status[STATUS_WEBS] = min(status[STATUS_WEBS] + how_much,8);
sprintf ((char *) c_line, " %s webbed.",(char *) name);
add_string_to_buf((char *) c_line);
one_sound(17);
put_pc_screen();
give_help(31,0,0);
}
void pc_record_type::acid(short how_much)
{
if (!isAlive()) return;
if (hasAbilEquip(36) < 24) {
sprintf ((char *) c_line, " %s resists acid.",(char *) name);
add_string_to_buf((char *) c_line);
return;
}
status[STATUS_ACID] += how_much;
sprintf ((char *) c_line, " %s covered with acid!",(char *) name);
add_string_to_buf((char *) c_line);
one_sound(42);
put_pc_screen();
}
void pc_record_type::heal(short amt)
{
if (!isAlive()) return;
if (cur_health > max_health) return;
cur_health += amt;
if (cur_health > max_health)
cur_health = max_health;
}
void pc_record_type::sortItems()
{
item_record_type store_item;
short item_priority[26] = {20,8,8,20,9, 9,3,2,1,0, 7,20,10,10,10, 10,10,10,5,6, 4,11,12,9,9, 9};
bool no_swaps = false, store_equip;
int i;
while (no_swaps == false) {
no_swaps = true;
for (i = 0; i < 23; i++)
if (item_priority[items[i + 1].variety] <
item_priority[items[i].variety]) {
no_swaps = false;
store_item = items[i + 1];
items[i + 1] = items[i];
items[i] = store_item;
store_equip = equip[i + 1];
equip[i + 1] = equip[i];
equip[i] = store_equip;
if (weap_poisoned == i + 1)
weap_poisoned--;
else if (weap_poisoned == i)
weap_poisoned++;
}
}
}
short pc_record_type::getNum()
{
short i;
for (i = 0; i < NUM_OF_PCS; i++)
{
if (&adven[i] == this) break;;
}
return i;
}
bool pc_record_type::giveToPC(item_record_type item, bool print_result)
{
short free_space;
char announce_string[60];
if (item.variety == 0)
return true;
if (item.variety == 3) {
party.gold += item.item_level;
ASB("You get some gold.");
return true;
}
if (item.variety == 11) {
party.food += item.item_level;
ASB("You get some food.");
return true;
}
if (item_weight(item) > amountCanCarry() - amountCarried()) {
if (print_result == true) {
MessageBeep(MB_OK);
ASB("Item too heavy to carry.");
}
return false;
}
if (((free_space = hasSpace()) == 24) || (!isAlive()))
return false;
else {
item.item_properties = item.item_properties & 253; // not property
item.item_properties = item.item_properties & 247; // not contained
items[free_space] = item;
if (print_result == 1) {
if (stat_window == getNum())
put_item_screen(stat_window,0);
}
if (in_startup_mode == false) {
if (item.isIdent() == false)
sprintf((char *) announce_string," %s gets %s.",name,item.name);
else sprintf((char *) announce_string," %s gets %s.",name,item.full_name);
if (print_result)
add_string_to_buf((char *)announce_string);
}
combineThings();
sortItems();
return true;
}
return false;
}
// returnes equipped protection level of specified abil, or -1 if no such abil is equipped
short pc_record_type::getProtLevel(short abil)
{
for (int i = 0; i < 24; i++)
if ((items[i].variety != 0) && (items[i].ability == abil) && (equip[i] == true))
return items[i].ability_strength;
return (-1);
}
short pc_record_type::hasAbilEquip(short abil)
{
short i = 0;
while (((items[i].variety == 0) || (items[i].ability != abil)
|| (equip[i] == false)) && (i < 24))
i++;
return i;
}
short pc_record_type::hasAbil(short abil)
{
short i = 0;
while (((items[i].variety == 0) || (items[i].ability != abil)) && (i < 24)) i++;
return i;
}
short pc_record_type::amountCanCarry()
{
return 100 + (15 * min(skills[0],20)) + ((traits[8] == 0) ? 0 : 30)
+ ((traits[14] == 0) ? 0 : -50);
}
short pc_record_type::amountCarried()
{
short i, storage = 0;
bool airy = false, heavy = false;
for (i = 0; i < 24; i++)
if (items[i].variety > 0)
{
storage += item_weight(items[i]);
if (items[i].ability == 44) airy = true;
if (items[i].ability == 45) heavy = true;
}
if (airy) storage -= 30;
if (heavy) storage += 30;
if (storage < 0) storage = 0;
return storage;
}
short pc_record_type::hasSpace()
{
int i = 0;
while (i < 24)
{
if (items[i].variety == 0)
return i;
i++;
}
return 24;
}
// returns 1 if OK, 2 if no room, 3 if not enough cash, 4 if too heavy, 5 if too many of item
short pc_record_type::okToBuy(short cost, item_record_type item)
{
int i;
if ((item.variety != 3) && (item.variety != 11)) {
for (i = 0; i < 24; i++)
if ((items[i].variety > 0) && (items[i].type_flag == item.type_flag)
&& (items[i].charges > 123))
return 5;
if (hasSpace() == 24) return 2;
if (item_weight(item) > amountCanCarry() - amountCarried()) return 4;
}
if (party.takeGold(cost, false) == false)
return 3;
return 1;
}
void pc_record_type::takeItem(short which_item)
//short pc_num,which_item; // if which_item > 30, don't update stat win, item is which_item - 30
{
int i;
bool do_print = true;
if (which_item >= 30) {
do_print = false;
which_item -= 30;
}
if ((weap_poisoned == which_item) && (status[0] > 0)) {
add_string_to_buf(" Poison lost. ");
status[0] = 0;
}
if ((weap_poisoned > which_item) && (status[0] > 0))
weap_poisoned--;
for (i = which_item; i < 23; i++) {
items[i] = items[i + 1];
equip[i] = equip[i + 1];
}
items[23] = return_dummy_item();
equip[23] = false;
if ((stat_window == getNum()) && (do_print))
put_item_screen(stat_window,1);
}
void pc_record_type::removeCharge(short which_item)
{
if (items[which_item].charges > 0)
{
items[which_item].charges--;
if (items[which_item].charges == 0) takeItem(which_item);
}
if (stat_window == getNum())
put_item_screen(stat_window,1);
}
void pc_record_type::enchantWeapon(short item_hit, short enchant_type, short new_val)
{
char store_name[60];
if ((items[item_hit].isMagic()) || (items[item_hit].ability != 0)) return;
items[item_hit].item_properties |= 4;
switch (enchant_type) {
case 0:
sprintf((char *)store_name,"%s (+1)", items[item_hit].full_name);
items[item_hit].bonus++;
items[item_hit].value = new_val;
break;
case 1:
sprintf((char *)store_name,"%s (+2)", items[item_hit].full_name);
items[item_hit].bonus += 2;
items[item_hit].value = new_val;
break;
case 2:
sprintf((char *)store_name,"%s (+3)", items[item_hit].full_name);
items[item_hit].bonus += 3;
items[item_hit].value = new_val;
break;
case 3:
sprintf((char *)store_name,"%s (F)", items[item_hit].full_name);
items[item_hit].ability = 110;
items[item_hit].ability_strength = 5;
items[item_hit].charges = 8;
break;
case 4:
sprintf((char *)store_name,"%s (F!)", items[item_hit].full_name);
items[item_hit].value = new_val;
items[item_hit].ability = 1;
items[item_hit].ability_strength = 5;
break;
case 5:
sprintf((char *)store_name,"%s (+5)", items[item_hit].full_name);
items[item_hit].value = new_val;
items[item_hit].bonus += 5;
break;
case 6:
sprintf((char *)store_name,"%s (B)", items[item_hit].full_name);
items[item_hit].bonus++;
items[item_hit].ability = 71;
items[item_hit].ability_strength = 5;
items[item_hit].magic_use_type = 0;
items[item_hit].charges = 8;
break;
default:
strcpy(store_name, items[item_hit].full_name);
break;
}
if (items[item_hit].value > 15000)
items[item_hit].value = 15000;
if (items[item_hit].value < 0)
items[item_hit].value = 15000;
strcpy(items[item_hit].full_name,store_name);
}
void pc_record_type::equipItem(short item_num)
{
short num_equipped_of_this_type = 0;
short num_hands_occupied = 0;
short i;
short equip_item_type = 0;
if ((overall_mode == MODE_COMBAT) && (items[item_num].variety == 11))
add_string_to_buf("Equip: Not in combat");
else {
// unequip
if (equip[item_num] == true) {
if ((equip[item_num] == true) &&
(items[item_num].isCursed()))
add_string_to_buf("Equip: Item is cursed. ");
else {
equip[item_num] = false;
add_string_to_buf("Equip: Unequipped");
if ((weap_poisoned == item_num) && (status[0] > 0)) {
add_string_to_buf(" Poison lost. ");
status[0] = 0;
}
}
}
else { // equip
if (equippable[items[item_num].variety] == false)
add_string_to_buf("Equip: Can't equip this item.");
else {
for (i = 0; i < 24; i++)
if (equip[i] == true) {
if (items[i].variety == items[item_num].variety)
num_equipped_of_this_type++;
num_hands_occupied = num_hands_occupied + num_hands_to_use[items[i].variety];
}
equip_item_type = excluding_types[items[item_num].variety];
// Now if missile is already equipped, no more missiles
if (equip_item_type > 0) {
for (i = 0; i < 24; i++)
if ((equip[i] == true) && (excluding_types[items[i].variety] == equip_item_type)) {
add_string_to_buf("Equip: You have something of");
add_string_to_buf(" this type equipped.");
return;
}
}
if ((is_combat()) && (items[item_num].variety == 13))
add_string_to_buf("Equip: Not armor in combat");
else if ((2 - num_hands_occupied) < num_hands_to_use[items[item_num].variety])
add_string_to_buf("Equip: Not enough free hands");
else if (num_that_can_equip[items[item_num].variety] <= num_equipped_of_this_type)
add_string_to_buf("Equip: Can't equip another");
else {
equip[item_num] = true;
add_string_to_buf("Equip: OK");
}
}
}
}
if (stat_window == getNum())
put_item_screen(stat_window,1);
}
void pc_record_type::dropItem(short item_num, location where_drop)
{
short choice, how_many = 0;
item_record_type item_store;
bool take_given_item = true;
location loc;
item_store = items[item_num];
if ((equip[item_num] == true) && (items[item_num].isCursed()))
add_string_to_buf("Drop: Item is cursed. ");
else switch (overall_mode) {
case 0:
choice = fancy_choice_dialog(1093,0);
if (choice == 1)
return;
add_string_to_buf("Drop: OK");
if ((item_store.type_flag > 0) && (item_store.charges > 1)) {
how_many = get_num_of_items(item_store.charges);
if (how_many == item_store.charges)
takeItem(item_num);
else items[item_num].charges -= how_many;
}
else takeItem(item_num);
break;
case 5: case 15:
loc = where_drop;
if ((item_store.type_flag > 0) && (item_store.charges > 1)) {
how_many = get_num_of_items(item_store.charges);
if (how_many <= 0)
return;
if (how_many < item_store.charges)
take_given_item = false;
item_store.charges = how_many;
}
if (is_container(loc) == true)
item_store.item_properties = item_store.item_properties | 8;
if (place_item(item_store,loc,false) == false) {
add_string_to_buf("Drop: Too many items on ground");
item_store.item_properties = item_store.item_properties & 247; // not contained
}
else {
if (item_store.isContained())
add_string_to_buf("Drop: Item put away");
else add_string_to_buf("Drop: OK");
items[item_num].charges -= how_many;
if (take_given_item) takeItem(item_num);
}
break;
}
}
void pc_record_type::giveThing(short item_num)
{
short who_to,how_many = 0;
item_record_type item_store;
bool take_given_item = true;
short pc_num = getNum();
if ((equip[item_num] == true) && (items[item_num].isCursed()))
add_string_to_buf("Give: Item is cursed. ");
else {
item_store = items[item_num];
who_to = char_select_pc(1,1,"Give item to who?");
if ((overall_mode == MODE_COMBAT) && (adjacent(pc_pos[pc_num],pc_pos[who_to]) == false)) {
add_string_to_buf("Give: Must be adjacent.");
who_to = 6;
}
if ((who_to < 6) && (who_to != pc_num)
&& ((overall_mode != MODE_COMBAT) || (adjacent(pc_pos[pc_num],pc_pos[who_to]) == true))) {
if ((item_store.type_flag > 0) && (item_store.charges > 1)) {
how_many = get_num_of_items(item_store.charges);
if (how_many == 0)
return;
if (how_many < item_store.charges)
take_given_item = false;
items[item_num].charges -= how_many;
item_store.charges = how_many;
}
if (adven[who_to].giveToPC(item_store,0) == true) {
if (take_given_item) takeItem(item_num);
}
else {
if (adven[who_to].hasSpace() == 24)
ASB("Can't give: PC has max. # of items.");
else ASB("Can't give: PC carrying too much.");
if (how_many > 0)
items[item_num].charges += how_many;
}
}
}
}
void pc_record_type::combineThings()
{
int i,j,test;
for (i = 0; i < 24; i++) {
if ((items[i].variety > 0) && (items[i].type_flag > 0) && (items[i].isIdent()))
{
for (j = i + 1; j < 24; j++)
if ((items[j].variety > 0) && (items[j].type_flag == items[i].type_flag) && (items[j].isIdent()))
{
add_string_to_buf("(items combined)");
test = items[i].charges + items[j].charges;
if (test > 125) {
items[i].charges = 125;
ASB("(Can have at most 125 of any item.");
}
else items[i].charges += items[j].charges;
if (equip[j] == true) {
equip[i] = true;
equip[j] = false;
}
takeItem(30 + j);
}
}
if ((items[i].variety > 0) && (items[i].charges < 0))
items[i].charges = 1;
}
}

View File

@@ -0,0 +1,89 @@
#ifndef _PC_H
#define _PC_H
#include "consts.h"
#include "item.h" //item_record_type
//#include "consts.h"
/* do not change */
/* dummy_pc_record_type is temporarily used in file reading/writing operations */
struct dummy_pc_record_type
{
short main_status;
char name[20];
short skills[30];
short max_health, cur_health, max_sp, cur_sp, experience, skill_pts, level;
short status[15];
item_record_type items[24];
char equip[24]; // boolean
char priest_spells[62], mage_spells[62]; // boolean
short which_graphic, weap_poisoned;
char advan[15], traits[15]; // boolean
short race, exp_adj, direction;
};
class pc_record_type
{
public:
/* DO NOT CHANGE */
short main_status;
char name[20];
short skills[30];
short max_health, cur_health, max_sp, cur_sp, experience, skill_pts, level;
short status[15];
item_record_type items[24];
char equip[24]; // boolean
char priest_spells[62], mage_spells[62]; // boolean
short which_graphic, weap_poisoned;
char advan[15], traits[15]; // boolean
short race, exp_adj, direction;
/* end of DO NOT CHANGE */
/* functions */
void acid(short how_much);
void cure(short how_much); // cure
void curse(short how_much); // curse
void disease(short how_much); // disease
void dumbfound(short how_much); // dumbfound
void heal(short how_much); // heal
void kill(short type); // kill
void poison(short how_much);
void sleep(short how_much,short what_type,short adjust);
void slow(short how_much);
void web(short how_much);
bool damage(short how_much, short damage_type, short type_of_attacker);
void drainXP(short how_much); // drain experience points
void giveXP(short how_much); // give experience points
void restoreSP(short how_much); // restore spell points
//bool takeSP(short how_much); // take spell points
void takeItem(short which_item);
void removeCharge(short which_item);
void enchantWeapon(short item_hit,short enchant_type,short new_val);
void equipItem(short item_num);
void dropItem(short item_num,location where_drop);
void giveThing(short item_num);
bool giveToPC(item_record_type item, bool print_result);
void combineThings();
bool runTrap(short trap_type, short trap_level, short diff);
short getProtLevel(short ability);
short hasAbilEquip(short ability);
short hasAbil(short ability);
short hasSpace();
short okToBuy(short cost, item_record_type item);
short statAdj(short which);
short amountCanCarry();
short amountCarried();
bool isAlive() { return (main_status == MAIN_STATUS_ALIVE); }
void sortItems();
short getNum();
};
#endif

View File

@@ -0,0 +1,711 @@
/*
* simpletypes.h
* BoE
*
* Created by Celtic Minstrel on 01/06/09.
*
*/
typedef unsigned short m_num_t;
typedef unsigned short ter_num_t;
typedef signed short spec_num_t;
typedef signed short item_num_t;
typedef unsigned short str_num_t;
enum eMainStatus {
MAIN_STATUS_ABSENT = 0, // absent, empty slot
MAIN_STATUS_ALIVE = 1,
MAIN_STATUS_DEAD = 2,
MAIN_STATUS_DUST = 3,
MAIN_STATUS_STONE = 4,
MAIN_STATUS_FLED = 5,
MAIN_STATUS_SURFACE = 6, // fled to surface?
MAIN_STATUS_WON = 7,
MAIN_STATUS_SPLIT = 10,
// The rest are not really necessary, but are here for completeness so that all valid values have a name.
MAIN_STATUS_SPLIT_ABSENT = MAIN_STATUS_SPLIT + MAIN_STATUS_ABSENT,
MAIN_STATUS_SPLIT_ALIVE = MAIN_STATUS_SPLIT + MAIN_STATUS_ALIVE,
MAIN_STATUS_SPLIT_DEAD = MAIN_STATUS_SPLIT + MAIN_STATUS_DEAD,
MAIN_STATUS_SPLIT_DUST = MAIN_STATUS_SPLIT + MAIN_STATUS_DUST,
MAIN_STATUS_SPLIT_STONE = MAIN_STATUS_SPLIT + MAIN_STATUS_STONE,
MAIN_STATUS_SPLIT_FLED = MAIN_STATUS_SPLIT + MAIN_STATUS_FLED,
MAIN_STATUS_SPLIT_SURFACE = MAIN_STATUS_SPLIT + MAIN_STATUS_SURFACE,
MAIN_STATUS_SPLIT_WON = MAIN_STATUS_SPLIT + MAIN_STATUS_WON,
};
/* adven[i].race */ //complete
enum eRace {
RACE_UNKNOWN = -1, // for parameters to some functions; not valid in the class
RACE_HUMAN = 0,
RACE_NEPHIL = 1,
RACE_SLITH = 2,
RACE_VAHNATAI = 3,
RACE_REPTILE = 4,
RACE_BEAST = 5,
RACE_IMPORTANT = 6,
RACE_MAGE = 7,
RACE_PRIEST = 8,
RACE_HUMANOID = 9,
RACE_DEMON = 10,
RACE_UNDEAD = 11,
RACE_GIANT = 12,
RACE_SLIME = 13,
RACE_STONE = 14,
RACE_BUG = 15,
RACE_DRAGON = 16,
RACE_MAGICAL = 17,
RACE_PLANT = 18,
RACE_BIRD = 19,
}; // TODO: Expand and merge with eMonsterType
/* adven[i].status*/ //complete - assign a positive value for a help pc effect, a negative for harm pc
enum eStatus {
STATUS_POISONED_WEAPON = 0,
STATUS_BLESS_CURSE = 1,
STATUS_POISON = 2,
STATUS_HASTE_SLOW = 3,
STATUS_INVULNERABLE = 4,
STATUS_MAGIC_RESISTANCE = 5,
STATUS_WEBS = 6,
STATUS_DISEASE = 7,
STATUS_INVISIBLE = 8, //sanctuary
STATUS_DUMB = 9,
STATUS_MARTYRS_SHIELD = 10,
STATUS_ASLEEP = 11,
STATUS_PARALYZED = 12,
STATUS_ACID = 13,
};
/* Monster Type */
enum eMonsterType {
MONSTER_TYPE_UNKNOWN = -1, // for parameters to some functions; not valid in the class
MONSTER_TYPE_HUMAN = 0,
MONSTER_TYPE_REPTILE = 1,
MONSTER_TYPE_BEAST = 2,
MONSTER_TYPE_IMPORTANT = 3,
MONSTER_TYPE_MAGE = 4,
MONSTER_TYPE_PRIEST = 5,
MONSTER_TYPE_HUMANOID = 6,
MONSTER_TYPE_DEMON = 7,
MONSTER_TYPE_UNDEAD = 8,
MONSTER_TYPE_GIANT = 9,
MONSTER_TYPE_SLIME = 10,
MONSTER_TYPE_STONE = 11,
MONSTER_TYPE_BUG = 12,
MONSTER_TYPE_DRAGON = 13,
MONSTER_TYPE_MAGICAL = 14,
};
/* Special Ability a.k.a spec_skill */
enum eMonstAbil {
MONST_NO_ABIL = 0,
// Missile abilities (extra1 = number of sided dice; extra2 = number of sides)
MONST_THROWS_DARTS = 10,
MONST_SHOOTS_ARROWS,
MONST_THROWS_SPEARS,
MONST_THROWS_ROCKS,
MONST_THROWS_RAZORDISKS,
MONST_GOOD_ARCHER,
MONST_SHOOTS_SPINES,
MONST_THROWS_KNIVES,
// Ray abilities (extra1 = type of damage / status where applicable)
MONST_DAMAGE_RAY = 20,
MONST_STATUS_RAY,
MONST_PETRIFY_RAY,
MONST_DRAIN_SP_RAY,
MONST_DRAIN_XP_RAY,
MONST_DRAIN_XP_DAMAGE_RAY,
MONST_KILL_RAY,
MONST_STEAL_FOOD_RAY,
MONST_STEAL_GOLD_RAY,
// Touch abilities (extra1 = type of damage / status where applicable)
MONST_DAMAGE_TOUCH = 30,
MONST_STATUS_TOUCH,
MONST_PETRIFY_TOUCH,
MONST_DRAIN_SP_TOUCH,
MONST_DRAIN_XP_TOUCH,
MONST_DRAIN_XP_DAMAGE_TOUCH,
MONST_KILL_TOUCH,
MONST_STEAL_FOOD_TOUCH,
MONST_STEAL_GOLD_TOUCH,
// Summon abilities (extra1 = which monster / type / species; extra2 = % chance)
MONST_SUMMON_ONE = 40,
MONST_SUMMON_TYPE,
MONST_SUMMON_SPECIES,
MONST_SUMMON_RANDOM,
MONST_MASS_SUMMON,
// Misc abilities (extra1 = field / special #; extra2 = % chance for radiate only)
MONST_SPLITS = 50,
MONST_FIELD_MISSILE,
MONST_MARTYRS_SHIELD,
MONST_ABSORB_SPELLS,
MONST_INVULNERABLE,
MONST_RADIATE,
MONST_CALL_LOCAL_SPECIAL,
MONST_CALL_GLOBAL_SPECIAL,
};
/* Terrains Special Properties : scenario.ter_types[i].special */ //complete
enum eTerSpec {
// TER_SPEC_NONE = 0,
// TER_SPEC_CHANGE_WHEN_STEP_ON = 1,
// TER_SPEC_DOES_FIRE_DAMAGE = 2,
// TER_SPEC_DOES_COLD_DAMAGE = 3,
// TER_SPEC_DOES_MAGIC_DAMAGE = 4,
// TER_SPEC_POISON_LAND = 5,
// TER_SPEC_DISEASED_LAND = 6,
// TER_SPEC_CRUMBLING_TERRAIN = 7,
// TER_SPEC_LOCKABLE_TERRAIN = 8,
// TER_SPEC_UNLOCKABLE_TERRAIN = 9,
// TER_SPEC_UNLOCKABLE_BASHABLE = 10,
// TER_SPEC_IS_A_SIGN = 11,
// TER_SPEC_CALL_LOCAL_SPECIAL = 12,
// TER_SPEC_CALL_SCENARIO_SPECIAL = 13,
// TER_SPEC_IS_A_CONTAINER = 14,
// TER_SPEC_WATERFALL = 15,
// TER_SPEC_CONVEYOR_NORTH = 16,
// TER_SPEC_CONVEYOR_EAST = 17,
// TER_SPEC_CONVEYOR_SOUTH = 18,
// TER_SPEC_CONVEYOR_WEST = 19,
// TER_SPEC_BLOCKED_TO_MONSTERS = 20,
// TER_SPEC_TOWN_ENTRANCE = 21,
// TER_SPEC_CHANGE_WHEN_USED = 22,
// TER_SPEC_CALL_SPECIAL_WHEN_USED = 23,
TER_SPEC_NONE = 0,
TER_SPEC_CHANGE_WHEN_STEP_ON = 1,
TER_SPEC_DAMAGING = 2,
TER_SPEC_BRIDGE = 3, // new
TER_SPEC_BED = 4, // new
TER_SPEC_DANGEROUS = 5,
TER_SPEC_UNUSED1 = 6,
TER_SPEC_CRUMBLING = 7,
TER_SPEC_LOCKABLE = 8,
TER_SPEC_UNLOCKABLE = 9,
TER_SPEC_UNUSED2 = 10,
TER_SPEC_IS_A_SIGN = 11,
TER_SPEC_CALL_SPECIAL = 12,
TER_SPEC_UNUSED3 = 13,
TER_SPEC_IS_A_CONTAINER = 14,
TER_SPEC_WATERFALL = 15,
TER_SPEC_CONVEYOR = 16,
TER_SPEC_UNUSED4 = 17,
TER_SPEC_UNUSED5 = 18,
TER_SPEC_UNUSED6 = 19,
TER_SPEC_BLOCKED_TO_MONSTERS = 20,
TER_SPEC_TOWN_ENTRANCE = 21,
TER_SPEC_CHANGE_WHEN_USED = 22,
TER_SPEC_CALL_SPECIAL_WHEN_USED = 23,
// 1. Change when step on (What to change to, number of sound, Unused)
// 2. Damaging terrain; can't rest here (Amount of damage done, multiplier, damage type)
// 3. Reserved
// 4. Reserved
// 5. Dangerous land; can't rest here; percentage chance may be 0 (Strength, Percentage chance, status type)
// 6. Reserved
// 7. Crumbling terrain (Terrain to change to, strength?, destroyed by what - quickfire, shatter/move mountains, or both)
// 8. Lockable terrain (Terrain to change to when locked, Unused, Unused)
// 9. Unlockable terrain (Terrain to change to when locked, Difficulty, can be bashed)
// 10. Reserved
// 11. Sign (Unused, Unused, Unused)
// 12. Call special (Special to call, local or scenario?, Unused)
// 13. Reserved
// 14. Container (Unused, Unused, Unused)
// 15. Waterfall (Direction, Unused, Unused)
// 16. Conveyor Belt (Direction, Unused, Unused)
// 17. Reserved
// 18. Reserved
// 19. Reserved
// 20. Blocked to Monsters (Unused, Unused, Unused)
// 21. Town entrance (Terrain type if hidden, Unused, Unused)
// 22. Change when Used (Terrain to change to when used, Number of sound, Unused)
// 23. Call special when used (Special to call, local or scenario?, Unused)
// 24. Bridge - if the party boats over it, they get the option to land. (Unused, Unused, Unused)
};
enum eTrimType {
TRIM_NONE = 0,
TRIM_WALL = 1, // not a trim, but trims will conform to it as if it's the same ground type (eg stone wall)
TRIM_S, TRIM_SE, TRIM_E, TRIM_NE, TRIM_N, TRIM_NW, TRIM_W, TRIM_SW,
TRIM_NE_INNER, TRIM_SE_INNER, TRIM_SW_INNER, TRIM_NW_INNER,
TRIM_FRILLS = 14, // like on lava and underground water; no trim_ter required
TRIM_ROAD = 15, // the game will treat it like a road space and draw roads; no trim_ter required
TRIM_WALKWAY = 16, // the game will draw walkway corners; trim_ter is base terrain to draw on
TRIM_WATERFALL = 17, // special case for waterfalls
TRIM_CITY = 18, // the game will join roads up to this space but not draw roads on the space
};
/* items[i].type a.k.a type of weapon */
enum eWeapType {
ITEM_NOT_MELEE = 0,
ITEM_EDGED = 1,
ITEM_BASHING = 2,
ITEM_POLE = 3,
};
/* items[i].variety a.k.a item type (in editor) */
enum eItemType {
ITEM_TYPE_NO_ITEM = 0,
ITEM_TYPE_ONE_HANDED = 1,
ITEM_TYPE_TWO_HANDED = 2,
ITEM_TYPE_GOLD = 3,
ITEM_TYPE_BOW = 4,
ITEM_TYPE_ARROW = 5,
ITEM_TYPE_THROWN_MISSILE = 6,
ITEM_TYPE_POTION = 7, // potion/magic item
ITEM_TYPE_SCROLL = 8, // scroll/magic item
ITEM_TYPE_WAND = 9,
ITEM_TYPE_TOOL = 10,
ITEM_TYPE_FOOD = 11,
ITEM_TYPE_SHIELD = 12,
ITEM_TYPE_ARMOR = 13,
ITEM_TYPE_HELM = 14,
ITEM_TYPE_GLOVES = 15,
ITEM_TYPE_SHIELD_2 = 16,
// don't know why a second type of shield is used ; it is actually checked
// in the armor code (item >= 12 and <= 17)
// and you can't equip another (12) shield while wearing it ... I didn't
// find a single item with this property in the bladbase.exs ...
ITEM_TYPE_BOOTS = 17,
ITEM_TYPE_RING = 18,
ITEM_TYPE_NECKLACE = 19,
ITEM_TYPE_WEAPON_POISON = 20,
ITEM_TYPE_NON_USE_OBJECT = 21,
ITEM_TYPE_PANTS = 22,
ITEM_TYPE_CROSSBOW = 23,
ITEM_TYPE_BOLTS = 24,
ITEM_TYPE_MISSILE_NO_AMMO = 25, //e.g slings
ITEM_TYPE_UNUSED1 = 26, // these are here solely because they are options in the editor
ITEM_TYPE_UNUSED2 = 27,
};
/* items[i].ability */
enum eItemAbil {
// Weapon abilities
ITEM_NO_ABILITY = 0,
ITEM_FLAMING_WEAPON = 1,
ITEM_DEMON_SLAYER = 2,
ITEM_UNDEAD_SLAYER = 3,
ITEM_LIZARD_SLAYER = 4,
ITEM_GIANT_SLAYER = 5,
ITEM_MAGE_SLAYER = 6,
ITEM_PRIEST_SLAYER = 7,
ITEM_BUG_SLAYER = 8,
ITEM_ACIDIC_WEAPON = 9,
ITEM_SOULSUCKER = 10,
ITEM_DRAIN_MISSILES = 11,
ITEM_WEAK_WEAPON = 12,
ITEM_CAUSES_FEAR = 13,
ITEM_POISONED_WEAPON = 14,
// General abilities
ITEM_PROTECTION = 30,
ITEM_FULL_PROTECTION = 31,
ITEM_FIRE_PROTECTION = 32,
ITEM_COLD_PROTECTION = 33,
ITEM_POISON_PROTECTION = 34,
ITEM_MAGIC_PROTECTION = 35,
ITEM_ACID_PROTECTION = 36,
ITEM_SKILL = 37,
ITEM_STRENGTH = 38,
ITEM_DEXTERITY = 39,
ITEM_INTELLIGENCE = 40,
ITEM_ACCURACY = 41,
ITEM_THIEVING = 42,
ITEM_GIANT_STRENGTH = 43,
ITEM_LIGHTER_OBJECT = 44,
ITEM_HEAVIER_OBJECT = 45,
ITEM_OCCASIONAL_BLESS = 46,
ITEM_OCCASIONAL_HASTE = 47,
ITEM_LIFE_SAVING = 48,
ITEM_PROTECT_FROM_PETRIFY = 49,
ITEM_REGENERATE = 50,
ITEM_POISON_AUGMENT = 51,
ITEM_DISEASE_PARTY = 52,
ITEM_WILL = 53,
ITEM_FREE_ACTION = 54,
ITEM_SPEED = 55,
ITEM_SLOW_WEARER = 56,
ITEM_PROTECT_FROM_UNDEAD = 57,
ITEM_PROTECT_FROM_DEMONS = 58,
ITEM_PROTECT_FROM_HUMANOIDS = 59,
ITEM_PROTECT_FROM_REPTILES = 60,
ITEM_PROTECT_FROM_GIANTS = 61,
ITEM_PROTECT_FROM_DISEASE = 62,
// Nonspell Usable
ITEM_POISON_WEAPON = 70, //put poison on weapon
ITEM_BLESS_CURSE = 71,
ITEM_AFFECT_POISON = 72,
ITEM_HASTE_SLOW = 73,
ITEM_AFFECT_INVULN = 74,
ITEM_AFFECT_MAGIC_RES = 75,
ITEM_AFFECT_WEB = 76,
ITEM_AFFECT_DISEASE = 77,
ITEM_AFFECT_SANCTUARY = 78,
ITEM_AFFECT_DUMBFOUND = 79,
ITEM_AFFECT_MARTYRS_SHIELD = 80,
ITEM_AFFECT_SLEEP = 81,
ITEM_AFFECT_PARALYSIS = 82,
ITEM_AFFECT_ACID = 83,
ITEM_BLISS = 84,
ITEM_AFFECT_EXPERIENCE = 85,
ITEM_AFFECT_SKILL_POINTS = 86,
ITEM_AFFECT_HEALTH = 87,
ITEM_AFFECT_SPELL_POINTS = 88,
ITEM_DOOM = 89,
ITEM_LIGHT = 90,
ITEM_STEALTH = 91,
ITEM_FIREWALK = 92,
ITEM_FLYING = 93,
ITEM_MAJOR_HEALING = 94,
// Spell Usable
ITEM_SPELL_FLAME = 110,
ITEM_SPELL_FIREBALL = 111,
ITEM_SPELL_FIRESTORM = 112,
ITEM_SPELL_KILL = 113,
ITEM_SPELL_ICE_BOLT = 114,
ITEM_SPELL_SLOW = 115,
ITEM_SPELL_SHOCKWAVE = 116,
ITEM_SPELL_DISPEL_UNDEAD = 117,
ITEM_SPELL_DISPEL_SPIRIT = 118,
ITEM_SPELL_SUMMONING = 119,
ITEM_SPELL_MASS_SUMMONING = 120,
ITEM_SPELL_ACID_SPRAY = 121,
ITEM_SPELL_STINKING_CLOUD = 122,
ITEM_SPELL_SLEEP_FIELD = 123,
ITEM_SPELL_VENOM = 124,
ITEM_SPELL_SHOCKSTORM = 125,
ITEM_SPELL_PARALYSIS = 126,
ITEM_SPELL_WEB_SPELL = 127,
ITEM_SPELL_STRENGTHEN_TARGET = 128, //wand of carrunos effect
ITEM_SPELL_QUICKFIRE = 129,
ITEM_SPELL_MASS_CHARM = 130,
ITEM_SPELL_MAGIC_MAP = 131,
ITEM_SPELL_DISPEL_BARRIER = 132,
ITEM_SPELL_MAKE_ICE_WALL = 133,
ITEM_SPELL_CHARM_SPELL = 134,
ITEM_SPELL_ANTIMAGIC_CLOUD = 135,
// Reagents
ITEM_HOLLY = 150, // Holly/Toadstool
ITEM_COMFREY_ROOT = 151,
ITEM_GLOWING_NETTLE = 152,
ITEM_WORMGRASS = 153, // Crypt Shroom/Wormgr.
ITEM_ASPTONGUE_MOLD = 154,
ITEM_EMBER_FLOWERS = 155,
ITEM_GRAYMOLD = 156,
ITEM_MANDRAKE = 157,
ITEM_SAPPHIRE = 158,
ITEM_SMOKY_CRYSTAL = 159,
ITEM_RESSURECTION_BALM = 160,
ITEM_LOCKPICKS = 161,
// Missile Abilities
ITEM_MISSILE_RETURNING = 170,
ITEM_MISSILE_LIGHTNING = 171,
ITEM_MISSILE_EXPLODING = 172,
ITEM_MISSILE_ACID = 173,
ITEM_MISSILE_SLAY_UNDEAD = 174,
ITEM_MISSILE_SLAY_DEMON = 175,
ITEM_MISSILE_HEAL_TARGET = 176,
};
/* adven[i].skills */ //complete
enum eSkill {
SKILL_STRENGTH = 0,
SKILL_DEXTERITY = 1,
SKILL_INTELLIGENCE = 2,
SKILL_EDGED_WEAPONS = 3,
SKILL_BASHING_WEAPONS = 4,
SKILL_POLE_WEAPONS = 5,
SKILL_THROWN_MISSILES = 6,
SKILL_ARCHERY = 7,
SKILL_DEFENSE = 8,
SKILL_MAGE_SPELLS = 9,
SKILL_PRIEST_SPELLS = 10,
SKILL_MAGE_LORE = 11,
SKILL_ALCHEMY = 12,
SKILL_ITEM_LORE = 13,
SKILL_DISARM_TRAPS = 14,
SKILL_LOCKPICKING = 15,
SKILL_ASSASSINATION = 16,
SKILL_POISON = 17,
SKILL_LUCK = 18,
};
/* adven[i].traits */ //complete
enum eTrait {
TRAIT_TOUGHNESS = 0,
TRAIT_MAGICALLY_APT = 1,
TRAIT_AMBIDEXTROUS = 2,
TRAIT_NIMBLE = 3,
TRAIT_CAVE_LORE = 4,
TRAIT_WOODSMAN = 5,
TRAIT_GOOD_CONST = 6,
TRAIT_HIGHLY_ALERT = 7,
TRAIT_STRENGTH = 8,
TRAIT_RECUPERATION = 9,
TRAIT_SLUGGISH = 10,
TRAIT_MAGICALLY_INEPT = 11,
TRAIT_FRAIL = 12,
TRAIT_CHRONIC_DISEASE = 13,
TRAIT_BAD_BACK = 14,
TRAIT_PACIFIST = 15,
};
/* damage type*/
/* used as parameter to some functions */
enum eDamageType {
DAMAGE_WEAPON = 0,
DAMAGE_FIRE = 1,
DAMAGE_POISON = 2,
DAMAGE_MAGIC = 3,
DAMAGE_UNBLOCKABLE = 4, //from the source files - the display is the same as the magic one (damage_monst in SPECIALS.cpp)
DAMAGE_COLD = 5,
DAMAGE_UNDEAD = 6, //from the source files - the display is the same as the weapon one
DAMAGE_DEMON = 7, //from the source files - the display is the same as the weapon one
// 8 and 9 aren't defined : doesn't print any damage. According to the source files the 9 is DAMAGE_MARKED though. Wrong ?
DAMAGE_MARKED = 10, // usage: DAMAGE_MARKED + damage_type
DAMAGE_WEAPON_MARKED = 10,
DAMAGE_FIRE_MARKED = 11,
DAMAGE_POISON_MARKED = 12,
DAMAGE_MAGIC_MARKED = 13,
DAMAGE_UNBLOCKABLE_MARKED = 14,
DAMAGE_COLD_MARKED = 15,
DAMAGE_UNDEAD_MARKED = 16,
DAMAGE_DEMON_MARKED = 17,
DAMAGE_NO_PRINT = 30, // usage: DAMAGE_NO_PRINT + damage_type
DAMAGE_WEAPON_NO_PRINT = 30,
DAMAGE_FIRE_NO_PRINT = 31,
DAMAGE_POISON_NO_PRINT = 32,
DAMAGE_MAGIC_NO_PRINT = 33,
DAMAGE_UNBLOCKABLE_NO_PRINT = 34,
DAMAGE_COLD_NO_PRINT = 35,
DAMAGE_UNDEAD_NO_PRINT = 36,
DAMAGE_DEMON_NO_PRINT = 37,
// What about both NO_PRINT and MARKED?
};
inline void operator -= (eDamageType& cur, eDamageType othr){
if((othr == DAMAGE_MARKED && cur >= DAMAGE_MARKED && cur < DAMAGE_NO_PRINT) ||
(othr == DAMAGE_NO_PRINT && cur >= DAMAGE_NO_PRINT))
cur = (eDamageType) ((int)cur - (int)othr);
}
inline void operator += (eDamageType& cur, eDamageType othr){
if((othr == DAMAGE_MARKED || othr == DAMAGE_NO_PRINT) && cur < DAMAGE_MARKED)
cur = (eDamageType) ((int)cur + (int)othr);
}
//class sbyte {
// signed char c;
//public:
// operator int() {return c;}
// sbyte(signed char k) : c(k) {}
//}
enum eSpecContext {
SPEC_OUT_MOVE = 0,
SPEC_TOWN_MOVE = 1,
SPEC_COMBAT_MOVE = 2,
SPEC_OUT_LOOK = 3,
SPEC_TOWN_LOOK = 4,
SPEC_ENTER_TOWN = 5,
SPEC_LEAVE_TOWN = 6,
SPEC_TALK = 7,
SPEC_USE_SPEC_ITEM = 8,
SPEC_TOWN_TIMER = 9,
SPEC_SCEN_TIMER = 10,
SPEC_PARTY_TIMER = 11,
SPEC_KILL_MONST = 12,
SPEC_OUTDOOR_ENC = 13,
SPEC_WIN_ENCOUNTER = 14,
SPEC_FLEE_ENCOUNTER = 15,
SPEC_TARGET = 16,
SPEC_USE_SPACE = 17,
SPEC_SEE_MONST = 18,
};
enum eSpecNodeType {
SPEC_NULL = 0,
SPEC_SET_SDF = 1,
SPEC_INC_SDF = 2,
SPEC_DISPLAY_MSG = 3,
SPEC_SECRET_PASSAGE = 4,
SPEC_DISPLAY_SM_MSG = 5,
SPEC_FLIP_SDF = 6,
SPEC_OUT_BLOCK = 7,
SPEC_TOWN_BLOCK = 8,
SPEC_FIGHT_BLOCK = 9,
SPEC_LOOK_BLOCK = 10,
SPEC_CANT_ENTER = 11,
SPEC_CHANGE_TIME = 12,
SPEC_SCEN_TIMER_START = 13,
SPEC_PLAY_SOUND = 14,
SPEC_CHANGE_HORSE_OWNER = 15,
SPEC_CHANGE_BOAT_OWNER = 16,
SPEC_SET_TOWN_VISIBILITY = 17,
SPEC_MAJOR_EVENT_OCCURRED = 18,
SPEC_FORCED_GIVE = 19,
SPEC_BUY_ITEMS_OF_TYPE = 20,
SPEC_CALL_GLOBAL = 21,
SPEC_SET_SDF_ROW = 22,
SPEC_COPY_SDF = 23,
SPEC_SANCTIFY = 24,
SPEC_REST = 25,
SPEC_WANDERING_WILL_FIGHT = 26,
SPEC_END_SCENARIO = 27,
SPEC_ONCE_GIVE_ITEM = 50,
SPEC_ONCE_GIVE_SPEC_ITEM = 51,
SPEC_ONCE_NULL = 52,
SPEC_ONCE_SET_SDF = 53,
SPEC_ONCE_DISPLAY_MSG = 54,
SPEC_ONCE_DIALOG = 55,
SPEC_ONCE_DIALOG_TERRAIN = 56,
SPEC_ONCE_DIALOG_MONSTER = 57,
SPEC_ONCE_GIVE_ITEM_DIALOG = 58,
SPEC_ONCE_GIVE_ITEM_TERRAIN = 59,
SPEC_ONCE_GIVE_ITEM_MONSTER = 60,
SPEC_ONCE_OUT_ENCOUNTER = 61,
SPEC_ONCE_TOWN_ENCOUNTER = 62,
SPEC_ONCE_TRAP = 63,
SPEC_SELECT_PC = 80,
SPEC_DAMAGE = 81,
SPEC_AFFECT_HP = 82,
SPEC_AFFECT_SP = 83,
SPEC_AFFECT_XP = 84,
SPEC_AFFECT_SKILL_PTS = 85,
SPEC_AFFECT_DEADNESS = 86,
SPEC_AFFECT_POISON = 87,
SPEC_AFFECT_SPEED = 88,
SPEC_AFFECT_INVULN = 89,
SPEC_AFFECT_MAGIC_RES = 90,
SPEC_AFFECT_WEBS = 91,
SPEC_AFFECT_DISEASE = 92,
SPEC_AFFECT_SANCTUARY = 93,
SPEC_AFFECT_CURSE_BLESS = 94,
SPEC_AFFECT_DUMBFOUND = 95,
SPEC_AFFECT_SLEEP = 96,
SPEC_AFFECT_PARALYSIS = 97,
SPEC_AFFECT_STAT = 98,
SPEC_AFFECT_MAGE_SPELL = 99,
SPEC_AFFECT_PRIEST_SPELL = 100,
SPEC_AFFECT_GOLD = 101,
SPEC_AFFECT_FOOD = 102,
SPEC_AFFECT_ALCHEMY = 103,
SPEC_AFFECT_STEALTH = 104,
SPEC_AFFECT_FIREWALK = 105,
SPEC_AFFECT_FLIGHT = 106,
SPEC_IF_SDF = 130,
SPEC_IF_TOWN_NUM = 131,
SPEC_IF_RANDOM = 132,
SPEC_IF_HAVE_SPECIAL_ITEM = 133,
SPEC_IF_SDF_COMPARE = 134,
SPEC_IF_TOWN_TER_TYPE = 135,
SPEC_IF_OUT_TER_TYPE = 136,
SPEC_IF_HAS_GOLD = 137,
SPEC_IF_HAS_FOOD = 138,
SPEC_IF_ITEM_CLASS_ON_SPACE = 139,
SPEC_IF_HAVE_ITEM_CLASS = 140,
SPEC_IF_EQUIP_ITEM_CLASS = 141,
SPEC_IF_HAS_GOLD_AND_TAKE = 142,
SPEC_IF_HAS_FOOD_AND_TAKE = 143,
SPEC_IF_ITEM_CLASS_ON_SPACE_AND_TAKE = 144,
SPEC_IF_HAVE_ITEM_CLASS_AND_TAKE = 145,
SPEC_IF_EQUIP_ITEM_CLASS_AND_TAKE = 146,
SPEC_IF_DAY_REACHED = 147,
SPEC_IF_BARRELS = 148,
SPEC_IF_CRATES = 149,
SPEC_IF_EVENT_OCCURRED = 150,
SPEC_IF_HAS_CAVE_LORE = 151,
SPEC_IF_HAS_WOODSMAN = 152,
SPEC_IF_ENOUGH_MAGE_LORE = 153,
SPEC_IF_TEXT_RESPONSE = 154,
SPEC_IF_SDF_EQ = 155,
SPEC_MAKE_TOWN_HOSTILE = 170,
SPEC_TOWN_CHANGE_TER = 171,
SPEC_TOWN_SWAP_TER = 172,
SPEC_TOWN_TRANS_TER = 173,
SPEC_TOWN_MOVE_PARTY = 174,
SPEC_TOWN_HIT_SPACE = 175,
SPEC_TOWN_EXPLODE_SPACE = 176,
SPEC_TOWN_LOCK_SPACE = 177,
SPEC_TOWN_UNLOCK_SPACE = 178,
SPEC_TOWN_SFX_BURST = 179,
SPEC_TOWN_CREATE_WANDERING = 180,
SPEC_TOWN_PLACE_MONST = 181,
SPEC_TOWN_DESTROY_MONST = 182,
SPEC_TOWN_NUKE_MONSTS = 183,
SPEC_TOWN_GENERIC_LEVER = 184,
SPEC_TOWN_GENERIC_PORTAL = 185,
SPEC_TOWN_GENERIC_BUTTON = 186,
SPEC_TOWN_GENERIC_STAIR = 187,
SPEC_TOWN_LEVER = 188,
SPEC_TOWN_PORTAL = 189,
SPEC_TOWN_STAIR = 190,
SPEC_TOWN_RELOCATE = 191, // Relocate outdoors
SPEC_TOWN_PLACE_ITEM = 192,
SPEC_TOWN_SPLIT_PARTY = 193,
SPEC_TOWN_REUNITE_PARTY = 194,
SPEC_TOWN_TIMER_START = 195,
SPEC_RECT_PLACE_FIRE = 200,
SPEC_RECT_PLACE_FORCE = 201,
SPEC_RECT_PLACE_ICE = 202,
SPEC_RECT_PLACE_BLADE = 203,
SPEC_RECT_PLACE_SCLOUD = 204,
SPEC_RECT_PLACE_SLEEP = 205,
SPEC_RECT_PLACE_QUICKFIRE = 206,
SPEC_RECT_PLACE_FIRE_BARR = 207,
SPEC_RECT_PLACE_FORCE_BARR = 208,
SPEC_RECT_CLEANSE = 209,
SPEC_RECT_PLACE_SFX = 210,
SPEC_RECT_PLACE_OBJECT = 211, // place barrels, etc
SPEC_RECT_MOVE_ITEMS = 212,
SPEC_RECT_DESTROY_ITEMS = 213,
SPEC_RECT_CHANGE_TER = 214,
SPEC_RECT_SWAP_TER = 215,
SPEC_RECT_TRANS_TER = 216,
SPEC_RECT_LOCK = 217,
SPEC_RECT_UNLOCK = 218,
SPEC_OUT_MAKE_WANDER = 225,
SPEC_OUT_CHANGE_TER = 226,
SPEC_OUT_PLACE_ENCOUNTER = 227,
SPEC_OUT_MOVE_PARTY = 228,
SPEC_OUT_STORE = 229,
};
enum eTalkNodeType {
TALK_REGULAR = 0,
TALK_DEP_ON_SDF = 1,
TALK_SET_SDF = 2,
TALK_INN = 3,
TALK_DEP_ON_TIME = 4,
TALK_DEP_ON_TIME_AND_EVENT = 5,
TALK_DEP_ON_TOWN = 6,
TALK_BUY_ITEMS = 7,
TALK_TRAINING = 8,
TALK_BUY_MAGE = 9,
TALK_BUY_PRIEST = 10,
TALK_BUY_ALCHEMY = 11,
TALK_BUY_HEALING = 12,
TALK_SELL_WEAPONS = 13,
TALK_SELL_ARMOR = 14,
TALK_SELL_ITEMS = 15,
TALK_IDENTIFY = 16,
TALK_ENCHANT = 17,
TALK_BUY_INFO = 18,
TALK_BUY_SDF = 19,
TALK_BUY_SHIP = 20,
TALK_BUY_HORSE = 21,
TALK_BUY_SPEC_ITEM = 22,
TALK_BUY_JUNK = 23,
TALK_BUY_TOWN_LOC = 24,
TALK_END_FORCE = 25,
TALK_END_FIGHT = 26,
TALK_END_ALARM = 27, // Town hostile
TALK_END_DIE = 28,
TALK_CALL_TOWN_SPEC = 29,
TALK_CALL_SCEN_SPEC = 30,
};

View File

@@ -0,0 +1,37 @@
#include "item.h"
bool item_record_type::isIdent() const
{
if (item_properties & ITEM_PROP_IDENTIFIED) return true;
else return false;
}
bool item_record_type::isMagic() const
{
if (item_properties & ITEM_PROP_MAGIC) return true;
else return false;
}
bool item_record_type::isContained() const
{
if (item_properties & ITEM_PROP_CONTAINED) return true;
else return false;
}
bool item_record_type::isCursed() const
{
if (item_properties & ITEM_PROP_CURSED) return true;
else return false;
}
bool item_record_type::isProperty() const
{
if (item_properties & ITEM_PROP_PROPERTY) return true;
else return false;
}
bool item_record_type::isConcealed() const
{
if (item_properties & ITEM_PROP_CONCEALED) return true;
else return false;
}

View File

@@ -0,0 +1,44 @@
#ifndef _ITEM_H
#define _ITEM_H
#include "location.h"
/* item_properties: */
/*
0000 0001 identified
0000 0010 someone's property
0000 0100 magic
0000 1000 contained in sth
0001 0000 cursed
0010 0000 concealed
0100 0000 <not used>
1000 0000 <not used>
*/
#define ITEM_PROP_IDENTIFIED 1
#define ITEM_PROP_PROPERTY 2
#define ITEM_PROP_MAGIC 4
#define ITEM_PROP_CONTAINED 8
#define ITEM_PROP_CURSED 16
#define ITEM_PROP_CONCEALED 32
struct item_record_type {
short variety, item_level;
char awkward, bonus, protection, charges, type, magic_use_type;
unsigned char graphic_num,ability, ability_strength, type_flag, is_special,a;
short value;
unsigned char weight, special_class;
location item_loc;
char full_name[25], name[15];
unsigned char treas_class, item_properties, reserved1, reserved2;
/* functions */
bool isIdent() const; /* is identified ? */
bool isMagic() const; /* is magic ? */
bool isContained() const; /* is contained in sth ? */
bool isCursed() const; /* is cursed ? */
bool isProperty() const; /* is someones property? */
bool isConcealed() const; /* is the item ability concealed ? */
};
#endif