Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   gunscript: Yeah i know how unoriginal (https://forums.graalonline.com/forums/showthread.php?t=134256819)

Liberated 11-05-2009 11:17 AM

gunscript: Yeah i know how unoriginal
 
Okay so im working on a gunscript.

PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.z, (playerdir 1) * pi 2NULLNULL"era_bulletfx"NULL);
  
setani("firegani"NULL);
  
freezeplayer(0.5);
  
}
function 
onActionProjectile()
{
   
player.hearts -= 2;


I don't know what im doing wrong, i don't really understand the shoot command yet, but it's not showing the bullet flying.
Oh and, sometimes if i shoot while walking and shoot again i hurt myself :s
as for this one.
PHP Code:

//#CLIENTSIDE
function onKeyPressed()
{
  
temp.equip 1;
  if (
keydown(5))
  {
    if(
temp.equip == 1)
    {
      
temp.equip 0;
      
setani("gunequip"NULL);
      
sleep(1);
      
setani("gunidle"NULL);
    } 
    else
    {
      
temp.equip 1;
      
setani("idle"NULL);
    }
  }
}
function 
onWeaponFired()
{
  if(
temp.equip == 0)
  {
    
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.z, (playerdir 1) * pi 2NULLNULL"era_bulletfx"NULL);
    
setani("gunidlegani"NULL);
    
freezeplayer(0.1);
  }
}
function 
onActionProjectile()
{
   
player.hearts -= 2;


I need to figure out if the player is moving or standing still, to add a walking/idle gani to it, but i have no idea how to check it, also, the ganis don't seem to be working on this one, i haven't made any gani's myself yet, so i used those of a server, and i even uploaded them to testbed, but they still don't work.

i would've checked the wiki for the shoot command, but as we all know that's temporarily down.

I myself think i need a timeout function that will constantly check if the player is moving or standing still

Demisis_P2P 11-05-2009 12:07 PM

Quote:

Originally Posted by Liberated (Post 1536620)
Okay so im working on a gunscript.

I need to figure out if the player is moving or standing still, to add a walking/idle gani to it, but i have no idea how to check it, also, the ganis don't seem to be working on this one, i haven't made any gani's myself yet, so i used those of a server, and i even uploaded them to testbed, but they still don't work.

i would've checked the wiki for the shoot command, but as we all know that's temporarily down.

I myself think i need a timeout function that will constantly check if the player is moving or standing still

You don't need to figure out if the player is walking or not, just use replaceani instead of setani.

PHP Code:

      client.replaceani = {"idle""gunidlegani"};
      
client.replaceani =  {"walk""gunwalkgani"}; 


Liberated 11-05-2009 12:31 PM

oh awesome! didn't know that.

Liberated 11-05-2009 01:34 PM

it fires, and uses the firing gani when i use the fire button, but then i go back to the normal idle gani, and my way of turning the weapon on and off also isn't working.
PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  if(
temp.equip == 0)
  {
    
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.z-1, (playerdir 1) * pi 2NULLNULL"arrow"NULL);
    
setani("era_deagle-fire"NULL);
    
client.replaceani =  {"idle""era_deagle-idle"};
    
client.replaceani =  {"walk""era_deagle-walk"};
    
freezeplayer(0.1);
  }
  else
  {
  
player.chat "hi";
  }
}
function 
onActionProjectile()
{
  
player.hearts -= 2;
}  
function 
onKeyPressed(code,key)


  if(
key == "f" && temp.equip == 1)
  {
    
client.replaceani =  {"era_deagle-reload"};
    
client.replaceani =  {"idle""era_deagle-idle"};
    
client.replaceani =  {"walk""era_deagle-walk"};
    
temp.equip 0;
  } 
  else if(
key == "f" && temp.equip == 0)
  {
    
setani("idle");
    
temp.equip 1;
  }



xXziroXx 11-05-2009 03:27 PM

PHP Code:

client.replaceani =  {"walk""era_deagle-walk"}; 

... is most likely a string that a system in Era reads to determine what ganis to replace. :p

The "proper" way of doing it would be like this:

PHP Code:

replaceAni("walk""era_deagle-walk"); 


Crow 11-05-2009 03:30 PM

Quote:

