miscellaneous

Forum > Miscellaneous > Bots4 battle script
Reply To Thread (login)
TheElect [63]
2011-08-27 00:30:44 🔗
[13 years, 125 days ago]

Does anyone know the battle script for bots4? Im thinking of making a text based rpg for myself so im wondering if i can base my game on that

thanks


 
stewie [75]
2011-08-27 01:26:24 🔗
[13 years, 125 days ago]

its all JS. pretty basic shit. just make sure u verify it server-side


 
kenlith1 [66]
2011-08-27 01:32:34 🔗
[13 years, 125 days ago]

JS?


 
Iron [30]
2011-08-27 01:34:57 🔗
[13 years, 125 days ago]

JavaScript.


 
stewie [75]
2011-08-27 02:01:09 🔗
[13 years, 125 days ago]

learn some programming languages before developing a game (at least PHP, HTML, CSS, JS)


 
Alan [120]
2011-08-27 03:09:29 🔗
[13 years, 125 days ago]

The javascript part is not what you want to run your game on.
Use MySQL + PHP to save all users data.
Have PHP run the battle code, send it to Javascript to sort it out and output it.

Here is a basic battle code

if(your_hitchance > rand(0,100)) {
     if(their_block < rand(0,100)) {
         damage = rand(your_min,your_max)
         thier_hp -= damage
         "You hit for ".damage." dmg";
     }
     else { "they blocked!"; }
  } else { "You missed!"; }

then, check if they have a shield/your second hit. and repeat for the next person.

I could go into more detail, but that's no fun for you :)

-Alan


 
stewie [76]
2011-08-27 03:16:28 🔗
[13 years, 125 days ago]

u are mistaking = for ==


 
Alan [120]
2011-08-27 03:17:51 🔗
[13 years, 125 days ago]

I have no conditions in there that require '=='.

I only used '=' twice, once for declaration of a the "damage" variable and one to minus the "damage" off of "their_hp".


 
stewie [76]
2011-08-27 03:22:25 🔗
[13 years, 125 days ago]

hang on, ill write something up


 
stewie [76]
2011-08-27 03:28:02 🔗
[13 years, 125 days ago]

this would be better

<?php
function attack($min, $max, $chance, $block, $theirhp) {
    if($chance > rand(0,100)) {
        if($block < rand(0,100)) {
            $damagehit == rand($min,$max);
            $hpleft - damage;
            echo "You hit for $damage dmg. They have $hpleft HP left.";
        }
        else {
            echo 'you where blocked!';
        }
    }
}

echo attack(150, 500, 74, 12, 750);
?>

 
Alan [120]
2011-08-27 03:35:07 🔗
[13 years, 125 days ago]

$damage == ?

Huh?

Also, that would work if you had it all set up in a loop and crap.

That is hard though to figure out the winner if you are switching names for the "attacker" and "defender" for code space.

I mean, I know PHP, I was just giving a rough sketch haha.


 
stewie [76]
2011-08-27 03:38:18 🔗
[13 years, 125 days ago]

yeah, my code wouldn't return anything. but its a ruff idea on using a function


 
stewie [76]
2011-08-27 03:41:12 🔗
[13 years, 125 days ago]

working code: http://codepad.org/GAnlwrf7


 
TheElect [63]
2011-08-27 03:48:06 🔗
[13 years, 125 days ago]

Well im 13 and a beginner i know basic javascript, (arrays, loops, functions etc) and i use html im currently trying to learn more javascript


 
Alan [120]
2011-08-27 03:52:14 🔗
[13 years, 125 days ago]

Try to make some "games" with javascript first.

Like, Hangman, Tic-tac-toe, maybe even a basic map that you can "walk" around on.

Then, head onto PHP + MySQL. They will become your best friends.


 
stewie [76]
2011-08-27 03:54:39 🔗
[13 years, 125 days ago]

make a JS guessing game.

input is in a form. u click submit and it tells you if your too high/too low


 
Alan [120]
2011-08-27 03:57:15 🔗
[13 years, 125 days ago]

This is how my path went

  • HTML, with prompts and crap
  • PHP, basic adding
  • MySql, with my first user database. Man that was a fun time.
  • CSS, just basic style sheets
  • more PHP, I couldn't wrap my mind around javascript, No $ for variables and stuff.
  • Javascript, a password protected page on vacation in the airport was my first page of JS.
  • Combining JS + PHP + MySQL into a very basic Bots replica called "Final stage".
  • Ajax, cool stuff.
  • JQuery, for making nifty javascript attachments
  • Java, hah. I failed at that.
  • C++, that was a bitch to learn.
  • Lua, I had fun with that one. actually My last language I have learnt.

 
stewie [76]
2011-08-27 03:58:33 🔗
[13 years, 125 days ago]

http://codepad.org/AwcXAzCc <-- alerts if you miss


 
stewie [76]
2011-08-27 03:59:33 🔗
[13 years, 125 days ago]

