Author Topic: Battle Script  (Read 2948 times)

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Battle Script
« on: November 07, 2006, 10:24:36 PM »
Anyone have a good battle script that you have written or happen to have?  That seems to be one of the things that I don't have. 

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Battle Script
« Reply #1 on: November 08, 2006, 10:19:52 AM »
Well, I wrote a primitive turn-based battle script, but it only supports player vs AI.
It's also pretty specialized, so I'm not sure if it will work on other games.

It's mainly for RPG games because it depends on different character stats to calculate how the battle goes and whose turn it is, etc.
It's a little buggy too. :/

Offline robot

  • Level 6
  • *
  • Posts: 26
  • Reputation: +0/-0
    • View Profile
    • PhpGame
Re: Battle Script
« Reply #2 on: November 08, 2006, 10:15:21 PM »
battle script happens to be the a very hard script to code. I have coded a few battle script for turn based game. hard to keep it well balance.but I think the most complex script would be the AI. anyone attempt to code an AI with php before?

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Battle Script
« Reply #3 on: November 09, 2006, 09:33:34 AM »
Um, what I meant by my 'turn-based' battle isn't like, a turn-based game.
I mean that you and the computer take turns to attack, kinda like in a pokemon game. You get to choose your method of attack each round, and the computer will respond.

I think an AI isn't so hard.
For like my type of turn-based battle system, I will just make a couple of IF's when it's the computers turn.

For example:
If the AI's life is above 20%, it will perform a normal attack:
A random number is generated and adjusted using that particular AI's preference for spells or normal attacks. Depending on this number, the type of attack the computer will use is determined.
If the AI's life is getting too low, it will check if it has any health potions to heal itself.
If it does have potions, it will heal itself, otherwise it will perform an attack.

It's a pretty simple 'AI'. It's not really Intelligent though :P

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: Battle Script
« Reply #4 on: November 09, 2006, 10:27:56 AM »
Think you could post that for us Zeggy?  Maybe we can work it into something really cool.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Battle Script
« Reply #5 on: November 09, 2006, 10:30:22 AM »
You mean, my battle script?

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: Battle Script
« Reply #6 on: November 09, 2006, 10:35:15 AM »
Yea that would be cool if you don't mind.  :D  At least I would have something to look at as a starting point maybe.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Battle Script
« Reply #7 on: November 09, 2006, 11:14:36 AM »
Okay, I've attached the file.
btw, the battle script was written a while ago, so please don't mind any mistakes... it's not very good nor efficient :P

Offline toto

  • Level 12
  • *
  • Posts: 82
  • Reputation: +1/-0
    • View Profile
Re: Battle Script
« Reply #8 on: December 09, 2006, 09:19:12 AM »
Thanks for the file!
I remember I wrote the battle and character system for the old (no longer online) neohogwarts.com site.
It was quite complex, and analysed several stats in each turn. Every night, a script ran, which made all players fight against each other, and gave prizes to the winners.
I could try to find it and give you more information, if anybody's interested.

Offline Zeggy

  • Global Moderator
  • Level 35
  • *****
  • Posts: 1,187
  • Reputation: +13/-4
    • View Profile
Re: Battle Script
« Reply #9 on: December 09, 2006, 09:31:30 AM »
That's an interesting game :)
Force all the players to battle each other? lol

Offline toto

  • Level 12
  • *
  • Posts: 82
  • Reputation: +1/-0
    • View Profile
