rpg leveling up after an ammount of monsters/enemies are killin

Started by PrimitiveUser, Sun 14/12/2008 17:39:56

Previous topic - Next topic

PrimitiveUser

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 ;)

Mantra of Doom

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
Code: ags
GiveScore(1);


Then in your global script you could add this into your rep_execute
Code: ags

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


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

"Imitation is the sincerest form of imitation."

Trent R

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
Code: ags
GiveScore(1);


Then in your global script you could add this into your rep_execute
Code: ags

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


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

Revamped:
Code: ags

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


~Trent
PS-Have you noticed the sticky in this forum that's all about RPGs with AGS?
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Lt. Smash

why not just
Code: ags

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);

Dualnames

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.

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

If I understand primitive user correctly, it takes an additional 10 kills to get to level 3, then another 15 kills aso.

Code: ags
// 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.

PrimitiveUser

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.

Trent R

[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
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Ghost

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:
Code: ags

int exp_needed = 5;


Then, for levelling:
Code: ags

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.

Khris

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.

PrimitiveUser

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!)

Ghost

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?


Khris

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.

PrimitiveUser

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.

Khris

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.

Dualnames

Code: ags

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..
}
*/
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

suicidal pencil

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.

Akatosh

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!

Dualnames

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.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

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 ;)

SMF spam blocked by CleanTalk