View Single Post
  #12  
Old 08-24-2013, 05:58 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
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)
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote