Make your own free website on
') document.write('
') nexttable='
'; document.write(nexttable); //-DRAW THE MAP i=0; while (i < 59) { for (h=0; h < 9; h++) { document.write(''); i++ } h=0; i++; document.write("
") } document.write('
'); //-DRAW HERO document.images[lToI(heroPos)].src = heroSprite; //-DRAW ITEMS for (m=0; m<=itemsTotal; m++) document.images[lToI(location[m])].src = sprite[m]; //-CREDITS document.write(' Fantastic Gateway The DungeonPager
') //-CONTROLS document.write('
') } // -rewrite the status bar with selected info function fillForms() { list = document.look.whichLook; lookAt = list.options[list.selectedIndex].text; if (lookAt == "Physique") displayString = "Physique "+nToG(phyStat, physique); if (lookAt == "Agility") displayString = "Agility "+nToG(agiStat, agility); if (lookAt == "Mentality") displayString = lookAt+"="+mentality; if (lookAt == "Risk") displayString = lookAt+"="+risk; if (lookAt == "Perception") displayString = lookAt+"="+perception; if (lookAt == "Social Status") displayString = "SocialStatus "+nToG(socStat, socStat); if (lookAt == "Health") {displayString = "A"+nToG(agiStat, agility); displayString += " P"+nToG(phyStat, physique); displayString += " S("+socStat+")"; displayString += nToG(socStat, socStat)} if (lookAt == "Amber") displayString = lookAt+"="+amber; status = displayString; return true } // - construct an ascii-graphic from numeric stats for status // - bar display function nToG(curr, maxi) { statGraph=""; for (i=0; i=0; p--) for (s=0; sstrength || speed[m]>agility && intelligence[ // >dexterity if (intelligence[m]>mentality))) //-------- WORK OUT CONTACTS for (m=0; m<=itemsTotal; m++) if (moveTo == location[m]) contact("hero", m); //-EXECUTE MOVE IF LEGAL if (validMove==false) {movementLoop(); return} document.images[lToI(heroPos)].src = oldSprite(heroPos); heroPos = moveTo //-MOVE MONSTERS movementLoop(); document.images[lToI(heroPos)].src = "hero.jpg"; fillForms(); } function movementLoop() { for (t=0; t<=itemsTotal; t++) if (location[t]>=0 && mobile[t]!=0) {active=t; monMove()} } // conduct a monster movement routine function monMove() { if (location[active]<0) return; validMove = true //-GENERATE RANDOM MOVE moveTo = smartMove(); //-CHECK FOR LEGAL MOVE if (moveTo<0 || moveTo>58) return; if (moveTo==9 || moveTo==19 || moveTo==29 || moveTo==39 || moveTo==49) return; //-CHECK FOR PASSABILITY for (p=0; p<=itemsTotal; p++) if (moveTo == location[p] && blocking[p]!=0) return; // check for items for (p=0; p<=itemsTotal; p++) if (moveTo == location[p]) contact(active, p); if (validMove == false) return; //-perform move temp = location[active]; location[active] = moveTo; document.images[lToI(temp)].src = oldSprite(temp); document.images[lToI(moveTo)].src = sprite[active] //-CHECK FOR HERO COLLISIONS if (moveTo == heroPos) contact(active, "hero"); //-CHECK FOR ITEM COLLISIONS } // move monster toward the predetermined target function smartMove() { position=location[active] news = Math.floor(Math.random()*(iq[active]+3)) // - random direction if (news<1) return position-1; if (news==1) return position+1; if (news==2) return position-10; if (news==3) return position+10; // - use AI if number is over3 posTens = Math.floor(position/10); posOnes = position-posTens*10 if (goal[active] == -99) currentGoal=heroPos; else currentGoal = goal[active] tarTens = Math.floor(currentGoal/10); tarOnes = currentGoal-tarTens*10; if (posTens == tarTens && posOnes == tarOnes) {goal[active] = -99; return position+1} if (Math.random()<.5) { if (posTens < tarTens) return position+10; if (posTens > tarTens) return position-10; if (posOnes < tarOnes) return position+1; if (posOnes > tarOnes) return position-1; } else { if (posOnes < tarOnes) return position+1; if (posOnes > tarOnes) return position-1; if (posTens < tarTens) return position+10; if (posTens > tarTens) return position-10; } } power=0 // -- randomise combat function combat(mon) { magMod = power - Math.floor(Math.random()*iq[mon]); if (magMod<=0) magMod=0; monRoll = Math.round(speed[mon]*(Math.random()+Math.random())/2) - damAcc[mon]; heroRoll = Math.round(Math.random()*risk+Math.random()*risk); if (heroRoll > risk) heroRoll = risk; dam = size[mon]+monRoll-magMod-heroRoll; damage(dam); } // divvy combat or other damage among hero stats function damage(ouch) { if (ouch <= 0) {alert("no damage"); return} alert("you are hit for "+ouch+" damage"); if (agiStat-ouch < 0) {ouch -= agiStat; agiStat = 0} else {agiStat-=ouch; ouch = 0} if (phyStat-ouch< 0) {ouch -= phyStat; phyStat = 0} else {phyStat-=ouch; ouch = 0} socStat -= ouch; agiStat = 0; if (socStat < 1) {alert("you die"); document.location=document.location} fillForms(); return false } // randomise heal results and apply to hero stats function heal() { if (phyStat < physique) { roll = Math.round(Math.random()*5)+1 result = "you feel no better than before" if (roll <= physique) {result = "you heal one physique point"; phyStat++} alert(result) } fillForms(); } // conduct bow attack function bow(targ) { tarTens = Math.floor(targ/10); tarOnes = targ - tarTens*10; heroTens = Math.floor(heroPos/10); heroOnes = heroPos - heroTens*10; xDist = Math.abs(tarTens-heroTens); yDist = Math.abs(tarOnes-heroOnes); if (xDist>yDist) dist=xDist; else dist=yDist; if (dist>perception) {alert("it is too far for your bow"); return} for (m=0; m<=itemsTotal; m++) if (location[m]==targ) if (Math.random()>.5) { damAcc[m]-=perception; alert("A hit!"); goal[m]=-99; } else alert("You miss") } // conduct magic attack function magic() { if (amber < 1) {alert("You are out of amber"); return} amber--; power = Math.floor(Math.random()*mentality); alert("Risk will be +"+power+" for the remainder of the battle"); } // calculate risk for new weapon function calcRISK(weapon) { var phy=physique; var agi=agility; per=perception; var men=mentality; if (phy < agi/2) phy = agi/2; axeRISK = Math.round(phy*1); spearRISK = Math.round(agi/3 + phy/3 + 1); if (agi < phy/2) agi = phy/2; swordRISK = Math.round(agi*1); shtswdRISK = Math.round(phy/4 + agi/4 + per/4 + men/4 + .5); if (weapon == "axe") {newRisk = axeRISK}; if (weapon == "sword") {newRisk = swordRISK}; if (weapon == "spear") {newRisk = spearRISK}; if (weapon == "shortsword") {newRisk = shtswdRISK}; if (newRisk > risk) {risk = newRisk; alert("your risk is now "+risk)} else alert("this weapon is not as good as your present one"); } // go through expertise routine function altar() { alert("you have earned an expertise point") if (confirm("do you want the point added to physique?") == true) {physique++; location[active] = -99; return} if (confirm("do you want the point added to agility?") == true) {agility++; location[active] = -99; return} if (confirm("do you want the point added to perception?") == true) {perception++; location[active] = -99; return} if (confirm("do you want the point added to mentality?") == true) {mentality++; location[active] = -99; return} fillForms() } //--All copies must include this message //- Permission is granted to reproduce //- for non-commercial use only. //- original by //- //---CUT & PASTE DATA BELOW--- heroPos=0; heroSprite="hero.jpg"; desc[0]="wall"; sprite[0]="wall.jpg"; damAcc[0]=0; speed[0]=0; size[0]=8; goal[0]=-99; iq[0]=1; priority[0]=0; blocking[0]=8; mobile[0]=0; location[0]=3; desc[1]="wall"; sprite[1]="wall.jpg"; damAcc[1]=0; speed[1]=0; size[1]=8; goal[1]=-99; iq[1]=1; priority[1]=0; blocking[1]=8; mobile[1]=0; location[1]=13; desc[2]="bloodknight"; sprite[2]="bloodknight.jpg"; damAcc[2]=0; speed[2]=10; size[2]=3; goal[2]=-99; iq[2]=2; priority[2]=1; blocking[2]=0; mobile[2]=10; location[2]=22; desc[3]="wall"; sprite[3]="wall.jpg"; damAcc[3]=0; speed[3]=0; size[3]=8; goal[3]=-99; iq[3]=1; priority[3]=0; blocking[3]=8; mobile[3]=0; location[3]=23; desc[4]="wall"; sprite[4]="wall.jpg"; damAcc[4]=0; speed[4]=0; size[4]=8; goal[4]=-99; iq[4]=1; priority[4]=0; blocking[4]=8; mobile[4]=0; location[4]=30; desc[5]="wall"; sprite[5]="wall.jpg"; damAcc[5]=0; speed[5]=0; size[5]=8; goal[5]=-99; iq[5]=1; priority[5]=0; blocking[5]=8; mobile[5]=0; location[5]=33; desc[6]="wall"; sprite[6]="wall.jpg"; damAcc[6]=0; speed[6]=0; size[6]=8; goal[6]=-99; iq[6]=1; priority[6]=0; blocking[6]=8; mobile[6]=0; location[6]=34; desc[7]="wall"; sprite[7]="wall.jpg"; damAcc[7]=0; speed[7]=0; size[7]=8; goal[7]=-99; iq[7]=1; priority[7]=0; blocking[7]=8; mobile[7]=0; location[7]=35; desc[8]="wall"; sprite[8]="wall.jpg"; damAcc[8]=0; speed[8]=0; size[8]=8; goal[8]=-99; iq[8]=1; priority[8]=0; blocking[8]=8; mobile[8]=0; location[8]=36; desc[9]="wall"; sprite[9]="wall.jpg"; damAcc[9]=0; speed[9]=0; size[9]=8; goal[9]=-99; iq[9]=1; priority[9]=0; blocking[9]=8; mobile[9]=0; location[9]=37; desc[10]="wall"; sprite[10]="wall.jpg"; damAcc[10]=0; speed[10]=0; size[10]=8; goal[10]=-99; iq[10]=1; priority[10]=0; blocking[10]=8; mobile[10]=0; location[10]=38; desc[11]="sword"; sprite[11]="sword.jpg"; damAcc[11]=0; speed[11]=0; size[11]=0; goal[11]=-99; iq[11]=0; priority[11]=0; blocking[11]=0; mobile[11]=0; location[11]=40; desc[12]="bloodknight"; sprite[12]="bloodknight.jpg"; damAcc[12]=0; speed[12]=10; size[12]=3; goal[12]=-99; iq[12]=2; priority[12]=1; blocking[12]=0; mobile[12]=10; location[12]=45; desc[13]="altar"; sprite[13]="altar.jpg"; damAcc[13]=0; speed[13]=0; size[13]=0; goal[13]=-99; iq[13]=0; priority[13]=0; blocking[13]=0; mobile[13]=0; location[13]=50; desc[14]="bloodknight"; sprite[14]="bloodknight.jpg"; damAcc[14]=0; speed[14]=10; size[14]=3; goal[14]=-99; iq[14]=2; priority[14]=1; blocking[14]=0; mobile[14]=10; location[14]=55; desc[15]="castle"; sprite[15]="castle.jpg"; damAcc[15]=0; speed[15]=8; size[15]=8; goal[15]=-99; iq[15]=8; priority[15]=1; blocking[15]=0; mobile[15]=0; location[15]=58; itemsTotal=15; function contact(phasing, obstacle) {if (phasing=="hero" || obstacle=="hero") {if (obstacle=="hero") {obstacle=phasing; phasing="hero"} if (obstacle==2) {alert(unescape("Going%20to%20Corum%3F%20I%20think%20not%21")); combat(obstacle); oblit(obstacle); } if (obstacle==11) {oblit(obstacle); calcRisk("sword")} if (obstacle==12) {alert(unescape("you%20shall%20go%20no%20further%21")); combat(obstacle); oblit(obstacle); } if (obstacle==13) {oblit(obstacle); altar()} if (obstacle==14) {alert(unescape("Halt%20I%20say%21")); combat(obstacle); oblit(obstacle); } if (obstacle==15) {newScreen("sample28.html"); } } else {}} makePage("bg-forest.gif") //-ready to cut and paste //---CUT AND PASTE DATA ABOVE---