This is the room code that makes the monster appear in the room and follow the character and when the character and player collide it transports the player to the battle room:
function room_RepExec()
{
//If goblin character = the alive view and is colliding with player, Display battle message and move player to room 301, the battle room.
if ((goblin.View==88)&&((player.IsCollidingWithChar(goblin) == 1))){
Display("Hostile intent is evident, You prepare for battle.");
player.ChangeRoom(301);
goblin.FollowCharacter(null);
}
}
//Random chance of the monster appearing when the player enters the room.
function room_AfterFadeIn()
{
int ran=Random(7777);
if (ran==777) goblin.ChangeRoom(21, 279, 121);
}
//Makes the living goblin character follow the character.
function room_FirstLoad()
{
goblin.FollowCharacter(player, 0, 0);
}
//Resets the goblin after he has been killed and the player leaves the room and changes him back to his living view with his beginning amount of life.
function room_Leave()
{
goblin.ChangeView(88);
monsterz=35;
goblin.FollowCharacter(player, 0, 0);
}
This is the battle room code where the battle takes place, then the player is transported back to the previous room he was in afterwards:
function room_AfterFadeIn()
{
//Turns on the monster/player lifebar "monsterui", places the character in the correct position for the battle.
monsterui.Visible=true;
player.PlaceOnWalkableArea();
//changes the object which acts as the characters sword and hand to the correct one
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
//makes the goblin character stop following so when the battle is over the goblin corpse wont follow you lol.
goblin.FollowCharacter(null);
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
}
function room_RepExec()
//Depending on which character the player chooses this changes him and the sword/hand object to the correct battle view.
{
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
//animates the sword/hand object
if (IsKeyPressed(eKeyUpArrow) == 1)
{
object[0].Animate(0, 3, eOnce, eBlock);
object[0].Animate(1, 3, eOnce, eBlock);
//Causes the monster random damage.
int dmg = Random(5);
monsterz -= dmg + 1;
//Animates the monster object.
object[1].SetView(56);
object[1].Animate(0, 25, eOnce, eBlock);
//Random damage the monster causes
if (dmg==0) health-=0;
else if (dmg==1) health-=1;
else if (dmg==2) health-=2;
else if (dmg==3) health-=3;
else if (dmg==4) health-=4;
else if (dmg==5) health-=5;
}
//if the monster is dead bring the player back to the room he was in before and placeonwalkable.
else if (monsterz<=0) {
int p=player.PreviousRoom;
player.ChangeRoom(p, 160, 120);
goblin.ChangeRoom(p, 160, 120);
player.PlaceOnWalkableArea();
///Still trying to figure out the best way to decrease the amount of experience gained and stats gained as the player levels
if (level == 1) {
level++;
expierance += 15;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
if (level > 2)
{
level++;
expierance += 12;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
if (level > 3) {
level++;
expierance += 10;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
///gives the player a random amount of gold after the battle.
int win=Random(2);
if (monsterz <= 0){
if (win==0) goldshow += 20;
else if (win==1) goldshow += 10;
else goldshow += 5;
}
}
}
}
}
}
///secondary check to make sure the player changes to the correct view for the battle scenedepending on which character he chose.
function room_Load()
{
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
}
///Displays defeat message, changes the player back to his correct non-battle view, sends a message to the server that the players speed has changed and sets the character to walking speed and view.
function room_Leave()
{
Display("You have triumphed over your enemy!");
if (player.View==85){
player.ChangeView(16);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==86) {
player.ChangeView(18);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==87) {
player.ChangeView(17);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
///removes the healthbars.
monsterui.Visible=false;
///changes the goblin to the dead corpse view.
goblin.ChangeView(89);
}
Goblin following character until it collides and starts battle:
(http://gamersplanet.tk/follow.png)
Inside the battle room:
(http://gamersplanet.tk/battle.png)
It's really messy and some beta testing might be necissary to fully understand it, any help would be greatly appreciated.
If you have any requests on syntax,grammar or explanations please let me know!
But be specific, Remember I am feeble minded :-\
I need to figure out a better way to tally the expeirance and level ups also probley need some type of adjustment as to how much strength,stamina,health,gold etc.... is added....
It needs ALOT of work :(
PS. I will clean up, organize and format the code as I find time to do so.
I'm not asking anyone to help me with all the problems at once, just give me small little tips here and there, my mind is not advanced enough to handle more than small tidbits at a time.
Thanks,
-Jared
int dmg=Random(5);
if (dmg==0) monsterz-=1;
else if (dmg==1) monsterz-=2;
else if (dmg==2) monsterz-=3;
else if (dmg==3) monsterz-=4;
else if (dmg==4) monsterz-=5;
else if (dmg==5) monsterz-=6;
\/
int dmg = Random(5);
monsterz -= dmg + 1;
These two lines will do the same as your seven.
(Just a tidbit for now, until you've cleaned up the code.)
Well, straight off your level up code is doubling up from level 4 onwards (4 > 2 & 4 > 3)
You really need an xpnext variable. check if xp > xpnext, if so increase stats, increase xp next.(or, reset xp to 0, and award xp based on level)
Yes, I am inexperienced with that type of code as of yet and still researching it, It would be greatly helpful if you or some could show me a piece of example code.
Thanks
-Jared
Quote from: Khris on Sat 10/03/2012 22:54:22
int dmg=Random(5);
if (dmg==0) monsterz-=1;
else if (dmg==1) monsterz-=2;
else if (dmg==2) monsterz-=3;
else if (dmg==3) monsterz-=4;
else if (dmg==4) monsterz-=5;
else if (dmg==5) monsterz-=6;
\/
int dmg = Random(5);
monsterz -= dmg + 1;
These two lines will do the same as your seven.
(Just a tidbit for now, until you've cleaned up the code.)
Sorry khris, Didn't see your post at first.
I dont exactly understand the logic of that code however I will trust you on it.
I changed it in the above script.
Thanks for the advice :D
Ok, I cleaned it up and commented it the best i can.
I really have no clue about formatting the code.
Thanks for taking the time to read,
-Jared
2 quick methods (probably full of coding errors)
// Insert this code when you award xp
experience+=15; // award the xp
if(experience > xpnext){
// Insert your stat changes here.
level++;
xpnext = (5*(level*level))+10; // sets the next xp requirement based on the current level.
// lvl 1:15, lvl2: 30, lvl3: 55, lvl4 90, etc. levels become progressively harder to gain.
if (experience > xpnext){ experience = xpnext-1; } // not required, but this will prevent double levels.
}
This gives you a classic xp method (like dungeons and dragons). Monsters still award the same xp, you just need to kill more of them to level up again. You might want to introduce a level cap (i.e. if (level < 10){ .... ), to prevent things getting out of hand.
OR
// Insert this code when you award xp
int xp = monster_xpvalue-level // the amount of xp awarded decreases as the player levels up. so you can't farm low level mobs.
if (xp > 0){ // stops negative xp awards
experience+=xp;
}
if(experience > xpnext){
// Insert your stat changes here.
level++;
experience = 0; // set experience to zero again, and you now get less xp per mob.
}
The advantage of this method is that it automatically level caps the player. Players can't farm 6 million boars to reach level 60. Once they reach a certain point even the biggest monsters won't award xp.
You can also scale your stat changes rather than code separate entries;
something like:
int hpgain;
hpgain = 10-level; // so you gain 9hp at lvl 1, 8 at level 2, 7 at 3......
if (hpgain < 0){ hpgain = 0; } // stops negative gains, (maxhp loss).
player_maxhealth+=hpgain;
It's up to you to adjust the formulas to your own design.
I'm sorry, I was more or less joking. I posted the same thing in the previous thread, which lead to all kinds of silliness, and since you've opened a new thread about this for the third or forth time like nothing ever happened, I played along. (The code is sound though, and always was.)
The thing is, until you can understand why my suggestion does the same thing as your code, this thread is pointless.
Victor6 means well, but snippets like his won't help you at all because you can't implement them properly.
You lack the basics of programming needed for something like a battle engine, and to actually help you, we'd have to basically code it for you in its entirety.
Please accept that at this point, what you should do is either recruit somebody to code the battle engine for you or give up for now and do some programming tutorials. If you don't even know how to indent code properly, you are pretty much unable to use the technical forum for what it's intended.
I know this sounds harsh, but you aren't the first person I'm telling this. It's got nothing to do with you personally, I'm simply stating what I perceive as facts.
Don't get all worked up over this. Maybe others won't see it like that and continue to help you here. But I see myself unable to do anything for you short of coding the entire thing for you (which I don't have the energy nor time for currently).
Quote from: Victor6 on Sun 11/03/2012 00:17:45
2 quick methods (probably full of coding errors)
// Insert this code when you award xp
experience+=15; // award the xp
if(experience > xpnext){
// Insert your stat changes here.
level++;
xpnext = (5*(level*level))+10; // sets the next xp requirement based on the current level.
// lvl 1:15, lvl2: 30, lvl3: 55, lvl4 90, etc. levels become progressively harder to gain.
if (experience > xpnext){ experience = xpnext-1; } // not required, but this will prevent double levels.
}
This gives you a classic xp method (like dungeons and dragons). Monsters still award the same xp, you just need to kill more of them to level up again. You might want to introduce a level cap (i.e. if (level < 10){ .... ), to prevent things getting out of hand.
OR
// Insert this code when you award xp
int xp = monster_xpvalue-level // the amount of xp awarded decreases as the player levels up. so you can't farm low level mobs.
if (xp > 0){ // stops negative xp awards
experience+=xp;
}
if(experience > xpnext){
// Insert your stat changes here.
level++;
experience = 0; // set experience to zero again, and you now get less xp per mob.
}
The advantage of this method is that it automatically level caps the player. Players can't farm 6 million boars to reach level 60. Once they reach a certain point even the biggest monsters won't award xp.
You can also scale your stat changes rather than code separate entries;
something like:
int hpgain;
hpgain = 10-level; // so you gain 9hp at lvl 1, 8 at level 2, 7 at 3......
if (hpgain < 0){ hpgain = 0; } // stops negative gains, (maxhp loss).
player_maxhealth+=hpgain;
It's up to you to adjust the formulas to your own design.
Yea, it's going to take awhile for me to figure out how the global vars and ints etc have to be setup with that,
Like I don't know what monster_xpvalue is supposed to be, or xpnext .
However this is the last functions i need for me to be happy with my battle system, If i can figure out how to use this i can implement the system gamewide.
think the expeirance system is a little diffrent, the way i have mine setup mine has a max value of 99999 which the user builds up to per fight.
Quote from: Khris on Sun 11/03/2012 02:53:08
I'm sorry, I was more or less joking. I posted the same thing in the previous thread, which lead to all kinds of silliness, and since you've opened a new thread about this for the third or forth time like nothing ever happened, I played along. (The code is sound though, and always was.)
The thing is, until you can understand why my suggestion does the same thing as your code, this thread is pointless.
Victor6 means well, but snippets like his won't help you at all because you can't implement them properly.
You lack the basics of programming needed for something like a battle engine, and to actually help you, we'd have to basically code it for you in its entirety.
Please accept that at this point, what you should do is either recruit somebody to code the battle engine for you or give up for now and do some programming tutorials. If you don't even know how to indent code properly, you are pretty much unable to use the technical forum for what it's intended.
I know this sounds harsh, but you aren't the first person I'm telling this. It's got nothing to do with you personally, I'm simply stating what I perceive as facts.
Don't get all worked up over this. Maybe others won't see it like that and continue to help you here. But I see myself unable to do anything for you short of coding the entire thing for you (which I don't have the energy nor time for currently).
Yea, In all reality this system shouldn't work as well as it does, but by blessing of god it does, All i need really is as victor posted for the system to be complete.
Hopefully i can figure it out eventually...
Not many coders around are intrested in helping with such a thing.
So i guess its like they say.
If you dont put your foot in the water you'll never learn to swim.
Thanks guys
-Jared
I don't know if it's been answered yet but I'm gonna take a shot at it. I gonna start by saying that since my RPG's code is different from most people who try to make one in AGS it may be just a tad bit confusing but I will explain to you.
I'm not show what inside the brackets cause I don't wan't everyone to know how my leveling system works.
if(playerLV == 99){
}
else{
playerLV += 1;
}
if(playerLV == 1 - 10){
}
if(playerLV == 11 - 25){
}
if(playerLV == 26 - 40){
}
if(playerLV == 41 - 70){
}
if(playerLV >= 70){
}
I have the game check if the play is Lv.99 first. If he is not then move on to the leveling. Now what I have it does it have it check for whether the player is between Lv.1-10 and if they are then give then just a bit of HP/MP+ and increase their base EXP. Now you can put what ever you would like to in there cause I don't include all the stamina stuff as my games goes by a different stat system. I have a few other variable that sting together the stat net. But I don't think I need to show all of those if I'm trying to explain this little chunk.
Icey; that code is interesting;
I would have sworn it was the same as having
if(playerLV != 99){
playerLV += 1;
}
if(playerLV == -9){
}
if(playerLV == -14){
}
if(playerLV == -14){
}
if(playerLV == -29){
}
if(playerLV >= 70){
}
So I've learned something new! ;D
I think you may be pulling my leg but let's say I did use that. What would happen is ist would do some checks between the current level and the End Level. I checking for equals to or in between not player level...something I don't it's to late for me to try to figure that out even if it is simple. All I know is my set currently works for me so I'm gonna stick with until the end. :D
IDK grim, His could work and maybe better than mine so you can try ether one. ;)
Sorry Icey, yes I was being facetious. I don't believe the code you have given will work in the way you think it will.
My version would be:
if(playerLV < 99){
playerLV++;
if(playerLV <= 10){
}
else if(playerLV <= 25){
}
else if(playerLV <= 40){
}
else if(playerLV <= 70){
}
else {
}
}
The "-" character means "subtract" in the context you have given it. I haven't found anything in the manual about it being used to mean "between". As far as I can see your code would never do anything if presented with a positve value.
But I haven't been working with AGS for long and would welcome input from someone with more experience than me in this.
Hi Icey. I wasn't absolutely sure, so I tested your code with every number from -40 to 72.
The results were as I predicted; -29, -14,-14,-9,70,71 and 72 were displayed.
The code may work for you, but I doubt many people would find it useful in the form you showed us.
ahh I see, thanks for clearing that up. I was at first think I could use the < sign alone but what happens is <= 10 ends up being the only thing read by the game. Same would happen in opposite effect if I used >.
Do you mean:
if(playerLV > 98){
}
else {
playerLV++;
if(playerLV >70){
}
else if(playerLV >40){
}
else if(playerLV >25){
}
else if(playerLV >10){
}
else {
}
}
?
I'm not sure why this code would behave in the way you seem to be suggesting. If you initialize playerLV to zero then call the code whenever a level-up is required it should go from one case to the next as playerLV is incremented - unless it is being reset to a value below 10 somewhere.
Icey:
Are you serious? What the hell?
OF COURSE you can use < alone. if (a < 4) does the same as if (a <= 3).
What you can NOT do, and what nobody ever suggested to you, and what sure as hell didn't work for you at any time, and most importantly, what you have no business posting in a help thread made by a guy who doesn't have a clue himself, is if (lvl == 1 - 10).
You can't take shortcuts like that in AGS, you have to use both conditions separately: if (lvl >= 1 && lvl <= 10).
Now stop confusing GrimReapYou and get the hell out of this thread.
Hernald: please don't humor him like that, now we have clutter here and there's probably going to be a fifth thread about this whole sad issue.
Seriously, what the fuck is wrong with you people. I just got out of bed and the first thing I see before breakfast on a Sunday morning is this. ::) :P
Sorry Khris. I'll get back to my game.
It's alright, it's not your fault.
Icey:
Also, the whole point of Victor6 and me posting here was to show that it's bad practice to use lots of else ifs when there's a clear pattern and one can use math instead.
But no, you waltz in here completely oblivious to anything posted before you, posting useless and wrong code.
Argh.
And you think you're ready to go commercial, on Steam? It'd be funny if it weren't so pathetic.
Well, thanks for trying icy, but yea... you code like me so....
and thanks for the humor hernald,
but yea... we dont need to get too off topic here for sure.
your a good guy khris, I dont care what they say :=
No prob grim.
Intended for Khris
Spoiler
Look Khris I had already stated I didn't know if 1 of his questions had been answered so I took a shot at it. This is also another reason why I didn't post what's inside the brackets because I didn't want someone to comment on my stuff in that type of manner. Sure I took a shot at helping Grim with something I think works for me. And even if Hernald came and cleaned it up a bit that shouldn't be a problem.
What I men't was <= and >=, and I didn't know I could use < and > alone.
Also who the hell do you think you are coming in here yelling at me like that, are you freaking crazy!! I don't appreciate that. I have been successful at helping people in the past and then there were times were I was wrong. I'm human just like you(I hope). I'm some super genius when it comes to AGS but I try to find ways to get it to work for me because if I don't I either won't get the right help or just non at all.
Quote
And you think you're ready to go commercial, on Steam? It'd be funny if it weren't so pathetic.
Spoiler
Really, like for real. Who says something like that? If I set you off that bad by not even attacking you and trying to help a friend then that's goddamn shame. And for your information, read what I say a little bit better cause I'm not trying to go commercial, I'm preparing myself for if I go commercial.
My point is you I guess you can be a complete asshole some times. And yet you would call me a troll. I don't start things and get madder when others get mad. I get mad when someone else comes off at me when I know their wrong.
And that is something people do every day so if I'm trolling, your trolling. good day sir!
This is my story and I'm not gonna sit here and let all the hatters write for me. That's my motto and I'm sticking by it.
It's only natural that you follow your very first instinct: backlash.
What you should do instead though is turn on your brain for a few seconds and try to figure out WHY I'd react like that.
You have constantly strained everyone's patience here. For months on end, people tried to get you to see why what you think is OK is in fact not. No dice.
Regardless of the other stupid shit you're doing in these forums, posting broken code is obviously not helping. Can we agree on that?
Can we also agree that you've posted broken code before and were told not to?
Last but not least, if somebody keeps doing dumb things, even after repeatedly being told to stop it, at what point is it justified for others to ditch courtesy? You are WAY past that point by now.
Do you actually think I give a fuck about what you appreciate? Is this what a serial killer is supposed to tell the cops? "I don't appreciate being put in jail?"
Please, pull your head out of your ass.
Alright, I've read this topic in its entirety. This is becoming like a gen-gen topic too fast, so congrats on somewhat achieving that, icey. Everyone after a post is just focusing of making fun of you, instead of helping grimreapyou.
Posting half-assed code that doesn't work is okay, and it happened even to the best of us (Khris included (once though)). Continuously doing that, is however wrong. Wanting to help and actually helping are two separate things. Even coming with the best intentions here, doesn't make up for the situation you caused. I mean, I want to be a doctor, but I don't even know the basics.
Worst part is that half of the posts here (including mine) have no use to whoever will come here in the future expecting for some help.
"I'm not show what inside the brackets cause I don't wan't everyone to know how my leveling system works."
You typed this before a code that has absolutely no chance of working in any of the parallel universes, and expect everyone to thank you. It baffles me really.
Alright, I got it working somewhat like this:
int xpnext=14;
// Insert this code when you award xp
expierance+=15; // award the xp
if(expierance > xpnext){
// Insert your stat changes here.
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
level++;
xpnext = (5*(level*level))+10; // sets the next xp requirement based on the current level.
// lvl 1:15, lvl2: 30, lvl3: 55, lvl4 90, etc. levels become progressively harder to gain.
if (expierance > xpnext){ expierance = xpnext-1; } // not required, but this will prevent double levels.
}
But I'm guessing I did something wrong here, because it just levels after every fight and the amount of exp required is not increased.. :-\
I've been avoiding looking at this topic because I'm helping Grim with this somewhere else (http://www.gamersplanet.tk/GamersPlanet/viewtopic.php?f=41=124&sid=a2243cd0645cbe4fe52e46766485e985), but now that I've read it I'm giggling like an idiot
and face-palming at the same time. :-\
Grim, buddy, I think the AGS forums need a break from the technical aspects of your QFG multiplayer remake. I've already told you I'm willing to help with the code in what ways I can. The next time you post about it, it should be about how awesome the latest build is looking ;) Khris is a helpful guy, but I've got the feeling his patience is running just a bit too thin, dealing with some of the delinquents romping around the forum.
Icey, my sentiments for your code have already been quite eloquently expressed:
Quote from: Khris
Are you serious? What the hell?
edit: Dammit Grim, you ninja'd me!
LOL, Yea...
I think it would be best to break from my blatant postings of stupidity, However i need to get this done ASAP, It's been holding me up over a week and i have barely touched the game because I'm ocd and cannot continue other aspects till this is complete.
I think it be best proceeding with some of victors code, seems swell however I'm going to need your help learning how some of it is implemented
Hit me up on the other forum homie or in the chat :D
Alright. Enough chit chats already, or else I may decide to break this thread up and remove the offtopic posts.
Quote from: Iceboty V7000a on Mon 12/03/2012 01:26:15
Alright. Enough chit chats already, or else I may decide to break this thread up and remove the offtopic posts.
Absolutely. In the attempt to drag this back on topic:
Lets talk experience and the player, in the simplest form we can.
you will need two variables, one that represents the required amount of xp that the player needs to level up (hereby known as '
X'), and the actual amount of xp the player has ('
Y'). Whenever
X equals or is greater than
Y,
X increases, and the player's level increments by '1'.
In code, that's
if(Y >= X) Level_Up();
where the function 'Level_Up' increases
X, and modifies the player's stats accordingly.
So now, the player only levels up when their accrued xp is high enough, instead of being leveled up every time xp is given.
So when the fight concludes and the player is victorious, somewhere in the code would be:
.
.
.
Y += Monster_Experience;
if(Y >= X) Level_Up;
so now how about
X incrementing geometrically?
A third variable needs to be involved. This variable can either be a constant or increase along side
X. I'm going to call this variable
A. Every time the player levels up,
X will equal
X *
AHere's my example:
Let
A equal '1.5'.
A is a constant, so it never changes. The player's level is '1', and
X equals 100.
Total XP required at level:
1) 100
2) 150
3) 225
4) 337.5
5) 506.25
6) 759.375
7) 1139.0625
8) 1708.59375
9) 2562.89063
10) 3844.33595
This also represents the difficulty curve nicely: The closer
A is to '1', the slower the rise in the difficulty of the game. The higher
A is, the higher the difficulty is (because you aren't leveling up and increasing your stats as often)
Now lets include 4 stats for the player that are affected by xp: Health, Mana, Constitution, and Wisdom.
So lets assume that:
Health = Constitution * 5
Mana = Wisdom * 10;
How do you know when to increase Wisdom and Constitution? It's simple if they increase every level, but what if you want Constitution to increase every second level (3, 5, 7, 9) and Wisdom to increase every third level (4, 7, 10, 13)? Use a counter!
Lets have a new variable, called
B. This variable starts as '0', and increments by '1' every time the player levels. Once it hits '3', it resets to '0'. Now lets define the 'Level_Up()' function with this new variable and what we defined above:
function Level_Up()
{
Player_Level++;
X *= A;
B++;
if(B == 2) Player_Constitution++;
else if(B == 3)
{
B = 0;
Player_Wisdom++;
}
Player_Health = Player_Constitution * 5;
Player_Mana = Player_Wisdom * 5;
}
These are the basics, and pretty much everything else is based off this.
Ok, this is what I've come up with from all of this however i keep getting parser error at : Required_XP .....
int expierance = 0; ///is a global var int
int Required_XP = 15; ///is a global var int
Increase_Factor = 2.0 ///is a global var float
else if (monsterz<=0) {
int p=player.PreviousRoom;
player.ChangeRoom(p, 160, 120);
goblin.ChangeRoom(p, 160, 120);
player.PlaceOnWalkableArea();
expierance += 15;
if(expierance >= Required_XP){
level++;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
Required_XP *= Increase_Factor;
Can anyone tell me why I'm getting this error, is it because 1 is an int and the other is a float in : Required_XP *= Increase_Factor;
Quote from: GrimReapYou on Mon 12/03/2012 09:19:40
Ok, this is what I've come up with from all of this however i keep getting parser error at : Required_XP .....
int expierance = 0; ///is a global var int
int Required_XP = 15; ///is a global var int
Increase_Factor = 2.0 ///is a global var float
Is there any reason why you're using a float for what is effectively integer multiplication? It seems needlessly complicated for something that could be just *2 or << 1.
In order to do float math with an Int, you need to convert it to a float with the IntToFloat and FloatToInt functions. The reason why it hasn't got to the type error is because, I think, you need to express the function as:
Required_XP = Required_XP * Increase_Factor;
I don't think AGS HAS *= as one of it's thingies, only += and -=.
Oh okay, I was thinking perhaps i could use an int value instead too.
mucho gracias :D
Switched it over to an int and its working great, Thanks bud :D
PS.
This was the end code if anyone is curious:
// room script file
// room script file
function room_AfterFadeIn()
{
monsterui.Visible=true;
player.PlaceOnWalkableArea();
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
goblin.FollowCharacter(null);
object[1].SetView(56);
object[1].Animate(0, 3, eOnce, eBlock);
}
function room_RepExec()
{
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
if (IsKeyPressed(eKeyUpArrow) == 1){
object[0].Animate(0, 3, eOnce, eBlock);
object[0].Animate(1, 3, eOnce, eBlock);
int dmg = Random(5);
monsterz -= dmg + 1;
object[1].SetView(56);
object[1].Animate(0, 25, eOnce, eBlock);
if (dmg==0) health-=0;
health -= dmg + 1;
}
else if (monsterz<=0) {
int p=player.PreviousRoom;
player.ChangeRoom(p, 160, 120);
goblin.ChangeRoom(p, 160, 120);
player.PlaceOnWalkableArea();
expierance += 15;
if(expierance >= Required_XP){
level++;
player_maxhealth += 1;
player_maxmana += 1;
player_maxstamina += 1;
strength += 1;
Display ("You have reached level %d And now have, %d strength, %d health, %d mana, %d stamina, %d gold",level, strength, player_maxhealth, player_maxmana,player_maxstamina, goldshow );
Required_XP = Required_XP * Increase_Factor;
int win=Random(2);
if (monsterz <= 0){
if (win==0) goldshow += 20;
else if (win==1) goldshow += 10;
else goldshow += 5;
}
}
}
}
function room_Load()
{
if ((player.View==42)||(player.View==16)) {
player.ChangeView(85);
object[0].SetView(82);
}
else if ((player.View==17)||(player.View==59)) {
player.ChangeView(87);
object[0].SetView(84);
}
else if ((player.View==18)||(player.View==58)) {
player.ChangeView(86);
object[0].SetView(83);
}
}
function room_Leave()
{
Display("You have triumphed over your enemy!");
if (player.View==85){
player.ChangeView(16);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==86) {
player.ChangeView(18);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
else if (player.View==87) {
player.ChangeView(17);
CafeDo(String.Format("speed is %d %d", 5, 5));
player.SetWalkSpeed(5, 5);
}
monsterui.Visible=false;
goblin.ChangeView(89);
}
If you actually want to double the required XP each time, 2 instead of 2.0 is fine.
But I think suicidal pencil chose 1.5 for a reason, namely to not make too big jumps. With a factor of 2, the XP the player has to gain to reach level X is all(!) the XP he had to gain to reach the level before that and then some, which might be a bit much.
Example: 2: 100, 3: 200, 4: 400: 5: 800, 6: 1600
Total XP necessary to reach lvl 5: 1500.
XP necessary on top of that(!) to reach lvl 6: 1600
Now there's no need for a global variable here since it never changes.
Thus the line should look like this:
Required_XP = (Required_XP * 3) / 2; // factor 1.5
I tried using it, just can't seem to get it working right.
I can see its a solid piece of code.I surely need the 1.5 instead of 2, that jump is lame.
Thanks for it, I'll continue to tinker with it as my knowledge advances.
My line is supposed to replace this line in your code:
Required_XP = Required_XP * Increase_Factor;
No further adjustments are necessary.
For some reason its giving me a level every fight for the first 5 fights,
then it takes 2 fights for level 6 and 3 fights for level 7.
I dont know what the issue is, probably on my end :(
Well, what's the initial value of Required_XP? Sounds like it is too low.
You are awarding 15 XP per fight, so it should start out as 40 or something, I guess.
That way, it takes three fights to reach 45 XP / lvl 2, then four fights to reach the new requirement of 60 XP.
EDIT: Khris beat me to it;-
XP for each level (roughly, since it'll be converted to an int):
level 2 : 15
level 3 : 15*1.5 = 22.5
level 4 : 22.5*1.5 = 33.75
level 5 : 33.75*1.5 = 50.65
level 6 : 50.65*1.5 = 75.9
XP after each fight
fight1 : 15 (requires 15 for level 2)
fight2 : 30 (requires 22.5 for level 3)
fight3 : 45 (requires 33.75 for level 4)
fight4 : 60 (requires 50.65 for level 5)
fight5 : 75 (requires 75.9 for level 6 - So no level gain.)
Well, after every level-up you could reset the player's accrued experience back down to zero when he levels up.
reusing my example:
Without reseting accrued experience:1) 100 (100xp required)
2) 150 (50xp required)
3) 225 (75xp required)
4) 337.5 (112.5xp required)
5) 506.25 (168.75xp required)
.
.
.
Now reseting experience to zero after every level:1) 100 (100xp required)
2) 150 (150xp required)
3) 225 (225xp required)
.
.
.
So in your code:if(expierance >= Required_XP){
level++;
expierance = 0; //<----just add this one line
.
.
.
edit: god damn, you guys beat me :<
Damn you guys are sick with the math.
Greatly appreciated :D
Yea, that:
1) 100 (100xp required)
2) 150 (50xp required)
3) 225 (75xp required)
4) 337.5 (112.5xp required)
5) 506.25 (168.75xp required)
Is whats happening I think.
However the total experience has its own value which is displayed to the players, so resetting it would mess that up, I guess i'd have to maby add something that will increase the required xp amount for those 5 levels?
[edit] Oh, khris I missed your question, Required_xp set at 15 But lowered xp given to 10.
Quote from: GrimReapYou on Mon 12/03/2012 21:51:48
Yea, that:
1) 100 (100xp required)
2) 150 (50xp required)
3) 225 (75xp required)
4) 337.5 (112.5xp required)
5) 506.25 (168.75xp required)
Is whats happening I think.
However the total experience has its own value which is displayed to the players, so resetting it would mess that up, I guess i'd have to maby add something that will increase the required exp amount for those 5 levels?
[edit] Oh, khris I missed your question, Required_xp set at 15 But lowered exp given to 10.
Well just to let everyone know I solved that issue by making 2 experiences, 1 that's visible and 1 that's not visible, Just added 2 different experience additions after battle and used the non visible one to tally exp, which is subtracted to zero after each battle thus removing the exp difference glitch.
So all is well, thanks all who helped here :)