Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-31-2005, 04:23 AM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Fire rate

I have a simple weapon script which fires a weapon but at the moment every time you press D it fires. How can i make it so theres a larger inteval between firing?

Thanks.
Reply With Quote
  #2  
Old 12-31-2005, 04:48 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
You could set a flag to true if the weapon is fired and the flag is false. Then, set a timeout to reset the flag.
Reply With Quote
  #3  
Old 12-31-2005, 05:29 AM
Kronan Kronan is offline
yo
Kronan's Avatar
Join Date: May 2001
Location: Florida, USA
Posts: 682
Kronan is on a distinguished road
Send a message via ICQ to Kronan Send a message via AIM to Kronan Send a message via Yahoo to Kronan
Here is a small example:


NPC Code:
//#CLIENTSIDE
function onCreated() {
this.fired = true;
}
function onWeaponFired() {
if (this.fired) {
// your stuff can go here
this.fired = false;
setTimer(5);
}
else
{
player.chat = "You must wait 5 seconds before firing again!";
}
}
function onTimeout() {
if (this.fired == false) {
this.fired = true;
setTimer(5);
}
}

__________________
Reply With Quote
  #4  
Old 12-31-2005, 05:32 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Kronan
Here is a small example:


NPC Code:
//#CLIENTSIDE
function onCreated() {
this.fired = true;
}
function onWeaponFired() {
if (this.fired) {
// your stuff can go here
this.fired = false;
setTimer(5);
}
else
{
player.chat = "You must wait 5 seconds before firing again!";
}
}
function onTimeout() {
if (this.fired == false) {
this.fired = true;
}
}

Why did you make this.fired counterintuitive?
Reply With Quote
  #5  
Old 12-31-2005, 03:57 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Thanks.

Is there any reason to use function onCreated() {} over if(created) {}?
Reply With Quote
  #6  
Old 12-31-2005, 04:43 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 JkWhoSaysNi
Thanks.

Is there any reason to use function onCreated() {} over if(created) {}?
Kronan's example is gscript2. if (created) is not.
__________________
Skyld
Reply With Quote
  #7  
Old 12-31-2005, 07:25 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
Ah, thanks.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:14 PM.


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