123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297 |
- /* Catacomb Armageddon Source Code
- * Copyright (C) 1993-2014 Flat Rock Software
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- // C3_WIZ.C
- #include "DEF.H"
- #include "gelib.h"
- #pragma hdrstop
- /*
- =============================================================================
- LOCAL CONSTANTS
- =============================================================================
- */
- ////////#define NUMSCROLLS 8
- #define SHOWITEMS 9
- #define NUKETIME 40
- #define NUMBOLTS 10
- #define BOLTTICS 6
- #define STATUSCOLOR 8
- #define TEXTCOLOR 14
- #define SIDEBARWIDTH 5
- #define BODYLINE 8
- #define POWERLINE 80
- #define SPECTILESTART 0 // 18
- #define SHOTDAMAGE 1
- #define BIGSHOTDAMAGE 3
- #define PLAYERSPEED 5120
- #define RUNSPEED (8192<<1)
- #define SHOTSPEED 10000
- //#define LASTWALLTILE 47
- //#define LASTSPECIALTILE 37
- #define LASTTILE (LASTWALLPIC-FIRSTWALLPIC) // 47
- #define FIRETIME 2
- #define HANDPAUSE 60
- #define RIGHTEDGE 205;
- #define LEFTEDGE 95;
- #define PRNY 32;
- #define WINX 10;
- #define WINY 32;
- /*
- =============================================================================
- GLOBAL VARIABLES
- =============================================================================
- */
- long lastnuke,lasthand;
- int lasttext;
- int handheight;
- int boltsleft,bolttimer;
- short RadarXY[MAX_RADAR_BLIPS][3]={-1,-1,-1};
- short radarx=RADARX,radary=RADARY,radar_xcenter=RADAR_XCENTER,radar_ycenter=RADAR_YCENTER;
- int key_x[4]={24,27,27,24},key_y[4]={30,57,30,57};
- boolean redraw_gems,button0down;
- /*
- =============================================================================
- LOCAL VARIABLES
- =============================================================================
- */
- int lastradar;
- unsigned lastfiretime;
- int strafeangle[9] = {0,90,180,270,45,135,225,315,0};
- short RotateAngle = -1; // -1 == No Angle to turn to...
- short FreezeTime = 0; // Stops all think (except player)
- short RotateSpeed; // Speed (and dir) to rotate..
- //===========================================================================
- void CalcBounds(objtype *ob);
- boolean VerifyGateExit(void);
- void DrawNSEWIcons(void);
- void DrawGems(void);
- void DrawRadar (void);
- void DrawChar (unsigned x, unsigned y, unsigned tile);
- void RedrawStatusWindow (void);
- void GiveBolt (void);
- void TakeBolt (void);
- void GiveNuke (void);
- void TakeNuke (void);
- void GivePotion (void);
- void TakePotion (void);
- void GiveKey (int keytype);
- void TakeKey (int keytype);
- ////////////void GiveScroll (int scrolltype,boolean show);
- ////////////void ReadScroll (int scroll);
- ////////////void DrawScrolls(void);
- void DrawNum(short x,short y,short value,short maxdigits);
- //----------
- void Shoot (void);
- void BigShoot (void);
- void CastBolt (void);
- void CastNuke (void);
- void DrinkPotion (void);
- //----------
- void DrawHealth(void);
- void SpawnPlayer (int tilex, int tiley, int dir);
- void Thrust (int angle, unsigned speed);
- void T_Player (objtype *ob);
- //void AddPoints (int points);
- void ClipMove (objtype *ob, long xmove, long ymove);
- boolean ShotClipMove (objtype *ob, long xmove, long ymove);
- //===========================================================================
- /*
- ===============
- =
- = DrawChar
- =
- ===============
- */
- void DrawChar (unsigned x, unsigned y, unsigned tile)
- {
- unsigned junk = latchpics[0];
- EGAWRITEMODE(1);
- asm mov bx,[y]
- asm shl bx,1
- asm mov di,[WORD PTR ylookup+bx]
- asm add di,[x]
- asm mov si,[tile]
- asm shl si,1
- asm shl si,1
- asm shl si,1
- asm add si,[junk] // the damn inline assembler won't reference latchpics
- asm mov ax,[screenseg]
- asm mov es,ax
- asm mov ds,ax
- asm mov dx,SCREENWIDTH-1
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm add di,dx
- asm movsb
- asm mov ax,ss
- asm mov ds,ax
- EGAWRITEMODE(0);
- }
- //===========================================================================
- /*
- ===============
- =
- = RedrawStatusWindow
- =
- ===============
- */
- void RedrawStatusWindow (void)
- {
- short keytype;
- EGABITMASK(0xff);
- for (keytype=0; keytype<4; keytype++)
- DrawNum(key_x[keytype],key_y[keytype],gamestate.keys[keytype],2);
- DrawNum(20,54,gamestate.potions,2);
- DrawNum(20,36,gamestate.nukes,2);
- DrawNum(20,18,gamestate.bolts,2);
- DrawHealth();
- DrawRadar();
- EGAWRITEMODE(0);
- DrawGems();
- //////// DrawScrolls();
- redraw_gems = false;
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveBolt
- =
- ===============
- */
- void GiveBolt (void)
- {
- if (gamestate.bolts == 99)
- return;
- SD_PlaySound (GETBOLTSND);
- DrawNum(20,18,++gamestate.bolts,2);
- }
- /*
- ===============
- =
- = TakeBolt
- =
- ===============
- */
- void TakeBolt (void)
- {
- SD_PlaySound (USEBOLTSND);
- DrawNum(20,18,--gamestate.bolts,2);
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveNuke
- =
- ===============
- */
- void GiveNuke (void)
- {
- if (gamestate.nukes == 99)
- return;
- SD_PlaySound (GETNUKESND);
- DrawNum(20,36,++gamestate.nukes,2);
- }
- /*
- ===============
- =
- = TakeNuke
- =
- ===============
- */
- void TakeNuke (void)
- {
- SD_PlaySound (USENUKESND);
- DrawNum(20,36,--gamestate.nukes,2);
- }
- //===========================================================================
- /*
- ===============
- =
- = GivePotion
- =
- ===============
- */
- void GivePotion (void)
- {
- if (gamestate.potions == 99)
- return;
- SD_PlaySound (GETPOTIONSND);
- DrawNum(20,54,++gamestate.potions,2);
- }
- /*
- ===============
- =
- = TakePotion
- =
- ===============
- */
- void TakePotion (void)
- {
- SD_PlaySound (USEPOTIONSND);
- DrawNum(20,54,--gamestate.potions,2);
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveKey
- =
- ===============
- */
- void GiveKey (int keytype)
- {
- int i,j,x;
- if (gamestate.keys[keytype] == 99)
- return;
- SD_PlaySound (GETKEYSND);
- DrawNum(key_x[keytype],key_y[keytype],++gamestate.keys[keytype],2);
- }
- /*
- ===============
- =
- = TakeKey
- =
- ===============
- */
- void TakeKey (int keytype)
- {
- int i,j,x;
- char *key_colors[] = {"a RED key",
- "a YELLOW key",
- "a GREEN key",
- "a BLUE key"};
- SD_PlaySound (USEKEYSND);
- DrawNum(key_x[keytype],key_y[keytype],--gamestate.keys[keytype],2);
- displayofs = bufferofs = screenloc[screenpage];
- CenterWindow(20,5);
- US_CPrint("\nYou use\n");
- US_CPrint(key_colors[keytype]);
- VW_UpdateScreen();
- VW_WaitVBL(120);
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveGem
- =
- ===============
- */
- void GiveGem (int gemtype)
- {
- #if 0
- int i,j,x;
- SD_PlaySound (GETKEYSND);
- DrawNum(key_x[keytype],key_y[keytype],++gamestate.keys[keytype],2);
- #endif
- }
- /*
- ===============
- =
- = TakeGem
- =
- ===============
- */
- void TakeGem (int gemtype)
- {
- #if 0
- int i,j,x;
- SD_PlaySound (USEKEYSND);
- DrawNum(key_x[keytype],key_y[keytype],--gamestate.keys[keytype],2);
- #endif
- }
- /*
- ===============
- =
- = DrawGem
- =
- ===============
- */
- void DrawGems()
- {
- short loop;
- redraw_gems = false;
- bufferofs = 0;
- LatchDrawPic (31,51,RADAR_BOTTOMPIC);
- for (loop=0; loop<5; loop++)
- if (gamestate.gems[loop])
- LatchDrawPic (32+loop,53,RADAR_RGEMPIC+loop);
- }
- //===========================================================================
- #if 0
- /*
- ===============
- =
- = GiveScroll
- =
- ===============
- */
- void GiveScroll (int scrolltype,boolean show)
- {
- int i,j,x,y,scrollnum;
- SD_PlaySound (GETSCROLLSND);
- gamestate.scrolls[scrolltype] = true;
- y = 30 + ((scrolltype > 3) * 10);
- x = 26 + (scrolltype % 4);
- DrawChar(x,y,SCROLLCHARS+scrolltype);
- if (show)
- ReadScroll(scrolltype);
- }
- /*
- ===============
- =
- = DrawScrolls
- =
- = Force draw of all scrolls
- =
- ===============
- */
- void DrawScrolls()
- {
- int loop,x,y;
- VW_Bar(210,30,30,18,0xf);
- for (loop=0;loop<8;loop++)
- if (gamestate.scrolls[loop])
- {
- y = 30 + ((loop > 3) * 10);
- x = 26 + (loop % 4);
- DrawChar(x,y,SCROLLCHARS+loop);
- }
- }
- #endif
- //===========================================================================
- #if 0
- /*
- ===============
- =
- = GivePoints
- =
- ===============
- */
- void GivePoints (int points)
- {
- pointcount = 1;
- pointsleft += points;
- }
- #endif
- //===========================================================================
- #if 0
- /*
- ===============
- =
- = AddPoints
- =
- ===============
- */
- void AddPoints (int points)
- {
- char str[10];
- int len,x,i;
- gamestate.score += points;
- ltoa (gamestate.score,str,10);
- len = strlen (str);
- x=24+(8-len);
- for (i=0;i<len;i++)
- DrawChar(x++,40,NUMBERCHARS+str[i]-'0');
- }
- #endif
- //===========================================================================
- /*
- ===============
- =
- = DrawHealth
- =
- ===============
- */
- void DrawHealth()
- {
- char picnum;
- int percentage;
- percentage = PERCENTAGE(100,MAXBODY,gamestate.body,9);
- DrawNum(11,57,percentage,3);
- if (percentage > 75)
- picnum = FACE1PIC;
- else
- if (percentage > 50)
- picnum = FACE2PIC;
- else
- if (percentage > 25)
- picnum = FACE3PIC;
- else
- if (percentage)
- picnum = FACE4PIC;
- else
- {
- picnum = FACE5PIC;
- CA_CacheGrChunk (picnum);
- }
- bufferofs = 0;
- if (!percentage)
- {
- UNMARKGRCHUNK(picnum);
- // VW_DrawPic(8,14,picnum);
- VW_DrawPic(10,14,picnum);
- }
- else
- LatchDrawPic(10,14,picnum);
- }
- //===========================================================================
- /*
- ===============
- =
- = DrawFreezeTime
- =
- ===============
- */
- void DrawFreezeTime()
- {
- long percentage;
- percentage = PERCENTAGE(100,MAXFREEZETIME,(long)FreezeTime,7);
- DrawNum(23,70,percentage,3);
- }
- //===========================================================================
- /*
- ===============
- =
- = DrawNum
- =
- ===============
- */
- void DrawNum(short x,short y,short value,short maxdigits)
- {
- char str[10],len,i;
- itoa(value,str,10);
- len=strlen(str);
- for (i=len; i<maxdigits; i++)
- DrawChar(x++,y,BLANKCHAR);
- for (i=0;i<len;i++)
- DrawChar(x++,y,NUMBERCHARS+str[i]-'0');
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveChest
- =
- ===============
- */
- void GiveChest(void)
- {
- char i;
- for (i=0;i<random(4);i++)
- {
- GiveBolt();
- SD_WaitSoundDone();
- }
- for (i=0;i<random(3);i++)
- {
- GiveNuke();
- SD_WaitSoundDone();
- }
- for (i=0;i<random(2);i++)
- {
- GivePotion();
- SD_WaitSoundDone();
- }
- }
- //===========================================================================
- /*
- ===============
- =
- = GiveGoal
- =
- ===============
- */
- void GiveGoal (void)
- {
- SD_PlaySound (GETPOINTSSND);
- playstate = ex_victorious;
- }
- //===========================================================================
- #if 0
- /*
- ===============
- =
- = DrawLevelNumber
- =
- ===============
- */
- void DrawLevelNumber (int number)
- {
- char str[10];
- int len;
- unsigned temp;
- bufferofs = 0;
- if (number<9)
- PrintX=13;
- else
- PrintX = 5;
- PrintY = 4;
- VW_Bar (5,4,16,9,STATUSCOLOR);
- temp = fontcolor;
- fontcolor = TEXTCOLOR^STATUSCOLOR;
- US_PrintUnsigned (number+1);
- fontcolor = temp;
- }
- #endif
- //===========================================================================
- /*
- ===============
- =
- = DrawText
- =
- ===============
- */
- void DrawText (boolean draw_text_whether_it_needs_it_or_not)
- {
- unsigned number;
- char str[80];
- char far *text;
- unsigned temp;
- //
- // draw a new text description if needed
- //
- number = *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex)-NAMESTART;
- if ( number>26 )
- number = 0;
- if ((number == lasttext) && (!draw_text_whether_it_needs_it_or_not))
- return;
- lasttext = number;
- text = (char _seg *)grsegs[LEVEL1TEXT+mapon]+textstarts[number];
- _fmemcpy (str,text,80);
- DisplayMsg(str,NULL);
- }
- //===========================================================================
- /*
- ===============
- =
- = DisplayMsg
- =
- ===============
- */
- char DisplayMsg(char *text,char *choices)
- {
- char ch=true;
- short temp;
- bufferofs = 0;
- PrintY = 1;
- WindowX = 20;
- WindowW = 270;
- VW_Bar (WindowX,2,WindowW,8,STATUSCOLOR);
- temp = fontcolor;
- fontcolor = TEXTCOLOR^STATUSCOLOR;
- US_CPrintLine (text);
- fontcolor = temp;
- if (choices)
- {
- ch=GetKeyChoice(choices,true);
- LastScan = 0;
- }
- return(ch);
- }
- /*
- ===============
- =
- = DisplaySMsg
- =
- ===============
- */
- char DisplaySMsg(char *text,char *choices)
- {
- char ch=true;
- short temp;
- bufferofs = 0;
- PrintY = 69;
- WindowX = 98;
- WindowW = 115;
- VW_Bar(WindowX,PrintY+1,WindowW,8,STATUSCOLOR);
- temp = fontcolor;
- fontcolor = TEXTCOLOR^STATUSCOLOR;
- US_CPrintLine (text);
- fontcolor = temp;
- if (choices)
- {
- ch=GetKeyChoice(choices,true);
- LastScan = 0;
- }
- return(ch);
- }
- //===========================================================================
- /*
- ===============
- =
- = DrawRadar
- =
- ===============
- */
- void DrawRadar (void)
- {
- int angle,number;
- short objnum;
- bufferofs = 0;
- LatchDrawPic (radarx,radary,RADAR_TOPPIC);
- asm cli
- asm mov dx,GC_INDEX
- asm mov ax,2*256+GC_MODE
- asm out dx,ax // write mode 2
- asm mov ax,GC_DATAROTATE
- asm out dx,ax // no rotation / logical operation
- asm mov dx,SC_INDEX
- asm mov al,SC_MAPMASK
- asm mov ah,15
- asm out dx,ax // write to all four planes
- asm sti
- objnum = 0;
- while (RadarXY[objnum][2] != -1)
- {
- RadarBlip(radar_xcenter+RadarXY[objnum][0],radar_ycenter+RadarXY[objnum][1],RadarXY[objnum][2]);
- objnum++;
- }
- asm cli
- asm mov dx,GC_INDEX
- asm mov ax,255*256+GC_BITMASK
- asm out dx,ax // reset bitmask to %11111111
- asm sti
- }
- //===========================================================================
- //--------------------------------------------------------------------------
- // DrawNSEWIcons(void)
- //--------------------------------------------------------------------------
- void DrawRadarObj(short dx, short dy, unsigned sprnum,signed long psin,signed long pcos);
- void DrawNSEWIcons()
- {
- signed x,y;
- x = -FixedByFrac(RADAR_X_IRADIUS,costable[player->angle]);
- y = -FixedByFrac(RADAR_Y_IRADIUS,sintable[player->angle]);
- VWB_DrawSprite(radar_xcenter+x-3,radar_ycenter+y-3,NORTHICONSPR);
- }
- #if 0
- /*
- ===============
- =
- = DrawBars
- =
- ===============
- */
- void DrawBars (void)
- {
- int i;
- unsigned source,dest,topline;
- for (i=0;i<3;i++)
- {
- bufferofs = screenloc[i];
- VW_Bar (34*8,POWERLINE,40,MAXSHOTPOWER,1);
- }
- EGAWRITEMODE(1);
- asm mov es,[screenseg]
- //
- // shot power
- //
- if (gamestate.shotpower)
- {
- topline = MAXSHOTPOWER - gamestate.shotpower;
- source = latchpics[SHOTPOWERPIC-FIRSTLATCHPIC]+topline*SIDEBARWIDTH;
- dest = (POWERLINE+topline)*SCREENWIDTH+34;
- asm mov si,[source]
- asm mov di,[dest]
- asm mov cx,[WORD PTR gamestate.shotpower]
- newline:
- asm mov al,[es:si]
- asm mov [es:di+PAGE1START],al
- asm mov [es:di+PAGE2START],al
- asm mov [es:di+PAGE3START],al
- asm mov al,[es:si+1]
- asm mov [es:di+1+PAGE1START],al
- asm mov [es:di+1+PAGE2START],al
- asm mov [es:di+1+PAGE3START],al
- asm mov al,[es:si+2]
- asm mov [es:di+2+PAGE1START],al
- asm mov [es:di+2+PAGE2START],al
- asm mov [es:di+2+PAGE3START],al
- asm mov al,[es:si+3]
- asm mov [es:di+3+PAGE1START],al
- asm mov [es:di+3+PAGE2START],al
- asm mov [es:di+3+PAGE3START],al
- asm mov al,[es:si+4]
- asm mov [es:di+4+PAGE1START],al
- asm mov [es:di+4+PAGE2START],al
- asm mov [es:di+4+PAGE3START],al
- asm add di,SCREENWIDTH
- asm add si,5
- asm loop newline
- }
- //
- // body
- //
- if (gamestate.body)
- {
- source = latchpics[BODYPIC-FIRSTLATCHPIC];
- dest = BODYLINE*SCREENWIDTH+34;
- asm mov si,[source]
- asm mov di,[dest]
- asm mov cx,[WORD PTR gamestate.body]
- newline2:
- asm mov al,[es:si]
- asm mov [es:di+PAGE1START],al
- asm mov [es:di+PAGE2START],al
- asm mov [es:di+PAGE3START],al
- asm mov al,[es:si+1]
- asm mov [es:di+1+PAGE1START],al
- asm mov [es:di+1+PAGE2START],al
- asm mov [es:di+1+PAGE3START],al
- asm mov al,[es:si+2]
- asm mov [es:di+2+PAGE1START],al
- asm mov [es:di+2+PAGE2START],al
- asm mov [es:di+2+PAGE3START],al
- asm mov al,[es:si+3]
- asm mov [es:di+3+PAGE1START],al
- asm mov [es:di+3+PAGE2START],al
- asm mov [es:di+3+PAGE3START],al
- asm mov al,[es:si+4]
- asm mov [es:di+4+PAGE1START],al
- asm mov [es:di+4+PAGE2START],al
- asm mov [es:di+4+PAGE3START],al
- asm add di,SCREENWIDTH
- asm add si,5
- asm loop newline2
- }
- if (gamestate.body != MAXBODY)
- {
- source = latchpics[NOBODYPIC-FIRSTLATCHPIC]+gamestate.body*SIDEBARWIDTH;
- dest = (BODYLINE+gamestate.body)*SCREENWIDTH+34;
- topline = MAXBODY-gamestate.body;
- asm mov si,[source]
- asm mov di,[dest]
- asm mov cx,[WORD PTR topline]
- newline3:
- asm mov al,[es:si]
- asm mov [es:di+PAGE1START],al
- asm mov [es:di+PAGE2START],al
- asm mov [es:di+PAGE3START],al
- asm mov al,[es:si+1]
- asm mov [es:di+1+PAGE1START],al
- asm mov [es:di+1+PAGE2START],al
- asm mov [es:di+1+PAGE3START],al
- asm mov al,[es:si+2]
- asm mov [es:di+2+PAGE1START],al
- asm mov [es:di+2+PAGE2START],al
- asm mov [es:di+2+PAGE3START],al
- asm mov al,[es:si+3]
- asm mov [es:di+3+PAGE1START],al
- asm mov [es:di+3+PAGE2START],al
- asm mov [es:di+3+PAGE3START],al
- asm mov al,[es:si+4]
- asm mov [es:di+4+PAGE1START],al
- asm mov [es:di+4+PAGE2START],al
- asm mov [es:di+4+PAGE3START],al
- asm add di,SCREENWIDTH
- asm add si,5
- asm loop newline3
- }
- EGAWRITEMODE(0);
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////
- //
- // Check the object and make sure it is a monster. Used in making the sound
- // of a monster being shot.
- //
- /////////////////////////////////////////////////////////////////////////////
- boolean PlayMonsterSound(classtype objclass)
- {
- switch (objclass)
- {
- case solidobj:
- case realsolidobj:
- return false;
- default:
- return true;
- }
- }
- /*
- =============================================================================
- SHOTS
- =============================================================================
- */
- void T_Pshot (objtype *ob);
- extern statetype s_pshot1;
- extern statetype s_pshot2;
- //extern statetype s_bigpshot1;
- //extern statetype s_bigpshot2;
- statetype s_pshot1 = {PSHOT1PIC,8,&T_Pshot,&s_pshot2};
- statetype s_pshot2 = {PSHOT2PIC,8,&T_Pshot,&s_pshot1};
- statetype s_pshot_exp1 = {PSHOT_EXP1PIC,7,NULL,&s_pshot_exp2};
- statetype s_pshot_exp2 = {PSHOT_EXP2PIC,7,NULL,&s_pshot_exp3};
- statetype s_pshot_exp3 = {PSHOT_EXP3PIC,7,NULL,NULL};
- //statetype s_shotexplode = {PSHOT2PIC,8,NULL,NULL};
- //statetype s_bigpshot1 = {BIGPSHOT1PIC,8,&T_Pshot,&s_bigpshot2};
- //statetype s_bigpshot2 = {BIGPSHOT2PIC,8,&T_Pshot,&s_bigpshot1};
- /*
- ===================
- =
- = SpawnPShot
- =
- ===================
- */
- void SpawnPShot (void)
- {
- DSpawnNewObjFrac (player->x,player->y,&s_pshot1,PIXRADIUS*7);
- new->obclass = pshotobj;
- new->speed = SHOTSPEED;
- new->angle = player->angle;
- new->active = always;
- }
- #if 0
- void SpawnBigPShot (void)
- {
- SpawnNewObjFrac (player->x,player->y,&s_bigpshot1,24*PIXRADIUS);
- new->obclass = bigpshotobj;
- new->speed = SHOTSPEED;
- new->angle = player->angle;
- }
- #endif
- /*
- ===================
- =
- = JimsShotClipMove
- =
- = Only checks corners, so the object better be less than one tile wide!
- =
- ===================
- */
- boolean JimsShotClipMove (objtype *ob, long xmove, long ymove)
- {
- int xl,yl,xh,yh,tx,ty,nt1,nt2,x,y;
- long intersect,basex,basey,pointx,pointy;
- unsigned inside,total,tile;
- objtype *check;
- boolean moveok;
- //
- // move player and check to see if any corners are in solid tiles
- //
- // basex = ob->x;
- // basey = ob->y;
- // ob->x += xmove;
- // ob->y += ymove;
- // CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- for (y=yl;y<=yh;y++)
- for (x=xl;x<=xh;x++)
- {
- check = actorat[x][y];
- if ((!check) || (check == player) || (!(check->flags & of_shootable)))
- continue;
- ob->x -= xmove;
- ob->y -= ymove;
- if (check->obclass != solidobj && check->obclass != hbunnyobj)
- {
- if (PlayMonsterSound(check->obclass))
- SD_PlaySound (SHOOTMONSTERSND);
- if (ob->obclass == bigpshotobj)
- ShootActor (check,BIGSHOTDAMAGE);
- else
- ShootActor (check,SHOTDAMAGE);
- }
- else
- if (check->obclass == solidobj && (check->flags & of_forcefield))
- {
- if (PlayMonsterSound(check->obclass))
- SD_PlaySound (SHOOTMONSTERSND);
- if (ob->obclass == bigpshotobj)
- ShootActor (check,BIGSHOTDAMAGE);
- else
- ShootActor (check,SHOTDAMAGE);
- }
- ob->state = &s_pshot_exp1;
- ob->ticcount = ob->state->tictime;
- return(true);
- }
- return(false); // move is OK!
- }
- /*
- ===============
- =
- = T_Pshot
- =
- ===============
- */
- #if 0
- void T_Pshot (objtype *ob)
- {
- objtype *check;
- long xmove,ymove,speed;
- //
- // check current position for monsters having moved into it
- //
- for (check = player->next; check; check=check->next)
- if ((check->flags & of_shootable)
- && ob->xl <= check->xh
- && ob->xh >= check->xl
- && ob->yl <= check->yh
- && ob->yh >= check->yl)
- {
- if (check->obclass != solidobj)
- {
- if (PlayMonsterSound(check->obclass))
- SD_PlaySound (SHOOTMONSTERSND);
- if (ob->obclass == bigpshotobj)
- ShootActor (check,BIGSHOTDAMAGE);
- else
- ShootActor (check,SHOTDAMAGE);
- }
- ob->state = &s_pshot_exp1;
- ob->ticcount = ob->state->tictime;
- return;
- }
- //
- // move ahead, possibly hitting a wall
- //
- speed = ob->speed*tics;
- xmove = FixedByFrac(speed,costable[ob->angle]);
- ymove = -FixedByFrac(speed,sintable[ob->angle]);
- if (ShotClipMove(ob,xmove,ymove))
- {
- ob->state = &s_pshot_exp1;
- ob->ticcount = ob->state->tictime;
- return;
- }
- ob->tilex = ob->x >> TILESHIFT;
- ob->tiley = ob->y >> TILESHIFT;
- //
- // check final position for monsters hit
- //
- for (check = player->next; check; check=check->next)
- if ((ob->flags & of_shootable)
- && ob->xl <= check->xh
- && ob->xh >= check->xl
- && ob->yl <= check->yh
- && ob->yh >= check->yl)
- {
- ShootActor (check,SHOTDAMAGE);
- ob->state = &s_pshot_exp1;
- ob->ticcount = ob->state->tictime;
- return;
- }
- }
- #endif
- void T_Pshot (objtype *ob)
- {
- objtype *check;
- long xmove,ymove,speed;
- int xl,yl,xh,yh,tx,ty,nt1,nt2,x,y;
- long intersect,basex,basey,pointx,pointy;
- unsigned inside,total,tile;
- boolean moveok;
- //
- // check current position for monsters having moved into it
- //
- for (check = player->next; check; check=check->next)
- if ((check->flags & of_shootable)
- && ob->xl <= check->xh
- && ob->xh >= check->xl
- && ob->yl <= check->yh
- && ob->yh >= check->yl)
- {
- if (check->obclass != solidobj && check->obclass != hbunnyobj)
- {
- if (PlayMonsterSound(check->obclass))
- SD_PlaySound (SHOOTMONSTERSND);
- if (ob->obclass == bigpshotobj)
- ShootActor (check,BIGSHOTDAMAGE);
- else
- ShootActor (check,SHOTDAMAGE);
- }
- ob->state = &s_pshot_exp1;
- ob->obclass = expobj;
- ob->ticcount = ob->state->tictime;
- return;
- }
- //
- // move ahead, possibly hitting a wall
- //
- speed = ob->speed*tics;
- xmove = FixedByFrac(speed,costable[ob->angle]);
- ymove = -FixedByFrac(speed,sintable[ob->angle]);
- if (ShotClipMove(ob,xmove,ymove))
- {
- ob->state = &s_pshot_exp1;
- ob->obclass = expobj;
- ob->ticcount = ob->state->tictime;
- return;
- }
- ob->tilex = ob->x >> TILESHIFT;
- ob->tiley = ob->y >> TILESHIFT;
- //
- // check final position for monsters hit
- //
- JimsShotClipMove(obj,xmove,ymove);
- }
- /*
- =============================================================================
- PLAYER ACTIONS
- =============================================================================
- */
- /*
- ===============
- =
- = BuildShotPower
- =
- ===============
- */
- void BuildShotPower (void)
- {
- int newlines,topline;
- long i;
- unsigned source,dest;
- if (gamestate.shotpower == MAXSHOTPOWER)
- return;
- newlines = 0;
- for (i=lasttimecount-realtics;i<lasttimecount;i++)
- newlines += (i&1);
- gamestate.shotpower += newlines;
- if (gamestate.shotpower > MAXSHOTPOWER)
- {
- newlines -= (gamestate.shotpower - MAXSHOTPOWER);
- gamestate.shotpower = MAXSHOTPOWER;
- }
- }
- //===========================================================================
- /*
- ===============
- =
- = ClearShotPower
- =
- ===============
- */
- void ClearShotPower (void)
- {
- unsigned source,dest,topline;
- #if 0
- topline = MAXSHOTPOWER - gamestate.shotpower;
- source = latchpics[L_NOSHOT]+topline*SIDEBARWIDTH;
- dest = (POWERLINE+topline)*SCREENWIDTH+34;
- asm mov es,[screenseg]
- asm mov si,[source]
- asm mov di,[dest]
- if (!gamestate.shotpower)
- return;
- EGAWRITEMODE(1);
- asm mov cx,[WORD PTR gamestate.shotpower]
- newline:
- asm mov al,[es:si]
- asm mov [es:di+PAGE1START],al
- asm mov [es:di+PAGE2START],al
- asm mov [es:di+PAGE3START],al
- asm mov al,[es:si+1]
- asm mov [es:di+1+PAGE1START],al
- asm mov [es:di+1+PAGE2START],al
- asm mov [es:di+1+PAGE3START],al
- asm mov al,[es:si+2]
- asm mov [es:di+2+PAGE1START],al
- asm mov [es:di+2+PAGE2START],al
- asm mov [es:di+2+PAGE3START],al
- asm mov al,[es:si+3]
- asm mov [es:di+3+PAGE1START],al
- asm mov [es:di+3+PAGE2START],al
- asm mov [es:di+3+PAGE3START],al
- asm mov al,[es:si+4]
- asm mov [es:di+4+PAGE1START],al
- asm mov [es:di+4+PAGE2START],al
- asm mov [es:di+4+PAGE3START],al
- asm add di,SCREENWIDTH
- asm add si,5
- asm loop newline
- EGAWRITEMODE(0);
- #endif
- gamestate.shotpower = 0;
- }
- //===========================================================================
- /*
- ===============
- =
- = Shoot
- =
- ===============
- */
- void Shoot (void)
- {
- ClearShotPower ();
- SD_PlaySound (SHOOTSND);
- SpawnPShot ();
- }
- //===========================================================================
- #if 0
- /*
- ===============
- =
- = BigShoot
- =
- ===============
- */
- void BigShoot (void)
- {
- ClearShotPower ();
- SD_PlaySound (BIGSHOOTSND);
- SpawnBigPShot ();
- }
- #endif
- //===========================================================================
- /*
- ===============
- =
- = CastBolt
- =
- ===============
- */
- void CastBolt (void)
- {
- if (!gamestate.bolts)
- {
- SD_PlaySound (NOITEMSND);
- return;
- }
- TakeBolt ();
- boltsleft = NUMBOLTS;
- bolttimer = BOLTTICS;
- Shoot ();
- }
- /*
- ===============
- =
- = ContinueBolt
- =
- ===============
- */
- void ContinueBolt (void)
- {
- bolttimer-=realtics;
- if (bolttimer<0)
- {
- boltsleft--;
- bolttimer = BOLTTICS;
- Shoot ();
- }
- }
- //===========================================================================
- /*
- ===============
- =
- = CastNuke
- =
- ===============
- */
- void CastNuke (void)
- {
- extern boolean autofire;
- int angle;
- if (!gamestate.nukes)
- {
- SD_PlaySound (NOITEMSND);
- return;
- }
- if (!autofire)
- TakeNuke ();
- lastnuke = TimeCount;
- for (angle = 0; angle < ANGLES; angle+= ANGLES/16)
- {
- DSpawnNewObjFrac (player->x,player->y,&s_pshot1,24*PIXRADIUS);
- new->obclass = bigpshotobj;
- new->speed = SHOTSPEED;
- new->angle = angle;
- new->active = always;
- }
- }
- //===========================================================================
- /*
- ===============
- =
- = DrinkPotion
- =
- ===============
- */
- void DrinkPotion (void)
- {
- unsigned source,dest,topline;
- if (!gamestate.potions)
- {
- SD_PlaySound (NOITEMSND);
- return;
- }
- DisplaySMsg("Curing", NULL);
- TakePotion ();
- gamestate.body = MAXBODY;
- VW_WaitVBL(30);
- status_flag = S_NONE;
- #if 0
- //
- // draw a full up bar
- //
- source = latchpics[L_BODYBAR];
- dest = BODYLINE*SCREENWIDTH+34;
- asm mov es,[screenseg]
- asm mov si,[source]
- asm mov di,[dest]
- EGAWRITEMODE(1);
- asm mov cx,MAXBODY
- newline:
- asm mov al,[es:si]
- asm mov [es:di+PAGE1START],al
- asm mov [es:di+PAGE2START],al
- asm mov [es:di+PAGE3START],al
- asm mov al,[es:si+1]
- asm mov [es:di+1+PAGE1START],al
- asm mov [es:di+1+PAGE2START],al
- asm mov [es:di+1+PAGE3START],al
- asm mov al,[es:si+2]
- asm mov [es:di+2+PAGE1START],al
- asm mov [es:di+2+PAGE2START],al
- asm mov [es:di+2+PAGE3START],al
- asm mov al,[es:si+3]
- asm mov [es:di+3+PAGE1START],al
- asm mov [es:di+3+PAGE2START],al
- asm mov [es:di+3+PAGE3START],al
- asm mov al,[es:si+4]
- asm mov [es:di+4+PAGE1START],al
- asm mov [es:di+4+PAGE2START],al
- asm mov [es:di+4+PAGE3START],al
- asm add di,SCREENWIDTH
- asm add si,5
- asm loop newline
- EGAWRITEMODE(0);
- #endif
- }
- //===========================================================================
- #if 0
- ////////////////////////////////////////////////////////////////////////////
- //
- // GetScrollText
- //
- // parms - scroll -- the number of the scroll to display
- // returns - a far pointer to the scroll text
- //
- ////////////////////////////////////////////////////////////////////////////
- char far *GetScrollText (int scroll)
- {
- boolean found;
- int i;
- char far *txt;
- unsigned ofset;
- CA_CacheGrChunk(SCROLLTEXT);
- found = false;
- i = 0;
- txt = (char _seg *)grsegs[SCROLLTEXT];
- while (!found)
- {
- while (*txt != '\n')
- {
- if (*txt == '\r')
- *txt = 0;
- txt++;
- }
- txt++;
- if (i == scroll)
- {
- found = true;
- ofset = FP_OFF(txt);
- while (*txt != '\n')
- {
- if (*txt == '\r')
- *txt = 0;
- txt++;
- }
- }
- i++;
- }
- txt = (char _seg *)grsegs[SCROLLTEXT]+ofset;
- UNMARKGRCHUNK(SCROLLTEXT);
- return(txt);
- } //End of GetScrollText
- //===========================================================================
- /*
- ===============
- =
- = ReadScroll
- =
- ===============
- */
- extern boolean tileneeded[NUMFLOORS];
- void ReadScroll (int scroll)
- {
- PresenterInfo pi;
- int i;
- unsigned *skytemp,*gndtemp,blackcolor=0;
- char far *scrolltext;
- DisplaySMsg("Reading Scroll", NULL);
- bufferofs = displayofs = screenloc[screenpage];
- if (status_flag != S_TIMESTOP)
- status_flag = S_NONE;
- FreeUpMemory();
- CA_CacheGrChunk (SCROLLTOPPIC);
- CA_CacheGrChunk (SCROLL1PIC);
- CA_CacheGrChunk (SCROLLBOTTOMPIC);
- skytemp = skycolor;
- gndtemp = groundcolor;
- skycolor = groundcolor = &blackcolor;
- VW_Bar(0,0,VIEWWIDTH,VIEWHEIGHT,0);
- VW_DrawPic (10,0,SCROLLTOPPIC);
- VW_DrawPic (10,32,SCROLL1PIC);
- VW_DrawPic (10,88,SCROLLBOTTOMPIC);
- scrolltext = GetScrollText(scroll);
- pi.xl = LEFTEDGE;
- pi.yl = PRNY;
- pi.xh = RIGHTEDGE;
- pi.yh = PRNY+1;
- pi.bgcolor = 7;
- pi.script[0] = (char far *)scrolltext;
- Presenter(&pi);
- skycolor = skytemp;
- groundcolor = gndtemp;
- UNMARKGRCHUNK(SCROLL1PIC);
- UNMARKGRCHUNK(SCROLLTOPPIC);
- UNMARKGRCHUNK(SCROLLBOTTOMPIC);
- MM_FreePtr (&grsegs[SCROLL1PIC]);
- MM_FreePtr (&grsegs[SCROLLTOPPIC]);
- MM_FreePtr (&grsegs[SCROLLBOTTOMPIC]);
- CacheScaleds();
- IN_ClearKeysDown ();
- lasttext = -1;
- DisplayMsg("Press ENTER or ESC to exit.",NULL);
- while ((!Keyboard[sc_Escape]) && (!Keyboard[sc_Enter]));
- IN_ClearKeysDown ();
- if (status_flag == S_TIMESTOP)
- DisplaySMsg("Time Stopped: ",NULL);
- }
- #endif
- //===============
- //
- // StopTime()
- //
- //
- //===============
- void StopTime()
- {
- FreezeTime = MAXFREEZETIME;
- SD_PlaySound(FREEZETIMESND);
- DisplaySMsg("Time Stopped: ",NULL);
- status_flag = S_TIMESTOP;
- }
- /*
- ===============
- =
- = TakeDamage
- =
- ===============
- */
- void TakeDamage (int points)
- {
- unsigned source,dest,topline;
- if (!gamestate.body || (bordertime && bcolor==FLASHCOLOR) || godmode)
- return;
- if (points != 1)
- points = EasyDoDamage(points);
- if (points >= gamestate.body)
- {
- points = gamestate.body;
- Flags |= FL_DEAD;
- }
- bordertime = FLASHTICS<<2;
- bcolor = FLASHCOLOR;
- VW_ColorBorder (FLASHCOLOR);
- DisplaySMsg("Damaging blows!", NULL);
- status_flag = S_NONE;
- status_delay = 80;
- if (gamestate.body<MAXBODY/3)
- SD_PlaySound (TAKEDMGHURTSND);
- else
- SD_PlaySound (TAKEDAMAGESND);
- gamestate.body -= points;
- }
- /*
- =============================================================================
- INTERACTION
- =============================================================================
- */
- #if 0
- /*
- ==================
- =
- = OpenDoor
- =
- ==================
- */
- void OpenDoor (unsigned bx, unsigned by, unsigned doorbase)
- {
- int x,y;
- unsigned far *map;
- x=bx;
- y=by;
- map = mapsegs[0]+farmapylookup[y]+x;
- while (tilemap[x][y]-doorbase<4)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map--;
- x--;
- }
- x=bx+1;
- map = mapsegs[0]+farmapylookup[y]+x;
- while (tilemap[x][y]-doorbase<4)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map++;
- x++;
- }
- x=bx;
- y=by-1;
- map = mapsegs[0]+farmapylookup[y]+x;
- while (tilemap[x][y]-doorbase<4)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map-=mapwidth;
- y--;
- }
- y=by+1;
- map = mapsegs[0]+farmapylookup[y]+x;
- while (tilemap[x][y]-doorbase<4)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map+=mapwidth;
- y++;
- }
- }
- #endif
- #if 0
- /*
- ==================
- =
- = RemoveWalls - similar to OpenDoor(), but on a different plane
- =
- ==================
- */
- void RemoveWalls (unsigned bx, unsigned by, unsigned remove_code)
- {
- int x,y;
- unsigned far *map,*p2;
- x=bx;
- y=by;
- p2 = *(mapsegs[2]+farmapylookup[y]+x);
- map = mapsegs[0]+farmapylookup[y]+x;
- while (*p2 == remove_code)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map--;
- p2--;
- x--;
- }
- x=bx+1;
- p2 = *(mapsegs[2]+farmapylookup[y]+x);
- map = mapsegs[0]+farmapylookup[y]+x;
- while (*p2 == remove_code)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map++;
- p2++;
- x++;
- }
- x=bx;
- y=by-1;
- p2 = *(mapsegs[2]+farmapylookup[y]+x);
- map = mapsegs[0]+farmapylookup[y]+x;
- while (*p2 == remove_code)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map-=mapwidth;
- p2 -= mapwidth;
- y--;
- }
- y=by+1;
- p2 = *(mapsegs[2]+farmapylookup[y]+x);
- map = mapsegs[0]+farmapylookup[y]+x;
- while (*p2 == remove_code)
- {
- tilemap[x][y] = (unsigned)actorat[x][y] = *map = 0;
- map+=mapwidth;
- p2 += mapwidth;
- y++;
- }
- }
- #endif
- /*
- ==================
- =
- = HitSpecialTile
- =
- = Returns true if the move is blocked
- =
- ==================
- */
- boolean HitSpecialTile (unsigned x, unsigned y, unsigned tile)
- {
- objtype *check;
- short keyspot;
- unsigned temp,spot,curmap=gamestate.mapon,newlevel;
- char *key_colors[] = {"a RED key",
- "a YELLOW key",
- "a GREEN key",
- "a BLUE key"};
- switch (tile)
- {
- case 65:
- playstate = ex_victorious;
- break;
- case 9:
- case 15:
- case 27:
- case 30:
- case 40:
- case 42:
- case 43:
- case 45:
- case 46:
- case 47:
- case 49:
- case 76:
- case 77:
- if (!playstate && !FreezeTime)
- {
- // Is this an openable door? (Is "openable" a word?)
- //
- spot = (*(mapsegs[2]+farmapylookup[y]+x)) >> 8;
- if (spot == CANT_OPEN_CODE) // CAN'T EVER OPEN (it's just for looks)
- {
- CenterWindow(30,4);
- US_CPrint("\nThis door is permanently blocked");
- VW_UpdateScreen();
- IN_ClearKeysDown();
- IN_Ack();
- return;
- }
- // make sure player has key to get into door
- //
- if (TILE_FLAGS(tile) & tf_EMBEDDED_KEY_COLOR)
- keyspot = GATE_KEY_COLOR(tile);
- else
- keyspot = (*(mapsegs[2]+farmapylookup[y+1]+x)) >> 8;
- if (keyspot--)
- if (!gamestate.keys[keyspot])
- {
- SD_PlaySound(HIT_GATESND);
- CenterWindow(20,5);
- US_CPrint("\nYou need\n");
- US_CPrint(key_colors[keyspot]);
- VW_UpdateScreen();
- IN_ClearKeysDown();
- IN_Ack();
- return;
- }
- //
- // deal with this gate (warp? simply open? whatever...)
- //
- switch (spot)
- {
- case NEXT_LEVEL_CODE: // WARP TO NEXT LEVEL
- newlevel = gamestate.mapon+1;
- playstate = ex_warped;
- break;
- case REMOVE_DOOR_CODE: // REMOVE DOOR
- (unsigned)actorat[x][y] = tilemap[x][y] = *(mapsegs[0]+farmapylookup[y]+x) = 0;
- *(mapsegs[2]+farmapylookup[y+1]+x) = 0; // key no longer needed
- if (keyspot>=0)
- TakeKey(keyspot);
- break;
- default: // WARP TO A LEVEL
- newlevel = spot;
- playstate = ex_warped;
- break;
- }
- if (playstate == ex_warped)
- {
- SD_PlaySound(HIT_GATESND);
- // levelinfo *li=&gamestate.levels[curmap];
- // OldAngle = FaceDoor(x,y);
- if (!VerifyGateExit())
- {
- IN_ClearKeysDown ();
- playstate = ex_stillplaying;
- break;
- }
- // FaceAngle(OldAngle);
- if (keyspot>=0)
- TakeKey(keyspot);
- *(mapsegs[2]+farmapylookup[y+1]+x) = 0; // key no longer needed
- gamestate.mapon = newlevel;
- SD_PlaySound(WARPUPSND);
- IN_ClearKeysDown ();
- // li->x = player->tilex;
- // li->y = player->tiley;
- // li->angle = player->angle+180;
- // if (li->angle > 360)
- // li->angle -= 360;
- }
- }
- break;
- }
- return true;
- }
- //-------------------------------------------------------------------------
- // VerifyGateExit()
- //-------------------------------------------------------------------------
- boolean VerifyGateExit()
- {
- char choices[] = {sc_Escape,sc_Y,sc_N,0},ch;
- ch=DisplayMsg("Pass this way? Y/N",choices);
- DrawText(true);
- return(ch == sc_Y);
- }
- /*
- ==================
- =
- = TouchActor
- =
- = Returns true if the move is blocked
- =
- ==================
- */
- boolean TouchActor (objtype *ob, objtype *check)
- {
- if (ob->xh < check->xl || ob->xl > check->xh ||
- ob->yh < check->yl || ob->yl > check->yh)
- return false; // not quite touching
- switch (check->obclass)
- {
- case bonusobj:
- switch (check->temp1)
- {
- case B_BOLT: GiveBolt (); break;
- case B_NUKE: GiveNuke (); break;
- case B_POTION: GivePotion (); break;
- // case B_RKEY2: GiveKey(B_RKEY-B_RKEY); break;
- case B_RKEY:
- case B_YKEY:
- case B_GKEY:
- case B_BKEY: GiveKey (check->temp1-B_RKEY); break;
- #if 0
- case B_SCROLL1:
- case B_SCROLL2:
- case B_SCROLL3:
- case B_SCROLL4:
- case B_SCROLL5:
- case B_SCROLL6:
- case B_SCROLL7:
- case B_SCROLL8: GiveScroll (check->temp1-B_SCROLL1,true); break;
- #endif
- case B_CHEST: GiveChest (); break;
- case B_RGEM:
- case B_YGEM:
- case B_GGEM:
- case B_BGEM:
- case B_PGEM:
- SD_PlaySound(GETGEMSND);
- gamestate.gems[check->temp1-B_RGEM] = GEM_DELAY_TIME;
- redraw_gems = true;
- break;
- default:
- Quit("TouchActor(): INVALID BONUS");
- break;
- }
- (unsigned)actorat[check->tilex][check->tiley] = 0;
- RemoveObj (check);
- return false;
- case freezeobj:
- StopTime();
- (unsigned)actorat[check->tilex][check->tiley] = 0;
- RemoveObj(check);
- return(false);
- case cloudobj:
- TakeDamage(2);
- return false;
- }
- return true;
- }
- /*
- ==================
- =
- = CalcBounds
- =
- ==================
- */
- void CalcBounds (objtype *ob)
- {
- //
- // calculate hit rect
- //
- ob->xl = ob->x - ob->size;
- ob->xh = ob->x + ob->size;
- ob->yl = ob->y - ob->size;
- ob->yh = ob->y + ob->size;
- }
- /*
- ===================
- =
- = LocationInActor
- =
- ===================
- */
- boolean LocationInActor (objtype *ob)
- {
- int x,y,xmin,ymin,xmax,ymax;
- objtype *check;
- CalcBounds (ob);
- xmin = (ob->x >> TILESHIFT)-2;
- ymin = (ob->y >> TILESHIFT)-2;
- xmax = xmin+5;
- ymax = ymin+5;
- for (x=xmin;x<xmax;x++)
- for (y=ymin;y<ymax;y++)
- {
- check = actorat[x][y];
- if (check>(objtype *)LASTTILE
- && (check->flags & of_shootable)
- && (check->obclass != bonusobj)
- && (check->obclass != freezeobj)
- && (check->obclass != solidobj)
- && ob->xl-SIZE_TEST <= check->xh
- && ob->xh+SIZE_TEST >= check->xl
- && ob->yl-SIZE_TEST <= check->yh
- && ob->yh+SIZE_TEST >= check->yl)
- return true;
- }
- return false;
- }
- /*
- ===================
- =
- = ClipXMove
- =
- = Only checks corners, so the object better be less than one tile wide!
- =
- ===================
- */
- void ClipXMove (objtype *ob, long xmove)
- {
- int xl,yl,xh,yh,tx,ty,nt1,nt2,x,y;
- long intersect,basex,basey,pointx,pointy;
- unsigned inside,total,tile;
- objtype *check;
- boolean moveok;
- boolean invisible_present = false;
- //
- // move player and check to see if any corners are in solid tiles
- //
- basex = ob->x;
- basey = ob->y;
- ob->x += xmove;
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- for (y=yl;y<=yh;y++)
- for (x=xl;x<=xh;x++)
- {
- check = actorat[x][y];
- if (!check)
- continue; // blank floor, walk ok
- if ((unsigned)check <= LASTTILE)
- {
- if (TILE_FLAGS((unsigned)check) & tf_SPECIAL)
- {
- HitSpecialTile(x,y,(unsigned)check-SPECTILESTART);
- goto blockmove;
- }
- if (TILE_FLAGS((unsigned)check) & tf_INVISIBLE_WALL)
- {
- invisible_present = true;
- goto blockmove;
- }
- if (TILE_FLAGS((unsigned)check) & tf_SOLID)
- {
- goto blockmove; // solid wall
- }
- }
- TouchActor(ob,check); // pick up items
- }
- //
- // check nearby actors
- //
- if (LocationInActor(ob))
- {
- ob->x -= xmove;
- if (LocationInActor(ob))
- {
- ob->x += xmove;
- if (LocationInActor(ob))
- ob->x -= xmove;
- }
- }
- return; // move is OK!
- blockmove:
- // if (!SD_SoundPlaying())
- // SD_PlaySound (HITWALLSND);
- moveok = false;
- do
- {
- xmove /= 2;
- if (moveok)
- {
- ob->x += xmove;
- }
- else
- {
- ob->x -= xmove;
- }
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- if (tilemap[xl][yl] || tilemap[xh][yl]
- || tilemap[xh][yh] || tilemap[xl][yh] )
- {
- moveok = false;
- if (xmove>=-2048 && xmove <=2048)
- {
- ob->x = basex;
- ob->y = basey;
- return;
- }
- }
- else
- if (invisible_present)
- {
- moveok = false;
- if (xmove>=-2048 && xmove <=2048)
- {
- ob->x = basex;
- ob->y = basey;
- return;
- }
- }
- else
- if (xmove>=-2048 && xmove <=2048)
- return;
- moveok = true;
- } while (1);
- }
- /*
- ===================
- =
- = ClipYMove
- =
- = Only checks corners, so the object better be less than one tile wide!
- =
- ===================
- */
- void ClipYMove (objtype *ob, long ymove)
- {
- int xl,yl,xh,yh,tx,ty,nt1,nt2,x,y;
- long intersect,basex,basey,pointx,pointy;
- unsigned inside,total,tile;
- objtype *check;
- boolean moveok;
- boolean invisible_present = false;
- //
- // move player and check to see if any corners are in solid tiles
- //
- basex = ob->x;
- basey = ob->y;
- ob->y += ymove;
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- for (y=yl;y<=yh;y++)
- for (x=xl;x<=xh;x++)
- {
- check = actorat[x][y];
- if (!check)
- continue; // blank floor, walk ok
- if ((unsigned)check <= LASTTILE)
- {
- if (TILE_FLAGS((unsigned)check) & tf_SPECIAL) // <=LASTSPECIALTILE)
- {
- HitSpecialTile (x,y,(unsigned)check-SPECTILESTART);
- goto blockmove;
- }
- if (TILE_FLAGS((unsigned)check) & tf_INVISIBLE_WALL)
- {
- invisible_present = true;
- goto blockmove;
- }
- if (TILE_FLAGS((unsigned)check) & tf_SOLID) // LASTWALLTILE)
- {
- goto blockmove; // solid wall
- }
- }
- TouchActor(ob,check); // pick up items
- }
- //
- // check nearby actors
- //
- if (LocationInActor(ob))
- {
- if (LocationInActor(ob))
- {
- ob->y -= ymove;
- }
- }
- return; // move is OK!
- blockmove:
- // if (!SD_SoundPlaying())
- // SD_PlaySound (HITWALLSND);
- moveok = false;
- do
- {
- ymove /= 2;
- if (moveok)
- {
- ob->y += ymove;
- }
- else
- {
- ob->y -= ymove;
- }
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- if (tilemap[xl][yl] || tilemap[xh][yl]
- || tilemap[xh][yh] || tilemap[xl][yh] )
- {
- moveok = false;
- if (ymove>=-2048 && ymove <=2048)
- {
- ob->x = basex;
- ob->y = basey;
- return;
- }
- }
- else
- if (invisible_present)
- {
- moveok = false;
- if (ymove>=-2048 && ymove <=2048)
- {
- ob->x = basex;
- ob->y = basey;
- return;
- }
- }
- else
- if (ymove>=-2048 && ymove <=2048)
- return;
- moveok = true;
- } while (1);
- }
- //==========================================================================
- /*
- ===================
- =
- = ShotClipMove
- =
- = Only checks corners, so the object better be less than one tile wide!
- =
- ===================
- */
- boolean ShotClipMove (objtype *ob, long xmove, long ymove)
- {
- int xl,yl,xh,yh,tx,ty,nt1,nt2,x,y;
- long intersect,basex,basey,pointx,pointy;
- unsigned inside,total,spot,tile;
- objtype *check;
- boolean moveok;
- //
- // move shot and check to see if any corners are in solid tiles
- //
- basex = ob->x;
- basey = ob->y;
- ob->x += xmove;
- ob->y += ymove;
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- for (y=yl;y<=yh;y++)
- for (x=xl;x<=xh;x++)
- {
- spot = (*(mapsegs[2]+farmapylookup[y]+x)) >> 8;
- if (spot == EXP_WALL_CODE)
- switch (ob->obclass)
- {
- case pshotobj:
- case bigpshotobj:
- ExplodeWall (x,y);
- goto blockmove;
- break;
- }
- tile = *(mapsegs[0]+farmapylookup[y]+x);
- if (TILE_FLAGS(tile) & tf_SOLID)
- goto blockmove;
- }
- return false; // move is OK!
- blockmove:
- SD_PlaySound (SHOOTWALLSND);
- moveok = false;
- do
- {
- xmove /= 2;
- ymove /= 2;
- if (moveok)
- {
- ob->x += xmove;
- ob->y += ymove;
- }
- else
- {
- ob->x -= xmove;
- ob->y -= ymove;
- }
- CalcBounds (ob);
- xl = ob->xl>>TILESHIFT;
- yl = ob->yl>>TILESHIFT;
- xh = ob->xh>>TILESHIFT;
- yh = ob->yh>>TILESHIFT;
- if (tilemap[xl][yl] || tilemap[xh][yl]
- || tilemap[xh][yh] || tilemap[xl][yh] )
- {
- moveok = false;
- if (xmove>=-2048 && xmove <=2048 && ymove>=-2048 && ymove <=2048)
- {
- ob->x = basex;
- ob->y = basey;
- return true;
- }
- }
- else
- {
- if (xmove>=-2048 && xmove <=2048 && ymove>=-2048 && ymove <=2048)
- return true;
- moveok = true;
- }
- } while (1);
- }
- /*
- =============================================================================
- PLAYER CONTROL
- =============================================================================
- */
- void T_Player (objtype *ob);
- statetype s_player = {0,0,&T_Player,&s_player};
- /*
- ===============
- =
- = SpawnPlayer
- =
- ===============
- */
- void SpawnPlayer (int tilex, int tiley, int dir)
- {
- #if 0
- levelinfo *li=&gamestate.levels[gamestate.mapon];
- if (li->x != -1)
- {
- tilex = li->x;
- tiley = li->y;
- player->angle = li->angle;
- }
- else
- player->angle = (1-dir)*90;
- #endif
- player->obclass = playerobj;
- player->active = always;
- player->tilex = tilex;
- player->tiley = tiley;
- player->x = ((long)tilex<<TILESHIFT)+TILEGLOBAL/2;
- player->y = ((long)tiley<<TILESHIFT)+TILEGLOBAL/2;
- player->state = &s_player;
- player->size = MINDIST;
- CalcBounds(player);
- player->angle = (1-dir)*90;
- if (player->angle<0)
- player->angle += ANGLES;
- }
- /*
- ===================
- =
- = Thrust
- =
- ===================
- */
- void Thrust (int angle, unsigned speed)
- {
- long xmove,ymove;
- if (lasttimecount>>5 != ((lasttimecount-tics)>>5) )
- {
- //
- // walk sound
- //
- if (lasttimecount&32)
- SD_PlaySound (WALK1SND);
- else
- SD_PlaySound (WALK2SND);
- }
- xmove = FixedByFrac(speed,costable[angle]);
- ymove = -FixedByFrac(speed,sintable[angle]);
- ClipXMove(player,xmove);
- ClipYMove(player,ymove);
- player->tilex = player->x >> TILESHIFT;
- player->tiley = player->y >> TILESHIFT;
- }
- /*
- =======================
- =
- = ControlMovement
- =
- =======================
- */
- void ControlMovement (objtype *ob)
- {
- int angle;
- long speed;
- if (control.button1)
- {
- //
- // strafing
- //
- //
- // side to side move
- //
- if (!mousexmove)
- speed = 0;
- else if (mousexmove<0)
- speed = -(long)mousexmove*300;
- else
- speed = -(long)mousexmove*300;
- if (control.xaxis == -1)
- {
- speed += PLAYERSPEED*tics;
- }
- else if (control.xaxis == 1)
- {
- speed -= PLAYERSPEED*tics;
- }
- if (speed > 0)
- {
- if (speed >= TILEGLOBAL)
- speed = TILEGLOBAL-1;
- angle = ob->angle + ANGLES/4;
- if (angle >= ANGLES)
- angle -= ANGLES;
- Thrust (angle,speed); // move to left
- }
- else if (speed < 0)
- {
- if (speed <= -TILEGLOBAL)
- speed = -TILEGLOBAL+1;
- angle = ob->angle - ANGLES/4;
- if (angle < 0)
- angle += ANGLES;
- Thrust (angle,-speed); // move to right
- }
- }
- else
- {
- //
- // not strafing
- //
- //
- // turning
- //
- if (control.xaxis == 1)
- {
- ob->angle -= tics;
- if (running) // fast turn
- ob->angle -= (tics<<1);
- }
- else if (control.xaxis == -1)
- {
- ob->angle+= tics;
- if (running) // fast turn
- ob->angle += (tics<<1);
- }
- ob->angle -= (mousexmove/10);
- if (ob->angle >= ANGLES)
- ob->angle -= ANGLES;
- if (ob->angle < 0)
- ob->angle += ANGLES;
- }
- //
- // forward/backwards move
- //
- if (!mouseymove)
- speed = 0;
- else if (mouseymove<0)
- speed = -(long)mouseymove*500;
- else
- speed = -(long)mouseymove*200;
- if (control.yaxis == -1)
- {
- speed += PLAYERSPEED*tics;
- }
- else if (control.yaxis == 1)
- {
- speed -= PLAYERSPEED*tics;
- }
- if (speed > 0)
- {
- if (speed >= TILEGLOBAL)
- speed = TILEGLOBAL-1;
- Thrust (ob->angle,speed); // move forwards
- }
- else if (speed < 0)
- {
- if (speed <= -TILEGLOBAL)
- speed = -TILEGLOBAL+1;
- angle = ob->angle + ANGLES/2;
- if (angle >= ANGLES)
- angle -= ANGLES;
- Thrust (angle,-speed); // move backwards
- }
- }
- /*
- ===============
- =
- = T_Player
- =
- ===============
- */
- void T_Player (objtype *ob)
- {
- extern boolean autofire;
- int angle,speed,scroll,loop;
- unsigned text,tilex,tiley;
- long lspeed;
- // boolean radar_moved=false;
- ControlMovement (ob);
- //
- // firing
- //
- if (boltsleft)
- {
- handheight+=(realtics<<2);
- if (handheight>MAXHANDHEIGHT)
- handheight = MAXHANDHEIGHT;
- ContinueBolt ();
- lasthand = lasttimecount;
- }
- else
- {
- if (control.button0)
- {
- handheight+=(realtics<<2);
- if (handheight>MAXHANDHEIGHT)
- handheight = MAXHANDHEIGHT;
- lasthand = lasttimecount;
- if (!button0down)
- Shoot();
- if (!autofire)
- button0down=true;
- }
- else
- {
- if (lasttimecount > lasthand+HANDPAUSE)
- {
- handheight-=(realtics<<1);
- if (handheight<0)
- handheight = 0;
- }
- button0down = false;
- }
- }
- #if 0
- if (control.button0)
- {
- handheight+=(realtics<<2);
- if (handheight>MAXHANDHEIGHT)
- handheight = MAXHANDHEIGHT;
- if ((unsigned)TimeCount/FIRETIME != lastfiretime)
- BuildShotPower ();
- lasthand = lasttimecount;
- }
- else
- {
- if (lasttimecount > lasthand+HANDPAUSE)
- {
- handheight-=(realtics<<1);
- if (handheight<0)
- handheight = 0;
- }
- if (gamestate.shotpower)
- {
- lastfiretime = (unsigned)TimeCount/FIRETIME;
- Shoot ();
- }
- }
- }
- #endif
- //
- // special actions
- //
- if ((Keyboard[sc_Space] || Keyboard[sc_C]) && gamestate.body != MAXBODY)
- DrinkPotion ();
- if (Keyboard[sc_Z] && !boltsleft)
- CastBolt ();
- if ( (Keyboard[sc_Enter] || Keyboard[sc_X]) && ((TimeCount-lastnuke > NUKETIME) || (autofire)))
- CastNuke ();
- #if 0
- scroll = LastScan-2;
- if ( scroll>=0 && scroll<NUMSCROLLS && gamestate.scrolls[scroll])
- ReadScroll (scroll);
- #endif
- DrawText(false);
- DrawHealth();
- if (FreezeTime)
- DrawFreezeTime();
- DrawRadar();
- EGAWRITEMODE(0);
- DrawNSEWIcons();
- if (redraw_gems)
- DrawGems();
- #if 0
- // gems fade out over time...
- //
- for (loop=0; loop<5; loop++)
- if (gamestate.gems[loop])
- {
- gamestate.gems[loop] -= realtics;
- if (gamestate.gems[loop] < 0)
- {
- gamestate.gems[loop] = 0;
- redraw_gems = true;
- }
- }
- #endif
- }
- #if 0
- //------------------------------------------------------------------------
- // FaceDir() -
- //
- // PARAMS : x,y - pixle coords to bring in to view.
- //
- // NOTE : Params CAN NOT be shifted fracs!
- //------------------------------------------------------------------------
- void FaceDir(short x,short y,boolean StopTime)
- {
- short diff;
- RotateAngle = CalcAngle(x-(player->x>>16l),(player->y>>16l)-y);
- FreezeTime = StopTime;
- diff = player->angle - RotateAngle;
- if (((diff>0) && (diff<180)) || ((diff<0) && (diff>-180)))
- RotateSpeed = -ROTATE_SPEED;
- else
- RotateSpeed = ROTATE_SPEED;
- }
- #endif
- #if 0
- //------------------------------------------------------------------------
- // CalcAngle() -
- //
- // DESC: Calculates the angle from a given dy & dx
- //------------------------------------------------------------------------
- short CalcAngle(short dx,short dy)
- {
- #define degtorad (180/PI)
- float angle;
- short diff;
- float rad_angle;
- if (dx)
- {
- angle = atan((float)dy/dx)* degtorad;
- if (angle<=0)
- angle += 180;
- if (dy>0)
- angle += 180;
- }
- else
- {
- // 90 Deg shift
- if (dy < 0)
- angle = 0 + 90; // Above player (NORTH)
- else
- angle = 180 + 90; // Below player (SOUTH)
- }
- if (!angle) // HACK
- angle++;
- return((short)abs(angle));
- }
- #endif
- #if 0
- //-------------------------------------------------------------------------
- // RotateView() -
- //
- // DESC : Rotates view (current view of game) to a dest angle.
- //-------------------------------------------------------------------------
- void RotateView()
- {
- short LastPos;
- // Store old angle position then change angle...
- //
- LastPos = player->angle;
- player->angle += RotateSpeed;
- // Check to see if we cranked past out dest angle...
- //
- if ((player->angle>ANGLES) || (!player->angle))
- player->angle = 1;
- else
- if (player->angle<1)
- player->angle = ANGLES;
- // Check to see if we over shot our dest angle...
- //
- if (((LastPos < RotateAngle) && (player->angle > RotateAngle) && (RotateSpeed > 0)) ||
- ((LastPos > RotateAngle) && (player->angle < RotateAngle) && (RotateSpeed < 0)))
- player->angle = RotateAngle;
- // Check for ending force turn....
- //
- if (player->angle == RotateAngle)
- RotateAngle = -1;
- }
- //--------------------------------------------------------------------------
- // InitRotate()
- //--------------------------------------------------------------------------
- void InitRotate(short DestAngle)
- {
- if (player->angle != DestAngle)
- {
- RotateAngle = DestAngle;
- if (player->angle > DestAngle)
- RotateSpeed = -ROTATE_SPEED;
- else
- RotateSpeed = ROTATE_SPEED;
- if (abs(player->angle - RotateAngle) > 180)
- RotateSpeed =- RotateSpeed;
- }
- }
- //------------------------------------------------------------------------
- // FaceAngle() -
- //
- // PARAMS : DestAngle - Destination angle to turn to
- //------------------------------------------------------------------------
- void FaceAngle(short DestAngle)
- {
- signed long dx,dy,radius,psin,pcos,newx,newy;
- int give;
- short objnum,LastPos;
- signed long ox,oy,xl,xh,yl,yh,px,py,norm_dx,norm_dy;
- short o_radius;
- void (*think)();
- // Calculate the direction we want to turn to...
- //
- InitRotate(DestAngle);
- RedrawStatusWindow();
- while (RotateAngle != -1)
- {
- RotateView();
- // PollControls();
- objnum=0;
- for (obj = player;obj;obj = obj->next)
- {
- if (obj->active >= yes)
- {
- // keep a list of objects around the player for radar updates
- //
- if (obj == player)
- {
- px = player->x;
- py = player->y;
- psin = sintable[player->angle];
- pcos = costable[player->angle];
- xl = px-((long)RADAR_WIDTH<<TILESHIFT)/2;
- xh = px+((long)RADAR_WIDTH<<TILESHIFT)/2-1;
- yl = py-((long)RADAR_HEIGHT<<TILESHIFT)/2;
- yh = py+((long)RADAR_HEIGHT<<TILESHIFT)/2;
- }
- if (objnum > MAX_RADAR_BLIPS-2)
- objnum = MAX_RADAR_BLIPS-2;
- ox = obj->x;
- oy = obj->y;
- if ((ox >= xl) && (ox <= xh) && (oy >= yl) && (oy <= yh))
- {
- norm_dx = (dx = px-ox)>>TILESHIFT;
- norm_dy = (dy = oy-py)>>TILESHIFT;
- o_radius = IntSqrt((norm_dx * norm_dx) + (norm_dy * norm_dy));
- if (o_radius < RADAR_RADIUS)
- {
- newx = FixedByFrac(dy,pcos)-FixedByFrac(dx,psin);
- newy = FixedByFrac(dy,psin)+FixedByFrac(dx,pcos);
- RadarXY[objnum][0]=newx>>TILESHIFT;
- RadarXY[objnum][1]=newy>>TILESHIFT;
- // Define color to use for this object...
- //
- switch (obj->obclass)
- {
- case playerobj:
- RadarXY[objnum++][2]=15;
- break;
- // RED GEM
- //
- case godessobj:
- if (gamestate.gems[B_RGEM-B_RGEM])
- if (obj->active == always)
- RadarXY[objnum++][2]=12;
- break;
- // GREEN GEM
- //
- case fatdemonobj:
- if (gamestate.gems[B_GGEM-B_RGEM])
- if (obj->active == always)
- RadarXY[objnum++][2]=10;
- break;
- // YELLOW GEM
- //
- case skeletonobj:
- if (gamestate.gems[B_YGEM-B_RGEM])
- if (obj->active == always)
- RadarXY[objnum++][2]=14;
- break;
- // BLUE GEM
- //
- case mageobj:
- case wetobj:
- if (gamestate.gems[B_BGEM-B_RGEM])
- if (obj->active == always)
- RadarXY[objnum++][2]=9;
- break;
- // PURPLE GEM
- //
- case zombieobj:
- if (gamestate.gems[B_PGEM-B_RGEM])
- if (obj->active == always)
- RadarXY[objnum++][2]=13;
- break;
- }
- }
- }
- }
- }
- RadarXY[objnum][2]=-1; // Signals end of RadarXY list...
- // refresh all
- //
- ThreeDRefresh();
- DrawRadar();
- EGAWRITEMODE(0);
- DrawNSEWIcons();
- // CheckKeys();
- }
- }
- //-------------------------------------------------------------------------
- // FaceDoor() - Turns the player to face a door (a tile) at a given TILE x & y
- //
- // RETURNS : Returns the orginal angle of the player.
- //------------------------------------------------------------------------
- short FaceDoor(short x, short y)
- {
- short p_x,p_y,angle,old_angle;
- old_angle = player->angle;
- p_x = player->x>>16l;
- p_y = player->y>>16l;
- if (p_x != x)
- {
- if (p_x > x)
- angle = 180; // Face Left
- else
- angle = 1; // Face Right
- }
- if (p_y != y)
- {
- if (p_y > y)
- angle = 90; // Face Up
- else
- angle = 270; // Face Down
- }
- FaceAngle(angle);
- return(old_angle);
- }
- #endif
- /*==========================================================================
- EXPLOSION SPAWNING ROUTINES
- ===========================================================================*/
- statetype s_explode = {0,1,T_ExpThink,&s_explode};
- //-------------------------------------------------------------------------
- // SpawnExplosion()
- //------------------------------------------------------------------------
- void SpawnExplosion(fixed x, fixed y, short Delay)
- {
- DSpawnNewObjFrac(x,y,&s_explode,PIXRADIUS*7);
- new->obclass = expobj;
- new->active = always;
- new->temp1 = Delay;
- }
- //---------------------------------------------------------------------------
- // T_ExpThink()
- //---------------------------------------------------------------------------
- void T_ExpThink(objtype *obj)
- {
- if (obj->temp1)
- {
- if ((obj->temp1-=realtics) <= 0)
- obj->temp1 = 0;
- }
- else
- {
- obj->state = &s_pshot_exp1;
- obj->ticcount = obj->state->tictime;
- SD_PlaySound(BOOMSND);
- }
- }
- //-------------------------------------------------------------------------
- // SpawnBigExplosion()
- //------------------------------------------------------------------------
- void SpawnBigExplosion(fixed x, fixed y, short Delay, fixed Range)
- {
- SpawnExplosion(x-random(Range),y+random(Range),random(Delay));
- SpawnExplosion(x+random(Range),y-random(Range),random(Delay));
- SpawnExplosion(x-random(Range),y-random(Range),random(Delay));
- SpawnExplosion(x+random(Range),y+random(Range),random(Delay));
- }
|