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 08-25-2012, 07:22 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
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?

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 
__________________
MY POSTS ARE PRONE TO EDITS!

Last edited by Jiroxys7; 08-25-2012 at 10:05 PM..
Reply With Quote
  #2  
Old 08-25-2012, 08:02 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
You should be able to just move the actual image (findImg(200).x = whatever).
__________________
Reply With Quote
  #3  
Old 08-25-2012, 08:26 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
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.)
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #4  
Old 08-25-2012, 08:35 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
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.
__________________
Reply With Quote
  #5  
Old 08-25-2012, 09:48 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
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
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #6  
Old 08-25-2012, 09:57 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 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.
__________________
Reply With Quote
  #7  
Old 08-25-2012, 09:59 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
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.
__________________
MY POSTS ARE PRONE TO EDITS!

Last edited by Jiroxys7; 08-25-2012 at 10:36 PM..
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 03:42 PM.


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