- 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

@ -52,6 +52,8 @@
#include "g_level.h"
extern void LoadActors ();
extern void InitBotStuff();
extern void ClearStrifeTypes();
TArray<PClassActor *> PClassActor::AllActorClasses;
@ -76,7 +78,7 @@ bool FState::CallAction(AActor *self, AActor *stateowner, StateCallData *stateca
//
//==========================================================================
int GetSpriteIndex(const char * spritename)
int GetSpriteIndex(const char * spritename, bool add)
{
static char lastsprite[5];
static int lastindex;
@ -102,6 +104,10 @@ int GetSpriteIndex(const char * spritename)
return (lastindex = (int)i);
}
}
if (!add)
{
return (lastindex = -1);
}
spritedef_t temp;
strcpy (temp.name, upper);
temp.numframes = 0;
@ -121,6 +127,7 @@ END_POINTERS
void PClassActor::StaticInit()
{
sprites.Clear();
if (sprites.Size() == 0)
{
spritedef_t temp;
@ -141,7 +148,9 @@ void PClassActor::StaticInit()
}
Printf ("LoadActors: Load actor definitions.\n");
ClearStrifeTypes();
LoadActors ();
InitBotStuff();
}
//==========================================================================
@ -502,6 +511,38 @@ void PClassActor::SetPainChance(FName type, int chance)
//
//==========================================================================
void PClassActor::SetPainFlash(FName type, PalEntry color)
{
if (PainFlashes == NULL)
PainFlashes = new PainFlashList;
PainFlashes->Insert(type, color);
}
//==========================================================================
//
// DmgFactors :: CheckFactor
//
// Checks for the existance of a certain damage type. If that type does not
// exist, the damage factor for type 'None' will be returned, if present.
//
//==========================================================================
fixed_t *DmgFactors::CheckFactor(FName type)
{
fixed_t *pdf = CheckKey(type);
if (pdf == NULL && type != NAME_None)
{
pdf = CheckKey(NAME_None);
}
return pdf;
}
//==========================================================================
//
//
//==========================================================================
FDoomEdMap DoomEdMap;
FDoomEdMap::FDoomEdEntry *FDoomEdMap::DoomEdHash[DOOMED_HASHSIZE];
@ -581,7 +622,7 @@ PClassActor *FDoomEdMap::FindType (int doomednum) const
struct EdSorting
{
const PClass *Type;
PClassActor *Type;
int DoomEdNum;
};
@ -637,24 +678,23 @@ static void SummonActor (int command, int command2, FCommandLine argv)
if (argv.argc() > 1)
{
const PClass *type = PClass::FindClass (argv[1]);
PClassActor *type = PClass::FindActor(argv[1]);
if (type == NULL)
{
Printf ("Unknown class '%s'\n", argv[1]);
Printf ("Unknown actor '%s'\n", argv[1]);
return;
}
Net_WriteByte (argv.argc() > 2 ? command2 : command);
Net_WriteString (type->TypeName.GetChars());
if (argv.argc () > 2) {
if (argv.argc () > 2)
{
Net_WriteWord (atoi (argv[2])); // angle
if (argv.argc () > 3) Net_WriteWord (atoi (argv[3])); // TID
else Net_WriteWord (0);
if (argv.argc () > 4) Net_WriteByte (atoi (argv[4])); // special
else Net_WriteByte (0);
for(int i = 5; i < 10; i++) { // args[5]
if(i < argv.argc()) Net_WriteLong (atoi (argv[i]));
else Net_WriteLong (0);
Net_WriteWord ((argv.argc() > 3) ? atoi(argv[3]) : 0); // TID
Net_WriteByte ((argv.argc() > 4) ? atoi(argv[4]) : 0); // special
for (int i = 5; i < 10; i++)
{ // args[5]
Net_WriteLong((i < argv.argc()) ? atoi(argv[i]) : 0);
}
}
}
@ -678,4 +718,87 @@ CCMD (summonmbf)
CCMD (summonfoe)
{
SummonActor (DEM_SUMMONFOE, DEM_SUMMONFOE2, argv);
}
}
// Damage type defaults / global settings
TMap<FName, DamageTypeDefinition> GlobalDamageDefinitions;
void DamageTypeDefinition::Apply(FName const type)
{
GlobalDamageDefinitions[type] = *this;
}
DamageTypeDefinition *DamageTypeDefinition::Get(FName const type)
{
return GlobalDamageDefinitions.CheckKey(type);
}
bool DamageTypeDefinition::IgnoreArmor(FName const type)
{
DamageTypeDefinition *dtd = Get(type);
if (dtd) return dtd->NoArmor;
return false;
}
//==========================================================================
//
// DamageTypeDefinition :: ApplyMobjDamageFactor
//
// Calculates mobj damage based on original damage, defined damage factors
// and damage type.
//
// If the specific damage type is not defined, the damage factor for
// type 'None' will be used (with 1.0 as a default value).
//
// Globally declared damage types may override or multiply the damage
// factor when 'None' is used as a fallback in this function.
//
//==========================================================================
int DamageTypeDefinition::ApplyMobjDamageFactor(int damage, FName const type, DmgFactors const * const factors)
{
if (factors)
{
// If the actor has named damage factors, look for a specific factor
fixed_t const *pdf = factors->CheckKey(type);
if (pdf) return FixedMul(damage, *pdf); // type specific damage type
// If this was nonspecific damage, don't fall back to nonspecific search
if (type == NAME_None) return damage;
}
// If this was nonspecific damage, don't fall back to nonspecific search
else if (type == NAME_None)
{
return damage;
}
else
{
// Normal is unsupplied / 1.0, so there's no difference between modifying and overriding
DamageTypeDefinition *dtd = Get(type);
return dtd ? FixedMul(damage, dtd->DefaultFactor) : damage;
}
{
fixed_t const *pdf = factors->CheckKey(NAME_None);
DamageTypeDefinition *dtd = Get(type);
// Here we are looking for modifications to untyped damage
// If the calling actor defines untyped damage factor, that is contained in "pdf".
if (pdf) // normal damage available
{
if (dtd)
{
if (dtd->ReplaceFactor) return FixedMul(damage, dtd->DefaultFactor); // use default instead of untyped factor
return FixedMul(damage, FixedMul(*pdf, dtd->DefaultFactor)); // use default as modification of untyped factor
}
return FixedMul(damage, *pdf); // there was no default, so actor default is used
}
else if (dtd)
{
return FixedMul(damage, dtd->DefaultFactor); // implicit untyped factor 1.0 does not need to be applied/replaced explicitly
}
}
return damage;
}