Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gani is not accepting any params being sent to it =| (https://forums.graalonline.com/forums/showthread.php?t=134267090)

Jiroxys7 09-08-2012 09:54 PM

Gani is not accepting any params being sent to it =|
 
I've been working on this dumb thing for about two hours now and I cannot for the life of me figure out why the gani isn't getting the param containing the angle data. There does not appear to be any syntax errors with the gani script.

Here's the class:
PHP Code:

function oncreated(){
  
join("systemfunctions");
  
attr[2] = this.dmg;
  
attr[1] = this.ang*100;
  
attr[3] = this.from;
  
attr[4] = this.fromguild;
  
attr[5] = this.fromgroup;
  
attr[6] = this.fromlvl;
  
this.timeleft 0.5;
  
onHitNPCs();
  
setTimer(0.5);
}

function 
onTimeout() {
  
this.lifetime++;
  if (
level.pos("gmap") < 0) {
    if (
<= || >= 64 || <= || >= 64) {
      
destroy();
    }
  }
  
  for (
temp.nfindareanpcs(x-7,y-7,14,14)) {
    if (
temp.n.attr[6] != NULL && this.hashit.index(temp.n) < 0) {
      for (
temp.0temp.4temp.a++) {
        if (
this.hashit.index(temp.n.attr[6]) < 0) {
          
temp.dist GetDist(temp.n,temp.a);
          if (
dist <= 5) {
            
temp.n.trigger("ActionDamage"this.dmg .6,{{"mdmg"},{"magic","water"},{"nomiss"}},attr[7],attr[6],attr[5],save[2]);
            
this.hashit.add(temp.n.attr[6]);
          }
        }
      }
    }
  }
  
  
+= (cos(attr[1]/100) * 1.25)*10;
  
-= (sin(attr[1]/100) * 1.25)*10;
  if (
this.lifetime >= 4destroy();
  
setTimer(.5);
}

function 
GetDist(targettemp.a) {
  return ((
target.- (this.cos(attr[1]/100) * 1.25 temp.a*2.5))^+ (target.- (this.sin(attr[1]/100) * 1.25 temp.a*2.5))^2)^.5
}

function 
onHitNPCs(){
  for (
nfindareanpcs(x-2,y-2,4,4)) {
    
n.trigger("ActionDamage",this.dmg,""/*{{"nomiss"}}*/,this.from,this.fromguild,this.fromgroup,this.fromlvl);
  }
}

//#CLIENTSIDE
function onCreated(){
  
setTimer(0.05);
}
function 
onTimeout(){
  
showani(201,this.x,this.y,0,"zod-projectile-harpoon",attr[1]/100);
  
+= cos(attr[1]/100) * 1.25//1.25
  
-= sin(attr[1]/100) * 1.25;
  
temp.len = ((player.x)^+ (player.y)^2)^.5//2,2,.5
  
if (temp.len <= 4) {
    if (!
this.hashit) {
      
findweapon("-System").trigger("ActionDamage",attr[8],{{"mdmg"},{"magic","water"},{"frozenlance"},{"nomiss"}},attr[7],attr[6],attr[5],save[2]);
      
this.hashit true;
    }
  }
  
//if (player.x in |x-2,x+2| && player.y in |y-2,y+2|) {
  //  if(player.account != attr[3]){
  //    findweapon("-System").trigger("ActionDamage",attr[2]/10,""/*{{"nomiss"}}*/,attr[3],attr[4],attr[5],attr[6]);
  //  }
  //}
  //play("axe.wav");
  
setTimer(0.05);


And the gani:
PHP Code:

SCRIPT
function onCreated(){

   
with (findimg(200))
  {
    
spin degtorad(0);
    
rotation degtorad(0);

    
with (emitter)
    {
      
delaymin 0;
      
delaymax 0;
      
nrofparticles 1;
      
emitautomatically true;
      
autorotation false;
      
firstinfront true;
      
emissionoffset = {0,0,0};
      
attachposition true;
      
checkbelowterrain false;
      
continueafterdestroy false;
      
attachtoowner true;
      
maxparticles 1;

      
particleTypes 1;

      
// Harpoon
      
with (particles[0])
      {
        
image "zodiac_harpoon.png";
        
zoom 2;
        
red 1;
        
green 1;
        
blue 1;
        
alpha 1;
        
mode 1;
        
lifetime 1;
        
angle degtorad(0);
        
zangle degtorad(0);
        
speed 0;
        
rotation degtorad(params[0]);
        
spin degtorad(0);
        
partx 0;
        
party 0;
        
partw 0;
        
parth 0;
        
stretchx 1;
        
stretchy 1;
        
sound "";
        
layer 2;
      }

    }
  }

   
with (findimg(201))
  {
    
spin degtorad(0);
    
rotation degtorad(0);

    
with (emitter)
    {
      
delaymin 0;
      
delaymax 0;
      
nrofparticles 1;
      
emitautomatically true;
      
autorotation false;
      
firstinfront true;
      
emissionoffset = {0.5,0.5,0};
      
attachposition false;
      
checkbelowterrain false;
      
continueafterdestroy false;
      
attachtoowner true;
      
maxparticles 100000;

      
particleTypes 1;

      
// Rope
      
with (particles[0])
      {
        
image "zodiac_harpoonrope.png";
        
zoom 2;
        
red 1;
        
green 1;
        
blue 1;
        
alpha 1;
        
mode 1;
        
lifetime 5;
        
angle degtorad(32);
        
zangle degtorad(0);
        
speed 0;
        
rotation degtorad(0);
        
spin degtorad(0);
        
partx 0;
        
party 0;
        
partw 0;
        
parth 0;
        
stretchx 1;
        
stretchy 1;
        
sound "";
        
layer 2;
      }

      
addlocalmodifier("once"00"rotation""replace"degtorad(0), degtorad(360)); // Random Rotation
    
}
  } 
}
SCRIPTEND 

In addition, I recently learned that you can do stuff like player.chat = whatever within gani scripts. But for some reason it's not working with this script. And earlier it was working like a this.chat instead. (I've taken it out of the posted script)
So what the hell is going on? !pissed!

Jiroxys7 09-09-2012 04:48 PM

Nobody has any idea why this is happening? =(

I've gotten projectile ganis to rotate before. But I can't figure out why it's not working in this instance.

cbk1994 09-09-2012 05:12 PM

Are you sure that the script is actually being executed? Most of the time I find it's necessary to do work in GANI scripts in both onCreated and onPlayerEnters. Add an echo or two as well to help debug (echo the params in particular to make sure they're being sent).

xXziroXx 09-09-2012 06:03 PM

I'm pretty sure onCreated does absolutely nothing in gani scripts, try with onPlayerEnters instead.

Jiroxys7 09-09-2012 07:14 PM

Well this is embarrassing... I did manage to get the echo's working this time somehow. Turns out the param was coming through just fine. I just forgot that the angle it was sending through was a radian. so putting it in the degtorad() part rotated it by such a small amount that I didn't think it was actually working. x_x

cbk1994 09-09-2012 08:16 PM

Quote:

Originally Posted by Jiroxys7 (Post 1703447)
Well this is embarrassing... I did manage to get the echo's working this time somehow. Turns out the param was coming through just fine. I just forgot that the angle it was sending through was a radian. so putting it in the degtorad() part rotated it by such a small amount that I didn't think it was actually working. x_x

Best to do work in programming in radians and not degrees anyway. Try to avoid degtorad and just use radians from the beginning.

Jiroxys7 09-10-2012 02:43 PM

Quote:

Originally Posted by cbk1994 (Post 1703451)
Best to do work in programming in radians and not degrees anyway. Try to avoid degtorad and just use radians from the beginning.

I hate to admit it, but I'm not at all familiar with radians. You learn about them in trig or something, right? The garbage school that I went to never taught past basic algebra. It's no wonder math is my weak point :/

cbk1994 09-10-2012 09:56 PM

Quote:

Originally Posted by Jiroxys7 (Post 1703500)
I hate to admit it, but I'm not at all familiar with radians. You learn about them in trig or something, right? The garbage school that I went to never taught past basic algebra. It's no wonder math is my weak point :/

Typically radians are introduced whenever you start doing basic right-triangle trig. They're just an alternative unit of measurement for angles. pi is 180 degrees; you can get the rest of the measurements you need from there, or just echo the appropriate degtorad (best not to use it repeatedly in code though).

You can see radian measurements and corresponding angle measurements:

http://teachers.henrico.k12.va.us/ma...UnitCircle.png


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

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