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 09-08-2012, 09:54 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Angry 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?
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #2  
Old 09-09-2012, 04:48 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
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.
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #3  
Old 09-09-2012, 05:12 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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).
__________________
Reply With Quote
  #4  
Old 09-09-2012, 06:03 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I'm pretty sure onCreated does absolutely nothing in gani scripts, try with onPlayerEnters instead.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 09-09-2012, 07:14 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
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.
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #6  
Old 09-09-2012, 08:16 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Jiroxys7 View Post
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.
Best to do work in programming in radians and not degrees anyway. Try to avoid degtorad and just use radians from the beginning.
__________________
Reply With Quote
  #7  
Old 09-10-2012, 02:43 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Quote:
Originally Posted by cbk1994 View Post
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 :/
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #8  
Old 09-10-2012, 09:56 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Jiroxys7 View Post
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:

__________________
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:45 PM.


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