Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   theres somthing wrong with my gun script (https://forums.graalonline.com/forums/showthread.php?t=84361)

GULTHEX 02-23-2009 02:55 AM

theres somthing wrong with my gun script
 
2 Attachment(s)
PHP Code:

//#CLIENTSIDE

if (weaponfired){
clientr.m16=1;}
{if(
clientr.m16=1);

function 
onKeyPressedcodekey ) {
  if ( 
key == "g" ) {
    
setshootparams PARAMEQUALS;
  
//shoot x,y,z,angle,zangle,power,gani,ganiparams;
  
shoot this.x,this.y,playerz,(playerdir 1) * pi 2,,,shuriken,;
  
setani dg_m16-fire,;
  
replaceani idle,dg_m16-idle;
  
replaceani walk,walk;
  
freezeplayer 0.0383;
  
sleep 0.1;

  
//up
if (playerdir=0)
  
this.x=playerx-1;
  
this.y=playery-2;

//left
if (playerdir=1)
  
this.x=playerx-2;
  
this.y=playery;

//down
if (playerdir=2)
  
this.x=playerx+1;
  
this.y=playery+2;

//right
if (playerdir=3)
  
this.x=playerx+2;
  
this.y=playery;


if (
actionprojectile) {
  if(
strequals(#p(index),PARAMEQUALS)) {
  
}}}}} 

ok ill explan whats wrong with it


its like this if i turn it on then shoot it shoots where i stand

when i move to a difrent spot it shoots from the same spot that i shot from
when i fire it again
until i shoot again

ok ill show you what i mean

heres a pic


it goes from this
http://forums.graalonline.com/forums...1&d=1235351866
]to this


http://forums.graalonline.com/forums...1&d=1235351866



so its from


the first pic


to the second pic


up to down

hotrian 02-23-2009 06:22 PM

bored enough to post..
 
Quote:

Originally Posted by GULTHEX (Post 1468759)
PHP Code:

//#CLIENTSIDE

if (weaponfired){
clientr.m16=1;}
{if(
clientr.m16=1);

function 
onKeyPressedcodekey ) {
  if ( 
key == "g" ) {
    
setshootparams PARAMEQUALS;
  
//shoot x,y,z,angle,zangle,power,gani,ganiparams;
  
shoot this.x,this.y,playerz,(playerdir 1) * pi 2,,,shuriken,;
  
setani dg_m16-fire,;
  
replaceani idle,dg_m16-idle;
  
replaceani walk,walk;
  
freezeplayer 0.0383;
  
sleep 0.1;

  
//up
if (playerdir=0)
  
this.x=playerx-1;
  
this.y=playery-2;

//left
if (playerdir=1)
  
this.x=playerx-2;
  
this.y=playery;

//down
if (playerdir=2)
  
this.x=playerx+1;
  
this.y=playery+2;

//right
if (playerdir=3)
  
this.x=playerx+2;
  
this.y=playery;


if (
actionprojectile) {
  if(
strequals(#p(index),PARAMEQUALS)) {
  
}}}}} 


What?

PHP Code:


if (weaponfired){
clientr.m16=1;}
{if(
clientr.m16=1); 

It's been a while, but I don't think this math is correct.
PHP Code:

 (playerdir 1) * pi 

Without brackets, only the line directly after an if statement is actually checking the statement; The second line is always running with your methods. Also, You're horribly mixing GS1 with GS2..

And why are you setting these after you have already "shot" the bullet? More than that, this.x and this.y are reserved vars; Use something else like this.dx and this.dy
PHP Code:

if (playerdir=1)
  
this.x=playerx-2;
  
this.y=playery

What are these closing?

PHP Code:

}}}}} 

'scuse me if I'm horribly wrong :3

cbk1994 02-24-2009 12:23 AM

This is like, you're third thread for the exact same script.

You need to use this for your angle:
PHP Code:

temp.angle = (pi 2) * (player.dir 1); 

Look carefully at your code, then look up something called "order of operations"; it will explain why "your" angle didn't work, though it is nearly the same.

Tolnaftate2004 02-24-2009 03:08 AM

Quote:

Originally Posted by cbk1994 (Post 1468899)
This is like, you're third thread for the exact same script.

You need to use this for your angle:
PHP Code:

temp.angle = (pi 2) * (player.dir 1); 

Look carefully at your code, then look up something called "order of operations"; it will explain why "your" angle didn't work, though it is nearly the same.

There are many things wrong with this script, but ironically, it is not this.

To clarify, match your brackets properly, and use player.x + 2*vecx(player.dir) + vecy(player.dir) and player.y + 2*vecy(player.dir) instead of this.x and this.y respectively.

Codein 02-24-2009 02:47 PM

I can see you're assigning values to playerdir rather than comparing them. Instead of using playerdir = 0 or playerdir = 1, use playerdir == 1.


All times are GMT +2. The time now is 12:02 AM.

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