Ok so I got it working on the basics, now I want to make it look better. Smoother rather. Any thoughts of how to achieve this?
Here's what I got.
In my Weapon I have this
PHP Code:
public function Equip()
{
return;
}
public function unEquip()
{
return;
}
//#CLIENTSIDE
function onCreated()
{
this.description = "<b><u>Small Bombs</u></b>\nDecent pack of power for a small bomb. Good for blasting enemies or holes in walls.";
}
function GraalControl.onKeyDown()
{
if ( clientr.currentCharacter.weapon[ 0] == name && params[ 0] == 68 && client.carry == NULL)
{
client.freeze = true;
player.attr[ 2] = "legends_sbombs-i.png";
setani( "legends_lay", NULL);
sleep( 0.3);
player.attr[ 2] = "";
temp.frontX = player.dir == 1? ( player.x - 1.5): player.dir == 3? ( player.x + 2.5): ( player.x + 0.5);
temp.frontY = player.dir == 0? ( player.y - 1.25): player.dir == 2? ( player.y + 2.5): ( player.y + 1.25);
triggerServer( "gui", "-system.core", "dropObj", temp.frontX, temp.frontY, "small_bombs", 1, true, "Small Bombs");
sleep( 0.1);
client.freeze = false;
}
}
in -system.core it puts an npc at the specified locations joined to what I have.
In class I have this.
PHP Code:
function onCreated()
{
setshape( 1, 32, 32);
setCharAni( "legends_smallBomb", NULL);
scheduleEvent( 5, "onDestroy");
}
function onDestroy()
{
if ( this.attr[ 2] != "")
findPlayer( this.attr[ 2]).client.carry = NULL;
with ( putNPC2( this.x - 1.5, this.y - 1.5, ""))
{ this.join( "explosion");}
this.destroy();
}
function onActionPulled()
{
temp.pl = findPlayer( params[ 0]);
temp.pl.client.carry = "sObj";
temp.pl.client.freeze = true;
temp.pl.setani( "legends_lift", NULL);
sleep( 0.35);
temp.pl.client.freeze = false;
this.attr[ 1] = "carried";
this.attr[ 2] = temp.pl.account;
setTimer( 0.3);
}
function onTimeout()
{
if ( this.attr[ 1] == "carried")
{
temp.pl = findPlayer( this.attr[ 2]);
this.x = temp.pl.x + 0.5;
this.y = temp.pl.y - 1;
}
if ( this.landed)
{
this.x = this.nx;
this.y = this.ny;
show();
this.landed = false;
}
setTimer( 0.1);
}
function onActionPlaced()
{
setTimer( 0);
temp.pl = findPlayer( params[ 0]);
temp.nx = temp.pl.dir == 1? ( temp.pl.x - 1.5): temp.pl.dir == 3? ( temp.pl.x + 2.5): ( temp.pl.x + 0.5);
temp.ny = temp.pl.dir == 0? ( temp.pl.y - 1.25): temp.pl.dir == 2? ( temp.pl.y + 2.5): ( temp.pl.y + 1.25);
temp.pl.client.freeze = true;
temp.pl.setani( "legends_lay", NULL);
sleep( 0.3);
temp.pl.client.carry =
temp.pl.client.freeze = false;
this.attr[ 1] = this.attr[ 2] = "";
this.x = temp.nx;
this.y = temp.ny;
}
function onActionThrown()
{
setTimer( 0);
temp.pl = findPlayer( params[ 0]);
this.nx = temp.pl.dir == 1? ( temp.pl.x - 5.5): temp.pl.dir == 3? ( temp.pl.x + 6.5): ( temp.pl.x + 0.5);
this.ny = temp.pl.dir == 0? ( temp.pl.y - 5.25): temp.pl.dir == 2? ( temp.pl.y + 6.5): ( temp.pl.y + 1.25);
temp.pl.client.freeze = true;
temp.pl.setani( "legends_grab", NULL);
temp.angle = getangle( vecx( temp.pl.dir), vecy( temp.pl.dir));
hide();
this.attr[ 1] = this.attr[ 2] = "";
temp.pl.client.carry = false;
setshootparams( "Small Bomb", this.name, temp.pl.account, timevar2);
shoot( temp.pl.x, temp.pl.y, temp.pl.z + 1, temp.angle, 0, 1, "legends_smallBomb", NULL);
onTimeout();
}
//#CLIENTSIDE
function onCreated()
{
setshape( 1, 32, 32);
dontBlock();
onTimeout();
}
function GraalControl.onKeyDown()
{
if ( this.attr[ 1] == "carried")
{
if ( params[ 0] == 68)
triggerAction( this.x, this.y, "Placed", player.account);
else if (params[ 0] == 65)
triggerAction( this.x, this.y, "Thrown", player.account);
}
}
function onTimeout()
{
if ( this.attr[ 1] == "carried")
{
drawOverPlayer();
if ( this.attr[ 2] == player.account)
{
this.x = player.x + 0.5;
this.y = player.y - 1;
}
}
else
this.layer = 1;
setTimer( 0.05);
}
Finally in the NPC-Control I have the onActionSProjectile to catch all projectiles.
PHP Code:
function onActionSProjectile()
{
switch ( params[ 2])
{
case "Small Bomb":
temp.pl = findPlayer( params[ 4]);
temp.n = findNPC( params[ 3]);
temp.pl.client.freeze = false;
temp.n.landed = true;
break;
}
}
How could I improve this?