Make your own free website on Tripod.com
') 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(' hymn@webtv.net 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 pickup(item) { if (item == "bomb") {alert("bomb picked up"); return} 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 (item == "axe") {newRisk = axeRISK}; if (item == "sword") {newRisk = swordRISK}; if (item == "spear") {newRisk = spearRISK}; if (item == "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++; return} if (confirm("do you want the point added to agility?") == true) {agility++; return} if (confirm("do you want the point added to perception?") == true) {perception++; return} if (confirm("do you want the point added to mentality?") == true) {mentality++; return} fillForms() } //--All copies must include this message //- Permission is granted to reproduce //- for non-commercial use only. //- original by hymn@webtv.net //- http://members.tripod.com/~AO //---CUT & PASTE DATA BELOW--- heroPos=24; heroSprite="hero.jpg"; desc[0]="altar"; sprite[0]="altar.jpg"; damAcc[0]=0; speed[0]=0; size[0]=0; goal[0]=-99; iq[0]=0; priority[0]=0; blocking[0]=0; mobile[0]=0; location[0]=0; desc[1]="skeleton"; sprite[1]="skeleton.jpg"; damAcc[1]=0; speed[1]=8; size[1]=2; goal[1]=-99; iq[1]=4; priority[1]=1; blocking[1]=0; mobile[1]=8; location[1]=4; desc[2]="sword"; sprite[2]="sword.jpg"; damAcc[2]=0; speed[2]=0; size[2]=0; goal[2]=-99; iq[2]=0; priority[2]=0; blocking[2]=0; mobile[2]=0; location[2]=8; desc[3]="skeleton"; sprite[3]="skeleton.jpg"; damAcc[3]=0; speed[3]=8; size[3]=2; goal[3]=-99; iq[3]=4; priority[3]=1; blocking[3]=0; mobile[3]=8; location[3]=22; 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]=23; 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]=25; desc[6]="skeleton"; sprite[6]="skeleton.jpg"; damAcc[6]=0; speed[6]=8; size[6]=2; goal[6]=-99; iq[6]=4; priority[6]=1; blocking[6]=0; mobile[6]=8; location[6]=26; 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]=33; 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]=35; desc[9]="altar"; sprite[9]="altar.jpg"; damAcc[9]=0; speed[9]=0; size[9]=0; goal[9]=-99; iq[9]=0; priority[9]=0; blocking[9]=0; mobile[9]=0; location[9]=41; desc[10]="skeleton"; sprite[10]="skeleton.jpg"; damAcc[10]=0; speed[10]=8; size[10]=2; goal[10]=-99; iq[10]=4; priority[10]=1; blocking[10]=0; mobile[10]=8; location[10]=44; desc[11]="altar"; sprite[11]="altar.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]=50; desc[12]="altar"; sprite[12]="altar.jpg"; damAcc[12]=0; speed[12]=0; size[12]=0; goal[12]=-99; iq[12]=0; priority[12]=0; blocking[12]=0; mobile[12]=0; location[12]=58; itemsTotal=12; function contact(phasing, obstacle) {if (phasing=="hero" || obstacle=="hero") {if (obstacle=="hero") {obstacle=phasing; phasing="hero"} if (obstacle==0) {oblit(obstacle); altar()} if (obstacle==1) {combat(obstacle); oblit(obstacle); } if (obstacle==2) {oblit(obstacle); pickup("sword")} if (obstacle==3) {combat(obstacle); oblit(obstacle); } if (obstacle==6) {combat(obstacle); oblit(obstacle); } if (obstacle==9) {oblit(obstacle); altar()} if (obstacle==10) {combat(obstacle); oblit(obstacle); } if (obstacle==11) {oblit(obstacle); altar()} if (obstacle==12) {oblit(obstacle); altar()} } else {}} makePage("bg-forest.gif") //-ready to cut and paste //---CUT AND PASTE DATA ABOVE---