12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350 |
- /* Catacomb Apocalypse 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 1
- #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 30
- #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()
- {
- short temp = fontcolor;
- long percentage;
- percentage = PERCENTAGE(100,MAXFREEZETIME,(long)FreezeTime,7);
- fontcolor = 1 ^ 14;
- DrawNum(23,70,percentage,3);
- fontcolor = temp;
- }
- //===========================================================================
- /*
- ===============
- =
- = 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];
- if (text[0] == '@')
- {
- bordertime = 20;//FLASHTICS;
- bcolor = 15;
- VW_ColorBorder (15 | 56);
- text++;
- }
- _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*2);
- 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)
- {
- 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)
- {
- 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;
- 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 44:
- playstate = ex_victorious;
- break;
- case 17:
- case 30:
- case 31:
- case 35:
- case 46:
- case 47:
- case 48:
- case 49:
- case 57:
- case 58:
- case 71:
- case 85:
- case 94:
- 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_OLDCHEST:
- 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);
- }
- 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:
- if (ob->obclass == pshotobj)
- 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
- //
- // STOMPY (DK RED)
- //
- case invisdudeobj:
- case stompyobj:
- RadarXY[objnum++][2]=4;
- break;
- // BLOB (LT RED)
- //
- case blobobj:
- RadarXY[objnum++][2]=12;
- break;
- // BLUE GEM
- //
- // ROBOTANK (LT BLUE)
- //
- case robotankobj:
- case fmageobj:
- RadarXY[objnum++][2]=9;
- break;
- #if 1
- // BLUE DEMON (DK BLUE)
- //
- case demonobj:
- RadarXY[objnum++][2]=1;
- break;
- #endif
- // GREEN GEM
- //
- // WIZARD (LT GREEN)
- //
- case wizardobj:
- RadarXY[objnum++][2]=10;
- break;
- // AQUA MAN (DK GREEN)
- //
- case aquamanobj:
- RadarXY[objnum++][2]=2;
- break;
- // YELLOW GEM
- //
- // EQYPTIAN HEAD (BROWN)
- //
- case headobj:
- RadarXY[objnum++][2]=6;
- break;
- // RAMBONE (YELLOW)
- // TROLL
- case ramboneobj:
- case trollobj:
- RadarXY[objnum++][2]=14;
- break;
- // BUG (LIGHT GRAY)
- case bugobj:
- RadarXY[objnum++][2]=7;
- break;
- // RAY (DARK GRAY)
- case rayobj:
- RadarXY[objnum++][2]=8;
- break;
- // PURPLE GEM
- //
- // MEC DEMON (PURPLE)
- //
- case cyborgdemonobj:
- RadarXY[objnum++][2]=5;
- break;
- // EYE (LT PURPLE)
- //
- case eyeobj:
- case reyeobj:
- 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));
- }
|