Well, you'll need something a bit more like this:
CODE
ffc script compass{ //This script plays a certain sfx upon entering the room if Link has a certain item.
void run(int sfx, int lvnum){ // D0 is for the and sfx number. For most, it should be 7. lvnum is the level number of
// the DMap you are getting the compass on.
if(Game->LItems[4]){
Game->PlaySound(sfx);
}
}
}
Firstly, if(true){ is pointless.
It'll just always run that bit of code, and only ever once.
You could've meant while(true){, but you don't need a while loop in this script.
CODE
if(something);{
is wrong, whereas
CODE
if(something){
is corrent.
You don't end if requirements with a semicolon.
Also, I'm afraid checking whether Link has the compass isn't as easy as 'if(Link->Item[22]){'.
When you pick up the compass, the only thing that is 'item ID' 22, is the sprite that appears on the screen that Link then grabs.
Once the game loads it into your inventory, it is no longer 'item ID' 22, it is 'the current DMap's compass item'.
This is the same for boss key, map and triforce piece.
This means you have to access it with this array:
CODE
int LItems[]
* The level items of level i currently under the posession of the player,
* where i is the index used to access this array. Each element of this
* array consists of flags ORed (|) together; use the LI_ constants in
* std.zh to set or compare these values.
Which is sort of what I wrote, although my code won't actually work either because I don't understand how this function works.
Different flags ORed together?
Eh?
EDIT:
Ah, after a little thinking, I have produced these:
CODE
ffc script compass{ //This script plays a certain sfx upon entering the room if Link has a certain item.
void run(int sfx, int lvnum){ // D0 is for the and sfx number. For most, it should be 7. lvnum is the level number of
// the DMap you are getting the compass on.
if(Game->LItems[lvnum] == 4|5|6|12|20){
Game->PlaySound(sfx);
}
}
}
CODE
ffc script compass{ //This script plays a certain sfx upon entering the room if Link has a certain item.
void run(int sfx, int lvnum){ // D0 is for the and sfx number. For most, it should be 7. lvnum is the level number of
// the DMap you are getting the compass on.
if(Game->LItems[lvnum] == 4){
Game->PlaySound(sfx);
}
}
}
CODE
ffc script compass{ //This script plays a certain sfx upon entering the room if Link has a certain item.
void run(int sfx, int lvnum){ // D0 is for the and sfx number. For most, it should be 7. lvnum is the level number of
// the DMap you are getting the compass on.
if(Game->LItems[lvum] == 4 || Game->LItems[lvum] == 5 || Game->LItems[lvum] == 6 || Game->LItems[lvum] == 12 || Game->LItems[lvum] == 20){
Game->PlaySound(sfx);
}
}
}
You could try any one of those three and see if they work.
In fact, however, I think the command uses binary, which I'm just going to research
EDIT2:
Ok, I have come to the conclusion that none of the above scripts will work, and I am currently devisng one that will.
However, I'm under the impression that I need to be able to express 16 in 4-bit binary, which seems rather illogical to me
EDIT3:
Right.
CODE
ffc script compass{ //This script plays a certain sfx upon entering the room if Link has a certain item.
void run(int sfx, int lvnum){ // D0 is for the and sfx number. For most, it should be 7. lvnum is the level number of
// the DMap you are getting the compass on.
int cmp = 0100b;
int curitems = Game->LItems[lvnum];
int chk = cmp & curitems;
if(chk == 0100b){
Game->PlaySound(sfx);
}
}
}
That
should work if Link has the compass, but not if he has the compass
and the boss key, due to not being able to express 16 in a 4 bit byte.
When I work out how to do this (I think I'm supposed to use 2 4-bit bytes, but I'm not sure of how to do it properly and make it work), then I'll update it.
Edited by Joe123, 07 February 2008 - 12:28 PM.