Severed bunny head
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Randomly lower a platform (or eight)
 
Author
All times are GMT. The time now is 00:12. Post New Thread    Post A Reply
Phendrena
Junior Member


Posts: 180
Registered: 09-12


Hi,

I would like to have the player walk over a linedef that triggers an ACS script (D-in-H format). The script will ideally lower a random platform, delay for about 20 seconds and then lower another random platform and so on until all eight platforms have been lowered. While I can do simple scripts, I can't work out how I would be able to do this?

Would anyone be able to provide an example please.

Thanks,

Dave

Old Post 10-15-12 11:23 #
Phendrena is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 11216
Registered: 07-07


Something like this should work.

code:
script "Platform Sequence" () { int i; int platforms[8] == { 1, 2, 3, 4, 5, 6, 7, 8 }; for (i = 0; i < 8; ++i) { int j = random(i, 7); int platform = platforms[j]; platforms[j] = platforms[i]; Floor_LowerToLowest(platform, 32); // or Floor_LowerByValue or whatever delay(20*35); } }


The platforms array (note the plural) contains the TIDs of the eight different platforms. In this example, they are 1 to 8, but they could be anything else.

The script will loop eight times. Each time, it'll pick a random number between the iteration (so, 0 the first time, 1 the second, 2 the third, etc. until 7 on the eighth) and 7. The TID from the array at that index is chosen as being our random platform for this iteration.

Then the value in the array is replaced by one that hasn't been used yet. (Though it might happen that it gets replaced by itself if the minimum was rolled. Not a problem.) The loop waits for twenty second. This way, we make sure that a same platform will not be randomly chosen twice.

Old Post 10-15-12 13:16 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Phendrena
Junior Member


Posts: 180
Registered: 09-12


Cheers Gez,

You really rather good at all this :)
My ideas outweight my skills atm. I am learning and I'll get there eventually!!

Dave

Old Post 10-15-12 14:41 #
Phendrena is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Phendrena
Junior Member


Posts: 180
Registered: 09-12


Hi Gez,

A couple of problems with the script...

code:
script "Platform Sequence" ()

DB2 gives an error regarding the script number or lack of, so adding one in,
code:
script 2 "Platform Sequence" ()

also errors with bad script declaration. If i change it to read,
code:
script 2 (void)

does compile further but errors at this point;
code:
int platforms[8] == { 9, 10, 11, 12, 13, 14, 15, 16 };

gives the errors,
1 Only map variables can be arrays
2 Invalid identifier

Any suggestions??

Cheers,

Dave

Old Post 10-15-12 21:46 #
Phendrena is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
gggmork
If you can make any sense of this post, congratulations


Posts: 2797
Registered: 06-07


I'm pretty sure arrays have to be global. So declare the array outside any script. Also I think just a simple mistake:
=
instead of
==
in that case (former is assignment operator, last means equals

Old Post 10-15-12 23:01 #
gggmork is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Phendrena
Junior Member


Posts: 180
Registered: 09-12



gggmork said:
I'm pretty sure arrays have to be global. So declare the array outside any script. Also I think just a simple mistake:
=
instead of
==
in that case (former is assignment operator, last means equals

Ok,

So I would take the following;
code:
int platforms[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };

and stick it after the #include line.

I'll give it a whirl in the morning as I'm off to bed now!

Thanks for all the help and the patience,

Dave

Old Post 10-15-12 23:48 #
Phendrena is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 11216
Registered: 07-07



Phendrena said:
Hi Gez,

A couple of problems with the script...

code:
script "Platform Sequence" ()



I gave you a named script for the example. If you haven't updated the ACC from the one that was provided with DB2, it's not going to work. Just replace the name with a number then.

For the other two things, gggmork is correct.

Old Post 10-15-12 23:53 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Phendrena
Junior Member


Posts: 180
Registered: 09-12


It is all working rather nicely now and will (hopefully) be quite a nasty surprise!!

Thank you all for you help :)

Dave

Old Post 10-16-12 09:46 #
Phendrena is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 00:12. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Doom Editing > Randomly lower a platform (or eight)

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.