Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-26-2005, 06:31 PM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
Talking TGC's School of Script: Emitters

Okay. About time I shared my newfound and dearly loved knowledge on emitters. (This is an extremely long post, but read it if you want to learn Particle Emitters through and through, and yes I will start from the beginning).

First off, new function, we will need this for the Emitters:
PHP Code:
findimg(index
This function can be used for the following script:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
showimg(1,"block.png",player.x,player.y);
  
findimg(1).player.5;
  
with (findimg(1)) {
    
mode 1;
    
red 1;
    
blue 0;
    
green .5;
  }

In short, findimg(index) works exactly like findplayer(index), and can be used in much the same way, but relative to images, and not a player.
Important notes before we start:
  1. Indefined images have an image of "" (A blank string)
  2. Undefined images have an x and y equal to the player's x and y

Now, onto Particle Emitters!!

A particle emitter is an object. Just like 'player.' or 'this.', it is an object. It's parent is the TShowImg, which is the showimg object. First off, you do not need to define an image to cast an emitter on it. in fact, I did not and I made some pretty nice and simple emitters. (Attached is a preview of what I have made, and that's on Babylon). Now, the 'emitter.' object is how we access and create an emitter. First off, the basics:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
with (findimg(1)) {
    
layer 2// This will make the emitter draw under the player
    
player.x;
    
player.y// These will show the emitter at the player's coords. 
Follow along with what I'm doing? Now, here are the variables we will need to define, after setting the layer, x, and y, still inside the findimg() bracket:
PHP Code:
emitter.delaymin float// This is the minimum delay between emissions
emitter.delaymax float// This is the maximum delay between emissions, both of these are in seconds
emitter.emissionoffset string// In format of "{float, float, float}", it's the offset from the x, y, and z that an emission will show. It's the delta variables for the location, basically.
emitter.nrofparticles integer// The number of particles to be released at the same exact time when the emitter emits. For example, set this to two, and you'll have two particles released every time instead of the default 1 
There. Define those as you wish. I have the mindelay as .01 and the max as .05. The offset I have as {.5,0,0}, which places the left edge of the emitters .5 tiles to the right. Now, time to teach how to change the particle attributes, and not just the base laws that govern them.
PHP Code:
emitter.particle.lifetime float// How long, in seconds, the emitter lasts.
emitter.particle.image string// The imagename of the emitter
emitter.particle.mode integer// Either 0, 1, or 2, the same as changeimgmode
emitter.particle.alpha float// Between 0 and 1, the alpha colour for transparancy
emitter.particle.zoom float// The zoom effect of the particle
emitter.particle.red float;
emitter.particle.green float;
emitter.particle.blue float// These three are between 0 and 1, and they're the colours of the individual particles

emitter.particle.zangle float// Between 0 and pi*2, it's the upward angle of the particles. Remember zangle from the shoot() function? Same basic idea.
emitter.particle.angle float// Again, between 0 and pi*2, it's the angle that the particle should flow.
emitter.particle.speed float// I'm not sure if this is measured in Tiles per second or what, but it's the speed. Higher = faster, obviously
emitter.particle.stretchy float// Remember elipses from your Advanced Algebra class? The eccentricity? Remember that? This is it! Yay. Values less than 1 stretch it horizontally, while values more than 1 stretch the image vertically. Fun, fun. 
Now time to close the code!
PHP Code:
  }

There.

Well, I hope that taught you a thing or two about emitters! <3, and attached is the picture of what I've done with my emitter images. Note: You'll have to change the image's x and y to the player's x and y inside a timeout loop if you want the emitter to follow the player, as I have it.

Have fun!

EDIT: I left out the things I, myself, don't fully understand. Sorry. z-z
Attached Thumbnails
Click image for larger version

Name:	emitters.png
Views:	444
Size:	147.0 KB
ID:	33200  
__________________
"The higher you fly, the harder it is to breathe."

[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight

Last edited by ForgottenLegacy; 08-26-2005 at 06:46 PM..
Reply With Quote
 


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 08:04 PM.


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