Advanced Search

Author Topic: ACS scripting question - Random ThrustThing values  (Read 2990 times)

0 Members and 1 Guest are viewing this topic.

February 28, 2011, 07:51:43 PM
Read 2990 times

Offline Audiophile

  • Standard Member
  • Date Registered: February 23, 2011, 02:25:11 AM

    • View Profile
ACS scripting question - Random ThrustThing values
« on: February 28, 2011, 07:51:43 PM »
As this is my first post, I would like to extend my greetings to the forum community.

With that out of the way, I'm in the process of making my first map. I'm trying to make a sector that, when stepped on, will thrust the player in a random direction at a random speed.

I've been doing some research on scripting and put together a patchwork of code I was able to assemble with the limited knowledge on the subject I have.

It is as follows:
Code: [Select]
#include "zcommon.acs"

int angarr[8] = {0,32,64,96,128,160,192,224};
int achoice;
achoice = angarr[random(0,7)];

int thrarr[6] = {5,10,15,20,25,30}
int tchoice;
tchoice = thrarr[random(0,5)];

script 1 open {
        thrustthing(achoice,tchoice,0,0);
        delay(1)
        }

I know this is incorrect, as it will not compile. My question is; Would this be an error in syntax, or the wrong methodology, or a combination of the two?

February 28, 2011, 07:55:34 PM
Reply #1

Offline Ivory

  • MM8BDM Extender
  • *********
  • Date Registered: August 25, 2009, 08:17:59 AM

    • View Profile
    • http://www.cutstuff.net/
Re: ACS scripting question - Random ThrustThing values
« Reply #1 on: February 28, 2011, 07:55:34 PM »
...There is no semi colon after the last delay...

February 28, 2011, 08:43:59 PM
Reply #2

Offline Audiophile

  • Standard Member
  • Date Registered: February 23, 2011, 02:25:11 AM

    • View Profile
Re: ACS scripting question - Random ThrustThing values
« Reply #2 on: February 28, 2011, 08:43:59 PM »
Quote from: "Ivory"
...There is no semi colon after the last delay...
thanks for pointing that out, but that's not the case.

the error it's kicking out is "invalid declarator" and it's pointing to

achoice = angarr[random(0,7)];

perhaps i should have mentioned that in the previous post

February 28, 2011, 09:18:06 PM
Reply #3

Offline Audiophile

  • Standard Member
  • Date Registered: February 23, 2011, 02:25:11 AM

    • View Profile
Re: ACS scripting question - Random ThrustThing values
« Reply #3 on: February 28, 2011, 09:18:06 PM »
Well, I have discovered why it wasn't working. I've overcomplicated things.

I was able to get the desired effect with the following code

Code: [Select]
#include "zcommon.acs"

script 1 open {
        thrustthing(random(0,359),random(5,30),0,0);
        delay(1);
        }

and it works perfectly.

February 28, 2011, 10:20:30 PM
Reply #4

Offline CutmanMike

  • Administrator

  • Is it hot in here or is it just zscript?
  • *******
  • Date Registered: December 17, 2008, 12:24:34 PM

    • View Profile
    • https://cutstuff.net
Re: ACS scripting question - Random ThrustThing values
« Reply #4 on: February 28, 2011, 10:20:30 PM »
I saw this and assumed you only wanted it to thrust in the directions you specified in the array. In which case this might have worked:

Code: [Select]
#include "zcommon.acs"

int angarr[7] = {0,32,64,96,128,160,192,224}; // I can't remember if this is the right syntax for putting values directly into arrays however

int thrarr[6] = {5,10,15,20,25,30};

script 1 open {
        thrustthing(angarr[random(0,7)],thrarr[random(0,5)],0,0);
        delay(1)
        }

February 28, 2011, 11:07:55 PM
Reply #5

Offline Audiophile

  • Standard Member
  • Date Registered: February 23, 2011, 02:25:11 AM

    • View Profile
Re: ACS scripting question - Random ThrustThing values
« Reply #5 on: February 28, 2011, 11:07:55 PM »
thanks boss, I'll remember that if need to use it for future maps  :mrgreen: