Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Virtual Welding (https://forums.graalonline.com/forums/showthread.php?t=134265133)

Gunderak 11-29-2011 11:14 AM

Virtual Welding
 
Hey, I am trying to re-create my favourite hobby, ARC Welding.
I am wondering how I could create the "sparks" that fly off though.
Here is the basics of my script so far.
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
hideimgs(200500000);
  
this.indexn 200;
  
onTimeout();
}

function 
onMouseDown(var) {
  if (var == 
"left") {
    
this.mode "on";
  }
}

function 
onMouseUp(var) {
  if (var == 
"left") {
    
this.mode "off";
  }
}

function 
onTimeout() {
  if (
this.mode == "on") {
    
this.indexn += 1;
    
showimg(this.indexn"g4_particle_sun.png"mousex 2mousey 2);
    
findimg(this.indexn).zoom random(0.20.3);
    
findimg(this.indexn).red 1;
    
findimg(this.indexn).green 1;
    
findimg(this.indexn).blue 1;
  }
  
settimer(0.05);


Maybe some kind of particle emmiter would do the job.

xAndrewx 11-29-2011 07:45 PM

ya use the particle system

Emera 11-29-2011 07:57 PM

Use a light particle, zoom it down and when you execute your welding action, make them fly off at random speeds in random directions.

papajchris 11-29-2011 10:17 PM

I thought this thread was titled virtual wedding. Got my hopes up...

Emera 11-29-2011 10:49 PM

Quote:

Originally Posted by papajchris (Post 1675785)
I thought this thread was titled virtual wedding. Got my hopes up...

That's so weird. I first read it and thought, "What the hell is he playing at now..."

Lol. Strange.

Fulg0reSama 11-29-2011 10:49 PM

Quote:

Originally Posted by papajchris (Post 1675785)
I thought this thread was titled virtual wedding. Got my hopes up...

+rep, likewise.

edit: uh I mean accidental -rep

papajchris 11-29-2011 11:07 PM

Quote:

Originally Posted by Fulg0reSama (Post 1675790)
+rep, likewise.

Umm you gave me negative! Its okay though, i made myself chuckle

Fulg0reSama 11-29-2011 11:14 PM

Quote:

Originally Posted by papajchris (Post 1675793)
Umm you gave me negative! Its okay though, i made myself chuckle

Uh, sorry D:

I pm'd you some compensation for your loss.

Gunderak 11-29-2011 11:16 PM

Does anyone happen to know how to make an image fly off at a random direction?
maybe something like this?
PHP Code:

this.angle random(06.4);
this.-= sin(this.angle)*1;
this.-= cos(this.angle)*1


cbk1994 11-29-2011 11:18 PM

Quote:

Originally Posted by Gunderak (Post 1675797)
Does anyone happen to know how to make an image fly off at a random direction?
maybe something like this?
PHP Code:

this.angle random(06.4);
this.-= sin(this.angle)*1;
this.-= cos(this.angle)*1


Why don't you try it and see if it works?

Emera 11-29-2011 11:19 PM

Quote:

Originally Posted by Gunderak (Post 1675797)
Does anyone happen to know how to make an image fly off at a random direction?
maybe something like this?
PHP Code:

this.angle random(06.4);
this.-= sin(this.angle)*1;
this.-= cos(this.angle)*1


When I was getting used to making particle effects, I used ziro's particle editor for quick effects. The effect you're trying to achieve can easily be composed using the editor. Have a look here.

Gunderak 11-29-2011 11:29 PM

@cbk1994 I can't test it because I am at work.
@Emera Thanks for the link il be sure to check It out.

xAndrewx 11-30-2011 12:03 AM

Quote:

Originally Posted by Fulg0reSama (Post 1675790)
+rep, likewise.

edit: uh I mean accidental -rep

Haha +Rep hahaha

Gunderak 11-30-2011 10:57 PM

I have now made the particle effect but how can I make it emit and stop emitting on command?
I have tried a few things but can't seem to get it to work.
Here is how it's set up.
PHP Code:

with(findimg(200)){ 
  
//Stuff.
    
with(emitter){
    
//More stuff.
      
with(particle[0]){
      
//Even more stuff.
      
}
   }



Crow 11-30-2011 10:59 PM

You can control the emitter's behavior by setting emitter.emitautomatically to true or false.

Gunderak 12-01-2011 06:55 AM

It was set to true by default, but changing emitter.stuff doesn't do anything O_o

fowlplay4 12-01-2011 06:57 AM

Just hide the image if you don't want it to emit.

Gunderak 12-01-2011 07:45 AM

Hiding the image isn't realistic.
I have found out to make an emitter emit it has to be within the findimg, so it now works.
Next up on the agenda is a way of hiding images when you're holding down the right mouse button and above them.

Gunderak 12-01-2011 03:09 PM

If anyone's interested in the finished script, here it is.
I may add a blue particle effect in the centre for the realism, at a later date.
PHP Code:

//#CLIENTSIDE
function onCreated() {
  
hideimgs(200100000);
  
this.indexn 200;
  
onTimeout();
}

function 
onMouseDown(var) {
  if (var == 
"left") {
    
this.mode "on";
    
Spark();
  }
}

function 
onMouseUp(var) {
  if (var == 
"left") {
    
this.mode "off";
    
emitter.destroy();
    
emitter.removeparticles();
    
emitter.removemodifiers();
  }
}

function 
onTimeout() {
  if (
this.mode == "on") {
    
this.indexn += 1;
    
showimg(this.indexn"g4_particle_sun.png"mousex 2mousey 2);
    
findimg(this.indexn).zoom random(0.20.3);
    
findimg(this.indexn).red 1;
    
findimg(this.indexn).green 1;
    
findimg(this.indexn).blue 1;
    
findimg(1000000).findimg(this.indexn).1.2;
    
findimg(1000000).findimg(this.indexn).0.8;
    
with(findimg(1000000)) {
      
emitter.emit();
    }
  }
  
settimer(0.05);
}

function 
Spark() {
  
with(findimg(1000000)) {
    
spin degtorad(0);
    
rotation degtorad(0);
    
with(emitter) {
      
delaymin 0.01;
      
delaymax 0.01;
      
nrofparticles 3;
      
emitautomatically false;
      
autorotation true;
      
firstinfront true;
      
emissionoffset = {
        
000
      
};
      
attachposition false;
      
checkbelowterrain false;
      
continueafterdestroy false;
      
maxparticles 100000;
      
particleTypes 1;
      
with(particles[0]) {
        
image "g4_animation_fire.gif";
        
zoom 0.25;
        
red 1;
        
green 1;
        
blue 1;
        
alpha 1;
        
mode 1;
        
lifetime 0.6;
        
angle degtorad(32);
        
zangle degtorad(0);
        
speed 30;
        
rotation degtorad(0);
        
spin degtorad(0);
        
partx 0;
        
party 0;
        
partw 0;
        
parth 0;
        
stretchx 1;
        
stretchy 1;
        
sound "none.wav";
        
layer 2;
      }
      
addlocalmodifier("once"00"angle""replace"degtorad(0), degtorad(360)); // Sparks
      
addlocalmodifier("range"0.250.5"alpha""replace"0.990); // SparkFadeOut
    
}
  }


Have fun ARC Welding pixels to other pixels!

fowlplay4 12-01-2011 03:55 PM

Quote:

Originally Posted by Gunderak (Post 1675955)
Hiding the image isn't realistic.

If you set continueafterdestroy = true; then you don't have your 'realistic' problem because the emitted particles will continue to live on until they die rather than disappear with the image.

xAndrewx 12-01-2011 10:01 PM

jw-

http://postimage.org/image/u4gbvexi9/

why not steal more stuff from era?

Emera 12-01-2011 10:03 PM

Quote:

Originally Posted by xandrewx (Post 1676014)
jw-

http://postimage.org/image/u4gbvexi9/

why not steal more stuff from era?

busted!

MysticalDragon 12-01-2011 10:11 PM

Quote:

Originally Posted by xAndrewx (Post 1676014)
jw-

http://postimage.org/image/u4gbvexi9/

why not steal more stuff from era?

I logged on this server the other day as I seen a lot of era dev staff on it, I guess I'll have to remove those staff o.o

DustyPorViva 12-01-2011 10:12 PM

Quote:

Originally Posted by xAndrewx (Post 1676014)
jw-

http://postimage.org/image/u4gbvexi9/

why not steal more stuff from era?

That street layout makes no damn sense.

Crow 12-01-2011 10:26 PM

Quote:

Originally Posted by xAndrewx (Post 1676014)
why not steal more stuff from era?

It's not like ideas can be stolen..

Emera 12-01-2011 10:32 PM

Quote:

Originally Posted by DustyPorViva (Post 1676019)
That street layout makes no damn sense.

We are looking at Ghetto though.

Gunderak 12-02-2011 12:15 AM

That car wasn't stolen, I scripted it from scratch.
The image was made from photoshop.
I was simply stating the functionality of it is very simmilar.
And what do you mean by why not steal more stuff from Era?
Are you implying that this welding idea was suposibly stolen from Era aswell?

cbk1994 12-02-2011 05:58 AM

Quote:

Originally Posted by xAndrewx (Post 1676014)
jw-

http://postimage.org/image/u4gbvexi9/

why not steal more stuff from era?

@Gunderak:
Is that my staff panel in the top-right corner or just one mimicking it? I've seen that used on like 20 different UC servers (without exaggerating). I don't even recall it being that great (but if it is mine, feel free to keep using it).

Gunderak 12-02-2011 06:12 AM

@cbk1994
I'm really not sure, Death put the script on Ghetto.

Hoo-ray for twitter quotes!


All times are GMT +2. The time now is 12:57 AM.

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