Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-08-2007, 06:26 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Basic leveling system

HTML Code:
public function gainExperience(levelName, amountGain)
  {
  if (!temp.levelName || !temp.amountGain)
    return false;
  
  temp.amountNeeded = this.expNeeded(temp.levelName);
  this.clientr.("stat_exp-" @ temp.levelName) += temp.amountGain;
 
  if (this.gatherExperience(temp.levelName) >= temp.amountNeeded)
    this.gainLevel(temp.levelName);  
  
  if (temp.levelName != "main")
    {
    this.gainExperience("main", temp.amountGain);
    this.chat = temp.levelName @"--"@ this.gatherExperience(temp.levelName) @"/" @ temp.amountNeeded;
    }
  }
function gainLevel(levelName)
  {
  this.clientr.("stat_level-" @ temp.levelName) += 1;
  this.chat = "Gained a level in" SPC temp.levelName @"! New level:" SPC this.gatherLevel(temp.levelName);
  //Add anything else you would like here, such as a bonus for gaining levels
  }
  
public function expNeeded(levelName)
  return int(((this.clientr.("stat_level-" @ temp.levelName) ^ 2) / 70) * 100) ^ 2;

public function gatherExperience(levelName)
  return this.clientr.("stat_exp-" @ temp.levelName);
  
public function gatherLevel(levelName)
  return this.clientr.("stat_level-" @ temp.levelName);
PHP Code:
  gainExperience(levelNameamountGain);
    
//gainExperience("stength", 45)
    // Gives the player 45 exp for a strength level. It also creates a stat for overall experience gained. This stat is saved as "clientr.stat_exp-main".

  
expNeeded(levelName);
    
//expNeeded("strength");
    // Returns how much EXP is needed for gaining a level.

  
gatherExperience(levelName);
    
//gatherExperience("strength");
    // How much experience the player currently has in that level. 
  
  
gatherLevel(levelName);
    
//gatherLevel("strength");
    // Returns the players current level 
Reply With Quote
  #2  
Old 03-08-2007, 06:32 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
Nice!
__________________
Reply With Quote
  #3  
Old 03-08-2007, 10:51 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
So this gains an experience for a multitude of differently named levels/stats and NOT one overall level? :o
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #4  
Old 03-08-2007, 11:17 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by killerogue View Post
So this gains an experience for a multitude of differently named levels/stats and NOT one overall level? :o
Read the PHP part of the script, you'll find you're mistaken!
Reply With Quote
  #5  
Old 03-15-2007, 11:23 AM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Quote:
Originally Posted by Chandler View Post
Read the PHP part of the script, you'll find you're mistaken!
Like I said Chandler, this gains levels for each stat? As you have strength their. Which is a stat so I assumed this gained levels for each stat.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #6  
Old 03-15-2007, 11:30 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by killerogue View Post
Like I said Chandler, this gains levels for each stat? As you have strength their. Which is a stat so I assumed this gained levels for each stat.
Ah yes, you're correct!
Please, fix your pms! I can't reply back to you!
Reply With Quote
Reply


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 11:19 PM.


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