hello all, yea I'm new here, I just have a couple questions to get my project started, I'm making a kind of freelance game, a kind of free form RPG where you do what you choose in the world. But WAIT, I know what your thinking, this is not some super project, this rpg will be very very VERY simple, and I want it to be so, I do have somthing to show but I need somewhere to upload it first, anyhow there is one game that my project is inspired by here http://www.nielsbauergames.com/smugglers3.html
on with the questions. first I should say that I got a turn based combat going on and it works, complete with semi random numerical outcomes (like any normal RPG), but I have run into two problems
Q - I have a small random number generated than I add a larger (non random) number to get what the attack hit would be. I display the health of me and the oponent in a number (for each) and the health gets updated with each attack on me or the bad guy. my problem is how do I display the numbers for each attack seperatly in a text message (pop up message), I could display the health at that point in the game but I just want to say how much damage was done instead :(
Q - when generating a random number is there a way to do a greater than / less than kind of thing, all I want is to tell the player the percentage chance they have to hit the bad guy, I could do this if there was a < and > things in the code, perhaps there is. . . hmmm
for your first question, i would suggest you have "thought bubbles" and use the player.thinkview for displaying their damage during the battle. Of course, you don' t need to actually have them look like bubbles, but by having a small borderless window pop up above the peoples head may be just what you want.
1.
int damage_int = 20 + Random(5);
Display("Damage: %d", damage_int);[/i]
Or something like that. Basically, you can use %d to put an int value into a Display/Speech/Think command. If you want it displayed on a GUI, it's a little more complicated - you have to use a 'dummy' string, e.g.:
int damage_int = 20 + Random(5);
string temp;
StrFormat(temp, "Damage: %d", damage_int);
SetLabelText (GUI, LABEL, temp);
2.
Yes, <, >, <= and >= are supported in script. (Although it may be => and =< - I always get them confused.)
int hit_chance = Random(50);
if (hit_chance <= 30) {
Display ("Hit!")
// Run hit code
}
else { // i.e. hit_chance < 30
Display ("Miss!");
// Run mis code
}
:DWOW thanks alot guys, I was really stumped on this and I did look around for the answer, thanks alot, I apreaciat it (spelling hehehe) :)
ok ok. . .. hmmmmm
I'm stuck agien, so how do you display the same attack hit on the health and in a pop up message at the same time,
the random number has to be subtracted from the health AND shown in pop up text (the same number)??? how is this done. .. . hmmmm :-[
Actually, that's not a problem at all; just store the random number immediately in a variable, and then you can use that variable for as many things as you want. As a matter of fact, Ashen's code already does this; all you have to do is add a line to the second code snippet that says
health -= damage_int;
This assumes, of course, that you've got a variable defined in your global script called "health", and that you've exported it properly so it can be accessed by the script that's doing this (assuming it's not also the global script). Or, if you don't want to mess with exporting variables from the global script, you could use one of the GlobalInts for health. Say you use GlobalInt 10, for example; then all you should need to reduce it is the following:
int health = GetGlobalInt(10);
SetGlobalInt(10, health - damage_int);
Yes, sorry, I kind of assumed youknew that bit, so I was focusing on the displaying part.
QuoteSay you use GlobalInt 10, for example; then all you should need to reduce it is the following:
int health = GetGlobalInt(10);
SetGlobalInt(10, health - damage_int);
In fact, you could reduce it further:
SetGlobalInt (10, GetGlobalInt(10) - damage_int);