Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PrimitiveUser on Sun 14/12/2008 17:39:56

Title: rpg leveling up after an ammount of monsters/enemies are killin
Post by: PrimitiveUser on Sun 14/12/2008 17:39:56
can you make me a script where you can level up with the amount of kills that you kill

i want the levels to be till 1-99

for example i just started playing a game im level 1 to get to level 2 i must kill 5 monsters wohoo i just leveled 2! now i need to kill 10!
sop its basically going up by 5s

the person who answers this correctly and is not a dumb face i will give a great thanks and a hug ;)
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Mantra of Doom on Sun 14/12/2008 19:17:52
I'm not sure if this is the cleanest way to approach the problem, but I believe it would work.

Make a global int called myLevel and start it out as 1

Then whenever you kill a monster, you could put the line
GiveScore(1);

Then in your global script you could add this into your rep_execute

if (game.Score==5)
{
  myLevel =2;
}


And you can do that for each level up to however many levels you need.

Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Trent R on Sun 14/12/2008 19:23:01
Quote from: MantraofDoom on Sun 14/12/2008 19:17:52
I'm not sure if this is the cleanest way to approach the problem, but I believe it would work.

Make a global int called myLevel and start it out as 1

Then whenever you kill a monster, you could put the line
GiveScore(1);

Then in your global script you could add this into your rep_execute

if (game.Score==5)
{
  myLevel =2;
}


And you can do that for each level up to however many levels you need.

Revamped:
if (game.Score==5 && myLevel<99)
{
  myLevel++;
}


~Trent
PS-Have you noticed the sticky in this forum that's all about RPGs with AGS?
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Lt. Smash on Sun 14/12/2008 20:22:03
why not just

int myLevel;
function on_event (EventType event, int data)  //global script
{
if (event == eEventGotScore && myLevel < 99)
myLevel = game.score/5;   //e.g.  score= 9 /5 = 1,8 to int = 1

}

Quote
Then whenever you kill a monster, you put the line
GiveScore(1);
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Dualnames on Sun 14/12/2008 20:29:59
Quote from: primitiveuser on Sun 14/12/2008 17:39:56
can you make me a script where you can level up with the amount of kills that you kill

i want the levels to be till 1-99

for example i just started playing a game I'm level 1 to get to level 2 i must kill 5 monsters wohoo i just leveled 2! now i need to kill 10!
sop its basically going up by 5s, I know you guys don't care about me telling this but what the hell, I thought I should post all the random shit , I could come up with.

the person who answers this correctly and is not a dumb face i will give a great thanks and a hug ;)(and I might have sex with him/her if she really begs for it)

int currentlevel=1;//this is a variable that will hold the number of levels.

Comment: now let's say you have created a character or an object to use as a monster, place the code below when the monster dies

int monstercounter=0;//this is a variable that works as a counter.

//code to put when a monster dies//
monstercounter++;
if (monstercounter==5) {
currentlevel++;
}

You only get what you give.

Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Khris on Mon 15/12/2008 13:53:32
If I understand primitive user correctly, it takes an additional 10 kills to get to level 3, then another 15 kills aso.

// top of global script

int lvl = 1;
int req_kills = 5;

void levelup() {
  Display(String.Format("You've reached level %d!", lvl));
  // do level up stuff
}

void kill() {
  req_kills--;
  if (req_kills == 0) {
    lvl++;
    req_kills = lvl * 5;
    levelup();
  }
}


Now call kill(); once a monster died.

I'd go with experience points though and award more for tougher monsters and additional xp for solving problems.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: PrimitiveUser on Tue 16/12/2008 21:32:31
No, You don't understand I specificly told you in the beginning, re-read my question it tells you what exp to get to what level, viceversa.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Trent R on Tue 16/12/2008 22:02:16
[rant]
primitiveuser, why are you so picky? The forums are here to help, not make your game. There are multiple posts and solutions in this thread already, and I do believe that Khris's is the most correct. So just pick some code (or CJ forbid, write it yourself!) and stop complaining.

[/rant]

~Trent
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: on Wed 17/12/2008 01:45:24
I read and read and read. The experience curve should be like this if I take your broken grammar literally.
First level: 5
Second level: 10
Third: 15.
And so on. And Khris just answered that. I'll do so again.

Just make an int exp_needed, and, when levelling up, say:
exp_needed+=5

Even more precise, using Trent's revamp:

Top of script:

int exp_needed = 5;


Then, for levelling:

if (game.Score==exp_needed && myLevel<99)
{
  myLevel++;
  exp_needed+=5;
}


Apart from that, all code supplied here is useful, functional and given to you, regardless of attitude. What you're asking for is basic stuff that, I think, you could well have figured out yourself, depending on your experience- it's simple math.
Be careful, primitiveuser, you're walking a fine line. A newcomer asking for help is one thing, but constantly demanding stuff and, honestly, shouting crap at long-time members like Khris, Dual and myself, who happen to know their scripting, leaves a bad taste.

If you want your code something else than what we figure out from your words, simply SAY what you want, instead of getting angry and boisterous.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Khris on Wed 17/12/2008 09:02:58
Quote from: primitiveuser on Tue 16/12/2008 21:32:31
No, You don't understand I specificly told you in the beginning, re-read my question it tells you what exp to get to what level, viceversa.

The code I've posted does what you want, if 'it' in 'its basically going up by 5s' is referring to the number of required kills.
To put it another way: 15 total kills to reach level 2, 30 total kills to reach level 3, and so on.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: PrimitiveUser on Wed 17/12/2008 17:24:00
Yeah, Bullshit again, Let me re-phrase what I want:

