- added UseInventory/UseActorInventory ACS functions.

SVN r636 (trunk)
This commit is contained in:
Christoph Oelckers 2007-12-25 08:44:13 +00:00
parent 3eb741e391
commit 671cf5a888
5 changed files with 93 additions and 2 deletions

View file

@ -1,3 +1,6 @@
December 25, 2007 (Changes by Graf Zahl)
- added UseInventory/UseActorInventory ACS functions.
December 24, 2007 (Changes by Graf Zahl)
- added some functionality to FDynamicColormap to allow not creating
the colormap data.

View file

@ -357,6 +357,61 @@ static void TakeInventory (AActor *activator, const char *type, int amount)
}
}
//============================================================================
//
// DoUseInv
//
// Makes a single actor use an inventory item
//
//============================================================================
static bool DoUseInv (AActor *actor, const PClass *info)
{
AInventory *item = actor->FindInventory (info);
if (item != NULL)
{
return actor->UseInventory(item);
}
return false;
}
//============================================================================
//
// UseInventory
//
// makes one or more actors use an inventory item.
//
//============================================================================
static int UseInventory (AActor *activator, const char *type)
{
const PClass *info;
int ret = 0;
if (type == NULL)
{
return 0;
}
info = PClass::FindClass (type);
if (info == NULL)
{
return 0;
}
if (activator == NULL)
{
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i])
ret += DoUseInv (players[i].mo, info);
}
}
else
{
ret = DoUseInv (activator, info);
}
return ret;
}
//============================================================================
//
// CheckInventory
@ -4322,6 +4377,32 @@ int DLevelScript::RunScript ()
pc += 1;
break;
case PCD_USEINVENTORY:
STACK(1) = UseInventory (activator, FBehavior::StaticLookupString (STACK(1)));
break;
case PCD_USEACTORINVENTORY:
{
int ret;
const char *type = FBehavior::StaticLookupString(STACK(1));
if (STACK(2) == 0)
{
ret = UseInventory(NULL, type);
}
else
{
FActorIterator it(STACK(2));
AActor *actor;
for (actor = it.Next(); actor != NULL; actor = it.Next())
{
ret += UseInventory(actor, type);
}
}
STACK(2) = ret;
sp--;
}
break;
case PCD_GETSIGILPIECES:
{
ASigil *sigil;

View file

@ -541,6 +541,8 @@ public:
PCD_PRINTBIND,
PCD_SETACTORSTATE,
PCD_THINGDAMAGE2,
PCD_USEINVENTORY,
PCD_USEACTORINVENTORY,
PCODE_COMMAND_COUNT
};

View file

@ -135,7 +135,7 @@ static int DoomSpecificInfo (char *buffer, char *end)
SDL_Quit();
p = 0;
p += snprintf (buffer+p, size-p, "ZDoom version " DOTVERSIONSTR " (" __DATE__ ")\n");
p += snprintf (buffer+p, size-p, GAMENAME" version " DOTVERSIONSTR " (" __DATE__ ")\n");
p += snprintf (buffer+p, size-p, "\nCommand line:");
for (i = 0; i < Args.NumArgs(); ++i)
{
@ -182,7 +182,7 @@ static int DoomSpecificInfo (char *buffer, char *end)
int main (int argc, char **argv)
{
printf("ZDoom v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
DOTVERSIONSTR_NOREV,SVN_REVISION_STRING,__DATE__);
{

View file

@ -31,6 +31,9 @@
**
*/
#ifndef __WIN32IFACE_H
#define __WIN32IFACE_H
#ifndef DIRECTDRAW_VERSION
#define DIRECTDRAW_VERSION 0x0300
#endif
@ -306,3 +309,5 @@ FILE *dbg;
#define LOG4(x,y,z,a,b)
#define LOG5(x,y,z,a,b,c)
#endif
#endif // __WIN32IFACE_H