Quote:
Originally Posted by fowlplay4
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, 3 };
else
temp.tarsize = { this.width, this.height };
this.dir = getdir((target.x + 1.5) - (this.x + temp.tarsize[0]/2), (target.y + 2) - (this.y + 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)