Originally Posted by xXziroXx (Post 1536633)
... is most likely a string that a system in Era reads to determine what ganis to replace. :p

Exactly :redface: What have you done, Demisis? :p

Liberated 11-05-2009 03:31 PM

ah thanks, hopefully it will work now

edit: so far so good,
only 1 problem, my gun always fires when i press D, and my script to turn it on/off doesn't respond at all.
PHP Code:

//#CLIENTSIDE

function onWeaponFired()
{
  if(
temp.equip == 0)
  {
    
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.z-1, (playerdir 1) * pi 2NULLNULL"arrow"NULL);
    
setani("era_deagle-fire"NULL);
    
replaceAni("idle""era_deagle-idle");
    
replaceAni("walk""era_deagle-walk");
    
freezeplayer(0.1);
  }
  else
  {
  
player.chat "hi";
  }
}
function 
onActionProjectile()
{
  
player.hearts -= 2;
}  
function 
onKeyPressed()
{
  if (
keydown(5))
  {
    if(
temp.equip == 1)
    {
      
setani("era_deagle-reload");
      
replaceani("idle""era_deagle-idle");
      
replaceani("walk""era_deagle-walk");
      
temp.equip 0;
    }

    else
    {
      
replaceAni("idle""idle");
      
replaceAni("walk""walk");
      
temp.equip 1;
    }
  }


editedit:
actually it does turn it off, but not on, and it also slashes my sword so i need to find a fix for that.

editeditedit: Yay got it working, thanks for the help! I also played a bit with the shoot settings, i now get how they work.
PHP Code:

//#CLIENTSIDE
function onKeyPressed()
{
  if (
keydown(6))
  {
    
this.equip this.equip;
    
    if (
this.equip == NULL)
    {
      
replaceAni("idle""idle");
      
replaceAni("walk""walk");
      
setani("walk");
    }
    else
    {
      
setani("era_deagle-reload");
      
replaceAni("idle""era_deagle-idle");
      
replaceAni("walk""era_deagle-walk");
    }
  }
}
function 
onWeaponFired()
{
  if(
this.equip == 1)
  {
    
shoot(player.0.5 vecx(player.dir), player.vecy(player.dir), player.z-1, (playerdir 1) * pi 2NULLNULL"arrow"NULL);
    
setani("era_deagle-fire"NULL);
    
freezeplayer(0.1);
  }
  else
  {
  
player.chat "no gun equiped";
  }
}
function 
onActionProjectile()
{
  
player.hearts -= 2;



Demisis_P2P 11-05-2009 08:49 PM

Quote:

Originally Posted by Crow (Post 1536638)
Exactly :redface: What have you done, Demisis? :p

I DIDN'T KNOW! Oh god, I accidentally gave away an Era secret.

(tbh I just suck at gs2)

Crow 11-05-2009 09:02 PM

Quote:

Originally Posted by Demisis_P2P (Post 1536690)
I DIDN'T KNOW! Oh god, I accidentally gave away an Era secret.

(tbh I just suck at gs2)

What a secret :rolleyes: Been leaked a hundred times already anyway. But you gave false advice! That's far worse :p

cbk1994 11-06-2009 01:02 AM

Quote:

Originally Posted by Demisis_P2P (Post 1536690)
I DIDN'T KNOW! Oh god, I accidentally gave away an Era secret.

(tbh I just suck at gs2)

That's not even the proper way to do it on Era :noob:.

Crow 11-06-2009 07:03 PM

Quote:

Originally Posted by cbk1994 (Post 1536747)
That's not even the proper way to do it on Era :noob:.

It was, if I recall correctly. Been a while.

cbk1994 11-06-2009 11:12 PM

Quote:

Originally Posted by Crow (Post 1536902)
It was, if I recall correctly. Been a while.

They're going to overwrite each other.

Quote:

Originally Posted by Demisis_P2P (Post 1536622)
You don't need to figure out if the player is walking or not, just use replaceani instead of setani.

PHP Code:

      client.replaceani = {"idle""gunidlegani"};
      
client.replaceani =  {"walk""gunwalkgani"}; 


You'll also need to call the movement system and tell it the GANIs have been updated.


All times are GMT +2. The time now is 02:16 AM.

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