chrismiceli
09-20-2002, 01:48 AM
if you like rpgs this is a cool script, the reason for the speed thing is to see how many turns you get, the enemy only gets one. You can edit it for your own porpuses but give me credit if you use it. You have to roll a three or above to attack.
<html>
<head>
<title>test</title>
<script language="javascript">
function stats() {
spd = prompt("Please enter your speed", "Enter your speed");
spd0 = spd;
}
function di() {
var ran_num = Math.round(5*Math.random()) + 1;
document.form1.res.value = ran_num;
if (document.form1.res.value > 3) {
var ran_num0 = Math.round(5*Math.random()) + 1;
document.form1.res0.value = ran_num0}
else document.form1.res0.value = "0";
document.form1.put.disabled=true;
}
function di0() {
var ran_num = Math.round(5*Math.random()) + 1;
document.form1.edmg.value = ran_num;
if (document.form1.edmg.value > 3) {
var ran_num0 = Math.round(5*Math.random()) + 1;
document.form1.edmg0.value = ran_num0}
else document.form1.edmg0.value = "0";
document.form1.edi.disabled=true
document.form1.hit0.disabled=false;
}
function dmg() {
--spd0;
var fh = document.form1.foehealth.value;
document.form1.foehealth.value = fh - document.form1.res0.value;
document.form1.foehealth.value = fh - document.form1.res0.value
if (spd0 <= 0) {
document.form1.hit.disabled=true;
document.form1.edi.disabled=false;
}
document.form1.res.value = "";
document.form1.res0.value = "";
document.form1.put.disabled=false;
if (document.form1.foehealth.value <= 0) {
alert("You have won!")}
}
function dmg0() {
var yh = document.form1.edmg0.value * 2;
var yh0 = document.form1.yhealth.value
document.form1.yhealth.value = yh0 - yh
document.form1.hit0.disabled=true;
document.form1.edmg.value = "";
document.form1.edmg0.value = "";
document.form1.hit.disabled=false
spd0 = spd;
if (document.form1.yhealth.value <= 0) {
alert("You have lost.")};
}
</script>
</head>
<body onLoad="stats()">
<form name="form1">
Your Health:<br>
<input type="text" name="yhealth" onfocus="document.form1.hit.focus()" size="12" value="500"><p>
<input type="text" name="res" onfocus="document.form1.hit.focus()"size="2" value="">
Roll to see if you will hit.<br>
<input type="text" name="res0" onfocus="document.form1.hit.focus()" size="2" value="">
You will deal this much damage.<br>
<input type="button" name="put" value="Roll Dice" onClick="di()"><p>
<input type="button" name="hit" value="Attack!" onClick="dmg()"><p><p>
<hr width="25%" align="left">
Enemy's Health:<br>
<input type="text" name="foehealth" onfocus="document.form1.hit.focus()" size="12" value="500"><p>
<input type="text" name="edmg" onfocus="document.form1.hit.focus()" size="2" value="">
Roll to see if the enemy will hit you.<br>
<input type="text" name="edmg0" onfocus="document.form1.hit.focus()" size="2" value="">
The enemy will deal this much damage <b>two times</b>.<br>
<input type="button" name="edi" value="Roll Dice" onClick="di0()"><p>
<input type="button" name="hit0" value="Attack!" onClick="dmg0()">
<body>
</form>
</form>
</body>
</html>
<html>
<head>
<title>test</title>
<script language="javascript">
function stats() {
spd = prompt("Please enter your speed", "Enter your speed");
spd0 = spd;
}
function di() {
var ran_num = Math.round(5*Math.random()) + 1;
document.form1.res.value = ran_num;
if (document.form1.res.value > 3) {
var ran_num0 = Math.round(5*Math.random()) + 1;
document.form1.res0.value = ran_num0}
else document.form1.res0.value = "0";
document.form1.put.disabled=true;
}
function di0() {
var ran_num = Math.round(5*Math.random()) + 1;
document.form1.edmg.value = ran_num;
if (document.form1.edmg.value > 3) {
var ran_num0 = Math.round(5*Math.random()) + 1;
document.form1.edmg0.value = ran_num0}
else document.form1.edmg0.value = "0";
document.form1.edi.disabled=true
document.form1.hit0.disabled=false;
}
function dmg() {
--spd0;
var fh = document.form1.foehealth.value;
document.form1.foehealth.value = fh - document.form1.res0.value;
document.form1.foehealth.value = fh - document.form1.res0.value
if (spd0 <= 0) {
document.form1.hit.disabled=true;
document.form1.edi.disabled=false;
}
document.form1.res.value = "";
document.form1.res0.value = "";
document.form1.put.disabled=false;
if (document.form1.foehealth.value <= 0) {
alert("You have won!")}
}
function dmg0() {
var yh = document.form1.edmg0.value * 2;
var yh0 = document.form1.yhealth.value
document.form1.yhealth.value = yh0 - yh
document.form1.hit0.disabled=true;
document.form1.edmg.value = "";
document.form1.edmg0.value = "";
document.form1.hit.disabled=false
spd0 = spd;
if (document.form1.yhealth.value <= 0) {
alert("You have lost.")};
}
</script>
</head>
<body onLoad="stats()">
<form name="form1">
Your Health:<br>
<input type="text" name="yhealth" onfocus="document.form1.hit.focus()" size="12" value="500"><p>
<input type="text" name="res" onfocus="document.form1.hit.focus()"size="2" value="">
Roll to see if you will hit.<br>
<input type="text" name="res0" onfocus="document.form1.hit.focus()" size="2" value="">
You will deal this much damage.<br>
<input type="button" name="put" value="Roll Dice" onClick="di()"><p>
<input type="button" name="hit" value="Attack!" onClick="dmg()"><p><p>
<hr width="25%" align="left">
Enemy's Health:<br>
<input type="text" name="foehealth" onfocus="document.form1.hit.focus()" size="12" value="500"><p>
<input type="text" name="edmg" onfocus="document.form1.hit.focus()" size="2" value="">
Roll to see if the enemy will hit you.<br>
<input type="text" name="edmg0" onfocus="document.form1.hit.focus()" size="2" value="">
The enemy will deal this much damage <b>two times</b>.<br>
<input type="button" name="edi" value="Roll Dice" onClick="di0()"><p>
<input type="button" name="hit0" value="Attack!" onClick="dmg0()">
<body>
</form>
</form>
</body>
</html>