Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 06:27 AM.


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