00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "obj_things.h"
00022
00023 #include <math.h>
00024 #include "globals.h"
00025 #include "lev_data.h"
00026 #include "obj_slabs.h"
00027 #include "lev_things.h"
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 const char *thing_fullnames[]={"Nothing", "Item/decoration", "unknown 2",
00054 "unknown 3", "unknown 4", "Creature", "unknown 6", "Effect Generatr",
00055 "Trap", "Door"};
00056 const char *thing_shortnames[]={"empty", "thing", "unkn2",
00057 "unkn3", "unkn4", "crtur", "unkn6", "effct", "trap", "door"};
00058 const char *traps[]={"", "Boulder", "Alarm", "Poison gas",
00059 "Lightning", "Word of power", "Lava", "Dummy 2", "Dummy 3",
00060 "Dummy 4", "Dummy 5", "Dummy 6", "Dummy 7"};
00061 const char *doors[]={"", "Wooden", "Braced", "Iron", "Magic"};
00062 const char *creature_names[]={"", "Wizrd", "Barb ", "Archr",
00063 "Monk ", "Dwarf", "Knigt", "Avtar", "Tunlr", "Witch",
00064 "Giant", "Fairy", "Thief", "Smuri", "Horny", "Skel ",
00065 "Troll", "Drgon", "Spawn", " Fly ", "DrkMs", "Warlk",
00066 "BileD", " Imp ", "Beetl", "Vamp ", "Spder", "Hound",
00067 "Ghost", "Tntcl", " Orc ", "Float"};
00068 const char *creature_fullnames[]={"", "Wizard", "Barbarian",
00069 "Archer", "Monk", "Dwarf", "Knight", "Avatar", "Tunneller",
00070 "Witch", "Giant", "Fairy", "Thief", "Samurai", "Horned Reaper",
00071 "Skeleton", "Troll", "Dragon", "Demon Spawn", "Fly", "Dark Mistress",
00072 "Warlock", "Bile Demon", "Imp", "Beetle", "Vampire", "Spider",
00073 "Hell Hound", "Ghost", "Tentacle", "Orc", "Floating spirit"};
00074 const char *effectgenrts[]={"unknown 0", "Lava", "Dripping water",
00075 "Rock Fall", "Entrance Ice", "Dry ice", "unknown 6", "unknown 7",
00076 "unknown 8"};
00077
00078 const unsigned char creatr_types[]={
00079 CREATR_SUBTP_WIZRD,CREATR_SUBTP_BARBARIN,CREATR_SUBTP_ARCHER,
00080 CREATR_SUBTP_MONK,CREATR_SUBTP_DWAFT,CREATR_SUBTP_KNIGHT,
00081 CREATR_SUBTP_AVATAR,CREATR_SUBTP_TUNELER,CREATR_SUBTP_WITCH,
00082 CREATR_SUBTP_GIANT,CREATR_SUBTP_FAIRY,CREATR_SUBTP_THEFT,
00083 CREATR_SUBTP_SMURI,CREATR_SUBTP_HORNY,CREATR_SUBTP_SKELETON,
00084 CREATR_SUBTP_TROLL,CREATR_SUBTP_DRAGON,CREATR_SUBTP_SPAWN,
00085 CREATR_SUBTP_FLY,CREATR_SUBTP_MISTRESS,CREATR_SUBTP_WARLOCK,
00086 CREATR_SUBTP_BILEDEMN,CREATR_SUBTP_IMP,CREATR_SUBTP_BEETLE,
00087 CREATR_SUBTP_VAMPIRE,CREATR_SUBTP_SPIDER,CREATR_SUBTP_HOUND,
00088 CREATR_SUBTP_GHOST,CREATR_SUBTP_TENTCL,CREATR_SUBTP_ORC,
00089 CREATR_SUBTP_FLOAT};
00090
00091 const unsigned char trap_types[]={
00092 TRAP_SUBTYPE_BOULDER,TRAP_SUBTYPE_ALARM,TRAP_SUBTYPE_GAS,
00093 TRAP_SUBTYPE_LIGHTNG,TRAP_SUBTYPE_WORDPWR,TRAP_SUBTYPE_LAVA,
00094 TRAP_SUBTYPE_DUMMY2,TRAP_SUBTYPE_DUMMY3,TRAP_SUBTYPE_DUMMY4,
00095 TRAP_SUBTYPE_DUMMY5,TRAP_SUBTYPE_DUMMY6,TRAP_SUBTYPE_DUMMY7};
00096
00097 const unsigned char door_types[]={
00098 DOOR_SUBTYPE_WOOD,DOOR_SUBTYPE_BRACED,
00099 DOOR_SUBTYPE_IRON,DOOR_SUBTYPE_MAGIC};
00100
00101 const unsigned char efctgen_types[]={
00102 EFCTGEN_SUBTP_LAVA,EFCTGEN_SUBTP_DRIPWTR,EFCTGEN_SUBTP_ROCKFAL,
00103 EFCTGEN_SUBTP_ENTRICE,EFCTGEN_SUBTP_DRYICE,
00104 };
00105
00106
00107
00108 const unsigned char items_nullthings[]={
00109 ITEM_SUBTYPE_NULL, ITEM_SUBTYPE_NULL1, ITEM_SUBTYPE_NULL2, };
00110
00111 const unsigned char items_effcts[]={
00112 ITEM_SUBTYPE_ARMOUR, ITEM_SUBTYPE_TEMPLESPN, ITEM_SUBTYPE_DISEASE, };
00113
00114 const unsigned char items_crtrlairs[]={
00115 ITEM_SUBTYPE_LAIRWIZRD,ITEM_SUBTYPE_LAIRBARBR,ITEM_SUBTYPE_LAIRARCHR,
00116 ITEM_SUBTYPE_LAIRMONK,ITEM_SUBTYPE_LAIRDWRFA,ITEM_SUBTYPE_LAIRKNGHT,
00117 ITEM_SUBTYPE_LAIRAVATR,ITEM_SUBTYPE_LAIRTUNLR,ITEM_SUBTYPE_LAIRWITCH,
00118 ITEM_SUBTYPE_LAIRGIANT,ITEM_SUBTYPE_LAIRFAIRY,ITEM_SUBTYPE_LAIRTHEFT,
00119 ITEM_SUBTYPE_LAIRSAMUR,ITEM_SUBTYPE_LAIRHORNY,ITEM_SUBTYPE_LAIRSKELT,
00120 ITEM_SUBTYPE_LAIRGOBLN,ITEM_SUBTYPE_LAIRDRAGN,ITEM_SUBTYPE_LAIRDEMSP,
00121 ITEM_SUBTYPE_LAIRFLY,ITEM_SUBTYPE_LAIRDKMIS,ITEM_SUBTYPE_LAIRSORCR,
00122 ITEM_SUBTYPE_LAIRBILDM,ITEM_SUBTYPE_LAIRIMP,ITEM_SUBTYPE_LAIRBUG,
00123 ITEM_SUBTYPE_LAIRVAMP,ITEM_SUBTYPE_LAIRSPIDR,ITEM_SUBTYPE_LAIRHLHND,
00124 ITEM_SUBTYPE_LAIRGHOST,ITEM_SUBTYPE_LAIRTENTC,ITEM_SUBTYPE_LAIRORC};
00125
00126 const unsigned char items_specboxes[]={
00127 ITEM_SUBTYPE_SPREVMAP,ITEM_SUBTYPE_SPRESURCT,ITEM_SUBTYPE_SPTRANSFR,
00128 ITEM_SUBTYPE_SPSTEALHR,ITEM_SUBTYPE_SPMULTPLY,ITEM_SUBTYPE_SPINCLEV,
00129 ITEM_SUBTYPE_SPMKSAFE,ITEM_SUBTYPE_SPHIDNWRL};
00130
00131 const unsigned char items_spellbooks[]={
00132 ITEM_SUBTYPE_SPELLHOE,ITEM_SUBTYPE_SPELLIMP,ITEM_SUBTYPE_SPELLMUST,
00133 ITEM_SUBTYPE_SPELLSLAP,ITEM_SUBTYPE_SPELLSOE,ITEM_SUBTYPE_SPELLCTA,
00134 ITEM_SUBTYPE_SPELLCAVI,ITEM_SUBTYPE_SPELLHEAL,ITEM_SUBTYPE_SPELLHLDA,
00135 ITEM_SUBTYPE_SPELLLIGH,ITEM_SUBTYPE_SPELLSPDC,ITEM_SUBTYPE_SPELLPROT,
00136 ITEM_SUBTYPE_SPELLCONC,ITEM_SUBTYPE_SPELLDISE,ITEM_SUBTYPE_SPELLCHKN,
00137 ITEM_SUBTYPE_SPELLDWAL,ITEM_SUBTYPE_SPELLTBMB,ITEM_SUBTYPE_SPELLARMG};
00138
00139 const unsigned char items_wrkshpbxs[]={
00140 ITEM_SUBTYPE_TBBOULDER,ITEM_SUBTYPE_TBALARM,ITEM_SUBTYPE_TBPOISONG,
00141 ITEM_SUBTYPE_TBLIGHTNG,ITEM_SUBTYPE_TBWRDOFPW,ITEM_SUBTYPE_TBLAVA,
00142 ITEM_SUBTYPE_TBDUMMY2,ITEM_SUBTYPE_TBDUMMY3,ITEM_SUBTYPE_TBDUMMY4,
00143 ITEM_SUBTYPE_TBDUMMY5,ITEM_SUBTYPE_TBDUMMY6,ITEM_SUBTYPE_TBDUMMY7,
00144 ITEM_SUBTYPE_DBWOOD,ITEM_SUBTYPE_DBBRACE,ITEM_SUBTYPE_DBSTEEL,
00145 ITEM_SUBTYPE_DBMAGIC, ITEM_SUBTYPE_WBITEM, };
00146
00147 const unsigned char items_spinnthings[]={
00148 ITEM_SUBTYPE_SPINNKEY, ITEM_SUBTYPE_SPINNKEY2,ITEM_SUBTYPE_SPINNCOIN, };
00149
00150 const unsigned char items_gold[]={
00151 ITEM_SUBTYPE_GOLDCHEST,ITEM_SUBTYPE_GOLD,ITEM_SUBTYPE_GOLDL,
00152 ITEM_SUBTYPE_GLDHOARD1,ITEM_SUBTYPE_GLDHOARD2,ITEM_SUBTYPE_GLDHOARD3,
00153 ITEM_SUBTYPE_GLDHOARD4,ITEM_SUBTYPE_GLDHOARD5, };
00154
00155 const unsigned char items_food[]={
00156 ITEM_SUBTYPE_CHICKNGRW, ITEM_SUBTYPE_CHICKN, ITEM_SUBTYPE_CHICKNSTB,
00157 ITEM_SUBTYPE_CHICKNWOB, ITEM_SUBTYPE_CHICKNCRK, };
00158
00159 const unsigned char items_torchcandls[]={
00160 ITEM_SUBTYPE_TORCH, ITEM_SUBTYPE_TORCHUN, ITEM_SUBTYPE_CANDLSTCK,};
00161
00162 const unsigned char items_heartflames[]={
00163 ITEM_SUBTYPE_HEARTFLMR, ITEM_SUBTYPE_HEARTFLMB, ITEM_SUBTYPE_HEARTFLMG,
00164 ITEM_SUBTYPE_HEARTFLMY,};
00165
00166 const unsigned char items_polebars[]={
00167 ITEM_SUBTYPE_GURDFLAGR,ITEM_SUBTYPE_GURDFLAGB,ITEM_SUBTYPE_GURDFLAGG,
00168 ITEM_SUBTYPE_GURDFLAGY,ITEM_SUBTYPE_FLAGPOST,ITEM_SUBTYPE_PRISONBAR,};
00169
00170 const unsigned char items_statues[]={
00171 ITEM_SUBTYPE_TEMPLESTA,ITEM_SUBTYPE_STATUEWO,ITEM_SUBTYPE_STATUHORN,
00172 ITEM_SUBTYPE_STATUE2,ITEM_SUBTYPE_STATUE3,ITEM_SUBTYPE_STATUE4,
00173 ITEM_SUBTYPE_STATUE5,ITEM_SUBTYPE_STATUE6,};
00174
00175 const unsigned char items_furniture[]={
00176 ITEM_SUBTYPE_BARREL,ITEM_SUBTYPE_POTION1,ITEM_SUBTYPE_POTION2,
00177 ITEM_SUBTYPE_POTION3, ITEM_SUBTYPE_ANVIL, };
00178
00179 const unsigned char items_roomequip[]={
00180 ITEM_SUBTYPE_TRAINPOST, ITEM_SUBTYPE_GRAVSTONE, ITEM_SUBTYPE_SCAVNGEYE,
00181 ITEM_SUBTYPE_WRKSHPMCH, ITEM_SUBTYPE_TORTURER, ITEM_SUBTYPE_TORTSPIKE, };
00182
00183 const unsigned char items_pwhand[]={
00184 ITEM_SUBTYPE_PWHAND, ITEM_SUBTYPE_PWHANDGRB, ITEM_SUBTYPE_PWHANDWHP,
00185 ITEM_SUBTYPE_PWSIGHT, ITEM_SUBTYPE_PWLIGHTNG, ITEM_SUBTYPE_PWHANDGLD, };
00186
00187 const unsigned char items_dncrucial[]={
00188 ITEM_SUBTYPE_DNHEART, ITEM_SUBTYPE_HEROGATE, };
00189
00190
00191
00192
00193 const unsigned char items_litthings[]={
00194 ITEM_SUBTYPE_TORCH, ITEM_SUBTYPE_CANDLSTCK,};
00195
00196 const unsigned char items_trapbxs[]={
00197 ITEM_SUBTYPE_TBBOULDER,ITEM_SUBTYPE_TBALARM,ITEM_SUBTYPE_TBPOISONG,
00198 ITEM_SUBTYPE_TBLIGHTNG,ITEM_SUBTYPE_TBWRDOFPW,ITEM_SUBTYPE_TBLAVA,
00199 ITEM_SUBTYPE_TBDUMMY2,ITEM_SUBTYPE_TBDUMMY3,ITEM_SUBTYPE_TBDUMMY4,
00200 ITEM_SUBTYPE_TBDUMMY5,ITEM_SUBTYPE_TBDUMMY6,ITEM_SUBTYPE_TBDUMMY7};
00201
00202 const unsigned char items_doorboxes[]={
00203 ITEM_SUBTYPE_DBWOOD,ITEM_SUBTYPE_DBBRACE,ITEM_SUBTYPE_DBSTEEL,
00204 ITEM_SUBTYPE_DBMAGIC, };
00205
00206 const unsigned char items_torches[]={
00207 ITEM_SUBTYPE_TORCHUN, ITEM_SUBTYPE_TORCH, };
00208
00209 typedef unsigned int (*thing_subtype_counter)(void);
00210
00211 const is_thing_subtype thing_subtype_tests[]={
00212 is_nulltng, is_effectgen, is_itemeffect,
00213 is_creature, is_crtrlair, is_trap,
00214 is_door, is_dngspecbox, is_spellbook,
00215 is_wrkshopbox, is_spinningtng, is_food,
00216 is_gold, is_torchcndl, is_heartflame,
00217 is_polebar, is_statue, is_furniture,
00218 is_roomequip, is_pwhand, is_dncrucial,
00219 };
00220
00221 const is_item_subtype item_subtype_tests[]={
00222 is_nulltng_stype, is_false_stype, is_itemeffect_stype,
00223 is_false_stype, is_crtrlair_stype, is_false_stype,
00224 is_false_stype, is_dngspecbox_stype, is_spellbook_stype,
00225 is_wrkshopbox_stype, is_spinningtng_stype, is_food_stype,
00226 is_gold_stype, is_torchcndl_stype, is_heartflame_stype,
00227 is_polebar_stype, is_statue_stype, is_furniture_stype,
00228 is_roomequip_stype, is_pwhand_stype, is_dncrucial_stype,
00229 };
00230
00231 const char *thing_subtype_fullnames[]={
00232 "Null Things", "Effect Generator", "Item Effects",
00233 "Creatures", "Creature Lairs", "Traps",
00234 "Doors", "Dung.Special boxes","Spell Books",
00235 "Workshop Boxes", "Spinning Things", "Food (Chickens)",
00236 "Valuable (Gold)", "Torches & Candles", "Heart Flames",
00237 "Poles & Bars", "Statues", "Furniture",
00238 "Room Equipment", "Power Hands", "Dungeon Crucial",
00239 };
00240
00241 const char *thing_subtype_shortnames[]={
00242 "Null Tngs", "EffectGen", "Itm Effct",
00243 "Creatures", "Lairs", "Traps",
00244 "Doors", "Dn.Specls", "Spl Books",
00245 "WrkshpBxs", "Spinn.Tng", "Chickens",
00246 "Gold Tngs", "Trch/Cndl", "Heart Flm",
00247 "Pols/Bars", "Statues", "Furniture",
00248 "RoomEquip", "Pwr Hands", "Dn.Crucil",
00249 };
00250
00251 const thing_subtype_counter thing_subtype_count[]={
00252 get_nulltng_count, get_effectgen_count, get_itemeffect_count,
00253 get_creature_count, get_crtrlair_count, get_trap_count,
00254 get_door_count, get_dngspecbox_count, get_spellbook_count,
00255 get_wrkshopbox_count, get_spinningtng_count, get_food_count,
00256 get_gold_count, get_torchcndl_count, get_heartflame_count,
00257 get_polebar_count, get_statue_count, get_furniture_count,
00258 get_roomequip_count, get_pwhand_count, get_dncrucial_count,
00259 };
00260
00261 const thing_subtype_arrayindex thing_subtype_arridx[]={
00262 get_nulltng_arridx, get_effectgen_arridx, get_itemeffect_arridx,
00263 get_creature_arridx, get_crtrlair_arridx, get_trap_arridx,
00264 get_door_arridx, get_dngspecbox_arridx, get_spellbook_arridx,
00265 get_wrkshopbox_arridx, get_spinningtng_arridx, get_food_arridx,
00266 get_gold_arridx, get_torchcndl_arridx, get_heartflame_arridx,
00267 get_polebar_arridx, get_statue_arridx, get_furniture_arridx,
00268 get_roomequip_arridx, get_pwhand_arridx, get_dncrucial_arridx,
00269 };
00270
00271 const thing_subtype_arrayitem thing_subtype_arritm[]={
00272 get_nulltng_arritm, get_effectgen_arritm, get_itemeffect_arritm,
00273 get_creature_arritm, get_crtrlair_arritm, get_trap_arritm,
00274 get_door_arritm, get_dngspecbox_arritm, get_spellbook_arritm,
00275 get_wrkshopbox_arritm, get_spinningtng_arritm, get_food_arritm,
00276 get_gold_arritm, get_torchcndl_arritm, get_heartflame_arritm,
00277 get_polebar_arritm, get_statue_arritm, get_furniture_arritm,
00278 get_roomequip_arritm, get_pwhand_arritm, get_dncrucial_arritm,
00279 };
00280
00281 unsigned char get_thing_type(const unsigned char *thing)
00282 {
00283 if (thing==NULL) return THING_TYPE_NONE;
00284 return thing[6];
00285 }
00286
00287 short set_thing_type(unsigned char *thing,unsigned char type_idx)
00288 {
00289 if (thing==NULL) return false;
00290 thing[6]=type_idx;
00291 return true;
00292 }
00293
00294 unsigned char get_thing_subtype(const unsigned char *thing)
00295 {
00296 if (thing==NULL) return ITEM_SUBTYPE_NULL;
00297 return thing[7];
00298 }
00299
00300 short set_thing_subtype(unsigned char *thing,const unsigned char stype_idx)
00301 {
00302 if (thing==NULL) return false;
00303 thing[7]=stype_idx;
00304 return true;
00305 }
00306
00307 unsigned char get_thing_owner(const unsigned char *thing)
00308 {
00309 if (thing==NULL) return PLAYER_UNSET;
00310 if (thing[8]>=PLAYERS_COUNT) return PLAYER_UNSET;
00311 return thing[8];
00312 }
00313
00314 short set_thing_owner(unsigned char *thing,unsigned char ownr_idx)
00315 {
00316 if (thing==NULL) return false;
00317 thing[8]=ownr_idx;
00318 return true;
00319 }
00320
00321 unsigned char get_thing_subtile_x(const unsigned char *thing)
00322 {
00323 if (thing==NULL) return 0;
00324 return (unsigned char)thing[1];
00325 }
00326
00327 short set_thing_subtile_x(unsigned char *thing,unsigned char pos_x)
00328 {
00329 if (thing==NULL) return 0;
00330 thing[1]=pos_x;
00331 }
00332
00333 unsigned char get_thing_subtile_y(const unsigned char *thing)
00334 {
00335 if (thing==NULL) return 0;
00336 return (unsigned char)thing[3];
00337 }
00338
00339 short set_thing_subtile_y(unsigned char *thing,unsigned char pos_y)
00340 {
00341 if (thing==NULL) return false;
00342 thing[3]=pos_y;
00343 return true;
00344 }
00345
00346 short set_thing_subtile(unsigned char *thing,unsigned char pos_x,unsigned char pos_y)
00347 {
00348 if (thing==NULL) return false;
00349 thing[1]=pos_x;
00350 thing[3]=pos_y;
00351 return true;
00352 }
00353
00354 unsigned char get_thing_subtile_h(const unsigned char *thing)
00355 {
00356 if (thing==NULL) return 0;
00357 return (char)thing[5];
00358 }
00359
00360 short set_thing_subtile_h(unsigned char *thing,unsigned char pos_h)
00361 {
00362 if (thing==NULL) return false;
00363 thing[5]=pos_h;
00364 return true;
00365 }
00366
00367 unsigned char get_thing_subtpos_x(const unsigned char *thing)
00368 {
00369 if (thing==NULL) return 128;
00370 return (unsigned char)thing[0];
00371 }
00372
00373 unsigned short get_thing_pos_x_adv(const unsigned char *thing)
00374 {
00375 if (thing==NULL) return 0;
00376 return (((unsigned short)thing[1])<<8) + thing[0];
00377 }
00378
00379 short set_thing_subtpos_x(unsigned char *thing,unsigned char pos_x)
00380 {
00381 if (thing==NULL) return false;
00382 thing[0]=pos_x;
00383 return true;
00384 }
00385
00386 unsigned char get_thing_subtpos_y(const unsigned char *thing)
00387 {
00388 if (thing==NULL) return 0x80;
00389 return (char)thing[2];
00390 }
00391
00392 unsigned short get_thing_pos_y_adv(const unsigned char *thing)
00393 {
00394 if (thing==NULL) return 0;
00395 return (((unsigned short)thing[3])<<8) + thing[2];
00396 }
00397
00398 short set_thing_subtpos_y(unsigned char *thing,unsigned char pos_y)
00399 {
00400 if (thing==NULL) return false;
00401 thing[2]=pos_y;
00402 return true;
00403 }
00404
00405 short set_thing_subtpos(unsigned char *thing,unsigned char pos_x,unsigned char pos_y)
00406 {
00407 if (thing==NULL) return false;
00408 thing[0]=pos_x;
00409 thing[2]=pos_y;
00410 return true;
00411 }
00412
00413 unsigned char get_thing_subtpos_h(const unsigned char *thing)
00414 {
00415 if (thing==NULL) return 0x80;
00416 return (char)thing[4];
00417 }
00418
00419 short set_thing_subtpos_h(unsigned char *thing,unsigned char pos_h)
00420 {
00421 if (thing==NULL) return false;
00422 thing[4]=pos_h;
00423 return true;
00424 }
00425
00426 unsigned char get_thing_range_subtpos(const unsigned char *thing)
00427 {
00428 if (thing==NULL) return 0x80;
00429 return (char)thing[9];
00430 }
00431
00432 short set_thing_range_subtpos(unsigned char *thing,unsigned char rng)
00433 {
00434 if (thing==NULL) return false;
00435 thing[9]=rng;
00436 return true;
00437 }
00438
00439 unsigned char get_thing_range_subtile(const unsigned char *thing)
00440 {
00441 if (thing==NULL) return 0x80;
00442 return (char)thing[10];
00443 }
00444
00445 short set_thing_range_subtile(unsigned char *thing,unsigned char rng)
00446 {
00447 if (thing==NULL) return false;
00448 thing[10]=rng;
00449 return true;
00450 }
00451
00452
00453
00454
00455 unsigned int get_thing_range_adv(const unsigned char *thing)
00456 {
00457 switch(get_thing_type(thing))
00458 {
00459 case THING_TYPE_ITEM:
00460 return (1<<8);
00461 case THING_TYPE_CREATURE:
00462 return (4<<8);
00463 case THING_TYPE_EFFECTGEN:
00464 return ((unsigned int)get_thing_range_subtile(thing)<<8)+get_thing_range_subtpos(thing);
00465 case THING_TYPE_TRAP:
00466 return (4<<8);
00467 case THING_TYPE_DOOR:
00468 return (4<<8);
00469 default:
00470 return 0;
00471 }
00472 }
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 unsigned long get_thing_distance_sqr_adv(const unsigned char *thing,const int ssx,const int ssy)
00483 {
00484 int dx=get_thing_pos_x_adv(thing)-ssx;
00485 int dy=get_thing_pos_y_adv(thing)-ssy;
00486 return (dx*dx)+(dy*dy);
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496 unsigned long get_thing_distance_adv(const unsigned char *thing,const int ssx,const int ssy)
00497 {
00498 int dx=get_thing_pos_x_adv(thing)-ssx;
00499 int dy=get_thing_pos_y_adv(thing)-ssy;
00500 float dist_sqr=((float)dx*dx)+((float)dy*dy);
00501 return sqrt(dist_sqr);
00502 }
00503
00504
00505
00506
00507
00508 unsigned char get_thing_level(const unsigned char *thing)
00509 {
00510 if (thing==NULL) return 0;
00511 return thing[14];
00512 }
00513
00514 short set_thing_level(unsigned char *thing,unsigned char lev_num)
00515 {
00516 if (thing==NULL) return false;
00517 thing[14]=lev_num;
00518 return true;
00519 }
00520
00521
00522
00523
00524 unsigned short get_thing_sensitile(const unsigned char *thing)
00525 {
00526 if (thing==NULL) return THING_SENSITILE_NONE;
00527 return (unsigned short)((thing[12]<<8)+thing[11]);
00528 }
00529
00530
00531
00532
00533 short set_thing_sensitile(unsigned char *thing,unsigned short til_num)
00534 {
00535 if (thing==NULL) return false;
00536 thing[12]=(til_num>>8)&255;
00537 thing[11]=til_num&255;
00538 return true;
00539 }
00540
00541 unsigned char get_door_orientation(const unsigned char *thing)
00542 {
00543 if (thing==NULL) return DOOR_ORIENT_NSPASS;
00544 return thing[13];
00545 }
00546
00547 short set_door_orientation(unsigned char *thing,unsigned char orient)
00548 {
00549 if (thing==NULL) return false;
00550 thing[13]=orient;
00551 return true;
00552 }
00553
00554 short switch_thing_subtype(unsigned char *thing,const short forward)
00555 {
00556 int i=get_thing_subtypes_arridx(thing);
00557 if (i<0)
00558 return false;
00559 unsigned char stype_idx=get_thing_subtype(thing);
00560 unsigned char stype_new;
00561 if (forward)
00562 stype_new=get_thing_subtypes_next(i,stype_idx);
00563 else
00564 stype_new=get_thing_subtypes_prev(i,stype_idx);
00565 if (stype_new!=stype_idx)
00566 {
00567 set_thing_subtype(thing,stype_new);
00568 return true;
00569 }
00570 return false;
00571 }
00572
00573 int get_thing_subtypes_arridx(const unsigned char *thing)
00574 {
00575 if (thing==NULL) return -1;
00576 int func_count=sizeof(thing_subtype_tests)/sizeof(is_thing_subtype);
00577 int i;
00578 for (i=0;i<func_count;i++)
00579 {
00580 if (thing_subtype_tests[i](thing))
00581 return i;
00582 }
00583 return -1;
00584 }
00585
00586
00587
00588
00589 unsigned int get_thing_subtypes_count(const unsigned short arr_idx)
00590 {
00591 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00592 if (arr_idx<func_count)
00593 return thing_subtype_count[arr_idx]();
00594 return 0;
00595 }
00596
00597
00598
00599
00600 unsigned int get_thing_subtypes_arritem(const unsigned short arr_idx,const int arr_itm)
00601 {
00602 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00603 if (arr_idx<func_count)
00604 return thing_subtype_arritm[arr_idx](arr_itm);
00605 return 0;
00606 }
00607
00608
00609
00610
00611 int get_thing_subtypes_arritmidx(const unsigned short arr_idx,const unsigned short stype_idx)
00612 {
00613 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00614 if (arr_idx<func_count)
00615 return thing_subtype_arridx[arr_idx](stype_idx);
00616 return -1;
00617 }
00618
00619
00620
00621
00622 thing_subtype_arrayitem get_thing_subtypes_arritem_func(const unsigned short arr_idx)
00623 {
00624 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00625 if (arr_idx<func_count)
00626 return thing_subtype_arritm[arr_idx];
00627 return NULL;
00628 }
00629
00630
00631
00632
00633 unsigned short get_thing_subtypes_next(const unsigned short arr_idx,const unsigned short stype_idx)
00634 {
00635 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00636 if (arr_idx>=func_count)
00637 return stype_idx;
00638 int prev_idx;
00639 prev_idx=thing_subtype_arridx[arr_idx](stype_idx);
00640 if (prev_idx<0)
00641 return stype_idx;
00642 return thing_subtype_arritm[arr_idx](prev_idx+1);
00643 }
00644
00645
00646
00647
00648 unsigned short get_thing_subtypes_prev(const unsigned short arr_idx,const unsigned short stype_idx)
00649 {
00650 const int func_count=sizeof(thing_subtype_arritm)/sizeof(thing_subtype_arrayitem);
00651 if (arr_idx>=func_count)
00652 return stype_idx;
00653 int prev_idx;
00654 prev_idx=thing_subtype_arridx[arr_idx](stype_idx);
00655 if (prev_idx<0)
00656 return stype_idx;
00657 return thing_subtype_arritm[arr_idx](prev_idx-1);
00658 }
00659
00660 char *get_thing_type_fullname(unsigned short type_idx)
00661 {
00662 int types_count=sizeof(thing_fullnames)/sizeof(char *);
00663 if (type_idx<types_count)
00664 return (char *)thing_fullnames[type_idx];
00665 else
00666 return "unknown(?!)";
00667 }
00668
00669 char *get_thing_type_shortname(const unsigned short type_idx)
00670 {
00671 int types_count=sizeof(thing_shortnames)/sizeof(char *);
00672 if (type_idx<types_count)
00673 return (char *)thing_shortnames[type_idx];
00674 else
00675 return "unkn!";
00676 }
00677
00678 char *get_thing_subtype_fullname(const unsigned short type_idx,const unsigned short stype_idx)
00679 {
00680 static char buffer[LINEMSG_SIZE];
00681 switch (type_idx)
00682 {
00683 case THING_TYPE_ITEM:
00684 sprintf(buffer,"%s",get_item_subtype_fullname(stype_idx));
00685 break;
00686 case THING_TYPE_CREATURE:
00687 sprintf(buffer,"%s",get_creature_subtype_fullname(stype_idx));
00688 break;
00689 case THING_TYPE_EFFECTGEN:
00690 sprintf(buffer,"%s effect",get_effectgen_subtype_fullname(stype_idx));
00691 break;
00692 case THING_TYPE_TRAP:
00693 sprintf(buffer,"%s trap",get_trap_subtype_fullname(stype_idx));
00694 break;
00695 case THING_TYPE_DOOR:
00696 sprintf(buffer,"%s door",get_door_subtype_fullname(stype_idx));
00697 break;
00698 default:
00699 sprintf(buffer,"%s",get_thing_type_fullname(type_idx));
00700 break;
00701 }
00702 return buffer;
00703 }
00704
00705
00706
00707
00708
00709
00710 unsigned char get_usual_thing_slab(unsigned char *thing)
00711 {
00712 if (thing==NULL) return SLAB_TYPE_CLAIMED;
00713 unsigned char type_idx=get_thing_type(thing);
00714 unsigned char stype_idx=get_thing_subtype(thing);
00715 switch (type_idx)
00716 {
00717 case THING_TYPE_CREATURE:
00718 return SLAB_TYPE_CLAIMED;
00719 case THING_TYPE_TRAP:
00720 return SLAB_TYPE_CLAIMED;
00721 case THING_TYPE_ITEM:
00722 return get_usual_item_slab(stype_idx);
00723 case THING_TYPE_EFFECTGEN:
00724 {
00725 switch (stype_idx)
00726 {
00727 case EFCTGEN_SUBTP_LAVA:
00728 return SLAB_TYPE_LAVA;
00729 case EFCTGEN_SUBTP_DRIPWTR:
00730
00731
00732
00733 return SLAB_TYPE_CLAIMED;
00734 case EFCTGEN_SUBTP_ROCKFAL:
00735 return SLAB_TYPE_PATH;
00736 case EFCTGEN_SUBTP_ENTRICE:
00737
00738
00739
00740 return SLAB_TYPE_CLAIMED;
00741 case EFCTGEN_SUBTP_DRYICE:
00742
00743
00744
00745 return SLAB_TYPE_CLAIMED;
00746 }
00747 };break;
00748 case THING_TYPE_DOOR:
00749 {
00750 switch (stype_idx)
00751 {
00752 case DOOR_SUBTYPE_WOOD:
00753 return SLAB_TYPE_DOORWOOD1;
00754 case DOOR_SUBTYPE_BRACED:
00755 return SLAB_TYPE_DOORBRACE1;
00756 case DOOR_SUBTYPE_IRON:
00757 return SLAB_TYPE_DOORIRON1;
00758 case DOOR_SUBTYPE_MAGIC:
00759 return SLAB_TYPE_DOORMAGIC1;
00760 }
00761 };break;
00762 }
00763 return SLAB_TYPE_CLAIMED;
00764 }
00765
00766
00767
00768
00769
00770
00771 unsigned char get_usual_item_slab(unsigned char stype_idx)
00772 {
00773 int catg=get_item_category(stype_idx);
00774 switch (catg)
00775 {
00776 case THING_CATEGR_CREATLAIR:
00777 return SLAB_TYPE_LAIR;
00778 case THING_CATEGR_FOOD:
00779 return SLAB_TYPE_HATCHERY;
00780 case THING_CATEGR_TORCHCNDL:
00781 return SLAB_TYPE_CLAIMED;
00782 case THING_CATEGR_HEARTFLAME:
00783 return SLAB_TYPE_DUNGHEART;
00784 case THING_CATEGR_ITEMEFFCT:
00785 case THING_CATEGR_POLEBAR:
00786 case THING_CATEGR_FURNITURE:
00787 case THING_CATEGR_ROOMEQUIP:
00788 case THING_CATEGR_DNCRUCIAL:
00789 {
00790
00791 switch (stype_idx)
00792 {
00793 case ITEM_SUBTYPE_DNHEART:
00794 return SLAB_TYPE_DUNGHEART;
00795 case ITEM_SUBTYPE_HEROGATE:
00796 return SLAB_TYPE_CLAIMED;
00797 case ITEM_SUBTYPE_FLAGPOST:
00798 case ITEM_SUBTYPE_GURDFLAGR:
00799 case ITEM_SUBTYPE_GURDFLAGB:
00800 case ITEM_SUBTYPE_GURDFLAGG:
00801 case ITEM_SUBTYPE_GURDFLAGY:
00802 return SLAB_TYPE_GUARDPOST;
00803
00804 case ITEM_SUBTYPE_PRISONBAR:
00805 return SLAB_TYPE_PRISONCASE;
00806 case ITEM_SUBTYPE_SCAVNGEYE:
00807 return SLAB_TYPE_SCAVENGER;
00808 case ITEM_SUBTYPE_ANVIL:
00809 case ITEM_SUBTYPE_WRKSHPMCH:
00810 return SLAB_TYPE_WORKSHOP;
00811 case ITEM_SUBTYPE_GRAVSTONE:
00812 return SLAB_TYPE_GRAVEYARD;
00813 case ITEM_SUBTYPE_TRAINPOST:
00814 return SLAB_TYPE_TRAINING;
00815 case ITEM_SUBTYPE_TORTSPIKE:
00816 case ITEM_SUBTYPE_TORTURER:
00817 return SLAB_TYPE_TORTURE;
00818 }
00819 };break;
00820 }
00821 return SLAB_TYPE_CLAIMED;
00822 }
00823
00824
00825
00826
00827
00828 unsigned char *create_thing_empty(void)
00829 {
00830 unsigned char *thing;
00831 thing = (unsigned char *)malloc(SIZEOF_DK_TNG_REC);
00832 if (thing==NULL)
00833 {
00834 message_error("create_thing: Out of memory.");
00835 return NULL;
00836 }
00837 return thing;
00838 }
00839
00840
00841
00842
00843
00844 unsigned char *create_thing(unsigned int sx, unsigned int sy)
00845 {
00846 unsigned char *thing;
00847 thing = create_thing_empty();
00848 int i;
00849 for (i=0; i < SIZEOF_DK_TNG_REC; i++)
00850 thing[i]=0;
00851 set_thing_subtpos(thing,((sx%MAP_SUBNUM_X)*0x40+0x40),((sy%MAP_SUBNUM_Y)*0x40+0x40));
00852 set_thing_subtile(thing,(unsigned char)sx,(unsigned char)sy);
00853 set_thing_subtile_h(thing,1);
00854
00855 set_thing_owner(thing,PLAYER_UNSET);
00856 return thing;
00857 }
00858
00859
00860
00861
00862
00863 unsigned char *create_thing_copy(const struct LEVEL *lvl,unsigned int sx, unsigned int sy,unsigned char *src)
00864 {
00865
00866 const int arr_entries_x=lvl->tlsize.x*MAP_SUBNUM_X;
00867 const int arr_entries_y=lvl->tlsize.y*MAP_SUBNUM_Y;
00868 sx%=arr_entries_x;
00869 sy%=arr_entries_y;
00870
00871 unsigned char *thing;
00872 thing = create_thing_empty();
00873 int i;
00874 memcpy(thing,src,SIZEOF_DK_TNG_REC);
00875 unsigned char type_idx=get_thing_type(thing);
00876 unsigned char stype_idx=get_thing_subtype(thing);
00877 set_thing_subtpos(thing,((sx%MAP_SUBNUM_X)*0x40+0x40),((sy%MAP_SUBNUM_Y)*0x40+0x40));
00878 set_thing_subtile(thing,(unsigned char)sx,(unsigned char)sy);
00879 if (type_idx==THING_TYPE_EFFECTGEN)
00880 set_thing_sensitile(thing,compute_effectgen_sensitile(lvl,thing));
00881 if (type_idx==THING_TYPE_ITEM)
00882 set_thing_sensitile(thing,compute_item_sensitile(lvl,thing));
00883 return thing;
00884 }
00885
00886
00887
00888
00889 unsigned char *create_item(const struct LEVEL *lvl,unsigned int sx, unsigned int sy, unsigned char stype_idx)
00890 {
00891 unsigned char *thing;
00892 thing = create_thing(sx,sy);
00893 int tx=sx/MAP_SUBNUM_X;
00894 int ty=sy/MAP_SUBNUM_Y;
00895 set_thing_type(thing,THING_TYPE_ITEM);
00896 set_thing_subtype(thing,stype_idx);
00897 set_thing_owner(thing,get_tile_owner(lvl,tx,ty));
00898 set_thing_sensitile(thing,THING_SENSITILE_NONE);
00899 return thing;
00900 }
00901
00902
00903
00904
00905 short is_spellbook(const unsigned char *thing)
00906 {
00907
00908 if (get_thing_type(thing) != THING_TYPE_ITEM)
00909 return false;
00910 return is_spellbook_stype(get_thing_subtype(thing));
00911 }
00912
00913
00914
00915
00916 short is_spellbook_stype(const unsigned char stype_idx)
00917 {
00918 if (get_spellbook_arridx(stype_idx)<0) return false;
00919 return true;
00920 }
00921
00922 int get_spellbook_arridx(const unsigned char stype_idx)
00923 {
00924 unsigned char *arr=(unsigned char *)items_spellbooks;
00925 int array_count=get_spellbook_count();
00926
00927 char *pos=memchr(arr,stype_idx,array_count);
00928 if (pos==NULL) return -1;
00929 return ((long)pos-(long)arr)/sizeof(unsigned char);
00930 }
00931
00932 unsigned char get_spellbook_arritm(const int arr_itm)
00933 {
00934 unsigned char *arr=(unsigned char *)items_spellbooks;
00935 int array_count=get_spellbook_count();
00936 if (arr_itm<0)
00937 return arr[0];
00938 if (arr_itm>=array_count)
00939 return arr[array_count-1];
00940 return arr[arr_itm];
00941 }
00942
00943 unsigned int get_spellbook_count(void)
00944 {
00945 return sizeof(items_spellbooks)/sizeof(unsigned char);
00946 }
00947
00948
00949
00950
00951 unsigned char get_spellbook_next(const unsigned char stype_idx)
00952 {
00953 int array_count=sizeof(items_spellbooks)/sizeof(unsigned char);
00954
00955 unsigned char *pos=memchr(items_spellbooks,stype_idx,array_count);
00956 if (pos!=NULL) pos+=sizeof(unsigned char);
00957 if ((pos<items_spellbooks)||(pos>=items_spellbooks+sizeof(items_spellbooks)))
00958 pos=(unsigned char *)items_spellbooks;
00959 return *pos;
00960 }
00961
00962
00963
00964
00965 unsigned char get_spellbook_prev(const unsigned char stype_idx)
00966 {
00967 int array_count=sizeof(items_spellbooks)/sizeof(unsigned char);
00968
00969 unsigned char *pos=memchr(items_spellbooks,stype_idx,array_count);
00970 if (pos!=NULL) pos-=sizeof(unsigned char);
00971 if ((pos<items_spellbooks)||(pos>=items_spellbooks+sizeof(items_spellbooks)))
00972 pos=(unsigned char *)items_spellbooks+(array_count-1)*sizeof(unsigned char);
00973 return *pos;
00974 }
00975
00976
00977
00978
00979 short is_dngspecbox(const unsigned char *thing)
00980 {
00981
00982 if (get_thing_type(thing) != THING_TYPE_ITEM)
00983 return false;
00984 return is_dngspecbox_stype(get_thing_subtype(thing));
00985 }
00986
00987
00988
00989
00990 short is_dngspecbox_stype(const unsigned char stype_idx)
00991 {
00992 if (get_dngspecbox_arridx(stype_idx)<0) return false;
00993 return true;
00994 }
00995
00996 int get_dngspecbox_arridx(const unsigned char stype_idx)
00997 {
00998 unsigned char *arr=(unsigned char *)items_specboxes;
00999 int array_count=get_dngspecbox_count();
01000
01001 char *pos=memchr(arr,stype_idx,array_count);
01002 if (pos==NULL) return -1;
01003 return ((long)pos-(long)arr)/sizeof(unsigned char);
01004 }
01005
01006 unsigned char get_dngspecbox_arritm(const int arr_itm)
01007 {
01008 unsigned char *arr=(unsigned char *)items_specboxes;
01009 int array_count=get_dngspecbox_count();
01010 if (arr_itm<0)
01011 return arr[0];
01012 if (arr_itm>=array_count)
01013 return arr[array_count-1];
01014 return arr[arr_itm];
01015 }
01016
01017 unsigned int get_dngspecbox_count(void)
01018 {
01019 return sizeof(items_specboxes)/sizeof(unsigned char);
01020 }
01021
01022
01023
01024
01025 unsigned char get_dngspecbox_next(const unsigned char stype_idx)
01026 {
01027 int array_count=sizeof(items_specboxes)/sizeof(unsigned char);
01028
01029 unsigned char *pos=memchr(items_specboxes,stype_idx,array_count);
01030 if (pos!=NULL) pos+=sizeof(unsigned char);
01031 if ((pos<items_specboxes)||(pos>=items_specboxes+sizeof(items_specboxes)))
01032 pos=(unsigned char *)items_specboxes;
01033 return *pos;
01034 }
01035
01036
01037
01038
01039 unsigned char get_dngspecbox_prev(const unsigned char stype_idx)
01040 {
01041 int array_count=sizeof(items_specboxes)/sizeof(unsigned char);
01042
01043 unsigned char *pos=memchr(items_specboxes,stype_idx,array_count);
01044 if (pos!=NULL) pos-=sizeof(unsigned char);
01045 if ((pos<items_specboxes)||(pos>=items_specboxes+sizeof(items_specboxes)))
01046 pos=(unsigned char *)items_specboxes+(array_count-1)*sizeof(unsigned char);
01047 return *pos;
01048 }
01049
01050
01051
01052
01053 short is_crtrlair(const unsigned char *thing)
01054 {
01055
01056 if (get_thing_type(thing) != THING_TYPE_ITEM)
01057 return false;
01058 return is_crtrlair_stype(get_thing_subtype(thing));
01059 }
01060
01061
01062
01063
01064 short is_crtrlair_stype(const unsigned char stype_idx)
01065 {
01066 if (get_crtrlair_arridx(stype_idx)<0) return false;
01067 return true;
01068 }
01069
01070 int get_crtrlair_arridx(const unsigned char stype_idx)
01071 {
01072 unsigned char *arr=(unsigned char *)items_crtrlairs;
01073 int array_count=get_crtrlair_count();
01074
01075 char *pos=memchr(arr,stype_idx,array_count);
01076 if (pos==NULL) return -1;
01077 return ((long)pos-(long)arr)/sizeof(unsigned char);
01078 }
01079
01080 unsigned char get_crtrlair_arritm(const int arr_itm)
01081 {
01082 unsigned char *arr=(unsigned char *)items_crtrlairs;
01083 int array_count=get_crtrlair_count();
01084 if (arr_itm<0)
01085 return arr[0];
01086 if (arr_itm>=array_count)
01087 return arr[array_count-1];
01088 return arr[arr_itm];
01089 }
01090
01091 unsigned int get_crtrlair_count(void)
01092 {
01093 return sizeof(items_crtrlairs)/sizeof(unsigned char);
01094 }
01095
01096
01097
01098
01099 unsigned char get_crtrlair_next(const unsigned char stype_idx)
01100 {
01101 int array_count=sizeof(items_crtrlairs)/sizeof(unsigned char);
01102
01103 unsigned char *pos=memchr(items_crtrlairs,stype_idx,array_count);
01104 if (pos!=NULL) pos+=sizeof(unsigned char);
01105 if ((pos<items_crtrlairs)||(pos>=items_crtrlairs+sizeof(items_crtrlairs)))
01106 pos=(unsigned char *)items_crtrlairs;
01107 return *pos;
01108 }
01109
01110
01111
01112
01113 unsigned char get_crtrlair_prev(const unsigned char stype_idx)
01114 {
01115 int array_count=sizeof(items_crtrlairs)/sizeof(unsigned char);
01116
01117 unsigned char *pos=memchr(items_crtrlairs,stype_idx,array_count);
01118 if (pos!=NULL) pos-=sizeof(unsigned char);
01119 if ((pos<items_crtrlairs)||(pos>=items_crtrlairs+sizeof(items_crtrlairs)))
01120 pos=(unsigned char *)items_crtrlairs+(array_count-1)*sizeof(unsigned char);
01121 return *pos;
01122 }
01123
01124
01125
01126
01127 short is_trapbox(const unsigned char *thing)
01128 {
01129
01130 if (get_thing_type(thing) != THING_TYPE_ITEM)
01131 return false;
01132 return is_trapbox_stype(get_thing_subtype(thing));
01133 }
01134
01135
01136
01137
01138 short is_trapbox_stype(const unsigned char stype_idx)
01139 {
01140 if (get_trapbox_arridx(stype_idx)<0) return false;
01141 return true;
01142 }
01143
01144 int get_trapbox_arridx(const unsigned char stype_idx)
01145 {
01146 unsigned char *arr=(unsigned char *)items_trapbxs;
01147 int array_count=get_trapbox_count();
01148
01149 char *pos=memchr(arr,stype_idx,array_count);
01150 if (pos==NULL) return -1;
01151 return ((long)pos-(long)arr)/sizeof(unsigned char);
01152 }
01153
01154 unsigned char get_trapbox_arritm(const int arr_itm)
01155 {
01156 unsigned char *arr=(unsigned char *)items_trapbxs;
01157 int array_count=get_trapbox_count();
01158 if (arr_itm<0)
01159 return arr[0];
01160 if (arr_itm>=array_count)
01161 return arr[array_count-1];
01162 return arr[arr_itm];
01163 }
01164
01165 unsigned int get_trapbox_count(void)
01166 {
01167 return sizeof(items_trapbxs)/sizeof(unsigned char);
01168 }
01169
01170
01171
01172
01173 unsigned char get_trapbox_next(const unsigned char stype_idx)
01174 {
01175 int array_count=sizeof(items_trapbxs)/sizeof(unsigned char);
01176
01177 unsigned char *pos=memchr(items_trapbxs,stype_idx,array_count);
01178 if (pos!=NULL) pos+=sizeof(unsigned char);
01179 if ((pos<items_trapbxs)||(pos>=items_trapbxs+sizeof(items_trapbxs)))
01180 pos=(unsigned char *)items_trapbxs;
01181 return *pos;
01182 }
01183
01184
01185
01186
01187 unsigned char get_trapbox_prev(const unsigned char stype_idx)
01188 {
01189 int array_count=sizeof(items_trapbxs)/sizeof(unsigned char);
01190
01191 unsigned char *pos=memchr(items_trapbxs,stype_idx,array_count);
01192 if (pos!=NULL) pos-=sizeof(unsigned char);
01193 if ((pos<items_trapbxs)||(pos>=items_trapbxs+sizeof(items_trapbxs)))
01194 pos=(unsigned char *)items_trapbxs+(array_count-1)*sizeof(unsigned char);
01195 return *pos;
01196 }
01197
01198
01199
01200
01201 short is_trap(const unsigned char *thing)
01202 {
01203 if (get_thing_type(thing) == THING_TYPE_TRAP)
01204 return true;
01205 return false;
01206 }
01207
01208 int get_trap_arridx(const unsigned char stype_idx)
01209 {
01210 unsigned char *arr=(unsigned char *)trap_types;
01211 int array_count=get_trap_count();
01212
01213 char *pos=memchr(arr,stype_idx,array_count);
01214 if (pos==NULL) return -1;
01215 return ((long)pos-(long)arr)/sizeof(unsigned char);
01216 }
01217
01218 unsigned char get_trap_arritm(const int arr_itm)
01219 {
01220 unsigned char *arr=(unsigned char *)trap_types;
01221 int array_count=get_trap_count();
01222 if (arr_itm<0)
01223 return arr[0];
01224 if (arr_itm>=array_count)
01225 return arr[array_count-1];
01226 return arr[arr_itm];
01227 }
01228
01229 unsigned int get_trap_count(void)
01230 {
01231 return sizeof(trap_types)/sizeof(unsigned char);
01232 }
01233
01234
01235
01236
01237 short is_creature(const unsigned char *thing)
01238 {
01239 if (get_thing_type(thing) == THING_TYPE_CREATURE)
01240 return true;
01241 return false;
01242 }
01243
01244 int get_creature_arridx(const unsigned char stype_idx)
01245 {
01246 unsigned char *arr=(unsigned char *)creatr_types;
01247 int array_count=get_creature_count();
01248
01249 char *pos=memchr(arr,stype_idx,array_count);
01250 if (pos==NULL) return -1;
01251 return ((long)pos-(long)arr)/sizeof(unsigned char);
01252 }
01253
01254 unsigned char get_creature_arritm(const int arr_itm)
01255 {
01256 unsigned char *arr=(unsigned char *)creatr_types;
01257 int array_count=get_creature_count();
01258 if (arr_itm<0)
01259 return arr[0];
01260 if (arr_itm>=array_count)
01261 return arr[array_count-1];
01262 return arr[arr_itm];
01263 }
01264
01265 unsigned int get_creature_count(void)
01266 {
01267 return sizeof(creatr_types)/sizeof(unsigned char);
01268 }
01269
01270
01271
01272
01273 unsigned char get_creature_next(const unsigned char stype_idx)
01274 {
01275 int array_count=sizeof(creatr_types)/sizeof(unsigned char);
01276
01277 unsigned char *pos=memchr(creatr_types,stype_idx,array_count);
01278 if (pos!=NULL) pos+=sizeof(unsigned char);
01279 if ((pos<creatr_types)||(pos>=creatr_types+sizeof(creatr_types)))
01280 pos=(unsigned char *)creatr_types;
01281 return *pos;
01282 }
01283
01284
01285
01286
01287 unsigned char get_creature_prev(const unsigned char stype_idx)
01288 {
01289 int array_count=sizeof(creatr_types)/sizeof(unsigned char);
01290
01291 unsigned char *pos=memchr(creatr_types,stype_idx,array_count);
01292 if (pos!=NULL) pos-=sizeof(unsigned char);
01293 if ((pos<creatr_types)||(pos>=creatr_types+sizeof(creatr_types)))
01294 pos=(unsigned char *)creatr_types+(array_count-1)*sizeof(unsigned char);
01295 return *pos;
01296 }
01297
01298
01299
01300
01301 short is_doorbox(const unsigned char *thing)
01302 {
01303
01304 if (get_thing_type(thing) != THING_TYPE_ITEM)
01305 return false;
01306 return is_doorbox_stype(get_thing_subtype(thing));
01307 }
01308
01309
01310
01311
01312 short is_doorbox_stype(const unsigned char stype_idx)
01313 {
01314 if (get_doorbox_arridx(stype_idx)<0) return false;
01315 return true;
01316 }
01317
01318 int get_doorbox_arridx(const unsigned char stype_idx)
01319 {
01320 unsigned char *arr=(unsigned char *)items_doorboxes;
01321 int array_count=get_doorbox_count();
01322
01323 char *pos=memchr(arr,stype_idx,array_count);
01324 if (pos==NULL) return -1;
01325 return ((long)pos-(long)arr)/sizeof(unsigned char);
01326 }
01327
01328 unsigned char get_doorbox_arritm(const int arr_itm)
01329 {
01330 unsigned char *arr=(unsigned char *)items_doorboxes;
01331 int array_count=get_doorbox_count();
01332 if (arr_itm<0)
01333 return arr[0];
01334 if (arr_itm>=array_count)
01335 return arr[array_count-1];
01336 return arr[arr_itm];
01337 }
01338
01339 unsigned int get_doorbox_count(void)
01340 {
01341 return sizeof(items_doorboxes)/sizeof(unsigned char);
01342 }
01343
01344
01345
01346
01347 unsigned char get_doorbox_next(const unsigned char stype_idx)
01348 {
01349 unsigned char *arr=(unsigned char *)items_doorboxes;
01350 int sizeof_arr=sizeof(items_doorboxes);
01351 int array_count=sizeof_arr/sizeof(unsigned char);
01352
01353 unsigned char *pos=memchr(arr,stype_idx,array_count);
01354 if (pos!=NULL) pos++;
01355 if ((pos<arr)||(pos>=arr+sizeof_arr))
01356 pos=arr;
01357 return *pos;
01358 }
01359
01360
01361
01362
01363 unsigned char get_doorbox_prev(const unsigned char stype_idx)
01364 {
01365 unsigned char *arr=(unsigned char *)items_doorboxes;
01366 int sizeof_arr=sizeof(items_doorboxes);
01367 int array_count=sizeof_arr/sizeof(unsigned char);
01368
01369 unsigned char *pos=memchr(arr,stype_idx,array_count);
01370 if (pos!=NULL) pos--;
01371 if ((pos<arr)||(pos>=arr+sizeof_arr))
01372 pos=arr;
01373 return *pos;
01374 }
01375
01376
01377
01378
01379 short is_door(const unsigned char *thing)
01380 {
01381 if (get_thing_type(thing) == THING_TYPE_DOOR)
01382 return true;
01383 return false;
01384 }
01385
01386 int get_door_arridx(const unsigned char stype_idx)
01387 {
01388 unsigned char *arr=(unsigned char *)door_types;
01389 int array_count=get_door_count();
01390
01391 char *pos=memchr(arr,stype_idx,array_count);
01392 if (pos==NULL) return -1;
01393 return ((long)pos-(long)arr)/sizeof(unsigned char);
01394 }
01395
01396 unsigned char get_door_arritm(const int arr_itm)
01397 {
01398 unsigned char *arr=(unsigned char *)door_types;
01399 int array_count=get_door_count();
01400 if (arr_itm<0)
01401 return arr[0];
01402 if (arr_itm>=array_count)
01403 return arr[array_count-1];
01404 return arr[arr_itm];
01405 }
01406
01407 unsigned int get_door_count(void)
01408 {
01409 return sizeof(door_types)/sizeof(unsigned char);
01410 }
01411
01412
01413
01414
01415 unsigned char get_door_next(const unsigned char stype_idx)
01416 {
01417 int array_count=sizeof(door_types)/sizeof(unsigned char);
01418
01419 unsigned char *pos=memchr(door_types,stype_idx,array_count);
01420 if (pos!=NULL) pos+=sizeof(unsigned char);
01421 if ((pos<door_types)||(pos>=door_types+sizeof(door_types)))
01422 pos=(unsigned char *)door_types;
01423 return *pos;
01424 }
01425
01426
01427
01428
01429 unsigned char get_door_prev(const unsigned char stype_idx)
01430 {
01431 int array_count=sizeof(door_types)/sizeof(unsigned char);
01432
01433 unsigned char *pos=memchr(door_types,stype_idx,array_count);
01434 if (pos!=NULL) pos-=sizeof(unsigned char);
01435 if ((pos<door_types)||(pos>=door_types+sizeof(door_types)))
01436 pos=(unsigned char *)door_types+(array_count-1)*sizeof(unsigned char);
01437 return *pos;
01438 }
01439
01440
01441
01442
01443 short is_effectgen(const unsigned char *thing)
01444 {
01445 if (get_thing_type(thing) == THING_TYPE_EFFECTGEN)
01446 return true;
01447 return false;
01448 }
01449
01450 int get_effectgen_arridx(const unsigned char stype_idx)
01451 {
01452 unsigned char *arr=(unsigned char *)efctgen_types;
01453 int array_count=get_effectgen_count();
01454
01455 char *pos=memchr(arr,stype_idx,array_count);
01456 if (pos==NULL) return -1;
01457 return ((long)pos-(long)arr)/sizeof(unsigned char);
01458 }
01459
01460 unsigned char get_effectgen_arritm(const int arr_itm)
01461 {
01462 unsigned char *arr=(unsigned char *)efctgen_types;
01463 int array_count=get_effectgen_count();
01464 if (arr_itm<0)
01465 return arr[0];
01466 if (arr_itm>=array_count)
01467 return arr[array_count-1];
01468 return arr[arr_itm];
01469 }
01470
01471 unsigned int get_effectgen_count(void)
01472 {
01473 return sizeof(efctgen_types)/sizeof(unsigned char);
01474 }
01475
01476
01477
01478
01479 unsigned char get_effectgen_next(const unsigned char stype_idx)
01480 {
01481 int array_count=sizeof(efctgen_types)/sizeof(unsigned char);
01482
01483 unsigned char *pos=memchr(efctgen_types,stype_idx,array_count);
01484 if (pos!=NULL) pos+=sizeof(unsigned char);
01485 if ((pos<efctgen_types)||(pos>=efctgen_types+sizeof(efctgen_types)))
01486 pos=(unsigned char *)efctgen_types;
01487 return *pos;
01488 }
01489
01490
01491
01492
01493 unsigned char get_effectgen_prev(const unsigned char stype_idx)
01494 {
01495 int array_count=sizeof(efctgen_types)/sizeof(unsigned char);
01496
01497 unsigned char *pos=memchr(efctgen_types,stype_idx,array_count);
01498 if (pos!=NULL) pos-=sizeof(unsigned char);
01499 if ((pos<efctgen_types)||(pos>=efctgen_types+sizeof(efctgen_types)))
01500 pos=(unsigned char *)efctgen_types+(array_count-1)*sizeof(unsigned char);
01501 return *pos;
01502 }
01503
01504
01505
01506
01507 short is_statue(const unsigned char *thing)
01508 {
01509
01510 if (get_thing_type(thing) != THING_TYPE_ITEM)
01511 return false;
01512 return is_statue_stype(get_thing_subtype(thing));
01513 }
01514
01515
01516
01517
01518 short is_statue_stype(const unsigned char stype_idx)
01519 {
01520 if (get_statue_arridx(stype_idx)<0) return false;
01521 return true;
01522 }
01523
01524 int get_statue_arridx(const unsigned char stype_idx)
01525 {
01526 unsigned char *arr=(unsigned char *)items_statues;
01527 int array_count=get_statue_count();
01528
01529 char *pos=memchr(arr,stype_idx,array_count);
01530 if (pos==NULL) return -1;
01531 return ((long)pos-(long)arr)/sizeof(unsigned char);
01532 }
01533
01534 unsigned char get_statue_arritm(const int arr_itm)
01535 {
01536 unsigned char *arr=(unsigned char *)items_statues;
01537 int array_count=get_statue_count();
01538 if (arr_itm<0)
01539 return arr[0];
01540 if (arr_itm>=array_count)
01541 return arr[array_count-1];
01542 return arr[arr_itm];
01543 }
01544
01545 unsigned int get_statue_count(void)
01546 {
01547 return sizeof(items_statues)/sizeof(unsigned char);
01548 }
01549
01550
01551
01552
01553 unsigned char get_statue_next(const unsigned char stype_idx)
01554 {
01555 int array_count=sizeof(items_statues)/sizeof(unsigned char);
01556
01557 unsigned char *pos=memchr(items_statues,stype_idx,array_count);
01558 if (pos!=NULL) pos+=sizeof(unsigned char);
01559 if ((pos<items_statues)||(pos>=items_statues+sizeof(items_statues)))
01560 pos=(unsigned char *)items_statues;
01561 return *pos;
01562 }
01563
01564
01565
01566
01567 unsigned char get_statue_prev(const unsigned char stype_idx)
01568 {
01569 int array_count=sizeof(items_statues)/sizeof(unsigned char);
01570
01571 unsigned char *pos=memchr(items_statues,stype_idx,array_count);
01572 if (pos!=NULL) pos-=sizeof(unsigned char);
01573 if ((pos<items_statues)||(pos>=items_statues+sizeof(items_statues)))
01574 pos=(unsigned char *)items_statues+(array_count-1)*sizeof(unsigned char);
01575 return *pos;
01576 }
01577
01578
01579
01580
01581 short is_food(const unsigned char *thing)
01582 {
01583
01584 if (get_thing_type(thing) != THING_TYPE_ITEM)
01585 return false;
01586 return is_food_stype(get_thing_subtype(thing));
01587 }
01588
01589
01590
01591
01592 short is_food_stype(const unsigned char stype_idx)
01593 {
01594 if (get_food_arridx(stype_idx)<0) return false;
01595 return true;
01596 }
01597
01598 int get_food_arridx(const unsigned char stype_idx)
01599 {
01600 unsigned char *arr=(unsigned char *)items_food;
01601 int array_count=get_food_count();
01602
01603 char *pos=memchr(arr,stype_idx,array_count);
01604 if (pos==NULL) return -1;
01605 return ((long)pos-(long)arr)/sizeof(unsigned char);
01606 }
01607
01608 unsigned char get_food_arritm(const int arr_itm)
01609 {
01610 unsigned char *arr=(unsigned char *)items_food;
01611 int array_count=get_food_count();
01612 if (arr_itm<0)
01613 return arr[0];
01614 if (arr_itm>=array_count)
01615 return arr[array_count-1];
01616 return arr[arr_itm];
01617 }
01618
01619 unsigned int get_food_count(void)
01620 {
01621 return sizeof(items_food)/sizeof(unsigned char);
01622 }
01623
01624
01625
01626
01627 unsigned char get_food_next(const unsigned char stype_idx)
01628 {
01629 int array_count=sizeof(items_food)/sizeof(unsigned char);
01630
01631 unsigned char *pos=memchr(items_food,stype_idx,array_count);
01632 if (pos!=NULL) pos+=sizeof(unsigned char);
01633 if ((pos<items_food)||(pos>=items_food+sizeof(items_food)))
01634 pos=(unsigned char *)items_food;
01635 return *pos;
01636 }
01637
01638
01639
01640
01641 unsigned char get_food_prev(const unsigned char stype_idx)
01642 {
01643 int array_count=sizeof(items_food)/sizeof(unsigned char);
01644
01645 unsigned char *pos=memchr(items_food,stype_idx,array_count);
01646 if (pos!=NULL) pos-=sizeof(unsigned char);
01647 if ((pos<items_food)||(pos>=items_food+sizeof(items_food)))
01648 pos=(unsigned char *)items_food+(array_count-1)*sizeof(unsigned char);
01649 return *pos;
01650 }
01651
01652 short is_gold(const unsigned char *thing)
01653 {
01654
01655 if (get_thing_type(thing) != THING_TYPE_ITEM)
01656 return false;
01657 return is_gold_stype(get_thing_subtype(thing));
01658 }
01659
01660 short is_gold_stype(const unsigned char stype_idx)
01661 {
01662 if (get_gold_arridx(stype_idx)<0) return false;
01663 return true;
01664 }
01665
01666 int get_gold_arridx(const unsigned char stype_idx)
01667 {
01668 unsigned char *arr=(unsigned char *)items_gold;
01669 int array_count=get_gold_count();
01670
01671 char *pos=memchr(arr,stype_idx,array_count);
01672 if (pos==NULL) return -1;
01673 return ((long)pos-(long)arr)/sizeof(unsigned char);
01674 }
01675
01676 unsigned char get_gold_arritm(const int arr_itm)
01677 {
01678 unsigned char *arr=(unsigned char *)items_gold;
01679 int array_count=get_gold_count();
01680 if (arr_itm<0)
01681 return arr[0];
01682 if (arr_itm>=array_count)
01683 return arr[array_count-1];
01684 return arr[arr_itm];
01685 }
01686
01687 unsigned int get_gold_count(void)
01688 {
01689 return sizeof(items_gold)/sizeof(unsigned char);
01690 }
01691
01692
01693
01694
01695 unsigned char get_gold_next(const unsigned char stype_idx)
01696 {
01697 int array_count=sizeof(items_gold)/sizeof(unsigned char);
01698
01699 unsigned char *pos=memchr(items_gold,stype_idx,array_count);
01700 if (pos!=NULL) pos+=sizeof(unsigned char);
01701 if ((pos<items_gold)||(pos>=items_gold+sizeof(items_gold)))
01702 pos=(unsigned char *)items_gold;
01703 return *pos;
01704 }
01705
01706
01707
01708
01709 unsigned char get_gold_prev(const unsigned char stype_idx)
01710 {
01711 int array_count=sizeof(items_gold)/sizeof(unsigned char);
01712
01713 unsigned char *pos=memchr(items_gold,stype_idx,array_count);
01714 if (pos!=NULL) pos-=sizeof(unsigned char);
01715 if ((pos<items_gold)||(pos>=items_gold+sizeof(items_gold)))
01716 pos=(unsigned char *)items_gold+(array_count-1)*sizeof(unsigned char);
01717 return *pos;
01718 }
01719
01720
01721
01722
01723 short is_torch(const unsigned char *thing)
01724 {
01725
01726 if (get_thing_type(thing) != THING_TYPE_ITEM)
01727 return false;
01728 return is_torch_stype(get_thing_subtype(thing));
01729 }
01730
01731 short is_torch_stype(const unsigned char stype_idx)
01732 {
01733 if (get_torch_arridx(stype_idx)<0) return false;
01734 return true;
01735 }
01736
01737 int get_torch_arridx(const unsigned char stype_idx)
01738 {
01739 unsigned char *arr=(unsigned char *)items_torches;
01740 int array_count=get_torch_count();
01741
01742 char *pos=memchr(arr,stype_idx,array_count);
01743 if (pos==NULL) return -1;
01744 return ((long)pos-(long)arr)/sizeof(unsigned char);
01745 }
01746
01747 unsigned char get_torch_arritm(const int arr_itm)
01748 {
01749 unsigned char *arr=(unsigned char *)items_torches;
01750 int array_count=get_torch_count();
01751 if (arr_itm<0)
01752 return arr[0];
01753 if (arr_itm>=array_count)
01754 return arr[array_count-1];
01755 return arr[arr_itm];
01756 }
01757
01758 unsigned int get_torch_count(void)
01759 {
01760 return sizeof(items_torches)/sizeof(unsigned char);
01761 }
01762
01763
01764
01765
01766 unsigned char get_torch_next(const unsigned char stype_idx)
01767 {
01768 int array_count=sizeof(items_torches)/sizeof(unsigned char);
01769
01770 unsigned char *pos=memchr(items_torches,stype_idx,array_count);
01771 if (pos!=NULL) pos+=sizeof(unsigned char);
01772 if ((pos<items_torches)||(pos>=items_torches+sizeof(items_torches)))
01773 pos=(unsigned char *)items_torches;
01774 return *pos;
01775 }
01776
01777
01778
01779
01780 unsigned char get_torch_prev(const unsigned char stype_idx)
01781 {
01782 int array_count=sizeof(items_torches)/sizeof(unsigned char);
01783
01784 unsigned char *pos=memchr(items_torches,stype_idx,array_count);
01785 if (pos!=NULL) pos-=sizeof(unsigned char);
01786 if ((pos<items_torches)||(pos>=items_torches+sizeof(items_torches)))
01787 pos=(unsigned char *)items_torches+(array_count-1)*sizeof(unsigned char);
01788 return *pos;
01789 }
01790
01791
01792
01793
01794 short is_heartflame(const unsigned char *thing)
01795 {
01796
01797 if (get_thing_type(thing) != THING_TYPE_ITEM)
01798 return false;
01799 return is_heartflame_stype(get_thing_subtype(thing));
01800 }
01801
01802 short is_heartflame_stype(const unsigned char stype_idx)
01803 {
01804 if (get_heartflame_arridx(stype_idx)<0) return false;
01805 return true;
01806 }
01807
01808 int get_heartflame_arridx(const unsigned char stype_idx)
01809 {
01810 unsigned char *arr=(unsigned char *)items_heartflames;
01811 int array_count=get_heartflame_count();
01812
01813 char *pos=memchr(arr,stype_idx,array_count);
01814 if (pos==NULL) return -1;
01815 return ((long)pos-(long)arr)/sizeof(unsigned char);
01816 }
01817
01818 unsigned char get_heartflame_arritm(const int arr_itm)
01819 {
01820 unsigned char *arr=(unsigned char *)items_heartflames;
01821 int array_count=get_heartflame_count();
01822 if (arr_itm<0)
01823 return arr[0];
01824 if (arr_itm>=array_count)
01825 return arr[array_count-1];
01826 return arr[arr_itm];
01827 }
01828
01829 unsigned int get_heartflame_count(void)
01830 {
01831 return sizeof(items_heartflames)/sizeof(unsigned char);
01832 }
01833
01834
01835
01836
01837 unsigned char get_heartflame_next(const unsigned char stype_idx)
01838 {
01839 unsigned char *arr=(unsigned char *)items_heartflames;
01840 int sizeof_arr=sizeof(items_heartflames);
01841 int sizeof_itm=sizeof(unsigned char);
01842 int array_count=sizeof_arr/sizeof_itm;
01843
01844 unsigned char *pos=memchr(arr,stype_idx,array_count);
01845 if (pos!=NULL) pos+=sizeof_itm;
01846 if ((pos<arr)||(pos>=arr+sizeof_arr))
01847 pos=arr;
01848 return *pos;
01849 }
01850
01851
01852
01853
01854 unsigned char get_heartflame_prev(const unsigned char stype_idx)
01855 {
01856 unsigned char *arr=(unsigned char *)items_heartflames;
01857 int sizeof_arr=sizeof(items_heartflames);
01858 int array_count=sizeof_arr/sizeof(unsigned char);
01859
01860 unsigned char *pos=memchr(arr,stype_idx,array_count);
01861 if (pos!=NULL) pos--;
01862 if ((pos<arr)||(pos>=arr+sizeof_arr))
01863 pos=arr+(array_count-1);
01864 return *pos;
01865 }
01866
01867
01868
01869
01870 short is_polebar(const unsigned char *thing)
01871 {
01872
01873 if (get_thing_type(thing) != THING_TYPE_ITEM)
01874 return false;
01875 return is_polebar_stype(get_thing_subtype(thing));
01876 }
01877
01878 short is_polebar_stype(const unsigned char stype_idx)
01879 {
01880 if (get_polebar_arridx(stype_idx)<0) return false;
01881 return true;
01882 }
01883
01884 int get_polebar_arridx(const unsigned char stype_idx)
01885 {
01886 unsigned char *arr=(unsigned char *)items_polebars;
01887 int array_count=get_polebar_count();
01888
01889 char *pos=memchr(arr,stype_idx,array_count);
01890 if (pos==NULL) return -1;
01891 return ((long)pos-(long)arr)/sizeof(unsigned char);
01892 }
01893
01894 unsigned char get_polebar_arritm(const int arr_itm)
01895 {
01896 unsigned char *arr=(unsigned char *)items_polebars;
01897 int array_count=get_polebar_count();
01898 if (arr_itm<0)
01899 return arr[0];
01900 if (arr_itm>=array_count)
01901 return arr[array_count-1];
01902 return arr[arr_itm];
01903 }
01904
01905 unsigned int get_polebar_count(void)
01906 {
01907 return sizeof(items_polebars)/sizeof(unsigned char);
01908 }
01909
01910
01911
01912
01913 short is_lit_thing(const unsigned char *thing)
01914 {
01915 if (get_thing_type(thing) == THING_TYPE_ITEM)
01916 return is_lit_thing_stype(get_thing_subtype(thing));
01917 return false;
01918 }
01919
01920 short is_lit_thing_stype(const unsigned char stype_idx)
01921 {
01922 if (get_lit_thing_arridx(stype_idx)<0) return false;
01923 return true;
01924 }
01925
01926 int get_lit_thing_arridx(const unsigned char stype_idx)
01927 {
01928 unsigned char *arr=(unsigned char *)items_litthings;
01929 int array_count=get_lit_thing_count();
01930
01931 char *pos=memchr(arr,stype_idx,array_count);
01932 if (pos==NULL) return -1;
01933 return ((long)pos-(long)arr)/sizeof(unsigned char);
01934 }
01935
01936 unsigned char get_lit_thing_arritm(const int arr_itm)
01937 {
01938 unsigned char *arr=(unsigned char *)items_litthings;
01939 int array_count=get_lit_thing_count();
01940 if (arr_itm<0)
01941 return arr[0];
01942 if (arr_itm>=array_count)
01943 return arr[array_count-1];
01944 return arr[arr_itm];
01945 }
01946
01947 unsigned int get_lit_thing_count(void)
01948 {
01949 return sizeof(items_litthings)/sizeof(unsigned char);
01950 }
01951
01952
01953
01954
01955 unsigned char get_lit_thing_next(const unsigned char stype_idx)
01956 {
01957 unsigned char *arr=(unsigned char *)items_litthings;
01958 int sizeof_arr=sizeof(items_litthings);
01959 int sizeof_itm=sizeof(unsigned char);
01960 int array_count=sizeof_arr/sizeof_itm;
01961
01962 unsigned char *pos=memchr(arr,stype_idx,array_count);
01963 if (pos!=NULL) pos+=sizeof_itm;
01964 if ((pos<arr)||(pos>=arr+sizeof_arr))
01965 pos=arr;
01966 return *pos;
01967 }
01968
01969
01970
01971
01972 unsigned char get_lit_thing_prev(const unsigned char stype_idx)
01973 {
01974 unsigned char *arr=(unsigned char *)items_litthings;
01975 int sizeof_arr=sizeof(items_litthings);
01976 int array_count=sizeof_arr/sizeof(unsigned char);
01977
01978 unsigned char *pos=memchr(arr,stype_idx,array_count);
01979 if (pos!=NULL) pos--;
01980 if ((pos<arr)||(pos>=arr+sizeof_arr))
01981 pos=arr+(array_count-1);
01982 return *pos;
01983 }
01984
01985
01986
01987
01988 short is_spinningtng(const unsigned char *thing)
01989 {
01990 if (get_thing_type(thing) == THING_TYPE_ITEM)
01991 return is_spinningtng_stype(get_thing_subtype(thing));
01992 return false;
01993 }
01994
01995 short is_spinningtng_stype(const unsigned char stype_idx)
01996 {
01997 if (get_spinningtng_arridx(stype_idx)<0) return false;
01998 return true;
01999 }
02000
02001 int get_spinningtng_arridx(const unsigned char stype_idx)
02002 {
02003 unsigned char *arr=(unsigned char *)items_spinnthings;
02004 int array_count=get_spinningtng_count();
02005
02006 char *pos=memchr(arr,stype_idx,array_count);
02007 if (pos==NULL) return -1;
02008 return ((long)pos-(long)arr)/sizeof(unsigned char);
02009 }
02010
02011
02012
02013
02014 unsigned char get_spinningtng_arritm(const int arr_itm)
02015 {
02016 unsigned char *arr=(unsigned char *)items_spinnthings;
02017 int array_count=get_spinningtng_count();
02018 if (arr_itm<0)
02019 return arr[0];
02020 if (arr_itm>=array_count)
02021 return arr[array_count-1];
02022 return arr[arr_itm];
02023 }
02024
02025 unsigned int get_spinningtng_count(void)
02026 {
02027 return sizeof(items_spinnthings)/sizeof(unsigned char);
02028 }
02029
02030
02031
02032
02033 unsigned char get_spinningtng_next(const unsigned char stype_idx)
02034 {
02035 unsigned char *arr=(unsigned char *)items_spinnthings;
02036 int sizeof_arr=sizeof(items_spinnthings);
02037 int sizeof_itm=sizeof(unsigned char);
02038 int array_count=sizeof_arr/sizeof_itm;
02039
02040 unsigned char *pos=memchr(arr,stype_idx,array_count);
02041 if (pos!=NULL) pos+=sizeof_itm;
02042 if ((pos<arr)||(pos>=arr+sizeof_arr))
02043 pos=arr;
02044 return *pos;
02045 }
02046
02047
02048
02049
02050 unsigned char get_spinningtng_prev(const unsigned char stype_idx)
02051 {
02052 unsigned char *arr=(unsigned char *)items_spinnthings;
02053 int sizeof_arr=sizeof(items_spinnthings);
02054 int sizeof_itm=sizeof(unsigned char);
02055 int array_count=sizeof_arr/sizeof_itm;
02056
02057 unsigned char *pos=memchr(arr,stype_idx,array_count);
02058 if (pos!=NULL) pos-=sizeof_itm;
02059 if ((pos<arr)||(pos>=arr+sizeof_arr))
02060 pos=arr+(array_count-1)*sizeof_itm;
02061 return *pos;
02062 }
02063
02064
02065
02066
02067 short is_nulltng(const unsigned char *thing)
02068 {
02069 if (get_thing_type(thing) == THING_TYPE_ITEM)
02070 return is_nulltng_stype(get_thing_subtype(thing));
02071 return false;
02072 }
02073
02074 short is_nulltng_stype(const unsigned char stype_idx)
02075 {
02076 if (get_nulltng_arridx(stype_idx)<0) return false;
02077 return true;
02078 }
02079
02080 int get_nulltng_arridx(const unsigned char stype_idx)
02081 {
02082 unsigned char *arr=(unsigned char *)items_nullthings;
02083 int array_count=get_nulltng_count();
02084
02085 char *pos=memchr(arr,stype_idx,array_count);
02086 if (pos==NULL) return -1;
02087 return ((long)pos-(long)arr)/sizeof(unsigned char);
02088 }
02089
02090
02091
02092
02093 unsigned char get_nulltng_arritm(const int arr_itm)
02094 {
02095 unsigned char *arr=(unsigned char *)items_nullthings;
02096 int array_count=get_nulltng_count();
02097 if (arr_itm<0)
02098 return arr[0];
02099 if (arr_itm>=array_count)
02100 return arr[array_count-1];
02101 return arr[arr_itm];
02102 }
02103
02104 unsigned int get_nulltng_count(void)
02105 {
02106 return sizeof(items_nullthings)/sizeof(unsigned char);
02107 }
02108
02109 short is_false_stype(const unsigned char stype_idx)
02110 {
02111 return false;
02112 }
02113
02114
02115
02116
02117 short is_itemeffect(const unsigned char *thing)
02118 {
02119 if (get_thing_type(thing) == THING_TYPE_ITEM)
02120 return is_itemeffect_stype(get_thing_subtype(thing));
02121 return false;
02122 }
02123
02124 short is_itemeffect_stype(const unsigned char stype_idx)
02125 {
02126 if (get_itemeffect_arridx(stype_idx)<0) return false;
02127 return true;
02128 }
02129
02130 int get_itemeffect_arridx(const unsigned char stype_idx)
02131 {
02132 unsigned char *arr=(unsigned char *)items_effcts;
02133 int array_count=get_itemeffect_count();
02134
02135 char *pos=memchr(arr,stype_idx,array_count);
02136 if (pos==NULL) return -1;
02137 return ((long)pos-(long)arr)/sizeof(unsigned char);
02138 }
02139
02140
02141
02142
02143 unsigned char get_itemeffect_arritm(const int arr_itm)
02144 {
02145 unsigned char *arr=(unsigned char *)items_effcts;
02146 int array_count=get_itemeffect_count();
02147 if (arr_itm<0)
02148 return arr[0];
02149 if (arr_itm>=array_count)
02150 return arr[array_count-1];
02151 return arr[arr_itm];
02152 }
02153
02154 unsigned int get_itemeffect_count(void)
02155 {
02156 return sizeof(items_effcts)/sizeof(unsigned char);
02157 }
02158
02159
02160
02161
02162 short is_wrkshopbox(const unsigned char *thing)
02163 {
02164 if (get_thing_type(thing) == THING_TYPE_ITEM)
02165 return is_wrkshopbox_stype(get_thing_subtype(thing));
02166 return false;
02167 }
02168
02169 short is_wrkshopbox_stype(const unsigned char stype_idx)
02170 {
02171 if (get_wrkshopbox_arridx(stype_idx)<0) return false;
02172 return true;
02173 }
02174
02175 int get_wrkshopbox_arridx(const unsigned char stype_idx)
02176 {
02177 unsigned char *arr=(unsigned char *)items_wrkshpbxs;
02178 int array_count=get_wrkshopbox_count();
02179
02180 char *pos=memchr(arr,stype_idx,array_count);
02181 if (pos==NULL) return -1;
02182 return ((long)pos-(long)arr)/sizeof(unsigned char);
02183 }
02184
02185
02186
02187
02188 unsigned char get_wrkshopbox_arritm(const int arr_itm)
02189 {
02190 unsigned char *arr=(unsigned char *)items_wrkshpbxs;
02191 int array_count=get_wrkshopbox_count();
02192 if (arr_itm<0)
02193 return arr[0];
02194 if (arr_itm>=array_count)
02195 return arr[array_count-1];
02196 return arr[arr_itm];
02197 }
02198
02199 unsigned int get_wrkshopbox_count(void)
02200 {
02201 return sizeof(items_wrkshpbxs)/sizeof(unsigned char);
02202 }
02203
02204
02205
02206
02207 short is_torchcndl(const unsigned char *thing)
02208 {
02209 if (get_thing_type(thing) == THING_TYPE_ITEM)
02210 return is_torchcndl_stype(get_thing_subtype(thing));
02211 return false;
02212 }
02213
02214 short is_torchcndl_stype(const unsigned char stype_idx)
02215 {
02216 if (get_torchcndl_arridx(stype_idx)<0) return false;
02217 return true;
02218 }
02219
02220 int get_torchcndl_arridx(const unsigned char stype_idx)
02221 {
02222 unsigned char *arr=(unsigned char *)items_torchcandls;
02223 int array_count=get_torchcndl_count();
02224
02225 char *pos=memchr(arr,stype_idx,array_count);
02226 if (pos==NULL) return -1;
02227 return ((long)pos-(long)arr)/sizeof(unsigned char);
02228 }
02229
02230
02231
02232
02233 unsigned char get_torchcndl_arritm(const int arr_itm)
02234 {
02235 unsigned char *arr=(unsigned char *)items_torchcandls;
02236 int array_count=get_torchcndl_count();
02237 if (arr_itm<0)
02238 return arr[0];
02239 if (arr_itm>=array_count)
02240 return arr[array_count-1];
02241 return arr[arr_itm];
02242 }
02243
02244 unsigned int get_torchcndl_count(void)
02245 {
02246 return sizeof(items_torchcandls)/sizeof(unsigned char);
02247 }
02248
02249
02250
02251
02252 short is_roomequip(const unsigned char *thing)
02253 {
02254 if (get_thing_type(thing) == THING_TYPE_ITEM)
02255 return is_roomequip_stype(get_thing_subtype(thing));
02256 return false;
02257 }
02258
02259 short is_roomequip_stype(const unsigned char stype_idx)
02260 {
02261 if (get_roomequip_arridx(stype_idx)<0) return false;
02262 return true;
02263 }
02264
02265 int get_roomequip_arridx(const unsigned char stype_idx)
02266 {
02267 unsigned char *arr=(unsigned char *)items_roomequip;
02268 int array_count=get_roomequip_count();
02269
02270 char *pos=memchr(arr,stype_idx,array_count);
02271 if (pos==NULL) return -1;
02272 return ((long)pos-(long)arr)/sizeof(unsigned char);
02273 }
02274
02275
02276
02277
02278 unsigned char get_roomequip_arritm(const int arr_itm)
02279 {
02280 unsigned char *arr=(unsigned char *)items_roomequip;
02281 int array_count=get_roomequip_count();
02282 if (arr_itm<0)
02283 return arr[0];
02284 if (arr_itm>=array_count)
02285 return arr[array_count-1];
02286 return arr[arr_itm];
02287 }
02288
02289 unsigned int get_roomequip_count(void)
02290 {
02291 return sizeof(items_roomequip)/sizeof(unsigned char);
02292 }
02293
02294
02295
02296
02297 short is_pwhand(const unsigned char *thing)
02298 {
02299 if (get_thing_type(thing) == THING_TYPE_ITEM)
02300 return is_pwhand_stype(get_thing_subtype(thing));
02301 return false;
02302 }
02303
02304 short is_pwhand_stype(const unsigned char stype_idx)
02305 {
02306 if (get_pwhand_arridx(stype_idx)<0) return false;
02307 return true;
02308 }
02309
02310 int get_pwhand_arridx(const unsigned char stype_idx)
02311 {
02312 unsigned char *arr=(unsigned char *)items_pwhand;
02313 int array_count=get_pwhand_count();
02314
02315 char *pos=memchr(arr,stype_idx,array_count);
02316 if (pos==NULL) return -1;
02317 return ((long)pos-(long)arr)/sizeof(unsigned char);
02318 }
02319
02320
02321
02322
02323 unsigned char get_pwhand_arritm(const int arr_itm)
02324 {
02325 unsigned char *arr=(unsigned char *)items_pwhand;
02326 int array_count=get_pwhand_count();
02327 if (arr_itm<0)
02328 return arr[0];
02329 if (arr_itm>=array_count)
02330 return arr[array_count-1];
02331 return arr[arr_itm];
02332 }
02333
02334 unsigned int get_pwhand_count(void)
02335 {
02336 return sizeof(items_pwhand)/sizeof(unsigned char);
02337 }
02338
02339
02340
02341
02342 short is_dncrucial(const unsigned char *thing)
02343 {
02344 if (get_thing_type(thing) == THING_TYPE_ITEM)
02345 return is_dncrucial_stype(get_thing_subtype(thing));
02346 return false;
02347 }
02348
02349 short is_dncrucial_stype(const unsigned char stype_idx)
02350 {
02351 if (get_dncrucial_arridx(stype_idx)<0) return false;
02352 return true;
02353 }
02354
02355 int get_dncrucial_arridx(const unsigned char stype_idx)
02356 {
02357 unsigned char *arr=(unsigned char *)items_dncrucial;
02358 int array_count=get_dncrucial_count();
02359
02360 char *pos=memchr(arr,stype_idx,array_count);
02361 if (pos==NULL) return -1;
02362 return ((long)pos-(long)arr)/sizeof(unsigned char);
02363 }
02364
02365
02366
02367
02368 unsigned char get_dncrucial_arritm(const int arr_itm)
02369 {
02370 unsigned char *arr=(unsigned char *)items_dncrucial;
02371 int array_count=get_dncrucial_count();
02372 if (arr_itm<0)
02373 return arr[0];
02374 if (arr_itm>=array_count)
02375 return arr[array_count-1];
02376 return arr[arr_itm];
02377 }
02378
02379 unsigned int get_dncrucial_count(void)
02380 {
02381 return sizeof(items_dncrucial)/sizeof(unsigned char);
02382 }
02383
02384
02385
02386
02387 short is_furniture(const unsigned char *thing)
02388 {
02389
02390 if (get_thing_type(thing) != THING_TYPE_ITEM)
02391 return false;
02392 return is_furniture_stype(get_thing_subtype(thing));
02393 }
02394
02395
02396
02397
02398 short is_furniture_stype(const unsigned char stype_idx)
02399 {
02400 if (get_furniture_arridx(stype_idx)<0) return false;
02401 return true;
02402 }
02403
02404 int get_furniture_arridx(const unsigned char stype_idx)
02405 {
02406 unsigned char *arr=(unsigned char *)items_furniture;
02407 int array_count=get_furniture_count();
02408
02409 char *pos=memchr(arr,stype_idx,array_count);
02410 if (pos==NULL) return -1;
02411 return ((long)pos-(long)arr)/sizeof(unsigned char);
02412 }
02413
02414 unsigned char get_furniture_arritm(const int arr_itm)
02415 {
02416 unsigned char *arr=(unsigned char *)items_furniture;
02417 int array_count=get_furniture_count();
02418 if (arr_itm<0)
02419 return arr[0];
02420 if (arr_itm>=array_count)
02421 return arr[array_count-1];
02422 return arr[arr_itm];
02423 }
02424
02425 unsigned int get_furniture_count(void)
02426 {
02427 return sizeof(items_furniture)/sizeof(unsigned char);
02428 }
02429
02430
02431
02432
02433 unsigned char get_furniture_next(const unsigned char stype_idx)
02434 {
02435 int array_count=sizeof(items_furniture)/sizeof(unsigned char);
02436
02437 unsigned char *pos=memchr(items_furniture,stype_idx,array_count);
02438 if (pos!=NULL) pos+=sizeof(unsigned char);
02439 if ((pos<items_furniture)||(pos>=items_furniture+sizeof(items_furniture)))
02440 pos=(unsigned char *)items_furniture;
02441 return *pos;
02442 }
02443
02444
02445
02446
02447 unsigned char get_furniture_prev(const unsigned char stype_idx)
02448 {
02449 int array_count=sizeof(items_furniture)/sizeof(unsigned char);
02450
02451 unsigned char *pos=memchr(items_furniture,stype_idx,array_count);
02452 if (pos!=NULL) pos-=sizeof(unsigned char);
02453 if ((pos<items_furniture)||(pos>=items_furniture+sizeof(items_furniture)))
02454 pos=(unsigned char *)items_furniture+(array_count-1)*sizeof(unsigned char);
02455 return *pos;
02456 }
02457
02458 short is_herogate(const unsigned char *thing)
02459 {
02460 if (get_thing_type(thing)==THING_TYPE_ITEM)
02461 if (get_thing_subtype(thing)==ITEM_SUBTYPE_HEROGATE)
02462 return true;
02463 return false;
02464 }
02465
02466 short is_dnheart(const unsigned char *thing)
02467 {
02468 if (get_thing_type(thing)==THING_TYPE_ITEM)
02469 if (get_thing_subtype(thing)==ITEM_SUBTYPE_DNHEART)
02470 return true;
02471 return false;
02472 }
02473
02474 short is_doorkey(const unsigned char *thing)
02475 {
02476 if (get_thing_type(thing)==THING_TYPE_ITEM)
02477 if (get_thing_subtype(thing)==ITEM_SUBTYPE_SPINNKEY)
02478 return true;
02479 return false;
02480 }
02481
02482 short is_trainpost(const unsigned char *thing)
02483 {
02484 if (get_thing_type(thing)==THING_TYPE_ITEM)
02485 if (get_thing_subtype(thing)==ITEM_SUBTYPE_TRAINPOST)
02486 return true;
02487 return false;
02488 }
02489
02490 short is_room_inventory(const unsigned char *thing)
02491 {
02492 switch (get_thing_type(thing))
02493 {
02494 case THING_TYPE_EFFECTGEN:
02495 switch (get_thing_subtype(thing))
02496 {
02497 case EFCTGEN_SUBTP_ENTRICE:
02498 case EFCTGEN_SUBTP_DRYICE:
02499 return true;
02500 }
02501 return false;
02502 case THING_TYPE_DOOR:
02503 return true;
02504 case THING_TYPE_ITEM:
02505 {
02506 int cat_idx=get_item_category(get_thing_subtype(thing));
02507 if ( (cat_idx==THING_CATEGR_ROOMEQUIP)||(cat_idx==THING_CATEGR_POLEBAR)
02508 ||(cat_idx==THING_CATEGR_TORCHCNDL)||(cat_idx==THING_CATEGR_DNCRUCIAL)
02509 ||(cat_idx==THING_CATEGR_HEARTFLAME) )
02510 return true;
02511
02512 switch (get_thing_subtype(thing))
02513 {
02514 case ITEM_SUBTYPE_SPINNKEY:
02515 case ITEM_SUBTYPE_SPINNKEY2:
02516 case ITEM_SUBTYPE_TEMPLESTA:
02517 case ITEM_SUBTYPE_ANVIL:
02518 return true;
02519 }
02520 };return false;
02521 default:
02522 return false;
02523 }
02524 }
02525
02526
02527
02528
02529
02530 short is_clmaffective_thing(const unsigned char *thing)
02531 {
02532 switch (get_thing_type(thing))
02533 {
02534 case THING_TYPE_DOOR:
02535 return true;
02536 case THING_TYPE_ITEM:
02537 {
02538 int cat_idx=get_item_category(get_thing_subtype(thing));
02539 if ( (cat_idx==THING_CATEGR_ROOMEQUIP)
02540 ||(cat_idx==THING_CATEGR_TORCHCNDL)||(cat_idx==THING_CATEGR_DNCRUCIAL)
02541 ||(cat_idx==THING_CATEGR_HEARTFLAME) )
02542 return true;
02543
02544 switch (get_thing_subtype(thing))
02545 {
02546 case ITEM_SUBTYPE_TEMPLESTA:
02547 case ITEM_SUBTYPE_ANVIL:
02548 return true;
02549 }
02550 };return false;
02551 default:
02552 return false;
02553 }
02554 }
02555
02556
02557
02558
02559 char *get_item_subtype_fullname(const unsigned short stype_idx)
02560 {
02561 switch (stype_idx)
02562 {
02563 case ITEM_SUBTYPE_NULL:
02564 return "Null";
02565 case ITEM_SUBTYPE_BARREL:
02566 return "Barrel";
02567 case ITEM_SUBTYPE_TORCH:
02568 return "Torch";
02569 case ITEM_SUBTYPE_GOLDCHEST:
02570 return "Gold Chest (500)";
02571 case ITEM_SUBTYPE_TEMPLESTA:
02572 return "Temple statue";
02573 case ITEM_SUBTYPE_DNHEART:
02574 return "Dungeon heart";
02575 case ITEM_SUBTYPE_GOLD:
02576 return "Gold Pot (250)";
02577 case ITEM_SUBTYPE_TORCHUN:
02578 return "Unlit torch";
02579 case ITEM_SUBTYPE_STATUEWO:
02580 return "Statue w/o flame";
02581 case ITEM_SUBTYPE_CHICKNGRW:
02582 return "Growing Chicken";
02583 case ITEM_SUBTYPE_CHICKN:
02584 return "Chicken";
02585
02586 case ITEM_SUBTYPE_SPELLHOE:
02587 return "Hand of evil spell";
02588 case ITEM_SUBTYPE_SPELLIMP:
02589 return "Create imp spell";
02590 case ITEM_SUBTYPE_SPELLMUST:
02591 return "Must obey spell";
02592 case ITEM_SUBTYPE_SPELLSLAP:
02593 return "Slap spell";
02594 case ITEM_SUBTYPE_SPELLSOE:
02595 return "Sight of evil spel";
02596 case ITEM_SUBTYPE_SPELLCTA:
02597 return "Call to arms spell";
02598 case ITEM_SUBTYPE_SPELLCAVI:
02599 return "Cave in spell";
02600 case ITEM_SUBTYPE_SPELLHEAL:
02601 return "Heal creature spel";
02602 case ITEM_SUBTYPE_SPELLHLDA:
02603 return "Hold audience spel";
02604 case ITEM_SUBTYPE_SPELLLIGH:
02605 return "Lightning spell";
02606 case ITEM_SUBTYPE_SPELLSPDC:
02607 return "Speed creature spl";
02608 case ITEM_SUBTYPE_SPELLPROT:
02609 return "Protect creatr spl";
02610 case ITEM_SUBTYPE_SPELLCONC:
02611 return "Conceal creatr spl";
02612
02613 case ITEM_SUBTYPE_NULL1:
02614 return "Null1";
02615 case ITEM_SUBTYPE_NULL2:
02616 return "Null2";
02617
02618 case ITEM_SUBTYPE_ANVIL:
02619 return "Anvil";
02620 case ITEM_SUBTYPE_PRISONBAR:
02621 return "Prison bar";
02622 case ITEM_SUBTYPE_CANDLSTCK:
02623 return "Candlestick";
02624 case ITEM_SUBTYPE_GRAVSTONE:
02625 return "Gravestone";
02626 case ITEM_SUBTYPE_STATUHORN:
02627 return "Horny Statue";
02628 case ITEM_SUBTYPE_TRAINPOST:
02629 return "Training post";
02630 case ITEM_SUBTYPE_TORTSPIKE:
02631 return "Torture spike";
02632 case ITEM_SUBTYPE_TEMPLESPN:
02633 return "Temple Spangle";
02634
02635 case ITEM_SUBTYPE_POTION1:
02636 return "Potion1";
02637 case ITEM_SUBTYPE_POTION2:
02638 return "Potion2";
02639 case ITEM_SUBTYPE_POTION3:
02640 return "Potion3";
02641 case ITEM_SUBTYPE_PWHAND:
02642 return "Power hand";
02643 case ITEM_SUBTYPE_PWHANDGRB:
02644 return "Power hand grab";
02645 case ITEM_SUBTYPE_PWHANDWHP:
02646 return "Power hand whip";
02647 case ITEM_SUBTYPE_CHICKNSTB:
02648 return "Chicken stable";
02649 case ITEM_SUBTYPE_CHICKNWOB:
02650 return "Chicken wobble";
02651 case ITEM_SUBTYPE_CHICKNCRK:
02652 return "Chicken crack";
02653 case ITEM_SUBTYPE_GOLDL:
02654 return "Gold (200)";
02655 case ITEM_SUBTYPE_SPINNKEY:
02656 return "Spinning key";
02657
02658 case ITEM_SUBTYPE_SPELLDISE:
02659 return "Disease spell";
02660 case ITEM_SUBTYPE_SPELLCHKN:
02661 return "Chicken spell";
02662 case ITEM_SUBTYPE_SPELLDWAL:
02663 return "Destroy walls spel";
02664 case ITEM_SUBTYPE_SPELLTBMB:
02665 return "Time bomb spell";
02666
02667 case ITEM_SUBTYPE_HEROGATE:
02668 return "Hero gate";
02669 case ITEM_SUBTYPE_SPINNKEY2:
02670 return "Spinning key 2";
02671
02672 case ITEM_SUBTYPE_ARMOUR:
02673 return "Armour";
02674 case ITEM_SUBTYPE_GLDHOARD1:
02675 return "Gold Hoarde 1";
02676 case ITEM_SUBTYPE_GLDHOARD2:
02677 return "Gold Hoarde 2";
02678 case ITEM_SUBTYPE_GLDHOARD3:
02679 return "Gold Hoarde 3";
02680 case ITEM_SUBTYPE_GLDHOARD4:
02681 return "Gold Hoarde 4";
02682 case ITEM_SUBTYPE_GLDHOARD5:
02683 return "Gold Hoarde 5";
02684
02685
02686 case ITEM_SUBTYPE_LAIRWIZRD:
02687 return "Wizard Lair";
02688 case ITEM_SUBTYPE_LAIRBARBR:
02689 return "Barbarian Lair";
02690 case ITEM_SUBTYPE_LAIRARCHR:
02691 return "Archer Lair";
02692 case ITEM_SUBTYPE_LAIRMONK:
02693 return "Monk Lair";
02694 case ITEM_SUBTYPE_LAIRDWRFA:
02695 return "Dwarfa Lair";
02696 case ITEM_SUBTYPE_LAIRKNGHT:
02697 return "Knight Lair";
02698 case ITEM_SUBTYPE_LAIRAVATR:
02699 return "Avatar Lair";
02700 case ITEM_SUBTYPE_LAIRTUNLR:
02701 return "Tunneller Lair";
02702 case ITEM_SUBTYPE_LAIRWITCH:
02703 return "Witch Lair";
02704 case ITEM_SUBTYPE_LAIRGIANT:
02705 return "Giant Lair";
02706 case ITEM_SUBTYPE_LAIRFAIRY:
02707 return "Fairy Lair";
02708 case ITEM_SUBTYPE_LAIRTHEFT:
02709 return "Thief Lair";
02710 case ITEM_SUBTYPE_LAIRSAMUR:
02711 return "Samurai Lair";
02712 case ITEM_SUBTYPE_LAIRHORNY:
02713 return "Horny Lair";
02714 case ITEM_SUBTYPE_LAIRSKELT:
02715 return "Skeleton Lair";
02716 case ITEM_SUBTYPE_LAIRGOBLN:
02717 return "Goblin Lair";
02718 case ITEM_SUBTYPE_LAIRDRAGN:
02719 return "Dragon Lair";
02720 case ITEM_SUBTYPE_LAIRDEMSP:
02721 return "Demonspawn Lair";
02722 case ITEM_SUBTYPE_LAIRFLY:
02723 return "Fly Lair";
02724 case ITEM_SUBTYPE_LAIRDKMIS:
02725 return "Dark Mistress Lair";
02726 case ITEM_SUBTYPE_LAIRSORCR:
02727 return "Sorceror Lair";
02728 case ITEM_SUBTYPE_LAIRBILDM:
02729 return "Bile Demon Lair";
02730 case ITEM_SUBTYPE_LAIRIMP:
02731 return "Imp Lair";
02732 case ITEM_SUBTYPE_LAIRBUG:
02733 return "Bug Lair";
02734 case ITEM_SUBTYPE_LAIRVAMP:
02735 return "Vampire Lair";
02736 case ITEM_SUBTYPE_LAIRSPIDR:
02737 return "Spider Lair";
02738 case ITEM_SUBTYPE_LAIRHLHND:
02739 return "Hell Hound Lair";
02740 case ITEM_SUBTYPE_LAIRGHOST:
02741 return "Ghost Lair";
02742 case ITEM_SUBTYPE_LAIRTENTC:
02743 return "Tentacle Lair";
02744
02745
02746 case ITEM_SUBTYPE_SPREVMAP:
02747 return "Reveal map";
02748 case ITEM_SUBTYPE_SPRESURCT:
02749 return "Resurrect creatre";
02750 case ITEM_SUBTYPE_SPTRANSFR:
02751 return "Transfer creature";
02752 case ITEM_SUBTYPE_SPSTEALHR:
02753 return "Steal hero";
02754 case ITEM_SUBTYPE_SPMULTPLY:
02755 return "Multiply creatres";
02756 case ITEM_SUBTYPE_SPINCLEV:
02757 return "Increase level";
02758 case ITEM_SUBTYPE_SPMKSAFE:
02759 return "Make safe";
02760 case ITEM_SUBTYPE_SPHIDNWRL:
02761 return "Reveal hiddn world";
02762
02763 case ITEM_SUBTYPE_TBBOULDER:
02764 return "Boulder trap box";
02765 case ITEM_SUBTYPE_TBALARM:
02766 return "Alarm trap box";
02767 case ITEM_SUBTYPE_TBPOISONG:
02768 return "Poison gas trapbx";
02769 case ITEM_SUBTYPE_TBLIGHTNG:
02770 return "Lightning trap bx";
02771 case ITEM_SUBTYPE_TBWRDOFPW:
02772 return "Word of Pwr trpbx";
02773 case ITEM_SUBTYPE_TBLAVA:
02774 return "Lava trap box";
02775 case ITEM_SUBTYPE_TBDUMMY2:
02776 return "Trap Dummy 2";
02777 case ITEM_SUBTYPE_TBDUMMY3:
02778 return "Trap Dummy 3";
02779 case ITEM_SUBTYPE_TBDUMMY4:
02780 return "Trap Dummy 4";
02781 case ITEM_SUBTYPE_TBDUMMY5:
02782 return "Trap Dummy 5";
02783 case ITEM_SUBTYPE_TBDUMMY6:
02784 return "Trap Dummy 6";
02785 case ITEM_SUBTYPE_TBDUMMY7:
02786 return "Trap Dummy 7";
02787
02788
02789 case ITEM_SUBTYPE_DBWOOD:
02790 return "Door Wood box";
02791 case ITEM_SUBTYPE_DBBRACE:
02792 return "Door Brace box";
02793 case ITEM_SUBTYPE_DBSTEEL:
02794 return "Door Steel box";
02795 case ITEM_SUBTYPE_DBMAGIC:
02796 return "Door Magic box";
02797 case ITEM_SUBTYPE_WBITEM:
02798 return "Workshop Item";
02799
02800 case ITEM_SUBTYPE_HEARTFLMR:
02801 return "Heart flame(red)";
02802 case ITEM_SUBTYPE_DISEASE:
02803 return "Disease";
02804 case ITEM_SUBTYPE_SCAVNGEYE:
02805 return "Scavenger eye";
02806 case ITEM_SUBTYPE_WRKSHPMCH:
02807 return "Workshop machine";
02808 case ITEM_SUBTYPE_GURDFLAGR:
02809 return "Guard Flag(red)";
02810 case ITEM_SUBTYPE_GURDFLAGB:
02811 return "Guard Flag(blue)";
02812 case ITEM_SUBTYPE_GURDFLAGG:
02813 return "Guard Flag(green)";
02814 case ITEM_SUBTYPE_GURDFLAGY:
02815 return "Guard Flag(yellow)";
02816 case ITEM_SUBTYPE_FLAGPOST:
02817 return "Flagpost";
02818 case ITEM_SUBTYPE_HEARTFLMB:
02819 return "Heart flame(blue)";
02820 case ITEM_SUBTYPE_HEARTFLMG:
02821 return "Heart flame(green)";
02822 case ITEM_SUBTYPE_HEARTFLMY:
02823 return "Heart flame(yellw)";
02824
02825
02826 case ITEM_SUBTYPE_PWSIGHT:
02827 return "Power Sight";
02828 case ITEM_SUBTYPE_PWLIGHTNG:
02829 return "Power Lightning";
02830
02831 case ITEM_SUBTYPE_TORTURER:
02832 return "Torturer";
02833 case ITEM_SUBTYPE_LAIRORC:
02834 return "Orc Lair";
02835 case ITEM_SUBTYPE_PWHANDGLD:
02836 return "Power Hand Gold";
02837 case ITEM_SUBTYPE_SPINNCOIN:
02838 return "Spinning Coin";
02839
02840 case ITEM_SUBTYPE_STATUE2:
02841 return "Statue 2";
02842 case ITEM_SUBTYPE_STATUE3:
02843 return "Statue 3";
02844 case ITEM_SUBTYPE_STATUE4:
02845 return "Statue 4";
02846 case ITEM_SUBTYPE_STATUE5:
02847 return "Statue 5";
02848 case ITEM_SUBTYPE_STATUE6:
02849 return "Statue 6";
02850 case ITEM_SUBTYPE_SPELLARMG:
02851 return "Armageddon Spell";
02852 default:
02853 return "Unknown";
02854 }
02855 }
02856
02857
02858
02859
02860 char *get_item_subtype_shortname(const unsigned short stype_idx)
02861 {
02862 switch (stype_idx)
02863 {
02864 case ITEM_SUBTYPE_NULL:
02865 case ITEM_SUBTYPE_NULL1:
02866 case ITEM_SUBTYPE_NULL2:
02867 return "Null";
02868 case ITEM_SUBTYPE_BARREL:
02869 return "Barrl";
02870 case ITEM_SUBTYPE_TORCH:
02871 case ITEM_SUBTYPE_TORCHUN:
02872 return "Torch";
02873 case ITEM_SUBTYPE_GOLDCHEST:
02874 return "GldCh";
02875 case ITEM_SUBTYPE_TEMPLESTA:
02876 case ITEM_SUBTYPE_STATUEWO:
02877 case ITEM_SUBTYPE_STATUHORN:
02878 case ITEM_SUBTYPE_STATUE2:
02879 case ITEM_SUBTYPE_STATUE3:
02880 case ITEM_SUBTYPE_STATUE4:
02881 case ITEM_SUBTYPE_STATUE5:
02882 case ITEM_SUBTYPE_STATUE6:
02883 return "Statu";
02884 case ITEM_SUBTYPE_DNHEART:
02885 return "Heart";
02886 case ITEM_SUBTYPE_GOLD:
02887 case ITEM_SUBTYPE_GOLDL:
02888 return "Gold";
02889 case ITEM_SUBTYPE_CHICKNGRW:
02890 case ITEM_SUBTYPE_CHICKN:
02891 case ITEM_SUBTYPE_CHICKNSTB:
02892 case ITEM_SUBTYPE_CHICKNWOB:
02893 case ITEM_SUBTYPE_CHICKNCRK:
02894 return "Food";
02895
02896 case ITEM_SUBTYPE_SPELLHOE:
02897 case ITEM_SUBTYPE_SPELLIMP:
02898 case ITEM_SUBTYPE_SPELLMUST:
02899 case ITEM_SUBTYPE_SPELLSLAP:
02900 case ITEM_SUBTYPE_SPELLSOE:
02901 case ITEM_SUBTYPE_SPELLCTA:
02902 case ITEM_SUBTYPE_SPELLCAVI:
02903 case ITEM_SUBTYPE_SPELLHEAL:
02904 case ITEM_SUBTYPE_SPELLHLDA:
02905 case ITEM_SUBTYPE_SPELLLIGH:
02906 case ITEM_SUBTYPE_SPELLSPDC:
02907 case ITEM_SUBTYPE_SPELLPROT:
02908 case ITEM_SUBTYPE_SPELLCONC:
02909 case ITEM_SUBTYPE_SPELLDISE:
02910 case ITEM_SUBTYPE_SPELLCHKN:
02911 case ITEM_SUBTYPE_SPELLDWAL:
02912 case ITEM_SUBTYPE_SPELLTBMB:
02913 case ITEM_SUBTYPE_SPELLARMG:
02914 return "Spell";
02915
02916 case ITEM_SUBTYPE_ANVIL:
02917 return "Anvil";
02918 case ITEM_SUBTYPE_PRISONBAR:
02919 return "PrBar";
02920 case ITEM_SUBTYPE_CANDLSTCK:
02921 return "Candl";
02922 case ITEM_SUBTYPE_GRAVSTONE:
02923 return "Grave";
02924 case ITEM_SUBTYPE_TRAINPOST:
02925 return "Trinr";
02926 case ITEM_SUBTYPE_TORTSPIKE:
02927 return "Spike";
02928 case ITEM_SUBTYPE_TEMPLESPN:
02929 return "Spngl";
02930
02931 case ITEM_SUBTYPE_POTION1:
02932 case ITEM_SUBTYPE_POTION2:
02933 case ITEM_SUBTYPE_POTION3:
02934 return "Potin";
02935 case ITEM_SUBTYPE_PWHAND:
02936 case ITEM_SUBTYPE_PWHANDGRB:
02937 case ITEM_SUBTYPE_PWHANDWHP:
02938 case ITEM_SUBTYPE_PWHANDGLD:
02939 return "PHand";
02940 case ITEM_SUBTYPE_SPINNKEY:
02941 case ITEM_SUBTYPE_SPINNKEY2:
02942 return "SpKey";
02943
02944 case ITEM_SUBTYPE_HEROGATE:
02945 return "HGate";
02946
02947 case ITEM_SUBTYPE_ARMOUR:
02948 return "Armor";
02949 case ITEM_SUBTYPE_GLDHOARD1:
02950 case ITEM_SUBTYPE_GLDHOARD2:
02951 case ITEM_SUBTYPE_GLDHOARD3:
02952 case ITEM_SUBTYPE_GLDHOARD4:
02953 case ITEM_SUBTYPE_GLDHOARD5:
02954 return "GldHr";
02955
02956 case ITEM_SUBTYPE_LAIRWIZRD:
02957 case ITEM_SUBTYPE_LAIRBARBR:
02958 case ITEM_SUBTYPE_LAIRARCHR:
02959 case ITEM_SUBTYPE_LAIRMONK:
02960 case ITEM_SUBTYPE_LAIRDWRFA:
02961 case ITEM_SUBTYPE_LAIRKNGHT:
02962 case ITEM_SUBTYPE_LAIRAVATR:
02963 case ITEM_SUBTYPE_LAIRTUNLR:
02964 case ITEM_SUBTYPE_LAIRWITCH:
02965 case ITEM_SUBTYPE_LAIRGIANT:
02966 case ITEM_SUBTYPE_LAIRFAIRY:
02967 case ITEM_SUBTYPE_LAIRTHEFT:
02968 case ITEM_SUBTYPE_LAIRSAMUR:
02969 case ITEM_SUBTYPE_LAIRHORNY:
02970 case ITEM_SUBTYPE_LAIRSKELT:
02971 case ITEM_SUBTYPE_LAIRGOBLN:
02972 case ITEM_SUBTYPE_LAIRDRAGN:
02973 case ITEM_SUBTYPE_LAIRDEMSP:
02974 case ITEM_SUBTYPE_LAIRFLY:
02975 case ITEM_SUBTYPE_LAIRDKMIS:
02976 case ITEM_SUBTYPE_LAIRSORCR:
02977 case ITEM_SUBTYPE_LAIRBILDM:
02978 case ITEM_SUBTYPE_LAIRIMP:
02979 case ITEM_SUBTYPE_LAIRBUG:
02980 case ITEM_SUBTYPE_LAIRVAMP:
02981 case ITEM_SUBTYPE_LAIRSPIDR:
02982 case ITEM_SUBTYPE_LAIRHLHND:
02983 case ITEM_SUBTYPE_LAIRGHOST:
02984 case ITEM_SUBTYPE_LAIRTENTC:
02985 case ITEM_SUBTYPE_LAIRORC:
02986 return "Lair";
02987
02988 case ITEM_SUBTYPE_SPREVMAP:
02989 case ITEM_SUBTYPE_SPRESURCT:
02990 case ITEM_SUBTYPE_SPTRANSFR:
02991 case ITEM_SUBTYPE_SPSTEALHR:
02992 case ITEM_SUBTYPE_SPMULTPLY:
02993 case ITEM_SUBTYPE_SPINCLEV:
02994 case ITEM_SUBTYPE_SPMKSAFE:
02995 case ITEM_SUBTYPE_SPHIDNWRL:
02996 return "SpcBx";
02997
02998 case ITEM_SUBTYPE_TBBOULDER:
02999 case ITEM_SUBTYPE_TBALARM:
03000 case ITEM_SUBTYPE_TBPOISONG:
03001 case ITEM_SUBTYPE_TBLIGHTNG:
03002 case ITEM_SUBTYPE_TBWRDOFPW:
03003 case ITEM_SUBTYPE_TBLAVA:
03004 case ITEM_SUBTYPE_TBDUMMY2:
03005 case ITEM_SUBTYPE_TBDUMMY3:
03006 case ITEM_SUBTYPE_TBDUMMY4:
03007 case ITEM_SUBTYPE_TBDUMMY5:
03008 case ITEM_SUBTYPE_TBDUMMY6:
03009 case ITEM_SUBTYPE_TBDUMMY7:
03010 return "TrpBx";
03011
03012 case ITEM_SUBTYPE_DBWOOD:
03013 case ITEM_SUBTYPE_DBBRACE:
03014 case ITEM_SUBTYPE_DBSTEEL:
03015 case ITEM_SUBTYPE_DBMAGIC:
03016 return "DorBx";
03017 case ITEM_SUBTYPE_WBITEM:
03018 return "WshBx";
03019
03020 case ITEM_SUBTYPE_HEARTFLMR:
03021 case ITEM_SUBTYPE_HEARTFLMB:
03022 case ITEM_SUBTYPE_HEARTFLMG:
03023 case ITEM_SUBTYPE_HEARTFLMY:
03024 return "Flame";
03025 case ITEM_SUBTYPE_DISEASE:
03026 return "Dises";
03027 case ITEM_SUBTYPE_SCAVNGEYE:
03028 return "ScEye";
03029 case ITEM_SUBTYPE_WRKSHPMCH:
03030 return "Machn";
03031 case ITEM_SUBTYPE_GURDFLAGR:
03032 case ITEM_SUBTYPE_GURDFLAGB:
03033 case ITEM_SUBTYPE_GURDFLAGG:
03034 case ITEM_SUBTYPE_GURDFLAGY:
03035 return "Flag";
03036 case ITEM_SUBTYPE_FLAGPOST:
03037 return "FlagP";
03038 case ITEM_SUBTYPE_PWSIGHT:
03039 return "PwSig";
03040 case ITEM_SUBTYPE_PWLIGHTNG:
03041 return "PwLgh";
03042 case ITEM_SUBTYPE_TORTURER:
03043 return "Tortr";
03044 case ITEM_SUBTYPE_SPINNCOIN:
03045 return "Coin";
03046 default:
03047 return "thing";
03048 }
03049 }
03050
03051
03052
03053
03054
03055 int get_item_category(unsigned char stype_idx)
03056 {
03057 int func_count=sizeof(item_subtype_tests)/sizeof(is_item_subtype);
03058 int i;
03059 for (i=0;i<func_count;i++)
03060 {
03061 if (item_subtype_tests[i](stype_idx))
03062 return i;
03063 }
03064 return THING_CATEGR_UNKNOWN;
03065 }
03066
03067
03068
03069
03070 char *get_creature_subtype_fullname(const unsigned short stype_idx)
03071 {
03072 int types_count=sizeof(creature_fullnames)/sizeof(char *);
03073 if (stype_idx<types_count)
03074 return (char *)creature_fullnames[stype_idx];
03075 else
03076 return "unknown(?!)";
03077 }
03078
03079
03080
03081
03082 char *get_creature_subtype_shortname(const unsigned short stype_idx)
03083 {
03084 int types_count=sizeof(creature_names)/sizeof(char *);
03085 if (stype_idx<types_count)
03086 return (char *)creature_names[stype_idx];
03087 else
03088 return "unknw";
03089 }
03090
03091
03092
03093
03094 char *get_trap_subtype_fullname(const unsigned short stype_idx)
03095 {
03096 int types_count=sizeof(traps)/sizeof(char *);
03097 if (stype_idx<types_count)
03098 return (char *)traps[stype_idx];
03099 else
03100 return "unknown(?!)";
03101 }
03102
03103
03104
03105
03106 char *get_door_subtype_fullname(const unsigned short stype_idx)
03107 {
03108 int types_count=sizeof(doors)/sizeof(char *);
03109 if (stype_idx<types_count)
03110 return (char *)doors[stype_idx];
03111 else
03112 return "unknown(?!)";
03113 }
03114
03115
03116
03117
03118 char *get_thing_category_fullname(const unsigned short arr_idx)
03119 {
03120 int types_count=sizeof(thing_subtype_fullnames)/sizeof(char *);
03121 if (arr_idx<types_count)
03122 return (char *)thing_subtype_fullnames[arr_idx];
03123 else
03124 return "unknown(?!)";
03125 }
03126
03127
03128
03129
03130 char *get_thing_category_shortname(const unsigned short arr_idx)
03131 {
03132 int types_count=sizeof(thing_subtype_shortnames)/sizeof(char *);
03133 if (arr_idx<types_count)
03134 return (char *)thing_subtype_shortnames[arr_idx];
03135 else
03136 return "unknwn(?)";
03137 }
03138
03139
03140
03141
03142 char *get_effectgen_subtype_fullname(const unsigned short stype_idx)
03143 {
03144 int types_count=sizeof(effectgenrts)/sizeof(char *);
03145 if (stype_idx<types_count)
03146 return (char *)effectgenrts[stype_idx];
03147 else
03148 return "unknown(?!)";
03149 }
03150
03151 short item_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03152 {
03153 unsigned char stype_idx=get_thing_subtype(thing);
03154 switch (get_item_category(stype_idx))
03155 {
03156 case THING_CATEGR_EFFCTGEN:
03157 case THING_CATEGR_ITEMEFFCT:
03158 case THING_CATEGR_CREATR:
03159 case THING_CATEGR_CREATLAIR:
03160 case THING_CATEGR_TRAP:
03161 case THING_CATEGR_DOOR:
03162 case THING_CATEGR_SPECIALBOX:
03163 case THING_CATEGR_SPELLBOOK:
03164 case THING_CATEGR_WRKSHOPBOX:
03165 case THING_CATEGR_SPINNTNG:
03166 case THING_CATEGR_FOOD:
03167 case THING_CATEGR_GOLD:
03168 case THING_CATEGR_TORCHCNDL:
03169 case THING_CATEGR_HEARTFLAME:
03170 case THING_CATEGR_POLEBAR:
03171 case THING_CATEGR_STATUE:
03172 case THING_CATEGR_FURNITURE:
03173 case THING_CATEGR_ROOMEQUIP:
03174 case THING_CATEGR_PWHAND:
03175 case THING_CATEGR_DNCRUCIAL:
03176 break;
03177 case THING_CATEGR_NULL:
03178 sprintf(verif_opt->err_msg,"Null item subtype (%d)",(int)stype_idx);
03179 return VERIF_WARN;
03180 case THING_CATEGR_UNKNOWN:
03181 default:
03182 sprintf(verif_opt->err_msg,"Unknown item subtype (%d)",(int)stype_idx);
03183 return VERIF_WARN;
03184 }
03185 int sen_tl;
03186 sen_tl=get_thing_sensitile(thing);
03187 int sx,sy;
03188 sx=get_thing_subtile_x(thing);
03189 sy=get_thing_subtile_y(thing);
03190 int tx,ty;
03191 tx=sx/MAP_SUBNUM_X;
03192 ty=sy/MAP_SUBNUM_Y;
03193 if (sen_tl!=THING_SENSITILE_NONE)
03194 {
03195
03196
03197 int sen_tlx,sen_tly;
03198 sen_tlx=sen_tl%verif_opt->tlsize.x;
03199 sen_tly=sen_tl/verif_opt->tlsize.x;
03200 if (((tx<sen_tlx-1)||(tx>sen_tlx+1)||
03201 (ty<sen_tly-1)||(ty>sen_tly+1)) &&
03202 (stype_idx!=ITEM_SUBTYPE_SPINNKEY))
03203 {
03204 sprintf(verif_opt->err_msg,"Item has wrong sensitive tile number");
03205 return VERIF_WARN;
03206 }
03207 }
03208 return VERIF_OK;
03209 }
03210
03211 short creature_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03212 {
03213 unsigned char stype_idx=get_thing_subtype(thing);
03214 if ((stype_idx>CREATR_SUBTP_FLOAT)||(stype_idx<CREATR_SUBTP_WIZRD))
03215 {
03216 sprintf(verif_opt->err_msg,"Unknown creature subtype (%d)",(int)stype_idx);
03217 return VERIF_WARN;
03218 }
03219 return VERIF_OK;
03220 }
03221
03222 short effectgen_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03223 {
03224 unsigned char stype_idx=get_thing_subtype(thing);
03225 if ((stype_idx>EFCTGEN_SUBTP_DRYICE)||(stype_idx<EFCTGEN_SUBTP_LAVA))
03226 {
03227 sprintf(verif_opt->err_msg,"Unknown effect generator subtype (%d)",(int)stype_idx);
03228 return VERIF_WARN;
03229 }
03230 int sen_tl;
03231 sen_tl=get_thing_sensitile(thing);
03232 int sx,sy;
03233 sx=get_thing_subtile_x(thing);
03234 sy=get_thing_subtile_y(thing);
03235 int tx,ty;
03236 tx=sx/MAP_SUBNUM_X;
03237 ty=sy/MAP_SUBNUM_Y;
03238 if (sen_tl!=THING_SENSITILE_NONE)
03239 {
03240
03241
03242 int sen_tlx,sen_tly;
03243 sen_tlx=sen_tl%verif_opt->tlsize.x;
03244 sen_tly=sen_tl/verif_opt->tlsize.x;
03245 if (((tx<sen_tlx-1)||(tx>sen_tlx+1)||
03246 (ty<sen_tly-1)||(ty>sen_tly+1)) &&
03247 (stype_idx!=EFCTGEN_SUBTP_ENTRICE))
03248 {
03249 sprintf(verif_opt->err_msg,"Effect generator has wrong sensitive tile number");
03250 return VERIF_WARN;
03251 }
03252 }
03253 int range_stl;
03254 range_stl=get_thing_range_subtile(thing);
03255 if (range_stl>MAP_SIZE_DKSTD_X)
03256 {
03257 sprintf(verif_opt->err_msg,"Effect generator range exceeds %d subtiles",MAP_SIZE_DKSTD_X);
03258 return VERIF_WARN;
03259 }
03260 return VERIF_OK;
03261 }
03262
03263 short door_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03264 {
03265 unsigned char stype_idx=get_thing_subtype(thing);
03266 if ((stype_idx>DOOR_SUBTYPE_MAGIC)||(stype_idx<DOOR_SUBTYPE_WOOD))
03267 {
03268 sprintf(verif_opt->err_msg,"Unknown door subtype (%d)",(int)stype_idx);
03269 return VERIF_WARN;
03270 }
03271 return VERIF_OK;
03272 }
03273
03274 short trap_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03275 {
03276 unsigned char stype_idx=get_thing_subtype(thing);
03277 if ((stype_idx>TRAP_SUBTYPE_LAVA)||(stype_idx<TRAP_SUBTYPE_BOULDER))
03278 {
03279 sprintf(verif_opt->err_msg,"Unknown trap subtype (%d)",(int)stype_idx);
03280 return VERIF_WARN;
03281 }
03282 return VERIF_OK;
03283 }
03284
03285 short thing_verify(unsigned char *thing, struct VERIFY_OPTIONS *verif_opt)
03286 {
03287 short result;
03288 int pos_h=get_thing_subtile_h(thing);
03289 int pos_x=get_thing_subtile_x(thing);
03290 int pos_y=get_thing_subtile_y(thing);
03291 if ((pos_h>=MAP_SUBNUM_H) || (pos_x>=verif_opt->tlsize.x*MAP_SUBNUM_X) ||
03292 (pos_y>=verif_opt->tlsize.y*MAP_SUBNUM_Y))
03293 {
03294 sprintf(verif_opt->err_msg,"Thing position (%d,%d,%d) invalid",pos_x,pos_y,pos_h);
03295 return VERIF_WARN;
03296 }
03297 switch(get_thing_type(thing))
03298 {
03299 case THING_TYPE_ITEM:
03300 return item_verify(thing, verif_opt);
03301 case THING_TYPE_CREATURE:
03302 return creature_verify(thing, verif_opt);
03303 case THING_TYPE_EFFECTGEN:
03304 return effectgen_verify(thing, verif_opt);
03305 case THING_TYPE_TRAP:
03306 return trap_verify(thing, verif_opt);
03307 case THING_TYPE_DOOR:
03308 return door_verify(thing, verif_opt);
03309 default:
03310 sprintf(verif_opt->err_msg,"Unknown thing type (%d)",(int)get_thing_type(thing));
03311 return VERIF_WARN;
03312 }
03313 }
03314
03315
03316
03317
03318
03319 short subtl_in_thing_range(const unsigned char *thing,unsigned int sx,unsigned int sy)
03320 {
03321 if (thing==NULL) return false;
03322 float pos_x=(float)get_thing_subtile_x(thing);
03323 float pos_y=(float)get_thing_subtile_y(thing);
03324 unsigned int rng=get_thing_range_adv(thing);
03325 float distance=sqrt(pow(pos_x-(float)sx,2)+pow(pos_y-(float)sy,2))*256.0;
03326 if (distance<=rng) return true;
03327 return false;
03328 }