Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Something as simple as a Bomb (https://forums.graalonline.com/forums/showthread.php?t=134261755)

MrOmega 01-19-2011 05:41 PM

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.weapon0] == name && params0] == 68 && client.carry == NULL)
  {
    
    
client.freeze true;
    
player.attr2] = "legends_sbombs-i.png";
    
setani"legends_lay"NULL);
    
sleep0.3);
    
player.attr2] = "";
    
temp.frontX player.dir == 1? ( player.1.5): player.dir == 3? ( player.2.5): ( player.0.5);
    
temp.frontY player.dir == 0? ( player.1.25): player.dir == 2? ( player.2.5): ( player.1.25);
    
triggerServer"gui""-system.core""dropObj"temp.frontXtemp.frontY"small_bombs"1true"Small Bombs");   
    
sleep0.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()
{

  
setshape13232);
  
setCharAni"legends_smallBomb"NULL);
  
scheduleEvent5"onDestroy");

}

function 
onDestroy()
{

  if ( 
this.attr2] != "")
    
findPlayerthis.attr2]).client.carry NULL;

  
with putNPC2this.1.5this.1.5""))
    { 
this.join"explosion");}
    
  
this.destroy();

}

function 
onActionPulled()
{

  
temp.pl findPlayerparams0]);
  
temp.pl.client.carry "sObj";
  
temp.pl.client.freeze true;
  
temp.pl.setani"legends_lift"NULL);
  
sleep0.35);
  
temp.pl.client.freeze false;
  
this.attr1] = "carried";
  
this.attr2] = temp.pl.account;
  
setTimer0.3);
  
}

function 
onTimeout()
{

  if ( 
this.attr1] == "carried")
  {
  
    
temp.pl findPlayerthis.attr2]);
    
    
this.temp.pl.0.5;
    
this.temp.pl.1;
  
  }
  
  if ( 
this.landed)
  {
  
    
this.this.nx;
    
this.this.ny;
    
show();
    
this.landed false;
  
  }
  
  
setTimer0.1);

}

function 
onActionPlaced()
{

  
setTimer0);
  
temp.pl findPlayerparams0]);
  
temp.nx temp.pl.dir == 1? ( temp.pl.1.5): temp.pl.dir == 3? ( temp.pl.2.5): ( temp.pl.0.5);
  
temp.ny temp.pl.dir == 0? ( temp.pl.1.25): temp.pl.dir == 2? ( temp.pl.2.5): ( temp.pl.1.25);  
  
temp.pl.client.freeze true;
  
temp.pl.setani"legends_lay"NULL);
  
sleep0.3);
  
temp.pl.client.carry =
  
temp.pl.client.freeze false;
  
this.attr1] = this.attr2] = "";
  
this.temp.nx;
  
this.temp.ny;

}

function 
onActionThrown()
{

  
setTimer0);
  
temp.pl findPlayerparams0]);
  
this.nx temp.pl.dir == 1? ( temp.pl.5.5): temp.pl.dir == 3? ( temp.pl.6.5): ( temp.pl.0.5);
  
this.ny temp.pl.dir == 0? ( temp.pl.5.25): temp.pl.dir == 2? ( temp.pl.6.5): ( temp.pl.1.25);  
  
temp.pl.client.freeze true;
  
temp.pl.setani"legends_grab"NULL);
  
temp.angle getanglevecxtemp.pl.dir), vecytemp.pl.dir));
  
hide();
  
this.attr1] = this.attr2] = "";        
  
temp.pl.client.carry false;
  
setshootparams"Small Bomb"this.nametemp.pl.accounttimevar2);
  
shoottemp.pl.xtemp.pl.ytemp.pl.1temp.angle01"legends_smallBomb"NULL);
  
onTimeout();     
 
}

//#CLIENTSIDE

function onCreated()
{

  
setshape13232);
  
dontBlock();
  
onTimeout();

}

function 
GraalControl.onKeyDown()
{

  if ( 
this.attr1] == "carried")
  {
  
    if ( 
params0] == 68)
      
triggerActionthis.xthis.y"Placed"player.account);

    else if (
params0] == 65)
      
triggerActionthis.xthis.y"Thrown"player.account);

  }
}

function 
onTimeout()
{

  if ( 
this.attr1] == "carried")
  {

    
drawOverPlayer();
    
    if ( 
this.attr2] == player.account)
    {
    
      
this.player.0.5;
      
this.player.1;
  
    }
  }
  
  else
    
this.layer 1;
  
  
setTimer0.05);



Finally in the NPC-Control I have the onActionSProjectile to catch all projectiles.

PHP Code:

function onActionSProjectile()
{

  switch ( 
params2])
  {
  
    case 
"Small Bomb":
    
      
temp.pl findPlayerparams4]);
      
