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
|
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 |
|
its all JS. pretty basic shit. just make sure u verify it server-side |
|
JS? |
|
JavaScript. |
|
learn some programming languages before developing a game (at least PHP, HTML, CSS, JS) |
|
The javascript part is not what you want to run your game on. 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 |
|
u are mistaking = for == |
|
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". |
|
hang on, ill write something up |
|
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); ?> |
|
$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. |
|
yeah, my code wouldn't return anything. but its a ruff idea on using a function |
|
working code: http://codepad.org/GAnlwrf7 |
|
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 |
|
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. |
|
make a JS guessing game. input is in a form. u click submit and it tells you if your too high/too low |
|
This is how my path went
|
|
http://codepad.org/AwcXAzCc <-- alerts if you miss |
|
@Alan JS password protection do not work. |
|
^ Duh. haha.... That was just my first JS thing. |
|
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. |
|
crap this involves patience... |
|
patience is good |
|
Im a teenager i dont understand patience xD |
|
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 |
|
shit happens |
dracula [20] |
don't swear !!!!!!!! |
|
COME AT ME BRO!!! |
|
haha |
Administrator |
Here's the main bots4 battle code: 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] |
Very useful thread |
|
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. |
Administrator |
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. :\ |
|
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 |
Administrator |
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. |
<Apex>
|
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. |
|
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?). |
Administrator |
If that does eventually happen, it hasn't happened to me yet. :) |