Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Need help with shoot() (https://forums.graalonline.com/forums/showthread.php?t=134265630)

khortez 01-25-2012 04:05 AM

Need help with shoot()
 
I have tried testing it to see if it would shoot a arrow or anything, but it was a no go, I don't even see a shadow being shot. so if anyone could point out what i need to do to get this working, it would be nice, thanks in advance.

Also, additional constructive criticism about the script i have would be nice too. like what i should do instead, or something i should not have done on it would be helpful.


PHP Code:

//#CLIENTSIDE
function onCreated() {
  
this.equip false;
  
this.gunout false;
}

function 
onKeyPressed(codekey) {
  if (
key == "d") {
    if (
this.gunout == true) {
      
onFire();
    } else {
      
onGani();
    }
  }
  if (
key == "a") {
    
this.equip this.gunout false;
    
setani("idle"null);
    
replaceani("idle""idle");
    
replaceani("walk""walk");
    
player.chat "Gun off!";
  }
}

function 
onGani() {
  
this.equip true;
  
setani(this.gani_idlenull);
  
replaceani("idle"this.gani_idle);
  
replaceani("walk"this.gani_walk);
  
player.chat "Gun on!";
  
this.gunout true;
}

//problems below

function onFire() {
  
player.chat "Firing!";
  
setani(this.gani_firenull);
  
setshootparams("arrow"player.account);
  
temp.angle getangle(vecx(player.dir), vecy(player.dir));
  
temp.zangle pi 4;
  
temp.power 1.5;
  
shoot(player.xplayer.yplayer.ztemp.angletemp.zangletemp.power"arrow""barrow0.png");


also, whats that second parameter in setani()?

cbk1994 01-25-2012 05:32 AM

At first glance I'd guess bullets are probably hitting the player after being fired. Have you tried changing the initial x/y?

fowlplay4 01-25-2012 05:40 AM

Not solving your problem directly but...

This scripted Bow example may be of use to you:

PHP Code:

//#CLIENTSIDE

function onWeaponfired() {
  
freezeplayer(0.1);
  
setani("shoot""wbow1.png"); 
  
setshootparams("classic""arrow"player.dirplayer.account);
  
temp.angl getangle(vecx(player.dir), vecy(player.dir));
  
shoot(player.0.5 vecx(player.dir), player.vecy(player.dir), player.ztemp.angl00"classic_arrow"player.dir);


The additional parameters in setani are well.. parameters in the gani:
setani(ani, param1, [param2, param3, ...]);

khortez 01-25-2012 06:08 AM

Quote:

Originally Posted by cbk1994 (Post 1682653)
At first glance I'd guess bullets are probably hitting the player after being fired. Have you tried changing the initial x/y?

I modified it a little bit by adding vecx and vecy but that was it.

and thanks fowlplay4 i'll give it a shot.


All times are GMT +2. The time now is 07:31 PM.

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