Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-19-2017, 04:19 AM
Kamaeru Kamaeru is offline
G2k1
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
Help me convert an old script

This script made by Loriel used to make "lava balls" bounce around the level. I'm not certain why it doesn't work anymore and my attempts to convert it failed.

NPC Code:
// Lava balls by Loriel
//#CLIENTSIDE
if (playerenters) {
seteffect .1,.05,0,0.03;
this.balls = 50;
setarray this.angle,10;
setarray this.x,10;
setarray this.y,10;
setarray this.radx,10;
setarray this.rady,10;
setarray this.speed,10;
setarray this.dir,10;
for (i=0; i<this.balls; i++)
init(); // First initalizing of all the arrays
while (true) {
for (i=0; i<this.balls; i++) {
if (this.angle[i] in |1.55,4.70|) init(); // Check if under lava (re init),
else loop(); // or above (loop)
}
looplights();
sleep 0.05;
}
}

function init() {
this.x[i] = random(0,60);
this.y[i] = random(0,62);
this.radx[i] = random(0,2);
this.rady[i] = random(2,8);
this.angle[i] = 4.75;
this.speed[i] = random(0.1,0.4);
this.dir[i] = int(random(0,2))*2-1;
}

function loop() {
this.angle[i] += this.speed[i]; // Move ball
this.angle[i] = this.angle[i]%6.3; // Make sure angle stays between 0 and 6.3
showimg i,light2.png,
this.x[i]-this.radx[i]*sin(this.angle[i])*this.dir[i],
this.y[i]-this.rady[i]*cos(this.angle[i]);
changeimgcolors i,0,random(0.1,0.1),.1,0.99;
changeimgzoom i,random(0.15,0.35);
}

function looplights() {
for (i = 0; i < arraylen(this.lpos)/2; i++)
changeimgzoom this.balls+i,random(0.4,0.6);
}



I'm assuming some of the syntax here is just no longer supported but I don't know what it is. Maybe setarray is the problem? A lot of the old gs1 scripts like this on g2k1 perplex me but perhaps they are not hard to fix.
__________________
3DS friendcode: 1118-0226-7975
Reply With Quote
  #2  
Old 07-20-2017, 03:33 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Changed it from using built-in variables (e.g. this.x, this.y).

Changed it to a regular timeout instead of while true loop.

function looplights doesn't seem to do anything so I removed that as well.

Made showimg use 200+ for the IDs so they aren't displayed globally.

PHP Code:
//#CLIENTSIDE

function onPlayerEnters() {
  
seteffect(0.10.0500.03);
  
this.balls 50;
  
this.balls_angle = new[this.balls];
  
this.balls_x = new[this.balls];
  
this.balls_y = new[this.balls];
  
this.balls_radx = new[this.balls];
  
this.balls_rady = new[this.balls];
  
this.balls_dir = new[this.balls];
  
this.balls_speed = new[this.balls];
  for (
temp.0temp.this.ballstemp.i++) {
    
init_ball(temp.i);
  }
  
onTimeout();
}

function 
onTimeout() {
  for (
temp.0temp.this.ballstemp.i++) {
    if (
this.balls_angle[temp.iin |1.55,4.70|) {
      
init_ball(temp.i);
    } else {
      
this.balls_angle[temp.i] += this.balls_speed[temp.i];    // Move ball
      
this.balls_angle[temp.i] = this.balls_angle[temp.i] % 6.3// Make sure angle stays between 0 and 6.3
      
showimg(200+temp.i,"light2.png",this.balls_x[temp.i]-this.balls_radx[temp.i]*sin(this.balls_angle[temp.i])*this.balls_dir[temp.i],this.balls_y[temp.i]-this.balls_rady[temp.i]*cos(this.balls_angle[temp.i]));
      
changeimgcolors(200+temp.i,0,random(0.1,0.1),.1,0.99);
      
changeimgzoom(200+temp.i,random(0.15,0.35));
    }
  }
  
setTimer(0.05);
}

function 
init_ball(i) {
  
this.balls_x[i] = random(0,60);
  
this.balls_y[i] = random(0,62);
  
this.balls_radx[i] = random(0,2);
  
this.balls_rady[i] = random(2,8);
  
this.balls_angle[i] = 4.75;
  
this.balls_speed[i] = random(0.1,0.4);
  
this.balls_dir[i] = int(random(0,2))*2-1;

note: completely untested, but did verify it compiles successfully in a class script.
__________________
Quote:
Reply With Quote
  #3  
Old 07-20-2017, 08:56 AM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
Quote:
this.balls = 50;
__________________
Reply With Quote
  #4  
Old 07-20-2017, 08:57 AM
Kamaeru Kamaeru is offline
G2k1
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
Quote:
Originally Posted by fowlplay4 View Post
note: completely untested, but did verify it compiles successfully in a class script.
It works perfect man. This will go a long way for nostalgia restoration purposes of classic levels on the server which I don't plan to get rid of. Also studying how you converted it will help me do the same for other scripts.
__________________
3DS friendcode: 1118-0226-7975
Reply With Quote
  #5  
Old 07-20-2017, 10:13 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
o good
__________________
Quote:
Reply With Quote
  #6  
Old 07-21-2017, 12:09 AM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
+rep4

edit: You must spread some Reputation around before giving it to fowlplay4 again.

shoot
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:49 PM.


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