FOnline Development > Questions and Answers

Missing sounds (doors, containers, etc)

<< < (2/3) > >>

JovankaB:
If you have more than one statement after if(condition), you have to put them in brackets:

            if( FLAG( locker.LockerCondition, LOCKER_ISOPEN ) )
            {
                locker.LockerClose();
                Map@ map = GetMap(locker.MapId);
                map.PlaySound( "AIRSIREN.ogg" );
            }
            else

Also notice that it's Map@ map not map@ map, AngelScript is case sensitive! And class names start with uppercase letter (it's just a naming convention though, to make them easily distinguishable from variables).
Maybe there is more errors, but that's what I noticed at first glance.

ffsake:
Alright, thanks. It works now properly (though I need to change the sound to something else, that air siren obviously gets annyoing really quickly)

Now to just figure out if I can make the script play a sound based on it SoundID. I'm thinking about using the bool LockerOpen(Item& item) bit from the end of 2238's lockers.fos and tweaking a bit. Not sure if will work at all, but it's worth a shot.

EDIT:


--- Code: ---            // Change state
            if( FLAG( locker.LockerCondition, LOCKER_ISOPEN ) )
            {
                 locker.LockerClose();
         Map@ map = GetMap(locker.MapId);
         string sound = locker.GetType() == ITEM_TYPE_DOOR ? "SODOORSA.ACM" : "IOCNTNRA.ACM";
         sound = locker.Proto.SoundId;
         map.PlaySound(sound);
    }
            else
                locker.LockerOpen();
        }

--- End code ---

Didn't get any errors when it compiled, but doesn't work either. Might have something to do with the map.PlaySound statement?

JovankaB:
OK, first of all, map.PlaySound() requires an argument that is a string (a sequence of characters) holding the sound's filename. Nothing else will work. You can do it directly, just like you did:

--- Code: ---map.PlaySound("AIRSIREN.ogg");
--- End code ---

Or pass it as a variable with string type, which stores the filename:

--- Code: ---string mySirenSound = "AIRSIREN.ogg";
map.PlaySound(mySirenSound);
--- End code ---

The stuff you did:

--- Code: ---sound = locker.Proto.SoundId;
map.PlaySound(sound);
--- End code ---
doesn't work, because locker.Proto.SoundId isn't even a string! It has uint8 (unsigned 8-bit integer) type - which means it can hold ONLY numbers in a range from 0 to 255. It can't be used to store a filename and it doesn't magically identify them. I don't even know what's the result of an expression like this (sound = locker.Proto.SoundId), maybe an empty string or something like "48" but not any meaningful filename for sure. That's why it doesn't play.

You should  check out the 2238 LockerOpen code again. It does something slightly different:

--- Code: ---sound[7] = item.Proto.SoundId;
--- End code ---
Notice the 7 in square brackets. It means "8th character of the sound string". Why 7 means 8th? Because the index starts from 0 (sound[0] means the first character of the sound string, sound[1] the second character etc).

So the code doesn't replace the whole sound string, only 8th character of it. What does it replace with? With a character which has ASCII code equal to item.Proto.SoundId. You have to look it up in the ASCII table.

So in case of "SODOORSA.ACM" it replaces the bold "A" with a character which ascii code is equal to the locker.Proto.SoundId. I guess it just happens that the door filenames sounds have only different the last character, so in their case item.Proto.SoundId is used to store this character's ASCII code. It's a bit primitive way to do it (to put it mildly), but it works for original Fallout door sounds.



BTW, I just realized it probably didn't work in your SDK (before you made any changes) because of added UNICODE and changes in string handling, that happened in FOnline some time ago. That most likely would brake the "sound[7]" crap.
It might be fixed in later revisions of the script, so just check later version of lockers.fos.

ffsake:
The "sound[7]" crap indeed seems to be broken, so I just worked around it. You could probably call it primitive at best but it works for me.


--- Code: ---            // Change state
            if( FLAG( locker.LockerCondition, LOCKER_ISOPEN ) )
    {
                                locker.LockerClose();
Map@ map = GetMap(locker.MapId);
uint8 sound = locker.Proto.SoundId;
if(sound == 65)
map.PlaySound("SCDOORSA.ACM");
if(sound == 66)
map.PlaySound("SCDOORSB.ACM");
if(sound == 67)
map.PlaySound("SCDOORSC.ACM");
if(sound == 68)
map.PlaySound("SCDOORSD.ACM");
if(sound == 69)
map.PlaySound("SCDOORSE.ACM");
if(sound == 70)
map.PlaySound("SCDOORSF.ACM");
if(sound == 71)
map.PlaySound("SCDOORSG.ACM");
if(sound == 72)
map.PlaySound("SCDOORSH.ACM");
if(sound == 73)
map.PlaySound("SCDOORSI.ACM");
if(sound == 74)
map.PlaySound("SCDOORSJ.ACM");
if(sound == 75)
map.PlaySound("SCDOORSK.ACM");
if(sound == 76)
map.PlaySound("SCDOORSL.ACM");
if(sound == 77)
map.PlaySound("SCDOORSM.ACM");
if(sound == 78)
map.PlaySound("SCDOORSN.ACM");
if(sound == 79)
map.PlaySound("SCDOORSO.ACM");
if(sound == 80)
map.PlaySound("SCDOORSP.ACM");
if(sound == 81)
map.PlaySound("SCDOORSQ.ACM");
if(sound == 82)
map.PlaySound("SCDOORSR.ACM");
if(sound == 83)
map.PlaySound("SCDOORSS.ACM");
if(sound == 84)
map.PlaySound("SCDOORST.ACM");
    }
            else
    {
                                locker.LockerOpen();
Map@ map = GetMap(locker.MapId);
uint8 sound = locker.Proto.SoundId;
if(sound == 65)
map.PlaySound("SODOORSA.ACM");
if(sound == 66)
map.PlaySound("SODOORSB.ACM");
if(sound == 67)
map.PlaySound("SODOORSC.ACM");
if(sound == 68)
map.PlaySound("SODOORSD.ACM");
if(sound == 69)
map.PlaySound("SODOORSE.ACM");
if(sound == 70)
map.PlaySound("SODOORSF.ACM");
if(sound == 71)
map.PlaySound("SODOORSG.ACM");
if(sound == 72)
map.PlaySound("SODOORSH.ACM");
if(sound == 73)
map.PlaySound("SODOORSI.ACM");
if(sound == 74)
map.PlaySound("SODOORSJ.ACM");
if(sound == 75)
map.PlaySound("SODOORSK.ACM");
if(sound == 76)
map.PlaySound("SODOORSL.ACM");
if(sound == 77)
map.PlaySound("SODOORSM.ACM");
if(sound == 78)
map.PlaySound("SODOORSN.ACM");
if(sound == 79)
map.PlaySound("SODOORSO.ACM");
if(sound == 80)
map.PlaySound("SODOORSP.ACM");
if(sound == 81)
map.PlaySound("SODOORSQ.ACM");
if(sound == 82)
map.PlaySound("SODOORSR.ACM");
if(sound == 83)
map.PlaySound("SODOORSS.ACM");
if(sound == 84)
map.PlaySound("SODOORST.ACM");
}
        }

--- End code ---

Wipe:
Ugh, that's just horrible :D

If you work on SDK r400+, instead of

--- Code: ---someString[7] = item.Proto.SoundId;
--- End code ---
use

--- Code: ---someString.rawSet( 7, item.Proto.SoundId );
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version