Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gun Script (https://forums.graalonline.com/forums/showthread.php?t=75933)

Knightmare1 07-29-2007 08:30 PM

Gun Script
 
my gun can only attack like a sword, and i need to make it so it fires from afar, can someone help me?


__________________________________________________ ________
//#CLIENTSIDE
function onCreated() {
client.max_m16_ammo = 100;
client.m16_ammo= 100;
this.m16_on = 0;
}
function onWeaponFired() {
if (this.m16_on = 0) {
this.m16_on = 1;
if (this.m16_on == 1 && client.m16_ammo > 0) {
replaceani("walk", "nightmare_m16_walk");
replaceani("idle", "nightmare_m16_idle");
replaceani("sword", "nightmare_m16_fire");
} else if (this.m16_on == 1 && client.m16_ammo == 0) {
replaceani("walk", "nightmare_m16_walk");
replaceani("idle", "nightmare_m16_idle");
replaceani("sword", "nightmare_m16_reload");
}
} else if (this.m16_on == 1) {
this.m16_on = 0;
replaceani("walk", "walk");
replaceani("idle", "idle");
replaceani("sword", "sword");
}
}
function onKeyPressed(keycode, keychar) {
if (this.harpo_on == 1 && keychar == "r") {
if (client.harpo_ammo == 0) {
setani("nightmare_m16_reload", " ");
client.m16_ammo = client.max_m16_ammo;
}
}
if (keychar == "s" && client.m16_ammo > 0) {
client.m16_ammo -= 1;
setshootparams("damage", 10);
temp.shootangle = getangle(vecx(player.dir), vecy(player.dir));
shoot(player.x+vecx(player.dir), player.y+vecy(player.dir), player.z, temp.shootangle, 0, 0, "nightmare_m16_bullet", NULL);
}
}

Knightmare1 08-10-2007 04:47 PM

.......... i know half of are stealing it so DONT READ UNLESS U CAN HELP!!!
(or u just wanna chat, thats fine too.)

xXziroXx 08-10-2007 09:18 PM

Why would anyone want to steal this..?

Horrified 08-10-2007 10:18 PM

Quote:

Originally Posted by Knightmare1 (Post 1335288)
my gun can only attack like a sword, and i need to make it so it fires from afar, can someone help me?

what do you mean o_o?

You mean you press S and a sword comes up anyway...?

and I don't know why someone would steal a script that's BROKEN.

Twinny 08-11-2007 01:16 AM

Also questionable whether you made that or not. Seems to follow a common format :whatever:

Cloven 08-11-2007 01:22 AM

Seems like sloppy code in general. x_x

zokemon 08-12-2007 03:30 AM

At least he seems to somewhat understand his objects.
But I cringe at this:
Quote:

if (this.m16_on = 0) {

Angel_Light 08-12-2007 05:31 AM

You need to use the shoot() command for a good gun in my opinion, wiki has good documentation on this command, but you could also use showimg with some checks and what not, seems like it might lag. The reason it only attacks like a sword is because your replace the sword ani which is default to only hurt the things in front you, not things that are afar.


All times are GMT +2. The time now is 01:24 AM.

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