Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-02-2006, 01:15 PM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
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?
__________________



Reply With Quote
  #2  
Old 06-02-2006, 02:17 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Rename your shoot function, otherwise it is recursively calling itself, that's why its probably -10000 since that is the "loop" limit.
Reply With Quote
  #3  
Old 06-02-2006, 04:08 PM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
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?
__________________




Last edited by Omini; 06-02-2006 at 04:26 PM..
Reply With Quote
  #4  
Old 06-02-2006, 04:24 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Good ol' Graal's lack of function overloading :P

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


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 06-02-2006, 05:09 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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).
Reply With Quote
  #6  
Old 06-02-2006, 05:35 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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()?
__________________
Skyld
Reply With Quote
  #7  
Old 06-03-2006, 04:43 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
O_o when was overloading functions implemented?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 06-03-2006, 11:31 AM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
Perhaps with the introduction to GS2?
__________________



Reply With Quote
  #9  
Old 06-03-2006, 02:34 PM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
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.
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
  #10  
Old 06-04-2006, 11:22 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Why not use C++ style and call the default functions just like ::shoot()?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:10 PM.


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