Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   need help with particle scripting (https://forums.graalonline.com/forums/showthread.php?t=134270497)

Kamaeru 06-03-2017 09:40 AM

need help with particle scripting
 
I want to use this in my emitter to draw the particle image at a different 90 degree angle depending on the player's direction. It should work I think, but it doesn't. I'm assuming it only calculates the rotated image once and never again. I can't think of a way to change it though. Is there a way to handle this?

NPC Code:
rotation = (pi / 2) + player.dir * (pi / 2);



To be more specific, I'm working on a script that draws footsteps behind the player when they walk, and to finish it I need to get the footsteps to draw in the correct corresponding direction. Seems like it would be easy, but I just spent a few hours trying to figure it out and failed. It seems like there is no way to change the image or rotate it once the emitter has started. I also couldn't find any documentation explaining how to properly stop an emitter.

NPC Code:
function drawFootSteps() {
this.drawdir = player.dir;

with (findImg(200)) {
attachtoowner = true;
offsetx = 1.0 - vecx(player.dir);
offsety = 1.5 + (vecy(player.dir) * 0.8) + (abs(vecx(player.dir)) * 0.2) - (vecx(player.dir) * 0.15);
layer = 0;

with (emitter) {
delaymin = 0.1;
delaymax = 0.2;
nrofparticles = 1;
continueafterdestroy = true;

with (particle) {
emissionoffset = {0.2 + offsetx,0.2 + offsety,0};

spin = 0;
angle = 0;

rotation = (pi / 2) + this.drawdir * (pi / 2);


image = "bi_effect_footsteps.png";
speed = 0;
mode = 1;

lifetime = 1.2;
alpha = 1;
zoom = 1;
}

addLocalModifier("range",0.5,1.2,"alpha","add",- 0.7,- 0.7);
addLocalModifier("once",0,0,"x","add",- vecy(player.dir) * 0.3,vecy(player.dir) * 0.3);
temp.addy1 = (vecx(player.dir) > 0 ? - vecx(player.dir) * 0.2 : vecx(player.dir) * 0.3);
temp.addy2 = (vecx(player.dir) < 0 ? - vecx(player.dir) * 0.2 : vecx(player.dir) * 0.3);
addLocalModifier("once",0,0,"y","add",temp.addy1,t emp.addy2);
settimer(.05);
}
}
}


Kamaeru 06-03-2017 11:23 AM

Okay I did figure out how to handle this, but still need help understanding how to stop an emitter without using hideimg() which causes a glitch with my script where the variables from the scope of the original emitter add to the new one instead of resetting when i do it that way. i just want to stop the emitter when my player is idle.

Kirko 06-03-2017 05:25 PM

Maybe something like this
NPC Code:
findimg(200).emitter.emitAutomatically = (player.ani == "idle" ? false : true);


Kamaeru 06-03-2017 07:04 PM

Quote:

Originally Posted by Kirko (Post 1741385)
Maybe something like this
NPC Code:
findimg(200).emitter.emitAutomatically = (player.ani == "idle" ? false : true);


Thanks I will try that when I get home later

Kamaeru 06-04-2017 10:27 AM

Your advice helped, thanks. I am still wondering what the best way is to handle rotating the particle by 90 degrees depending on the player direction. I've tried stuff like " findimg(200).rotation " but it doesn't appear to work that way.


All times are GMT +2. The time now is 12:56 PM.

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