Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-23-2013, 06:09 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Joining and leaving classes

is there an event called when joining and/or leaving classes? Something along the lines of onJoinedClass(); and onLeaveClass();.

I'm at work right now so I cannot provide an exact example of what I'm currently doing but it's something along the lines of the following.

PHP Code:
functions loadClassData(temp.objtemp.classlist) {
  for (
temp.classnametemp.classlist) {
    if (
temp.classname in temp.obj.joinedclasses) {
      
temp.obj.(temp.classname "::onJoined")();
    } else {
      
temp.obj.join(temp.classname);
      
temp.obj.(temp.classname "::onJoined")();
    }
  }

I did a quick search and didn't see anything that stuck out.
Reply With Quote
  #2  
Old 08-23-2013, 06:17 PM
baseman101 baseman101 is offline
Scripter
baseman101's Avatar
Join Date: Nov 2012
Location: Purcellville, VA
Posts: 76
baseman101 will become famous soon enough
Yes, there does happen to be an event that happens when you join a class. I'm certain about onClassJoined() but not too certain about onClassLeaves (or something similar).
Reply With Quote
  #3  
Old 08-23-2013, 06:45 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by baseman101 View Post
Yes, there does happen to be an event that happens when you join a class. I'm certain about onClassJoined() but not too certain about onClassLeaves (or something similar).
Could not find any documentation on it and a forum search yielded no relevant post.
Reply With Quote
  #4  
Old 08-23-2013, 06:51 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
PHP Code:
onClassLoaded(strevent class script has been updatedname of the class 
That's about it. What are you trying to achieve?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 08-23-2013, 06:53 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by xXziroXx View Post
PHP Code:
onClassLoaded(strevent class script has been updatedname of the class 
That's about it. What are you trying to achieve?
Ah, was looking for 'join' not 'class' when i was searching scriptfuctions
Reply With Quote
  #6  
Old 08-23-2013, 07:03 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Double post since you wanted to know what i was trying to achieve.

For certain classes such as skills I want to load all the data such as names, icons and descriptions when it's initially loaded. It's more for the benefit of tool tips than anything else. I don't feel the need to make a database with descriptions and such of each. I only have 4 skills per class that i can load in a single array for each of them so it's not like i'm setting 50 flags with a huge amount of data in them. I didn't feel like it requires an SQLite table. I'll see if this resolves my issue when i get off work.
Reply With Quote
  #7  
Old 08-23-2013, 07:19 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I have a similar approach on Maloria, although instead I make sure to load all the important classes upon login before proceeding with adding any weapons.

PHP Code:
function onActionServerSide(temp.command)
{
  if (
temp.command == "initialized") {
    
player.triggerAllWeapons("onPlayerInitialized");
    
    
player.removeWeapon(this.name);
  }
}

public function 
loadClasses()
{
  if (
player.classesLoaded)
    return echo(
format("[%s]: Classes already loaded for player %s, aborting..."this.nameplayer.communityName));
  
  
temp.classList = { // Array with the classes you want to preload
  
};
  
  for (
temp.classNametemp.classList)
    
player.join(temp.className);
  
  
player.classesLoaded true;
  
triggerClient("gui"this.name"loadClasses"temp.classList);
}

function 
onPlayerLogout(temp.playerObject)
  
temp.playerObject.classesLoaded false;

//#CLIENTSIDE
const DEBUG_MODE true;

function 
onActionClientSide(temp.command)
{
  
// Return if it's not the trigger sent from loadClasses()
  
if (temp.command != "loadClasses")
    return;
  
// Return if classes has already been loaded this session
  
if (player.classesLoaded)
    return;
  
  
temp.classList.copyFrom(params[1]);
  
  for (
temp.classNametemp.classList) {
    
// Load the class to the player
    
if (!player.isInClass(temp.className)) {
      
player.join(temp.className);
      
debug(format("[%s]: Joining class '%s'..."this.nametemp.className));
    }
    
    
// Maybe the class is loaded already?
    
if (isClassLoaded(temp.className)) {
      continue;
    }
    
    
loadClass(temp.className);
    
debug(format("[%s]: Class '%s' not loaded yet, loading..."this.nametemp.className));
    
    while (!
isClassLoaded(temp.className))
      
sleep(0.05);
  }
  
  
player.classesLoaded true;
  
debug(format("[%s]: All classes loaded!"this.name));
  
  
triggerServer("gui"this.name"initialized");
}




function 
debug(temp.text)
{
  if (
DEBUG_MODE)
    echo(
temp.text);

__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #8  
Old 08-23-2013, 07:25 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
I'm actually doing something more similar to your post than my original but sometimes joining clientside classes is touchy and unreliable as they don't load right away. I might need to add a sleep such as you have and that would probably resolve those issues.
Reply With Quote
  #9  
Old 08-23-2013, 11:57 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
onClassLoaded doesn't do anything it appears.
Reply With Quote
  #10  
Old 08-24-2013, 12:44 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
Are you giving your skills their own weapon script?

If so just store a 'this.description' flag for your other scripts to read from.
__________________
Quote:
Reply With Quote
  #11  
Old 08-24-2013, 12:49 AM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by fowlplay4 View Post
Are you giving your skills their own weapon script?

If so just store a 'this.description' flag for your other scripts to read from.
I'm creating them all in classes so I can easily use the same skills with NPCs such as baddies or friendly quest NPCs without rescripting them.
Reply With Quote
  #12  
Old 08-24-2013, 05:58 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by fowlplay4 View Post
Are you giving your skills their own weapon script?
I'm not. Each skill has it's own class code. At some point, I made all skills useable by both players and NPC baddies, which was quite messy but worked quite nicely for spells and such that you'd want NPC baddies to be able to use. Old example of it:

PHP Code:
public function onUseSkill(target)
{
  
temp.var = (objecttype() == "TServerPlayer" "clientr" "this");
  
temp.var2 = (objecttype() == "TServerPlayer" "client" "this");
  
  
// Name of this skill
  
temp.skill "melee";
  
// Skill data
  
temp.skill.copyFrom(this.skills.(@skill));
  
// What hand is the player attacking with (MainHand/OffHand)?
  //this.(@temp.skill @ "_hand") = (this.(@temp.skill @ "_hand") == "MainHand" ? "OffHand" : "MainHand");
  
this.(@temp.skill.indentifier "_hand") = "MainHand";
  
// What is equipped in that hand?
  
temp.identifier this.equippedInSlot(this.(@temp.skill.indentifier "_hand"));
  
temp.identifier this.getItemIdentifier(temp.identifier);
  
// Item data
  
temp.item_data CACHE.query("items"temp.identifier);
  
  if (var == 
"this") {
    (@
var2).freezetimer item_data.freezeTimer;
  
    
setCharAni(this.gani_idle"");
    
setCharAni(this.gani_attack"");
    
    if (
this.width == NULL && this.height == NULL)
      
temp.tarsize = { 2};
    else
      
temp.tarsize = { this.widththis.height };
    
    
this.dir getdir((target.1.5) - (this.temp.tarsize[0]/2), (target.2) - (this.temp.tarsize[1]/2));
  }
  
  
target.trigger("WeaponAttack"this, (@var).equipped_MainHand);
}

//#CLIENTSIDE
public function onUseSkill()
{
  
temp.var = (this.objecttype() == "TPlayer" "player" "this");
  
  
// Is the player already busy?
  
if ((@var).freezetimer 0)
    return;
  
  
// Name of this skill
  
temp.skill "melee";
  
// Skill data
  
temp.skill.copyFrom(this.skills.(@skill));
  
// What hand is the player attacking with (MainHand/OffHand)?
  //this.(@temp.skill @ "_hand") = (this.(@temp.skill @ "_hand") == "MainHand" ? "OffHand" : "MainHand");
  
this.(@temp.skill "_hand") = "MainHand";
  
// What is equipped in that hand?
  
temp.identifier player.equippedInSlot(this.(@temp.skill "_hand"));
  
//echo(this.(@temp.skill @ "_hand") @ ":" SPC temp.identifier);
  
temp.identifier player.getItemIdentifier(temp.identifier);
  
// Item data
  
temp.item_data CACHE.query("items"temp.identifier);
    
  (@var).
freezetimer temp.item_data.freezeTimer;
    
  
onSetAni(client.gani_idle);
  
onSetAni(client.gani_attack);
}

function 
onSetAni(gani)
{
  if (
player != NULL)
    
setAni(gani"");
  else
    
setCharAni(gani"");

(it's old, messy and made with poor styling - I haven't actually been using it since 2010)
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
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 08:15 PM.


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