Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Javascript Battle Script Help

Status
Not open for further replies.
Joined
Sep 30, 2010
Messages
4
Reaction score
0
Ok, so I am in need of some major help. I have a basic knowledge in javascript plus some. I am wanting to make a generator/game button that will allow for two players to input their information(damage, health points, etc) and select whose attacking and whose defending. Using that information, the generator uses its functions to decide the damage taken, or if the defender avoided the attack.
This is to help my forum to replace the dice system which gets very ugly sometimes. Honestly, I need to know where to start and other essential information. I can give more details if you need.

Thanks,
Chris Hickingbottom


Edit::

Ok, sorry about that. I should have definitely put more information. Well, I thought to myself, "hey lets start with something simple." So, I tried to create an Earned Exp. Generator. I certainly don't think its working.

<html>

<head>

<title>Earned Experience Generator</title>
<script type="text/javascript">
var level=prompt("Place your Level Here");
var a=level;
function writeRand() {
document.write(Math.ceil(Math.random()*101));
}
function writeA() {
document.write(writeRand()*a);
}
</script>
</head>
<body>
<a href="javascript:writeA()">Experience Calculator</a><br />
</body>

</html>
 
Last edited:
Joined
Sep 10, 2006
Messages
2,817
Reaction score
1,417
this.
section rules said:
4. Include enough information
Make sure you paste relevant code, indicate what you tried already, etc. If we have to guess what help you want it'll take a lot longer before we can help you!

5. Don't just dump your problem and hope we sort it out for you!
Coders section is not a general 'I need something fixed so lets ask you guys to fix it for me' forum! If you have a specific problem, for instance a typecast that's giving you trouble or a regex that's not working correctly, feel free to ask. But do not dump here 50 lines of code with the message 'its not working, fix please', or expect us to write your scripts for you!
 
Joined
Sep 30, 2010
Messages
4
Reaction score
0
Ok,so I fixed the above above generator by doing this.
Code:
<html>

<head>
<title>Random Number</title>
<script type="text/javascript">
var A= Math.round(Math.random()*100);

var B= prompt('Place your Level Here');

function Expearned()
{
document.write(Exp=B*A);
document.write(" Experience Points Earned");
}

</script>
</head>
<body>
<a href="javascript:Expearned()">Experience Calculator</a><br />
</body>
</html>

That works, but... I am wanting somewhere along the lines of the input being on the page rather than a prompt. So, I tried this:

Code:
<html>

<head>
<title>Experience Generator</title>
<script type="text/javascript">
var A= Math.round(Math.random()*100);

var B= input.text();

function Expearned()
{
document.write(Exp=B*A);
document.write(" Experience Points Earned");
}

</script>
</head>
<body>
<FORM ACTION="#" NAME=LeveltoExp>
Enter Celsius
<INPUT TYPE=TEXT NAME="Enter Level" SIZE=3>
<BR><BR>
<INPUT TYPE=BUTTON VALUE="Earn Experience"
ONCLICK=" Expearned()
  + 'is '
  + ' Experienced Earned'">
<BR><BR>
<TEXTAREA NAME=Resultexp COLS=30 ROWS=2 DISABLED>
</TEXTAREA>
</FORM>
</body>
</html>

But it came up as an error for the var B= input.text(); part. Any suggestions or ideas to fix this?
 
Last edited:
Joined
Sep 30, 2010
Messages
4
Reaction score
0
I have solved this. Here is the resulting code:

Code:
<html>
<head>
<title>Experience Generator</title>
<script type="text/javascript">
function Expearned()
{
var A= Math.round(Math.random()*100);

var B= document.formselect.numbers.value;
document.getElementById("myDiv").innerHTML = B*A + ' Experience Points Earned';

}
</script>
</head>
<body>
<form name='formselect'>
<select name='numbers' > <option value=1 selected>One</option> <option value=2>Two</option> <option value=3>Three</option> <option value=4>Four</option> <option value=5>Five</option> </select> 
<BR><BR>
<INPUT TYPE='button' VALUE="Earn Experience" onclick='Expearned()'>
<BR><BR>
</form>
<div id='myDiv'></div>
</body>
</html>
 
Last edited:
Status
Not open for further replies.
Back
Top