Start out with level 1, I kill 1 monster, I level up to 2, I kill 5 monsters to geto level 3, I kill 10 monsters to get level 4, and so on by 5's(The freaking exp is going up by 5's!)
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: on Wed 17/12/2008 18:00:29
Quote from: PrimitiveUser
I'm level 1 to get to level 2 i must kill 5 monsters wohoo i just leveled 2! now i need to kill 10!

Quote from: PrimitiveUser
start out with level 1, I kill 1 monster, I level up to 2, I kill 5 monsters to geto level 3, I kill 10 monsters to get level 4, and so on by 5's(The freaking exp is going up by 5's!)

Now who's bullshitting whom? But really, is it so hard to alter a few numbers in perfectly working code?

Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Khris on Wed 17/12/2008 19:35:23
Quote from: PrimitiveUser on Wed 17/12/2008 17:24:00
Yeah, Bullshit again
Are you so immature you seriously feel the need to change your request because I was the first one to post the code you were looking for? And you don't even bother to edit your first post? Hahaha, Jesus Christ.

And you've spelled diarrhea wrong.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: PrimitiveUser on Wed 17/12/2008 20:03:11
First of all, I have a swearing problem, if I swear at anyone I don't mean it.

So.., Do me a favor Ghost and KhrisPRICK, when I'm asking a question, please do not answer it.

Good day.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Khris on Wed 17/12/2008 20:51:16
Believe me, swearing is the least of your problems you should be worried about.
And just out of spite, I will continue to answer your questions.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Dualnames on Wed 17/12/2008 21:15:00

int monstercounter=4;//this is a variable that works as a counter.
int currentlevel=1;//starts on level one
//int amountofmonsterskilled=0;
//un-comment the line if you want monsters to be counted on. So for example you use that integer in a GUI that shows how many monsters you've killed.

//code to put when a monster dies//
monstercounter++;
//amountofmonsterskilled++;
if (monstercounter==5) {
currentlevel++;
monstercounter=0;
/*
if (currentlevel==2) {
//have a character animate like FF games do ecc..
}
*/
}
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: suicidal pencil on Wed 17/12/2008 21:23:31
Quote from: PrimitiveUser on Wed 17/12/2008 17:24:00
Start out with level 1, I kill 1 monster, I level up to 2, I kill 5 monsters to geto level 3, I kill 10 monsters to get level 4, and so on by 5's(The freaking exp is going up by 5's!)

You just described a Geometric sequence turning into an arithmetic sequence, which, depending how you code it, can get very messy

I'd recommend just using a geometric sequence for the experience.

So, level one would take 1 xp
Level two would take  5 xp
level three would take 25 xp
level four would take 125 xp
level five would take 625 xp
and so on.

The formula representing this would look like this:

tn = as(n-1)

where tn is the amount of experience, (n-1) is the level, a is the first number in the series (so, in this case, 1), and s is the common ratio.

So for level twenty, you will need tn = (1)(5)(20-1) experience, or...

tn = (1)(5)(20-1)
tn = (1)(5)(19)
tn = (1)(19073486328125)
tn = 19073486328125

It seems like a serious amount, but if you raise the experience that the monsters you fight in the late game give you, it doesn't see too harsh.

And personally, I think that level 20 should be your max if you decide to use this method, for the amount of experience needed would be about 3.1554436208840472216469142611311x1068, or 3, followed by about 68 zeroes.

Just create a function to do it, and you'll be fine for the rest of your game.

note: You don't have to use 5 as the common ratio.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Akatosh on Wed 17/12/2008 21:26:06
Khris, you can't just go around answering stupid questions in a calm and helpful manner but act all surprised when the people turn against you!
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Dualnames on Wed 17/12/2008 21:31:35
Suidical pencil, I think he wants exp to go up to five per level..

EDIT: Just noticed you offered an alternative. Nevermind me. Good idea btw.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Khris on Wed 17/12/2008 22:06:00
Urgh.
I already answered his original question, with code.
His "new" question requires a small change to that code; "1" instead of "5" in the third line.
Is this some kind of contest now?

Akatosh: yeah, what was I thinking ;)
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Dualnames on Wed 17/12/2008 22:12:07
Quote from: KhrisMUC on Wed 17/12/2008 22:06:00
Urgh.
I already answered his original question, with code.
His "new" question requires a small change to that code; "1" instead of "5" in the third line.
Is this some kind of contest now?


I don't really think it is. I just posted my code again because it worked in the first time. As yours.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: Trent R on Wed 17/12/2008 22:25:23
Personally, I like seeing multiple ways to write code. If you set it up simply the first time, it can be easier to make adjustments in the future. Not to mention ideas to completely change it, such as suicidal pencil's.

~Trent
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: space boy on Wed 17/12/2008 22:26:33
Quote from: PrimitiveUser on Wed 17/12/2008 20:03:11
First of all, I have a swearing problem, if I swear at anyone I don't mean it.

How about not swearing at all instead of making dumb excuses for being an ass?
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: suicidal pencil on Wed 17/12/2008 22:43:02
Quote from: KhrisMUC on Wed 17/12/2008 22:06:00
Is this some kind of contest now?

What gives you that idea?

I'm just giving suggestions on how primitive could optimize the experience needed.
Title: Re: rpg leveling up after an ammount of monsters/enemies are killin
Post by: R4L on Wed 17/12/2008 23:30:07
Just stop answering his questions. It's obvious that he isn't experienced and won't learn on his own, so he's just going to boss you guys around. Soon he'll probably be asking for sprites...

Please don't waste your time on him. :)