Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   TGC's School of Script: Emitters (https://forums.graalonline.com/forums/showthread.php?t=60740)

ForgottenLegacy 08-26-2005 06:31 PM

TGC's School of Script: Emitters
 
1 Attachment(s)
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. :D
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

Gamba_Legend 08-26-2005 07:05 PM

thats pretty O.o

Ajira 08-26-2005 07:45 PM

You totally forgot about local and global modifiers. You will need those if you want to make nice effects with the particle engine. =/

ChibiChibiLuc 08-26-2005 08:27 PM

Then tell us about local and global modifiers.
TGC doesn't have Stefan's particle system script to look at for reference.

Ajira 08-26-2005 08:38 PM

Quote:

Originally Posted by ChibiChibiLuc
TGC doesn't have Stefan's particle system script to look at for reference.

Now he does.

ForgottenLegacy 08-26-2005 10:23 PM

Quote:

Originally Posted by ChibiChibiLuc
Then tell us about local and global modifiers.
TGC doesn't have Stefan's particle system script to look at for reference.

Yeah I did Yen, it was in Alex's NPC. I just now learned what they can do, so I didn't include it in my post.

I won't post them now because I don't know the difference between a LocalModifier and a GlobalModifier. Ajira gave me an idea, but until he gets an answer from Stefan or I find a way to verify his idea, I won't include them.

calani 08-27-2005 02:30 AM

"omgomgomg breaks of rule #2 ! delet plx !"
:rolleyes:


way to go, TGC!
keep up the good work
I'll be besting you shortly when i can log on again ;)
(and have time to play with them -.-)




Edit:
Quote:

Originally Posted by ForgottenLegacy
Indefined

might want to fix that :p

Ajira 08-27-2005 02:34 AM

Quote:

Originally Posted by calani
"omgomgomg breaks of rule #2 ! delet plx !"
:rolleyes:

Stop doing that please =/
Besides, it doesn't break the rule. He gave the basis of a script, not an actual script, and it was just for educational purposes anyway.

Gamba_Legend 08-27-2005 02:37 AM

Yeah
Please keep up the good work guys
you give slow retarded scripters like me a fair chance at good NAT'ing
<3

calani 08-27-2005 04:11 AM

Quote:

Originally Posted by Gamba_Legend
you give slow retarded scripters like me a fair chance at good NAT'ing

hehe



Quote:

Originally Posted by Ajira
Stop doing that please =/
Besides, it doesn't break the rule. He gave the basis of a script, not an actual script, and it was just for educational purposes anyway.

Seriously, if I posted something like that, it would likely get deleted for the same reason as the last three: supposedly breaking rule #2 with script(s) that demonstrated how to do something with a non-working, bare-bones script.

ForgottenLegacy 08-27-2005 04:25 AM

Rule two states I cannot give a full and complete working script that a person can copy and paste, to solve their problem.

I didn't do that. I gave every aspect of a system, every aspect I understood at that moment, in an effort to teach people about a brand new system that I like. Now, I do think I'm able to post whole scripts as 'donations' to the Grawl public, but I'm not sure. Am I allowed to do that? (If so, I might end up having a few gifts for you guys ^_~)

ChibiChibiLuc 08-27-2005 04:27 AM

It's also illegal to harass players and use RC to give out player's IPs...
But nobody cares, do they? ;)

calani 08-27-2005 04:33 AM

Its also apparently illegal to post broken and incomplete scripts that appear to be complete :whatever:


All times are GMT +2. The time now is 03:15 PM.

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