temp.n  findNPCparams3]);
      
temp.pl.client.freeze false;
      
temp.n.landed true;

    break;
  
  }


How could I improve this?

fowlplay4 01-19-2011 05:52 PM

:( @ using keycodes instead of keydown(i).

MrOmega 01-19-2011 06:05 PM

Quote:

Originally Posted by fowlplay4 (Post 1624085)
:( @ using keycodes instead of keydown(i).

Would that send the triggeraction any faster? :/

Deas_Voice 01-19-2011 08:51 PM

Quote:

Originally Posted by MrOmega (Post 1624087)
Would that send the triggeraction any faster? :/

no, but it would allow a player to use his/her key options in F3

MrOmega 01-19-2011 09:09 PM

Quote:

Originally Posted by Deas_Voice (Post 1624127)
no, but it would allow a player to use his/her key options in F3

I'm not in favor of that currently. I'll probably implement a custom key assignment system on my server sometime in the future.

fowlplay4 01-19-2011 09:09 PM

Quote:

Originally Posted by Deas_Voice (Post 1624127)
no, but it would allow a player to use his/her key options in F3

Yes, despite the small amount of controls the actions native to Graal (Grab, Attack, Use) they should be checked using the proper keydown functions.

DustyPorViva 01-19-2011 09:13 PM

Quote:

Originally Posted by MrOmega (Post 1624134)
I'm not in favor of that currently. I'll probably implement a custom key assignment system on my server sometime in the future.

Eww. GTFO. Let people use what keys they ****ing want to use.

MrOmega 01-19-2011 09:15 PM

Quote:

Originally Posted by DustyPorViva (Post 1624137)
Eww. GTFO. Let people use what keys they ****ing want to use.

hey chill out, I will implement one eventually but as for now it's classic forced ASD and arrows.

Deas_Voice 01-19-2011 09:17 PM

fair enuff' if his going to make his own key assignment system, no?

fowlplay4 01-19-2011 09:45 PM

Quote:

Originally Posted by Deas_Voice (Post 1624140)
fair enuff' if his going to make his own key assignment system, no?

Since keydown also applies to joystick support, no. There's no reason he can't add a button to open the F3 menu and set it to the Controls tab though or just modify that table altogether to include his extra features.

But we've drifted quite far off from what he actually wanted help with...

Deas_Voice 01-19-2011 09:51 PM

Quote:

Originally Posted by fowlplay4 (Post 1624144)
Since keydown also applies to joystick support, no. There's no reason he can't add a button to open the F3 menu and set it to the Controls tab though or just modify that table altogether to include his extra features.

who uses joystick these days? :oo:
also, isn't it removed in v6?

and i would like a custom one instead as it could have a nicer graphic and more/better functions.
Quote:

Originally Posted by fowlplay4 (Post 1624144)
But we've drifted quite far off from what he actually wanted help with...

true'..


as far as i know, doing it tru projectile stuff and placing the bomb with putnpc, is the best way to do it.
did something similar but with arrow's landing on walls or on the player who got hit a long time ago, but not like a GK bow where you click and it would land there, more like a classic one'

Lance 01-19-2011 11:55 PM

Only have time for a small comment right now, but please remember that triggeractions are trusted implicitly; you have just created some functions where a malicious person could make any other player pick up or throw your bombs. Don't send the account as a parameter like that.

Also I assume it was just a typo but your onActionPlaced has an unfinished line.

MrOmega 01-20-2011 12:38 AM

Ok, how would I talk to the serverside of a class script? Where do you see a typo in onActionPlaced.

Lance 01-20-2011 05:49 AM

Quote:

Originally Posted by MrOmega (Post 1624242)
Ok, how would I talk to the serverside of a class script?

The problem occurs when you are including an arbitrary account as a parameter, so a malicious player could send the wrong account to do some screwy stuff. I guess the simplest way around that would be to stick with what you're doing but use 'actionplayer' serverside to get the account of the person doing the action instead of passing it as a parameter.

Quote:

Where do you see a typo in onActionPlaced.
I was referring to:

PHP Code:

  temp.pl.client.carry =
  
temp.pl.client.freeze false

where your code implies you are trying to do

PHP Code:

  temp.pl.client.carry temp.pl.client.freeze false

while your formatting implies that these are supposed to be two distinct lines with one being unfinished. I'm not trying to do any stylistic criticism here but it just seemed a bit ambiguous to me. :)

MrOmega 01-20-2011 06:36 AM

Actionplayer it is.

Oh and that's just my styling, it can be chaotic to others but I can read it fast and good. :D


All times are GMT +2. The time now is 12:35 PM.

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