Quote:
Originally Posted by Stephen
How are they detecting that element in the song - or are they synchronized?
|
There's a map(basically just an array) of times that I made that determines when they should dance.
PHP Code:
// NPC made by Dusty
if (created) {
setstring this.dancemaps_0,5.9,6.3,10.6,11,33.8,34.2,57.1,57.5,61.1,61.5,61.8,62.1,65.7,66.1,66.4,66.7,70.4,70.8,71.1,71.4,80.6,81;
setstring client.song,;
}
if (playerenters) {
playlooped nsmb_overworld.mp3;
setarray this.dancemap,sarraylen(this.dancemaps_0);
for (i=0;i<sarraylen(this.dancemaps_0);i++) this.dancemap[i] = strtofloat(#I(this.dancemaps_0,i));
timeout = 0.05;
}
if (timeout) {
if (aindexof((int(musicpos/.1+.05))*.1,this.dancemap[0]) >= 0) {
for (n=0;n<npcscount;n++) callnpc n,dance;
}
timeout = 0.05;
}
A cleaned up copy of the script. It's actually way more complicated than it should be, because of GS1's ability to make simple things impossible.