- Update scripting branch to trunk.

SVN r3758 (scripting)
This commit is contained in:
Randy Heit 2012-07-14 03:04:41 +00:00
commit 562cf04db2
614 changed files with 63691 additions and 31256 deletions

View file

@ -45,9 +45,9 @@ struct Keygroup
struct Lock
{
TArray<Keygroup *> keylist;
TArray<FSoundID> locksound;
FString Message;
FString RemoteMsg;
FSoundID locksound;
int rgb;
Lock()
@ -199,27 +199,11 @@ static void ParseLock(FScanner &sc)
keynum = sc.Number;
sc.MustGetString();
if (sc.Compare("DOOM"))
if (!sc.Compare("{"))
{
if (gameinfo.gametype != GAME_Doom) keynum=-1;
if (!CheckGame(sc.String, false)) keynum = -1;
sc.MustGetStringName("{");
}
else if (sc.Compare("HERETIC"))
{
if (gameinfo.gametype != GAME_Heretic) keynum=-1;
}
else if (sc.Compare("HEXEN"))
{
if (gameinfo.gametype != GAME_Hexen) keynum=-1;
}
else if (sc.Compare("STRIFE"))
{
if (gameinfo.gametype != GAME_Strife) keynum=-1;
}
else if (sc.Compare("CHEX"))
{
if (gameinfo.gametype != GAME_Chex) keynum=-1;
}
else sc.UnGet();
ignorekey = true;
if (keynum > 0 && keynum < 255)
@ -230,7 +214,8 @@ static void ParseLock(FScanner &sc)
delete locks[keynum];
}
locks[keynum] = lock;
locks[keynum]->locksound = "misc/keytry";
locks[keynum]->locksound.Push("*keytry");
locks[keynum]->locksound.Push("misc/keytry");
ignorekey=false;
}
else if (keynum != -1)
@ -238,7 +223,6 @@ static void ParseLock(FScanner &sc)
sc.ScriptError("Lock index %d out of range", keynum);
}
sc.MustGetStringName("{");
while (!sc.CheckString("}"))
{
sc.MustGetString();
@ -273,8 +257,21 @@ static void ParseLock(FScanner &sc)
break;
case 4: // locksound
sc.MustGetString();
lock->locksound = sc.String;
lock->locksound.Clear();
for (;;)
{
sc.MustGetString();
lock->locksound.Push(sc.String);
if (!sc.GetString())
{
break;
}
if (!sc.Compare(","))
{
sc.UnGet();
break;
}
}
break;
default:
@ -398,27 +395,32 @@ void P_DeinitKeyMessages()
bool P_CheckKeys (AActor *owner, int keynum, bool remote)
{
const char *failtext = NULL;
FSoundID failsound;
FSoundID *failsound;
int numfailsounds;
if (owner == NULL) return false;
if (keynum<=0 || keynum>255) return true;
// Just a safety precaution. The messages should have been initialized upon game start.
if (!keysdone) P_InitKeyMessages();
FSoundID failage[2] = { "*keytry", "misc/keytry" };
if (!locks[keynum])
{
if (keynum==103 && gameinfo.gametype == GAME_Strife)
failtext = "THIS AREA IS ONLY AVAILABLE IN THE RETAIL VERSION OF STRIFE";
if (keynum == 103 && (gameinfo.flags & GI_SHAREWARE))
failtext = "$TXT_RETAIL_ONLY";
else
failtext = "That doesn't seem to work";
failtext = "$TXT_DOES_NOT_WORK";
failsound = "misc/keytry";
failsound = failage;
numfailsounds = countof(failage);
}
else
{
if (locks[keynum]->check(owner)) return true;
failtext = remote? locks[keynum]->RemoteMsg : locks[keynum]->Message;
failsound = locks[keynum]->locksound;
failsound = &locks[keynum]->locksound[0];
numfailsounds = locks[keynum]->locksound.Size();
}
// If we get here, that means the actor isn't holding an appropriate key.
@ -426,7 +428,20 @@ bool P_CheckKeys (AActor *owner, int keynum, bool remote)
if (owner == players[consoleplayer].camera)
{
PrintMessage(failtext);
S_Sound (owner, CHAN_VOICE, failsound, 1, ATTN_NORM);
// Play the first defined key sound.
for (int i = 0; i < numfailsounds; ++i)
{
if (failsound[i] != 0)
{
int snd = S_FindSkinnedSound(owner, failsound[i]);
if (snd != 0)
{
S_Sound (owner, CHAN_VOICE, snd, 1, ATTN_NORM);
break;
}
}
}
}
return false;