Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-08-2011, 01:27 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Needed Formula for Exp / Level Gain

Hey guys, i'm here with another question.
--------------------------------------------------------------------------
What would be a good formula to substitute for all of this repetition:
PHP Code:
    if (clientr.exp == 200) {
      
clientr.explevel 2;
      
clientr.exp 1;
      
clientr.expneeded 199;
    }
    if (
clientr.exp 400) {
      
clientr.explevel 3;
      
clientr.exp 1;
      
clientr.expneeded 399;
    }
    if (
clientr.exp 800) {
      
clientr.explevel 4;
      
clientr.exp 1;
      
clientr.expneeded 799;
    }
    if (
clientr.exp 1600) {
      
clientr.explevel 5;
      
clientr.exp 1;
      
clientr.expneeded 1599;
    }
    if (
clientr.exp 3200) {
      
clientr.explevel 6;
      
clientr.exp 1;
      
clientr.expneeded 3199;
    }
    if (
clientr.exp 6400) {
      
clientr.explevel 7;
      
clientr.exp 1;
      
clientr.expneeded 6399;
    }
    if (
clientr.exp 12800) {
      
clientr.explevel 8;
      
clientr.exp 1;
      
clientr.expneeded 12799;
    } 
Thanks in advance!
__________________
Reply With Quote
  #2  
Old 09-08-2011, 01:32 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
temp.needed = (2 ^ clientr.explevel) * 100;
__________________
Quote:
Reply With Quote
  #3  
Old 09-08-2011, 01:36 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Quote:
Originally Posted by fowlplay4 View Post
temp.needed = (2 ^ clientr.explevel) * 100;
How would I implent that?
__________________
Reply With Quote
  #4  
Old 09-08-2011, 01:43 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
If you are using my EXP Barebones then all you need to do is replace the temp.needed line in the getEXPNeeded function.

Link: http://forums.graalonline.com/forums...58&postcount=3
__________________
Quote:
Reply With Quote
  #5  
Old 09-08-2011, 01:44 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by Ohk4y View Post
How would I implent that?
PHP Code:
if ( clientr.exp => temp.needed ) {
  
// stuff

I would imagine.
Reply With Quote
  #6  
Old 09-08-2011, 01:47 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Okay, I replaced it and it is working now, thanks again fowlplay4!
__________________
Reply With Quote
  #7  
Old 09-08-2011, 02:00 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
>_<

Wait, Nevermind. It just about killed my hud that displays all of the information..

class : expfunctions
PHP Code:
function onCreated() { 
  
// Check if EXP Level is 0 
  
if (clientr.explevel == 0) { 
    
// Initialize Player EXP Level and EXP Needed 
    
levelUp(); 
  } 


public function 
addEXP(amount) { 
  
// Increment EXP by Amount 
  
clientr.exp += amount
  
checkEXP(); 


function 
checkEXP() { 
  
// Calculate EXP Needed 
  
temp.needed getEXPNeeded(); 
  
// Check if EXP Needed Matches Clientr EXP Needed Flag 
  
if (clientr.expneeded != temp.needed) { 
    
// Update Clientr Flag 
    
clientr.expneeded temp.needed
  } 
  
// Check if EXP is Greater than or Equal to EXP Needed 
  
if (clientr.exp >= temp.needed) { 
    
levelUp(); 
  } 


function 
getEXPNeeded() { 
  
// Calculate Amount of EXP Needed for Level 
  
temp.needed = (clientr.explevel) * 100;
  return 
temp.needed


public function 
levelUp() { 
  
// Set EXP to 0 
  
clientr.exp 0
  
// Increase Level 
  
clientr.explevel++; 
  
// Update EXP Needed for New Level 
  
clientr.expneeded getEXPNeeded(); 

weapon : -System/LevelUp
PHP Code:

function onActionServerSide(cmd) {
  if (
cmd == "LevelUp") {
    if (
clientr.exp == null) {
      
clientr.exp 1;
    }
    if (
clientr.explevel == null) {
      
clientr.explevel 1;
    }
    if (
clientr.expneeded == null) {
      
clientr.expneeded 199;    
    }
    if ( 
clientr.exp => temp.needed ) { 
      
temp.needed = (clientr.explevel) * 100;
    }  
  }
}

//#CLIENTSIDE
function onCreated() onTimeOut();
function 
onTimeOut() {
triggerserver("gui"name"LevelUp");
setTimer(.05);

__________________
Reply With Quote
  #8  
Old 09-08-2011, 02:08 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
You don't need that system at all, and all your system is doing is spamming the server with triggers for no reason...

Everything is taken care of in the player-joined expfunctions class.

All you have to do in other systems is call the player's addEXP function.

Show me what script you have in your onActionPlayerOnline function in your Control-NPC, because I have a feeling you might not even be using it correctly.
__________________
Quote:
Reply With Quote
  #9  
Old 09-08-2011, 02:11 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
PHP Code:
function onActionPlayerOnline() {
  
//list of other weapons I had but chose not to include in this post :p
  
player.join("expfunctions"); 

    
showStats(0x400+0x200+0x100);
  
EnableFeatures(AllFeatures 4);    
  echo(
"Esteria (Server): "@player.communityname@" has logged in!");
  }

 
/* if (this.accounts.index(player.account)==-1) 
  {
    this.accounts.add(player.account);
    sendtorc("/reset "@ player.account);
  } */ 
__________________
Reply With Quote
  #10  
Old 09-08-2011, 02:22 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
showStats and enableFeatures are both clientside-only, they shouldn't be in onActionPlayerOnline.
__________________
Reply With Quote
  #11  
Old 09-08-2011, 02:24 AM
Ohk4y Ohk4y is offline
Registered User
Ohk4y's Avatar
Join Date: Jun 2011
Posts: 43
Ohk4y is an unknown quantity at this point
Send a message via AIM to Ohk4y
Quote:
Originally Posted by cbk1994 View Post
showStats and enableFeatures are both clientside-only, they shouldn't be in onActionPlayerOnline.
I didn't add them there, though I will remove them, thank you.
__________________
Reply With Quote
  #12  
Old 09-08-2011, 02:27 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
Alright now in other scripts you just have to call:

player.addEXP(100); or findplayer("Ohk4y").addEXP(100);

To add experience to yourself, expfunctions then internally checks to see if you gained enough EXP to level up. The class is flexible enough so you don't have to reset EXP if you change your EXP Needed formula.

It also initializes the player to level 1 if they haven't logged in before (or if their level is 0).

You can also call:

player.levelUp(); if you just want to directly level yourself.
__________________
Quote:
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 06:21 AM.


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