(Solved) Regions and footstep sounds.

Started by Canister, Wed 16/03/2011 16:01:08

Previous topic - Next topic

Canister

Well, I have a problem with different footstep sounds for different regions. Well, basically I have 4 different sounds for each region like grass or sand, etc.
I put in the room script something like this:
Code: ags

function region1_Standing() // I use this function for each region
{
  int grass = Random (3);
   if (grass == 0) {
     SetFrameSound(1, 0, 1, 6);
     SetFrameSound(1, 0, 4, 6);
     SetFrameSound(1, 1, 3, 6);
     SetFrameSound(1, 1, 6, 6);
     SetFrameSound(1, 2, 3, 6);
     SetFrameSound(1, 2, 6, 6);
     SetFrameSound(1, 3, 1, 6);
     SetFrameSound(1, 3, 4, 6);
   }
   if (grass == 1) {
    SetFrameSound(1, 0, 1, 7);
    SetFrameSound(1, 0, 4, 7);
    (...)

And, well, it kinda... works. But there's a problem when player do something which includes moving from region to region. When player just clicks "walk to..." its ok, but when he click, for example "interact" its not (character walks to thing he want to interact, however sound doesn't change, while he is changing the region).
Also, I know its not the best way of doing this, and I should use repeatedly_execute() but I don't really know how to. How do I retrieve information about region that player is standing on?
Ah, I tried using CharacterRegionSounds v0.80b module, but it didn't work (bunch of errors).

Anyway, hi ;), this is my first post on this forum. Sorry for my bad English.

Matti

Quote from: Canister on Wed 16/03/2011 16:01:08
How do I retrieve information about region that player is standing on?

if (Region.GetAtRoomXY(character.x, character.y) == region[1])  // do stuff

Quote
Anyway, hi ;), this is my first post on this forum. Sorry for my bad English.

Welcome to the forums, your English is okay  :)

Canister

#2
Thanks, I've changed the code, now I have something like this:
Code: ags


function repeatedly_execute() {
  if (Region.GetAtRoomXY(cSeba.x, cSeba.y) == region[1]) 
  {
  SetFrameSound(1, 0, 1, 10);
  SetFrameSound(1, 0, 4, 11);
  SetFrameSound(1, 1, 3, 10);
  SetFrameSound(1, 1, 6, 11);
  SetFrameSound(1, 2, 3, 10);
  SetFrameSound(1, 2, 6, 11);
  SetFrameSound(1, 3, 1, 10);
  SetFrameSound(1, 3, 4, 11);
 }
 else {
    SetFrameSound(1, 0, 1, 6);
    SetFrameSound(1, 0, 4, 7);
    SetFrameSound(1, 1, 3, 6);
    SetFrameSound(1, 1, 6, 7);
    SetFrameSound(1, 2, 3, 6);
    SetFrameSound(1, 2, 6, 7);
    SetFrameSound(1, 3, 1, 6);
    SetFrameSound(1, 3, 4, 7);
 }

Well, there's no random different sounds for now, but I still have the problem with changing sounds while doing something different than "Walk to...". For example: I have the bush in the middle of lawn. Player is standing on the sand, and clicks "Walk to..." on grass and it works perfectly. Then, the same situation - player is sanding on sand, and clicks "Interact" on bush, so character is moving to the WalkToPoint, and when he's on the grass it still sounds like sand. What should I do?

Dualnames

Code: ags

function repeatedly_execute_always() { //This will fix the sand issue (I believe)
int a=6;
int x;
int y=1;

 if (Region.GetAtRoomXY(cSeba.x, cSeba.y) == region[1])    a=10;
   while (x<4) {
   SetFrameSound(1, x, y, a);
   SetFrameSound(1, x, y+3, a+1);
    if (x<1) y=3;
    if (x==2) y=1;
   x++;
 }

}


This will probably work better, and excuse me if there's a parse error or anything.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Canister

#4
It works! :D Thank you very much! Well, I hope that I won't have any problems with modifying this function later.

Edit:
Well I have some problems, I want "a" to be random number between 6 and 9, but when I change int a=6; to int a=6 + Random(3); error "audio clip aSound9 not found" is displayed. Of course, I have files named Sound9, Sound 10 and so...

Edit no.2:
Oooh, its this new object-oriented audio, nevermind.

Dualnames

int a=6 should be int a=6+Random(2);


Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

No it shouldn't. Random returns a value between 0 and max inclusive,,so 6 + Random(3) yields a maximum result of 9 which is what he wanted. It was simply a mix up between the old and new audio systems..as indicated by the "aSound9".

SMF spam blocked by CleanTalk