@Alan

JS password protection do not work.


 
Alan [120]
2011-08-27 04:00:42 🔗
[13 years, 125 days ago]

^ Duh. haha....

That was just my first JS thing.


 
stewie [76]
2011-08-27 04:03:24 🔗
[13 years, 125 days ago]

i started with cryptography and bash scripts (linux shell <3) then got into html and other markup languages. then php, loved php and stuck with it. never really bothered with JS but i know basics. now PHP security/hacking(white hat) is a hobby. i have gotten into many areas with JS password protection.


 
TheElect [63]
2011-08-27 04:05:10 🔗
[13 years, 125 days ago]

crap this involves patience...


 
stewie [76]
2011-08-27 04:07:16 🔗
[13 years, 125 days ago]

patience is good


 
TheElect [63]
2011-08-27 04:12:55 🔗
[13 years, 125 days ago]

Im a teenager i dont understand patience xD


 
Necro [76]
2011-08-27 04:14:58 🔗
[13 years, 125 days ago]

All good things are worth waiting for ;)

I'm more of a stand-alone language guy

C++, C#, Perl, Ruby, python

Isn't worth a damn though xD


 
stewie [76]
2011-08-27 04:15:08 🔗
[13 years, 125 days ago]

shit happens


 
dracula [20]
2011-08-27 04:17:25 🔗
[13 years, 125 days ago]

don't swear !!!!!!!!


 
Necro [76]
2011-08-27 04:19:30 🔗
[13 years, 125 days ago]

COME AT ME BRO!!!


 
stewie [77]
2011-08-27 04:19:54 🔗
[13 years, 125 days ago]

haha


 
Ender [1]
Administrator
2011-08-27 08:59:14 🔗
[13 years, 125 days ago]

Here's the main bots4 battle code:

http://pastebin.com/dQ3hwygy

This is obviously just one way of doing it. I don't claim it to be the best or anything, but I'm a fan of object-oriented programming so that's the way I write.

Note that it's not complete in that it relies on other classes that aren't shown, but you should be able to get the main idea of what's involved.


 
Metal [26]
2011-08-31 03:00:43 🔗
[13 years, 121 days ago]

Very useful thread


 
TheElect [35]
2014-10-04 07:50:58 🔗
[10 years, 86 days ago]

o.o Oh thanks guys, unfortunately I stopped playing before seeing the rest of the thread replies. I ended up familiarising myself with most of the languages mentioned above and ended up making a few crappy text based games in my spare time. The only problem with them was (well, the only problem besides my interesting CSS) the game formulas. I considered using some of bots' formulas, but don't really want to copy them :s. If I were to create my own formulas, are there any guidelines I should follow? I really dont know where to start... atm, I have crazy exponentials that dont match up with the shop prices or anything else at all :p.


 
Ender [1]
Administrator
2014-10-04 10:23:10 🔗
[10 years, 86 days ago]

Don't worry about borrowing formulas/ideas from other games. I certainly had no qualms. :)

If you really want to make your own formulas, I like to create a spreadsheet to graph it and see how various tweaks affect it. Some basic math knowledge helps, e.g. knowing the difference between how linear and exponential formulas scale for larger values. In general I find it more of a guess-and-check art than a well defined science.

Also, that code I posted is a total clusterfuck and should not be looked to for inspiration. :\


 
TheElect [35]
2014-10-05 02:35:13 🔗
[10 years, 85 days ago]

Ah ok, I figured that it would be a guess and check process. Knowing my patience, I'll probably end up borrowing some formulas :p

Haha, alright. I actually thought that it was amazing compared to my code xD - guess that shows I need more practice. Cheers for the help Ender.


 
Ender [1]
Administrator
2014-10-05 06:50:50 🔗
[10 years, 85 days ago]

I've found that as a programmer, you're always looking back at code you wrote even just 6 months ago and wondering what the hell you were doing. It's a neverending learning process and you'll be continuously iterating on the way you approach problems and design solutions. I've been doing this for around a decade now (several years professionally) and that's always been a constant.


 
Trio [356]
2014-10-05 07:40:07 🔗
[10 years, 85 days ago]

It's always best if you're continually improving your skill. How boring would work be if you weren't trying to pick something out that you learned and then apply it.


 
TheElect [35]
2014-10-05 22:46:45 🔗
[10 years, 85 days ago]

Hmm, I can definitely relate to that. Figuring out different ways to do things really adds fun to programming (heh, for me anyway). Although, I thought that eventually you would reach a point where you just stick to certain ways of doing things because they just work so well, but I guess that isn't really the case >> (Right?).


 
Ender [1]
Administrator
2014-10-07 00:43:37 🔗
[10 years, 83 days ago]

If that does eventually happen, it hasn't happened to me yet. :)


 
Forum > Miscellaneous > Bots4 battle script
Reply To Thread (login)