Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Shoot problem? (https://forums.graalonline.com/forums/showthread.php?t=66405)

Omini 06-02-2006 01:15 PM

Shoot problem?
 
I don't quite understand it. So I finally got the C-X (Millenium Shotgun) to work which fires 6 bullets etc etc using this part

PHP Code:

function shoot()
  {
    
freezeplayer(0.4);
    
setani("millenium_cx-fire","");
    
client.cxclip -= 1;
    
this.angle getangle(vecx(player.dir),vecy(player.dir));
    
this.dx player.x+vecx(player.dir)*2;
    
this.dy = (player.y-.5)+vecy(player.dir)*2.5;
    
//Setting Shoot Params
    
setshootparams("shoot",this.gunpow,player.account);
    
//Shooting Bullets
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
    
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
  } 

All fine and dandy. But using the exact same script apart from changing client.cx flags to client.stallion (client.cxammo -> client.stallionammo etc)

Altough it seems when I only use 4 shoot commands or less, it completely messes up the script and sets the client.stallionammo to -9983 (yes, in the minuses).

PHP Code:

function shoot()
  {
    
freezeplayer(0.4);
    
setani("millenium_stallion-fire","");
    
client.stallionclip -= 1;
    
this.angle getangle(vecx(player.dir),vecy(player.dir));
    
this.dx player.x+vecx(player.dir)*2;
    
this.dy = (player.y-.5)+vecy(player.dir)*2.5;
    
//Setting Shoot Params
    
setshootparams("shoot",this.gunpow,player.account);
    
//Shooting Bullets
  
shoot(this.dx,this.dy,player.z,this.angle+random(this.maxangle*-1,this.maxangle),0,0,"millenium_bullet","");
  } 

I can't figure out why. To me it's illogical for this to happen because it appears like nothing in the script should effect the amount of bullets that are fired apart from the shoot parts - so why does it mess up when there's 4 or less?

Admins 06-02-2006 02:17 PM

Rename your shoot function, otherwise it is recursively calling itself, that's why its probably -10000 since that is the "loop" limit.

Omini 06-02-2006 04:08 PM

So instead of

PHP Code:

setshootparams("shoot",this.gunpow,player.account); 

Change that? To something like

PHP Code:

setshootparams(player.weapon,this.gunpow.playeraccount); 

If that's not what you mean, then what exactly do you mean?

Edit 1:

Oooh you mean the function shoot()

Alright, thanks.

Edit 2:

Works now, thanks Stefan. I assume the function shoot() was colliding with the shoot command or something?

ApothiX 06-02-2006 04:24 PM

Good ol' Graal's lack of function overloading :P

Shouldn't that flag an error though? like "Function already defined" or something?

Admins 06-02-2006 05:09 PM

You can overload functions, but you should not call your own function if not needed (there is no way yet to call the built-in function explicitely).

Skyld 06-02-2006 05:35 PM

Quote:

Originally Posted by Stefan
You can overload functions, but you should not call your own function if not needed (there is no way yet to call the built-in function explicitely).

Well, you've already got the :: thing going for functions defined in classes. Perhaps you could have global:: or something to get predefined functions, like global::shoot()?

ApothiX 06-03-2006 04:43 AM

O_o when was overloading functions implemented?

Omini 06-03-2006 11:31 AM

Perhaps with the introduction to GS2?

Maniaman 06-03-2006 02:34 PM

Quote:

Originally Posted by Skyld
Well, you've already got the :: thing going for functions defined in classes. Perhaps you could have global:: or something to get predefined functions, like global::shoot()?

I would really, really, really like this. global::shoot() adventure::shoot() default::shoot() anything like that for calling graal's predefined functions.

ApothiX 06-04-2006 11:22 PM

Why not use C++ style and call the default functions just like ::shoot()?


All times are GMT +2. The time now is 07:26 AM.

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