Re: Battle Script
« Reply #10 on: December 09, 2006, 09:56:08 AM »
Haha, yes, it was automated, and it was just to check who was the strongest member, or who had used the best strategy.
The funny part is that I was never able to win, even though I knew the codes (and the users didn't).
I sometimes look back at how much time I've invested in writing my online games... it's scary, to say the least!

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Battle Script
« Reply #11 on: January 18, 2007, 08:33:17 PM »
I'm getting ready to release Alpha 2 of my game Gladiator Battles, going to give ya'll first dibs at checking it out when it's ready :)

The interesting part of this game is the battle script. Instead of going the way most battle scripts go (the strongest stats + some random equals winner) this script instead goes to the opposite. Since gladiator games were spectator sports you don't want to kill your opponent right away as this provides zero entertainment value to the crowd. Instead you have to get as close to losing the battle yet win to gain favor with the crowd and thus win the gold for the battle :)

Creating online addictions, one game at a time:

Offline Comrade Ravenhawk

  • Level 12
  • *
  • Posts: 79
  • Reputation: +1/-0
    • View Profile
    • The Socialist Gamer Review
Re: Battle Script
« Reply #12 on: January 19, 2007, 09:35:30 AM »
I'm getting ready to release Alpha 2 of my game Gladiator Battles, going to give ya'll first dibs at checking it out when it's ready :)

The interesting part of this game is the battle script. Instead of going the way most battle scripts go (the strongest stats + some random equals winner) this script instead goes to the opposite. Since gladiator games were spectator sports you don't want to kill your opponent right away as this provides zero entertainment value to the crowd. Instead you have to get as close to losing the battle yet win to gain favor with the crowd and thus win the gold for the battle :)


The idea behind that is much better thought out than most battle scripts. And the historic reference of it is cool too. It'd be interesting to see how it plays out.

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Battle Script
« Reply #13 on: February 24, 2007, 02:22:52 PM »
I'm getting ready to release Alpha 2 of my game Gladiator Battles, going to give ya'll first dibs at checking it out when it's ready :)

The interesting part of this game is the battle script. Instead of going the way most battle scripts go (the strongest stats + some random equals winner) this script instead goes to the opposite. Since gladiator games were spectator sports you don't want to kill your opponent right away as this provides zero entertainment value to the crowd. Instead you have to get as close to losing the battle yet win to gain favor with the crowd and thus win the gold for the battle :)



That sounds like a game I'm working on. (You're the manager of a gladiator-school and have options to buy slaves, train them, buy veterans, etc... The battle doesn't only focus on the stats but also on the tactics you tell your warriors to use like closed circle, phalanx, everyone on his own, gang up on one victim, etc.)

 I'd be really intereset in how you decide how to "weight" or calculate the entertainment factor. Are you gonna take the standard battle-system to see who wins and then try to evaluate the entertainment factor through other attributes/stats?

Offline Marek

  • Level 18
  • *
  • Posts: 177
  • Reputation: +7/-0
  • XHTML, CSS, JS, PHP and MySQL are my pantheon.
    • View Profile
Re: Battle Script
« Reply #14 on: February 28, 2007, 09:27:04 AM »
Sounds like codestryke is basing the entertainment on how close the battle was, after determining the outcome I presume.?

Brilliant idea, by the way, if I may say so :)

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Battle Script
« Reply #15 on: March 05, 2007, 02:36:32 AM »
(So, back from military again)

So the players try to be as evenly matched as possible to get the biggest revenue.

This could very well form into a 3-layer game:
the bottom layer are the gladiators: each player can be a gladiator and train, etc.
the middle layer are the team owners: they have to build up their team and give orders, etc.
the top layer are the stadium owner: they need to pick the right teams to get the most revenue, etc.

But a really innovative system.

Offline codestryke

  • Administrator
  • Level 33
  • *****
  • Posts: 589
  • Reputation: +22/-0
    • View Profile
    • eXtremeCast Games
Re: Battle Script
« Reply #16 on: March 05, 2007, 05:32:15 AM »
Sounds like codestryke is basing the entertainment on how close the battle was, after determining the outcome I presume.?

Brilliant idea, by the way, if I may say so :)

Correct.

In Alpha 1 I used the standard if this attribute + this attribute equal to or greater then this attribute plus a random roll then produce a "hit". Pretty much the same old battle system you see in any game, which is a derivative of the D&D hit formula..

Anyways.. For my battle engine it didn't work well. Couple of points in the attributes either way would sway the outcome way to drastically. Since I wanted close battles this wasn't going to work, obviously ;)

So I canned that whole battle script and re-wrote a new one using a bell curve / gaussian distribution system.. So with this system it's worked out fantastically in testing, we'll have to see what happens when Alpha 2 goes online though LOL...

Creating online addictions, one game at a time:

Offline harntrox

  • Level 3
  • *
  • Posts: 9
  • Reputation: +1/-0
    • View Profile
    • Galaktikon
Re: Battle Script
« Reply #17 on: May 29, 2007, 06:23:32 PM »
in PHP5, using mt_rand over rand will allow the server to run its floating point code in another thread. makes for fast number crunching though possibly slightly less random -- (but im not 100% sure about the 2nd half of that statement !)

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: Battle Script
« Reply #18 on: June 04, 2007, 07:29:55 AM »
harntrox: do you happen to know at which points rand causes significant slowdown over mt_rand? I mean, is there a cap after which mt_rand is clearly faster (1s vs. 0.1s)?
Or is it just a slight speed-gain?

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal