Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Moving a Particle Emitter (https://forums.graalonline.com/forums/showthread.php?t=134267037)

Jiroxys7 08-25-2012 07:22 PM

Moving a Particle Emitter
 
First the story. I'm trying to make a new effect on Zodiac using the Blessing of Stamina gani as a template, since it makes an image float around behind, and in front of the player. I made a particle with a trail effect, and I'm trying to figure out how to move the emitter along the path that blessing of stamina uses. The problem is, I can't for the life of me figure out how to move it. And I have to move the emitter in order to retain the trailing effect. So moving the particle isn't an option here. Does anyone know how to do this? :confused:

This is the one that I had figured would work:
(I've also tried with(findimg(200)){emitter.x += stuff;emitter.y += stuff;} with no success.)

PHP Code:

GANI0001

CONTINUOUS
DEFAULTHEAD head19
.png
DEFAULTBODY body
.png

SCRIPT
function onPlayerenters(){
  
this.max 1;
  
this.0;
  
this.1;
  
this..2;
  if (
this.max <= 0this.max 1;
  
setarray(this.angle,this.max);
  
setarray(this.zed,this.max);
  
setarray(this.zmove,this.max);
  
setarray(this.zgoto,this.max);


  for(
a=0;a<this.max;a++) {
    
this.angle[a] = 4.78;
    
this.zed[a] = random(0,1.25);
    
this.zmove[a] = 0;
    
this.zgoto[a] = random(0,1.5);
  }

  
setTimer(.05);
}

function 
onTimeout(){
  
setTimer(.05);
  for(
a=0;a<this.max;a++) {
    
this.angle[a] = (this.angle[a]+.1)%6.28;
    if (
this.zgoto[a] > this.zed[a]) {
      if (
this.zmove[a] < .1this.zmove[a] += .05;
    }
    if (
this.zgoto[a] < this.zed[a]) {
      if (
this.zmove[a] > -.1this.zmove[a] -= .05;
    }
    if (
this.zed[ain |this.zgoto[a]-.1,this.zgoto[a]+.1|) this.zgoto[a] = random(0,1.5);
    
this.zed[a] += this.zmove[a];
    
findimg(200).x+=.75+sin(this.angle[a]);
    
findimg(200).y+=.5+cos(this.angle[a])*.5;
    
findimg(200).this.zed[a]-1;

    if (
this.angle[ain |1.57,4.71|) findimg(200).layer 1
    else 
findimg(200).layer 2;
  }
}

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;
      
attachtoowner true;
      
checkbelowterrain false;
      
continueafterdestroy true;
      
maxparticles 100000;

      
particleTypes 1;

      
// Curse
      
with (particles[0])
      {
        
image "light4.png";
        
zoom 0.2;
        
red 0.5;
        
green 1;
        
blue 0;
        
alpha 1;
        
mode 2;
        
lifetime 1;
        
angle degtorad(270);
        
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("range"0.251"zoom""replace"0.20); // Zoom Out
      
addlocalmodifier("range"0.251"alpha""replace"0.990); // Fade Out
      
addlocalmodifier("range"00.5"red""replace"0.51); // Red
      
addlocalmodifier("range"00.5"blue""replace"01); // Blue
    
    
}
  }
}
SCRIPTEND

ANI
ANIEND 


cbk1994 08-25-2012 08:02 PM

You should be able to just move the actual image (findImg(200).x = whatever).

Jiroxys7 08-25-2012 08:26 PM

Quote:

Originally Posted by cbk1994 (Post 1702522)
You should be able to just move the actual image (findImg(200).x = whatever).

Isn't that in the code I posted? It doesn't seem to work =S

Even when I put just findimg(200) += 1; In the timeout it fails. (Just in case the mathematics weren't actually being calculated.)

cbk1994 08-25-2012 08:35 PM

Quote:

Originally Posted by Jiroxys7 (Post 1702525)
Isn't that in the code I posted? It doesn't seem to work =S

Even when I put just findimg(200) += 1; In the timeout it fails. (Just in case the mathematics weren't actually being calculated.)

You need to move the x, not the object. I didn't test your code, though. Add an actual image (like block.png) to the findimg to see if it's moving or not.

Jiroxys7 08-25-2012 09:48 PM

Quote:

Originally Posted by cbk1994 (Post 1702526)
You need to move the x, not the object. I didn't test your code, though. Add an actual image (like block.png) to the findimg to see if it's moving or not.

Well it'll move if I nest a x+=1; into the findimg(200) part but outside of the with(emitter) part. However, it'll only start at a different area. After that it doesn't seem to want to move. Even if I call onCreated(); from the timeout. The block seems to confirm this. =S

cbk1994 08-25-2012 09:57 PM

Quote:

Originally Posted by Jiroxys7 (Post 1702536)
Well it'll move if I nest a x+=1; into the findimg(200) part but outside of the with(emitter) part. However, it'll only start at a different area. After that it doesn't seem to want to move. Even if I call onCreated(); from the timeout. The block seems to confirm this. =S

An emitter is not a physical object in the level, it's part of the image. You need to move the image if you want the emission location to move. Possibly you need to look into attachtoowner or similar if you want emitted particles to follow the image after it moves.

I would get it working in an NPC first then move it to a GANI script later, they are notoriously annoying.

Jiroxys7 08-25-2012 09:59 PM

Quote:

Originally Posted by cbk1994 (Post 1702537)
An emitter is not a physical object in the level, it's part of the image. You need to move the image if you want the emission location to move. Possibly you need to look into attachtoowner or similar if you want emitted particles to follow the image after it moves.

I would get it working in an NPC first then move it to a GANI script later, they are notoriously annoying.

It is set to attachtoowner = true. It really seems like it's a case of you-can-move-it-once-but-never-again. I'll try making an npc though.

Edit: It appears the problem was in fact attachtoowner = true; Once I set it to false, it was much more receptive to moving around.


All times are GMT +2. The time now is 06:19 PM.

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