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 07-01-2002, 12:28 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
A little help please.

Ok. I haven't had many server jobs and im not very good at online scripting. So I need help with this fireworks script.

It works just fine for the leader but only he can see the fireworks.

NPC Code:

// NPC made by Rogue Shadow -TT-*C* (TCN)
if (created){this.time=0;timereverywhere;}

if (((playerenters)||timeout)&&this.firing==false){
this.firing=true;
this.red=random(0,1);this.green=random(0,1);this.b lue=random(0,1);
this.on=3;
this.angle = 6.28+random(-(3.14/8),(3.14/8));
this.mag = random(10,26);
this.x=x - (sin(this.angle)*this.mag);
this.y=y - (cos(this.angle)*this.mag);
this.startx=x;
this.starty=y;
geta();
}
function geta(){
this.dx=(this.x-this.startx);
this.dy=(this.y-this.starty);
this.mag = ((this.dx^2+this.dy^2)^.5)*.1;
this.angle=getangle(this.dx,this.dy)+(3.14/2);
this.vel = {sin(this.angle)*this.mag , cos(this.angle)*this.mag };
timeout=.05;
play fire.wav;
}
if (timeout&&this.on==3){
if (lighteffectsenabled){
showimg 5,light2.png,this.startx,this.starty;
changeimgzoom 5,.3;
changeimgcolors 5,1,1,1,.9;
}else{
showimg 5,@arial@o,this.startx,this.starty;
}
this.startx+=this.vel[0];
this.starty+=this.vel[1];
this.vel[1]+=.05;
if ( this.vel[1] > (0+random(0,2)) ){
timeout=0;
this.on=false;
explode();
hideimg 5;
}
timeout=.05;
}
if (timeout&&this.explode==true){
draw_dot();
timeout=.05;
if (this.time>70){
this.firing=false;
this.time=-1;
this.explode=false;
hidestuff();
timeout=random(.5,3);
}
}

function explode(){
this.time=0;
setarray this.vars,int(random(1,200))*6;
for (i=0;i<arraylen(this.vars);i+=6){
this.vars[i+0]=this.startx;
this.vars[i+1]=this.starty;
this.vars[i+2]=random(0,6.28);
this.vars[i+3]=random(.1,1);
}
this.explode=true;
timeout=.05;
play fire.wav;
}

function draw_dot(){
this.time++;
for (i=0;i<arraylen(this.vars);i+=6){
for (i=0;i<arraylen(this.vars);i+=6){
this.vars[i+0]=this.vars[i+0]+this.vars[i+4];
this.vars[i+5]+=(.05*this.time);
this.vars[i+1]=this.vars[i+1]+this.vars[i+5];
if (lighteffectsenabled){
showimg i,light2.png,this.vars[i+0],this.vars[i+1];
changeimgzoom i,.15;
changeimgcolors i,this.red,this.green,this.blue,.9;
}else{
showimg i,@arial@.,this.vars[i+0],this.vars[i+1];
}
vector();
}
}
}
function vector(){
this.dx = (this.vars[i+0] - ((this.vars[i+0] + ( sin(this.vars[i+2])*this.vars[i+3]))));
this.dy = (this.vars[i+1] - ((this.vars[i+1] + ( cos(this.vars[i+2])*this.vars[i+3]))));
this.mag = (this.dx^2+this.dy^2)^.5;
this.vars[i+4] = (this.dx/this.mag)*this.vars[i+3];
this.vars[i+5] = (this.dy/this.mag)*this.vars[i+3];
}
function hidestuff(){
for (this.i=0;this.i<arraylen(this.vars)*4;this.i+=4)h ideimg this.i;
}




It's not the prettiest script in the world I know.

Please don't use this without asking.

But anyhow as I said only first person in the level can see so I guess it wouldn't do you a lot of good except to see for yourself.


I tried everything I can think of. But im not very good at online scripting. This is for a non-npc-server , server.



Also if you wanna post and tell me you like my fireworks that will be cool too. It makes me happy.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly

Last edited by adam; 07-01-2002 at 12:45 PM..
Reply With Quote
  #2  
Old 07-01-2002, 03:14 PM
Xbob42 Xbob42 is offline
Registered User
Join Date: May 2002
Posts: 429
Xbob42 is on a distinguished road
wasn't it something you had to do with something like
if(created||playerenters&&!isleader){
//scripts
}

I'm not sure though. I read it on Ace's tutorial, but it's been a while since I looked at it.
__________________
Criminal uses this account to post.
Reply With Quote
  #3  
Old 07-01-2002, 11:14 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by Xbob42
wasn't it something you had to do with something like
if(created||playerenters&&!isleader){
//scripts
}

I'm not sure though. I read it on Ace's tutorial, but it's been a while since I looked at it.

Wow. It seems to have worked.

I was a little surprised but.

OMI.. it worked!

Thanx.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
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 08:07 PM.


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