Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Now, I need a Battle Script.

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Valigarmander
Bye-Bye




Joined: 04 Mar 2006
Posts: 750
Location: Nowhere

PostPosted: Tue Nov 14, 2006 7:32 am    Post subject: Now, I need a Battle Script. Reply with quote

Argh, I just wrote an entire page of this crap but it logged me out before I could post it. Lost it all. Fuck. Pissed off!

Anywho, I'm working on a game called They Hunger. It is about these teens who blah, blah, you've all heard it. I've decided that I probably won't have a flashlight script, as I had imagined earlier (there's a thread on it somewhere in here), but I do plan on doing something unique scriptwise. So, I'm thinking about having a unique battle system.

If my memory serves me correct, then my idea is somewhat like Shadowiii's Seventh Day. I think. It's been a while since I've played the game. But the basic concept is, the player is moving around, the monster is pacing back and forth, the two come to a certain distance. They walk into place directly in front of each other, and the battle begins. The battle cycles between the player's turn and the monster's turn. During the player's turn, you can (you choose by touching one of four icons surrounding the player) attack (either melee or ranged; melee only works when the enemy is at melee range, ranged requires ammo), use an item (only one item), or attempt to run. After the player moves, the monster goes. At the start of the battle the enemy is 3 paces away from the player (well, 4 actually, but we need that extra space for attacking). The monster usually just moves towards the player until it reaches melee range, where it will begin to attack. Your ammunition and health is displayed in the lower-left corner of the screen, while the monster's health is in the lower-right (I have no idea how to do this, more info down the page a bit). The battle ends once either the player or the monster dies (i.e. loses all of its health).

So, if you all don't already know, I suck very much when it comes to plotscripts, and I need some help. I think I'll be able to get the basics down, but elsewhere I'm going to need a hand. I'll just give you all a short list of things that come to mind when I think, "things I need help with." See if you can give me said help!

How will the game know what position (long, medium, close, & melee range) the monster is in?

I want the attack damage (both the player's and the monster's), attack hit ratio (both the player's and the monster's), and the run success ratio to be randomized. How do I do that?

How do I make certain that once the player or the monster reaches 0 health or below 0 health, the battle comes to an end, and also, how do I make sure that the ending depends on who is the victor?

How do I display different variables (your health, ammo, enemy's health) on the screen? I think I can manage getting the variables to work, it's just displaying them on the screen I need help with.

How will the script know whether or not the monster should approach or attack (in other words, is it in melee range or not)?

The "battle action icons" are supposed to "disappear" and move to the side (to allow easy movement back and forth for the player). How do I get them to disappear without destroying them? (Using tags destroys them, doesn't it? O.o I feel so stupid.)

How do I make it so after using one item (if the player decides to use an item), and only ONE item, the game exits the item menu and goes directly to the monster's turn?

Can I do this all in one script? Or would it be better to use multiple? That being said, I do not know what command allows you to activate a seperate script. Oookay...

I want the damage of the player's attacks to be based off of her stats (physical strength and gun caliber). Also, I want the player's other stats (defense; maybe even evade, but that might be a push) to play a role. How do I do that? Something to do with setting the variables to be the same as the stats, I think. Am I right? Close?

I want to have it so after winning a battle the player gains a level. Can I even do that?

Will I need new scripts for each consecutive battle? Or can I recycle scripts?

Can I do all (or any) of this at all? Is my concept even within the OHR's capabilities?


Argh, I know. I'm a mess. But bear with me. The rest (getting attack animations to work, activating sfx, other easier scripts) I think I can manage. I know, I could probably figure all of this out on my own, but I'd much rather have someone experienced in the field of plotscripting to tell me how it's done, instead of reading through the entire manual. (Hell, I've already tried that. And the manual still leaves certain tricks out!) So, yeah. I guess I'll keep you all posted with information here, and hopefully I'll be able to show you guys some more about what I had in mind. Maybe a diagram, yeah, that would be cool...

So, yeah, any help here? Any and all will be appreciated. Happy And hopefully, soon I'll have a working battle script. Peace out.
Back to top
View user's profile Send private message Send e-mail
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Tue Nov 14, 2006 8:51 am    Post subject: Reply with quote

Can I suggest you hold off on this until you've done something simpler? You A) clearly have no idea where to start, B) don't seem to have ever put two scripts together before and C) seem to be trying to replicate the battle system in The Seventh Day rather than making your own.

There are plenty of good plotscripting resources out there. You should try your hand at a few minigames or something (and you can even integrate them into what you're doing if you do it right -- you don't have to halt production) before you attempt something this large-scale.

The questions you're asking show that you don't understand how to do this at a fundamental level. The answers to your questions follow, though I suspect they won't be as useful as you'd hoped.

How will the game know what position (long, medium, close, & melee range) the monster is in?
However you decide to tell it. It doesn't innately know things related to your battle engine, though.

I want the attack damage (both the player's and the monster's), attack hit ratio (both the player's and the monster's), and the run success ratio to be randomized. How do I do that?
Use the random function.

How do I make certain that once the player or the monster reaches 0 health or below 0 health, the battle comes to an end, and also, how do I make sure that the ending depends on who is the victor?
You'll need a few if statements in your code that check these variables.

How do I display different variables (your health, ammo, enemy's health) on the screen? I think I can manage getting the variables to work, it's just displaying them on the screen I need help with.
The easiest way to do this is probably with the string commands, but you can do it any way you want to.

How will the script know whether or not the monster should approach or attack (in other words, is it in melee range or not)?
You'll have to write the AI yourself.

The "battle action icons" are supposed to "disappear" and move to the side (to allow easy movement back and forth for the player). How do I get them to disappear without destroying them? (Using tags destroys them, doesn't it? O.o I feel so stupid.)
This question isn't really clear without knowing what function the icons perform. However, I don't see why you wouldn't want to destroy them, since you can always recreate them. (Using tags does not destroy them, but it removes them temporarily from the map.)

How do I make it so after using one item (if the player decides to use an item), and only ONE item, the game exits the item menu and goes directly to the monster's turn?
You'll have to program your own menu script in order to do this.

Can I do this all in one script? Or would it be better to use multiple? That being said, I do not know what command allows you to activate a seperate script. Oookay...
You can do this all in one script, but it would be a really bad idea. Check tutorials on how to call scripts from scripts.

I want the damage of the player's attacks to be based off of her stats (physical strength and gun caliber). Also, I want the player's other stats (defense; maybe even evade, but that might be a push) to play a role. How do I do that? Something to do with setting the variables to be the same as the stats, I think. Am I right? Close?
Um... the stats are variables. You'll have to write damage formulas for all of this.

I want to have it so after winning a battle the player gains a level. Can I even do that?
Yes.

Will I need new scripts for each consecutive battle? Or can I recycle scripts?
You can recycle if you do it right.

Can I do all (or any) of this at all? Is my concept even within the OHR's capabilities?
Yes, but I'm not sure what you're trying to do and I'm not sure you are, either.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Camdog




Joined: 08 Aug 2003
Posts: 606

PostPosted: Tue Nov 14, 2006 9:14 am    Post subject: Reply with quote

This is all certainly possible with the OHR, but it's a lot of complicated plotscripting and your questions suggest that you don't have a lot of experience with that. You might want to start out with something a bit more simple, but I'll try to offer some solutions to your problems and if they make sense for you, go for it.

Quote:
How will the game know what position (long, medium, close, & melee range) the monster is in?


This is a matter of first figuring out what long medium and close mean, and then finding the distance between the npc and the hero and determining what position that distance equates to. You can find distance through the equation a^2 + b^2 = c^2, where a is the difference in horizontal distance between the two elements, and b is the difference in vertical distance. So, to write a function that finds distance, we'd do something like this:

(If you don't understand where enemy and player come from, read about how arguments work here.

Code:
define script(autonumber, distance, 2, 0, 0) #autonumber because we'll only call this script from other scripts, not from the rpg

#here, enemy is the enemy's npc id, and player is the hero's id
script, distance, enemy, player, begin
  variable(a)
  variable(b)

  a := npcx(enemy) -- herox(player) #the x distance between enemy and hero
  b := npcy(enemy) -- heroy(player) #the y distance

  return ( (a^2) + (b^2) ) #return the distance, squared
end


I don't think there's a way to find square roots with the ohr (correct me if I'm wrong), but that's ok as long as, when we're checking for position, we check for the distance squared, as opposed to the distance.

Quote:
I want the attack damage (both the player's and the monster's), attack hit ratio (both the player's and the monster's), and the run success ratio to be randomized. How do I do that?


Easy. Since you're doing a custom battle system, you can just store this kind of information as variables, and set them to random whenever you like with the random command.

Code:
variable(playerAttackDamage)
playerAttackDamage := random(1, 10)


...will set the player attack damage to a random number between 1 and 10.

Quote:
How do I make certain that once the player or the monster reaches 0 health or below 0 health, the battle comes to an end, and also, how do I make sure that the ending depends on who is the victor?


This is a simple if... then statement. Check to see if either the player or the enemy has less than 0 health at the end of your script, then act accordingly depending on who died. (The || means "or").

Code:
if ( (playerHealth <= 0) || (enemyHealth <= 0) ) then (
  if (playerHealth <= 0) then (
    #the player died, game over
  )
  else (
    #otherwise, the monster died.  keep going
  )
)


Quote:
How do I display different variables (your health, ammo, enemy's health) on the screen? I think I can manage getting the variables to work, it's just displaying them on the screen I need help with.


Check here.

Quote:
How will the script know whether or not the monster should approach or attack (in other words, is it in melee range or not)?


Again, this depends on what we decide is the maximum distance the monster can be and still perform a melee attack. We'll use the distance script I showed you above. Say we want the monster to attack whenever it is within 2 squares of you. Since we're working with squared numbers, the target number we're checking for is 4.

Code:
if (distance(monsterId, me) <= 4) then(
  #attack!
)
else (
  #move forward
)


Here, monsterId is the monster's npc id, and me is the constant defined in your include file which refers to the first member of the party.

Quote:
The "battle action icons" are supposed to "disappear" and move to the side (to allow easy movement back and forth for the player). How do I get them to disappear without destroying them? (Using tags destroys them, doesn't it? O.o I feel so stupid.)


You can do 1 of three things. Move the icons that are supposed to disappear under overhead tiles set outside of the area the group is allowed to walk on, change the picture of the npcs to be blank, or simply move the npcs off the screen. All of these can be done with simple plotscripting commands. Check here for ways to move them around, and this command for how to change an npc's picture.

Quote:
How do I make it so after using one item (if the player decides to use an item), and only ONE item, the game exits the item menu and goes directly to the monster's turn?


This one is tough. You can call up various sections of the menu through plotscripting (see here) but I've never tried forcing a player out of a menu. From the description of "item menu":

Quote:
Note that if the player uses an item that calls up a text box, the items menu command will behave like a show text box command for that text box.


So, if you know the player is going to use an item that calls up a text box, I think the following code will use the item, call up the text box, and then close out of the menu and text box:

Code:
item menu
wait for text box


But I've never done it, so I'm not sure if that's the behavior you'll get.

You could always create a custom item menu, but that's a lot of work. If you really want to try that, I created a custom menu for The Ritual, and I'd be happy to show you the plotscript that drives the custom menu.

Quote:
Can I do this all in one script? Or would it be better to use multiple? That being said, I do not know what command allows you to activate a seperate script.


Best programming practice would be to have a "master" script which controlled the battle in its entirety, and then use other scripts within that master script to perform complex things (like finding the distance).

Calling one script from another is easy! Just type in the script name you want to call like you would any other command. If the script takes arguments, follow the script name with a list of the arguments, seperated by commas, in parentheses (again, just like any other command). For example, if you wanted to use the distance script defined above in another script to find the distance between the npc with the id of 0 and the hero with the id of 0, you'd do it like this:

Code:
script, happy fun time, begin

  #do some stuff

  variable(x)
  x:= distance(0, 0)

  #do some other stuff
end


Quote:
I want the damage of the player's attacks to be based off of her stats (physical strength and gun caliber). Also, I want the player's other stats (defense; maybe even evade, but that might be a push) to play a role. How do I do that? Something to do with setting the variables to be the same as the stats, I think. Am I right? Close?


That's exactly what you'd do. Just use the command get hero stat, and stick that number in any variable you please.

Quote:
I want to have it so after winning a battle the player gains a level. Can I even do that?


Yup. set hero level. When you have a question like this, it helps to check the plotscripting dictionary. Often the answer is obvious.

Quote:
Will I need new scripts for each consecutive battle? Or can I recycle scripts?


Certainly not! You can call the same script as often as you'd like. You can even call them recursively! But... uh... we'll save that lesson for another day.

Quote:
Can I do all (or any) of this at all? Is my concept even within the OHR's capabilities?


Yes indeedy, but like I said before, your questions show you aren't too familiar with plotscripting or programming in general, so it's going to take a LOT of learning and a LOT of work to get this done. Might I suggest you try to create some working, less ambitious scripts before you embark on this one?

You can certainly learn how to this, and I'm happy to help, just be ready.
Back to top
View user's profile Send private message
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Tue Nov 14, 2006 9:38 am    Post subject: Re: Now, I need a Battle Script. Reply with quote

Moogle is right. You have to learn to crawl before you learn to walk, and learn to walk before you learn to dance, and learn to dance before you can learn to do the awesome ultimate deadly up-side-down quadriple underwater ninja hamster tango of death.

But in the interest of learning to crawl, let's tackle your first sub-question:

Valigarmander wrote:

How will the game know what position (long, medium, close, & melee range) the monster is in?


Assuming that you will be using your walkabout heroes for the heroes, and NPCs for the enemies, you simply need to do some math on their x and y positions. Here is an example script that calculates the range between a hero and an NPC

Code:

plotscript, find distance, hero=0, NPC=0, begin
  variable(x1,x2,y1,y2,xdiff,ydiff)
  x1 := hero X (hero)
  y1 := hero Y (hero)
  x2 := NPC X (NPC)
  y2 := NPC Y (NPC)
  xdiff := x2 - x1
  ydiff := y2 - y1
  if (xdiff << 0) then (xdiff := xdiff * -1)
  if (ydiff << 0) then (ydiff := ydiff * -1)
  if (xdiff >> ydiff)
    then (exit returning(xdiff))
    else (exit returning(ydiff))
end


So all that gives you a number that tells approx how far away the hero and NPC are. Then, you can use it like this:

Code:

variable(distance)
distance := find distance(whatever hero, whatever monster)

if(distance == 0) then, begin
  # overlapping
end

if(distance == 1) then, begin
  # melee
end

if(distance >> 1 && distance <= 4) then, begin
  # midrange
end

if(distance >>  4) then, begin
  # longrange
end


Does that all make sense?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Valigarmander
Bye-Bye




Joined: 04 Mar 2006
Posts: 750
Location: Nowhere

PostPosted: Tue Nov 14, 2006 11:56 am    Post subject: Reply with quote

Argh, you guys are right. I am in a bit over my head. But I can do it, I've made scripts before, mainly trial and error, just screwing around until it works right. But this time I want to do something unique. But yeah, maybe I should start off somewhere simpler. Oookay...

Anywho, thanks for the help. And no, I am not trying to duplicate the Seventh Day battle script, Moogs, I was just comparing my idea to Shadowiii's. I can hardly even remember what you did in the battles (in Seventh Day), aside from the fact that it involved some sort of nifty scripting.

To James: My brain hurts, but I think I get it. Also I think I'll only need the Y positions for this. But thanks, it makes more sense now.

[Edit]

OK, I also have some new information. Mostly about stats and crap. I think I've figured out the formulas for damage and stuff, here they are.

Player melee attack: Damage = STR

Player ranged attack: Damage = CAL + (RANGE x variable A x 15)

Enemy attack: Damage = Enemy Attack - DEF

(STR, CAL, RANGE, and DEF are player stats)
(variable A = enemy's distance from player, 0 furthest, 3 closest)

The player's melee attack is pretty straightforward. The damage is equal to the strength. The ranged attack is a bit more complicated. The damage is the same if the weapon equipped has a RANGE of 0 (meaning, the attack deals CAL damage). But if the weapon has a RANGE of 1, then the attack deals more damage the closer the monster is. Good for weapons such as shotguns. The enemy attack is almost the same as the player melee attack, but the player's defense is factored in.

See, I'm not a complete dumbass. I came up with formulae. More information to come, and I'll keep you posted on my incredible journey into the Realm of Plotscripting.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group