Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-26-2006, 12:57 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Leveling System

PHP Code:
/*
  player.addExperience(leveltype, amount)
    Will add some experience for the player
  
  player.findEXPNeeded(leveltype)
    Will return how much EXP is needed to gain a level
*/
function onCreated()
{
  
this.levelTypes = {"Physical""Magic"};
}

public function 
findEXPNeeded(levelType)
{
  if (
this.levelTypes.index(temp.levelType) < 0)
  {
    return 
false;
  }
  
temp.neededEXP this.findSolution(makevar("this.clientr.level_" temp.levelType));
  
temp.currentEXP makevar("this.clientr.exp_" temp.levelType);

  
this.chat format(_("I need to gain %f more experience!"), (temp.neededEXP temp.currentEXP));
}

function 
findSolution(playerLevel)
{
  
temp.expNeeded = (((temp.playerLevel 100) * 1000) / 50);
  return 
temp.expNeeded;
}
  
public function 
addExperience(expTypeamountAdding)
{
  if (
this.levelTypes.index(temp.expType) < 0)
  {
    return 
false;
  }
  if (
temp.amountAdding == NULL)
  {
    return 
false;
  }
  
temp.amountAdding int(temp.amountAdding);
  
  
this.clientr.("exp_" temp.expType) += temp.amountAdding;
  
savelog2("ExpLog.txt"format(_("+%s added %f to %s!"), thistemp.AmountAddingtemp.expType));

  
temp.curExpAmount makevar("this.clientr.exp_" temp.expType);
  
temp.neededEXP this.findSolution(makevar("this.clientr.level_" temp.expType));

  
this.chat format(_("Gained %d in %s! (%d / %d)"), temp.amountAddingtemp.expTypetemp.curExpAmounttemp.neededEXP);
  
  if (
temp.curExpAmount => temp.neededEXP)
  {
    
this.clientr.("level_" temp.expType) += 1;
    
savelog2("LevelLog.txt"format(_("+%s gained a level in %s. (Exp Gained: %f. Current Level: %i.)!"), thistemp.expTypetemp.AmountAddingthis.clientr.("level_" temp.expType)));

    
this.chat format(_("Gained a level in %s! I am now level %d!"), temp.expTypemakevar("this.clientr.level_" temp.expType));
  }

It's a player class, so you'll need to join it to the player (player.join("expsystem").
It explains how to add experience to the player and also return how much EXP is needed for a certain level type.
To create your own level types, just edit the 'this.levelTypes' array.
__________________

Last edited by Skyld; 11-26-2006 at 03:56 PM.. Reason: Use PHP tags >:(
Reply With Quote
  #2  
Old 11-26-2006, 11:14 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I do mine differently. I use clientr.mud(job type) = {currentexp, exp for that level to pass, current level};
Only need 1 function now ^-^.

Also i use a exp table instead of making the new exp needed.

Last edited by Twinny; 11-27-2006 at 09:50 AM..
Reply With Quote
  #3  
Old 11-26-2006, 11:26 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Weird algorithm :o

At level 5, 10000 exp needed, level 6: 12000, level 7: 14000, level 8: 16000, hmm? could of just had done like, + 2000

Level 1, 2000 exp needed, hmm if you had a better algorithm it would been better btw, nice script

edit: That script looks like it would been good on a medevil server or something, magic and stuff
It gave me an idea
__________________
Reply With Quote
  #4  
Old 11-29-2009, 05:56 AM
Samposse Samposse is offline
Chopa Shopa !
Samposse's Avatar
Join Date: Nov 2008
Location: Norway
Posts: 87
Samposse is an unknown quantity at this point
Send a message via AIM to Samposse Send a message via MSN to Samposse
Hi , im Trying to get it to work :P but is it an thing Important i need to get it to work ? or only that it Join the player on login and its a class called expsystem ?

it wont work ... and btw , whats the Flags i use for it ? like clientr.level=60 or clientr.exp_cur and clientr.exp_max ? or is it even any flags i uyse for this to work :P
__________________
Delitto :3

A
SERVER
UNDER
CONSTRUCTION !

feel free to ask me about delitto
Reply With Quote
  #5  
Old 11-29-2009, 06:37 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
This script is pretty outdated, and the use of a single log is ultimately useless, but you just call the function (assuming you joined the class to the player on login) that it provides to you like so:

PHP Code:
function onCreated() {
  
player.addExperience("Physical"1000);

__________________
Quote:
Reply With Quote
  #6  
Old 11-29-2009, 10:53 AM
Samposse Samposse is offline
Chopa Shopa !
Samposse's Avatar
Join Date: Nov 2008
Location: Norway
Posts: 87
Samposse is an unknown quantity at this point
Send a message via AIM to Samposse Send a message via MSN to Samposse
ok shoud i use that in an weapon to the playerr for testing the Script ? and when i level upp ,will it show ? or player say's "LEVEL UP , Curnt levle in" SPC Level "

?

may you Post all the Command i will hawe use for in this Levling System plz
__________________
Delitto :3

A
SERVER
UNDER
CONSTRUCTION !

feel free to ask me about delitto
Reply With Quote
  #7  
Old 11-29-2009, 10:58 AM
Samposse Samposse is offline
Chopa Shopa !
Samposse's Avatar
Join Date: Nov 2008
Location: Norway
Posts: 87
Samposse is an unknown quantity at this point
Send a message via AIM to Samposse Send a message via MSN to Samposse
i did added

Quote:
function onCreated() {
player.addExperience("Physical", 1000);
}
and added the Weapon to the player and reconnect adn then Updated that Weaoon like 5 - 7 times and still nothing -.- is it working ?
__________________
Delitto :3

A
SERVER
UNDER
CONSTRUCTION !

feel free to ask me about delitto
Reply With Quote
  #8  
Old 11-29-2009, 08:22 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
The code I provided will not work in a weapon script like that and was just an example of the proper usage, you need to specify the player object.

PHP Code:
function onCreated() {
  
findplayer("Samposse").addExperience("Physical"1000);

__________________
Quote:
Reply With Quote
  #9  
Old 12-08-2009, 01:55 PM
Samposse Samposse is offline
Chopa Shopa !
Samposse's Avatar
Join Date: Nov 2008
Location: Norway
Posts: 87
Samposse is an unknown quantity at this point
Send a message via AIM to Samposse Send a message via MSN to Samposse
Dos it work ?
__________________
Delitto :3

A
SERVER
UNDER
CONSTRUCTION !

feel free to ask me about delitto
Reply With Quote
  #10  
Old 12-08-2009, 08:28 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by Samposse View Post
Dos it work ?
Yes.
__________________
Stan.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.