- added two new things which can set a sector's color without the need of tags

or scripts. ColorSetter (#9038) sets the sector's color and FadeSetter (#9039)
  sets the fog color.
- added new flags MF5_ALWAYSFAST and MF5_NEVERFAST. These flags unconditionally
  enable or disable fast movement logic, regardless of skill settings.
- added an abstraction layer for skill related settings. This is a preparation
  for implementing custom skill definitions but right now all it does is
  returning the original values but keeping the related information all in one
  place


SVN r557 (trunk)
This commit is contained in:
Christoph Oelckers 2007-10-29 22:15:46 +00:00
parent ab9a6623fd
commit 170b633e91
19 changed files with 185 additions and 104 deletions

View File

@ -1,3 +1,14 @@
October 29, 2007 (Changes by Graf Zahl)
- added two new things which can set a sector's color without the need of tags
or scripts. ColorSetter (#9038) sets the sector's color and FadeSetter (#9039)
sets the fog color.
- added new flags MF5_ALWAYSFAST and MF5_NEVERFAST. These flags unconditionally
enable or disable fast movement logic, regardless of skill settings.
- added an abstraction layer for skill related settings. This is a preparation
for implementing custom skill definitions but right now all it does is
returning the original values but keeping the related information all in one
place
October 28, 2007 (Changes by Graf Zahl)
- Fixed: The pointer cleanup code must also check a sector's sky box pointers.

View File

@ -291,6 +291,8 @@ enum
MF5_NOBLOODDECALS = 0x00001000, // Actor bleeds but doesn't spawn blood decals
MF5_USESPECIAL = 0x00002000, // Actor executes its special when being 'used'.
MF5_NOPAIN = 0x00004000, // If set the pain state won't be entered
MF5_ALWAYSFAST = 0x00008000, // always uses 'fast' attacking logic
MF5_NEVERFAST = 0x00010000, // never uses 'fast' attacking logic
// --- mobj.renderflags ---
@ -757,6 +759,7 @@ public:
bool SetState (FState *newstate);
bool SetStateNF (FState *newstate);
virtual bool UpdateWaterLevel (fixed_t oldz, bool splash=true);
bool isFast();
FState *FindState (FName label) const;
FState *FindState (FName label, FName sublabel, bool exact = false) const;

View File

@ -79,7 +79,7 @@ CCMD (toggleconsole)
bool CheckCheatmode ()
{
if (((gameskill == sk_nightmare) || netgame || deathmatch) && (!sv_cheats))
if ((G_SkillProperty(SKILLP_DisableCheats) || netgame || deathmatch) && (!sv_cheats))
{
Printf ("sv_cheats must be true to enable this command.\n");
return true;
@ -230,7 +230,7 @@ CCMD (chase)
}
else
{
if (deathmatch && CheckCheatmode ())
if (gamestate == GS_LEVEL && deathmatch && CheckCheatmode ())
return;
Net_WriteByte (DEM_GENERICCHEAT);

View File

@ -76,9 +76,6 @@ extern bool autostart;
EXTERN_CVAR (Int, gameskill);
extern int NextSkill; // [RH] Skill to use at next level load
// Nightmare mode flag, single player.
extern int respawnmonsters;
// Netgame? Only true if >1 player.
extern bool netgame;

View File

@ -339,7 +339,7 @@ ABossTarget *DBrainState::GetTarget ()
{
Easy = !Easy;
if (gameskill <= sk_easy && !Easy)
if (G_SkillProperty(SKILLP_EasyBossBrain) && !Easy)
return NULL;
ABossTarget *target;

View File

@ -106,7 +106,6 @@ CVAR (Bool, storesavepic, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
gameaction_t gameaction;
gamestate_t gamestate = GS_STARTUP;
int respawnmonsters;
int paused;
bool sendpause; // send a pause event next tic

View File

@ -1549,23 +1549,8 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
}
delete map;
if (dmflags & DF_MONSTERS_RESPAWN)
{
respawnmonsters = TICRATE;
}
else if (gameinfo.gametype & (GAME_Doom|GAME_Strife) && gameskill == sk_nightmare)
{
respawnmonsters = TICRATE;
}
else
{
respawnmonsters = 0;
}
// Monsters wait longer before respawning in Strife.
respawnmonsters *= gameinfo.gametype != GAME_Strife ? 12 : 16;
oldSpeed = GameSpeed;
wantFast = (dmflags & DF_FAST_MONSTERS) || (gameskill == sk_nightmare);
wantFast = !!G_SkillProperty(SKILLP_FastMonsters);
GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal;
if (oldSpeed != GameSpeed)
@ -3028,3 +3013,54 @@ static void InitPlayerClasses ()
}
}
}
int G_SkillProperty(ESkillProperty prop)
{
switch(prop)
{
case SKILLP_AmmoFactor:
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
return FRACUNIT;
else
return FRACUNIT*3/2;
}
return FRACUNIT;
case SKILLP_DamageFactor:
if (gameskill == sk_baby) return FRACUNIT/2;
return FRACUNIT;
case SKILLP_FastMonsters:
return (gameskill == sk_nightmare || (dmflags & DF_FAST_MONSTERS));
case SKILLP_Respawn:
if (dmflags & DF_MONSTERS_RESPAWN ||
gameinfo.gametype & (GAME_DoomStrife) && gameskill == sk_nightmare)
{
return TICRATE * (gameinfo.gametype != GAME_Strife ? 12 : 16);
}
else
{
return 0;
}
case SKILLP_Aggressiveness:
return FRACUNIT;
case SKILLP_DisableCheats:
return gameskill == sk_nightmare;
case SKILLP_AutoUseHealth:
return gameskill == sk_baby;
case SKILLP_EasyBossBrain:
return gameskill == sk_baby;
case SKILLP_SpawnFilter:
return gameskill <= sk_easy? MTF_EASY : gameskill == sk_medium? MTF_NORMAL : MTF_HARD;
}
return 0;
}

View File

@ -354,4 +354,19 @@ struct PNGHandle;
void G_ReadSnapshots (PNGHandle *png);
void G_WriteSnapshots (FILE *file);
enum ESkillProperty
{
SKILLP_AmmoFactor,
SKILLP_DamageFactor,
SKILLP_FastMonsters,
SKILLP_Respawn,
SKILLP_Aggressiveness,
SKILLP_DisableCheats,
SKILLP_AutoUseHealth,
SKILLP_SpawnFilter,
SKILLP_EasyBossBrain,
};
int G_SkillProperty(ESkillProperty prop);
#endif //__G_LEVEL_H__

View File

@ -79,13 +79,7 @@ bool AAmmo::HandlePickup (AInventory *item)
if (!(item->ItemFlags&IF_IGNORESKILL))
{
// extra ammo in baby mode and nightmare mode
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
receiving += receiving;
else
receiving += receiving >> 1;
}
receiving = FixedMul(receiving, G_SkillProperty(SKILLP_AmmoFactor));
}
int oldamount = Amount;
Amount += receiving;
@ -138,13 +132,7 @@ AInventory *AAmmo::CreateCopy (AActor *other)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
amount <<= 1;
else
amount += amount >> 1;
}
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
if (GetClass()->ParentClass != RUNTIME_CLASS(AAmmo))
@ -1517,13 +1505,7 @@ AInventory *ABackpackItem::CreateCopy (AActor *other)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
amount <<= 1;
else
amount += amount >> 1;
}
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
if (ammo == NULL)
{ // The player did not have the ammo. Add it.
@ -1578,13 +1560,7 @@ bool ABackpackItem::HandlePickup (AInventory *item)
// extra ammo in baby mode and nightmare mode
if (!(item->ItemFlags&IF_IGNORESKILL))
{
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
amount <<= 1;
else
amount += amount >> 1;
}
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
probe->Amount += amount;
if (probe->Amount > probe->MaxAmount)

View File

@ -0,0 +1,42 @@
#include "r_defs.h"
#include "actor.h"
#include "info.h"
class AColorSetter : public AActor
{
DECLARE_STATELESS_ACTOR(AColorSetter, AActor)
void PostBeginPlay()
{
Super::PostBeginPlay();
Sector->SetColor(args[0], args[1], args[2], args[3]);
Destroy();
}
};
IMPLEMENT_STATELESS_ACTOR(AColorSetter, Any, 9038, 0)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY)
PROP_Flags3 (MF3_DONTSPLASH)
PROP_RenderStyle (STYLE_None)
END_DEFAULTS
class AFadeSetter : public AActor
{
DECLARE_STATELESS_ACTOR(AFadeSetter, AActor)
void PostBeginPlay()
{
Super::PostBeginPlay();
Sector->SetFade(args[0], args[1], args[2]);
Destroy();
}
};
IMPLEMENT_STATELESS_ACTOR(AFadeSetter, Any, 9039, 0)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY)
PROP_Flags3 (MF3_DONTSPLASH)
PROP_RenderStyle (STYLE_None)
END_DEFAULTS

View File

@ -257,13 +257,7 @@ AAmmo *AWeapon::AddAmmo (AActor *other, const PClass *ammotype, int amount)
// extra ammo in baby mode and nightmare mode
if (!(this->ItemFlags&IF_IGNORESKILL))
{
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
amount += amount;
else
amount += amount >> 1;
}
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
ammo = static_cast<AAmmo *>(other->FindInventory (ammotype));
if (ammo == NULL)
@ -298,13 +292,7 @@ bool AWeapon::AddExistingAmmo (AAmmo *ammo, int amount)
// extra ammo in baby mode and nightmare mode
if (!(ItemFlags&IF_IGNORESKILL))
{
if (gameskill == sk_baby || (gameskill == sk_nightmare && gameinfo.gametype != GAME_Strife))
{
if (gameinfo.gametype & (GAME_Doom|GAME_Strife))
amount += amount;
else
amount += amount >> 1;
}
amount = FixedMul(amount, G_SkillProperty(SKILLP_AmmoFactor));
}
ammo->Amount += amount;
if (ammo->Amount > ammo->MaxAmount)

View File

@ -331,7 +331,8 @@ bool AActor::SuggestMissileAttack (fixed_t dist)
if (flags4 & MF4_MISSILEMORE) dist >>= 1;
if (flags4 & MF4_MISSILEEVENMORE) dist >>= 3;
return pr_checkmissilerange() >= MIN<int> (dist >> FRACBITS, MinMissileChance);
int mmc = FixedMul(MinMissileChance, G_SkillProperty(SKILLP_Aggressiveness));
return pr_checkmissilerange() >= MIN<int> (dist >> FRACBITS, mmc);
}
//=============================================================================
@ -1804,8 +1805,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
}
}
if (nightmarefast &&
(gameskill == sk_nightmare || (dmflags & DF_FAST_MONSTERS)))
if (nightmarefast && G_SkillProperty(SKILLP_FastMonsters))
{ // Monsters move faster in nightmare mode
actor->tics -= actor->tics / 2;
if (actor->tics < 3)
@ -1897,7 +1897,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
if (actor->flags & MF_JUSTATTACKED)
{
actor->flags &= ~MF_JUSTATTACKED;
if ((gameskill != sk_nightmare) && !(dmflags & DF_FAST_MONSTERS))
if (!actor->isFast())
{
P_NewChaseDir (actor);
}
@ -2009,8 +2009,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
// check for missile attack
if (missilestate)
{
if (gameskill < sk_nightmare
&& actor->movecount && !(dmflags & DF_FAST_MONSTERS))
if (!actor->isFast() && actor->movecount)
{
goto nomissile;
}

View File

@ -687,7 +687,9 @@ void P_AutoUseHealth(player_t *player, int saveHealth)
normalAmount = normalItem != NULL ? normalItem->Amount : 0;
superAmount = superItem != NULL ? superItem->Amount : 0;
if ((gameskill == sk_baby) && (normalAmount*25 >= saveHealth))
bool skilluse = !!G_SkillProperty(SKILLP_AutoUseHealth);
if (skilluse && (normalAmount*25 >= saveHealth))
{ // Use quartz flasks
count = (saveHealth+24)/25;
for(i = 0; i < count; i++)
@ -713,7 +715,7 @@ void P_AutoUseHealth(player_t *player, int saveHealth)
}
}
}
else if ((gameskill == sk_baby)
else if (skilluse
&& (superAmount*100+normalAmount*25 >= saveHealth))
{ // Use mystic urns and quartz flasks
count = (saveHealth+24)/25;
@ -861,13 +863,10 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
return;
}
player = target->player;
if (player && gameskill == sk_baby)
if (player && damage > 1)
{
// Take half damage in trainer mode
if (damage > 1)
{
damage >>= 1;
}
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
}
// Special damage types
if (inflictor)
@ -1041,7 +1040,7 @@ void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage
}
if (damage >= player->health
&& ((gameskill == sk_baby) || deathmatch)
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
&& !player->morphTics)
{ // Try to use some inventory health
P_AutoUseHealth (player, damage - player->health + 1);
@ -1324,10 +1323,10 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage,
{ // target is invulnerable
return;
}
if (player && gameskill == sk_baby)
if (player)
{
// Take half damage in trainer mode
damage >>= 1;
damage = FixedMul(damage, G_SkillProperty(SKILLP_DamageFactor));
}
if(damage < 1000 && ((player->cheats&CF_GODMODE)
|| (player->mo->flags2 & MF2_INVULNERABLE)))
@ -1335,7 +1334,7 @@ void P_PoisonDamage (player_t *player, AActor *source, int damage,
return;
}
if (damage >= player->health
&& ((gameskill == sk_baby) || deathmatch)
&& (G_SkillProperty(SKILLP_AutoUseHealth) || deathmatch)
&& !player->morphTics)
{ // Try to use some inventory health
P_AutoUseHealth (player, damage - player->health+1);

View File

@ -2033,11 +2033,10 @@ FUNC(LS_Sector_SetColor)
// Sector_SetColor (tag, r, g, b, desaturate)
{
int secnum = -1;
PalEntry color = PalEntry (arg1, arg2, arg3);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0)
{
sectors[secnum].ColorMap = GetSpecialLights (color, sectors[secnum].ColorMap->Fade, arg4);
sectors[secnum].SetColor(arg1, arg2, arg3, arg4);
}
return true;
@ -2047,11 +2046,10 @@ FUNC(LS_Sector_SetFade)
// Sector_SetFade (tag, r, g, b)
{
int secnum = -1;
PalEntry fade = PalEntry (arg1, arg2, arg3);
while ((secnum = P_FindSectorFromTag (arg0, secnum)) >= 0)
{
sectors[secnum].ColorMap = GetSpecialLights (sectors[secnum].ColorMap->Color, fade, sectors[secnum].ColorMap->Desaturate);
sectors[secnum].SetFade(arg1, arg2, arg3);
}
return true;
}

View File

@ -467,7 +467,7 @@ int AActor::GetTics(FState * newstate)
{
int tics = newstate->GetTics();
if (gameskill == sk_nightmare || (dmflags & DF_FAST_MONSTERS))
if (isFast())
{
if (flags5 & MF5_FASTER)
{
@ -2943,13 +2943,14 @@ void AActor::Tick ()
}
else
{
int respawn_monsters = G_SkillProperty(SKILLP_Respawn);
// check for nightmare respawn
if (!respawnmonsters || !(flags3 & MF3_ISMONSTER) || (flags2 & MF2_DORMANT))
if (!respawn_monsters || !(flags3 & MF3_ISMONSTER) || (flags2 & MF2_DORMANT))
return;
movecount++;
if (movecount < respawnmonsters)
if (movecount < respawn_monsters)
return;
if (level.time & 31)
@ -3132,7 +3133,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
FRandom &rng = bglobal.m_Thinking ? pr_botspawnmobj : pr_spawnmobj;
if (gameskill == sk_nightmare && actor->flags3 & MF3_ISMONSTER)
if (actor->isFast() && actor->flags3 & MF3_ISMONSTER)
actor->reactiontime = 0;
if (actor->flags3 & MF3_ISMONSTER)
@ -3152,7 +3153,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
actor->frame = st->GetFrame();
actor->renderflags = (actor->renderflags & ~RF_FULLBRIGHT) | st->GetFullbright();
actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98
if (gameskill == sk_nightmare || (dmflags & DF_FAST_MONSTERS))
if (G_SkillProperty(SKILLP_FastMonsters))
actor->Speed = actor->GetClass()->Meta.GetMetaFixed(AMETA_FastSpeed, actor->Speed);
// set subsector and/or block links
@ -3307,6 +3308,13 @@ void AActor::BeginPlay ()
{
}
bool AActor::isFast()
{
if (flags5&MF5_ALWAYSFAST) return true;
if (flags5&MF5_NEVERFAST) return false;
return !!G_SkillProperty(SKILLP_FastMonsters);
}
void AActor::Activate (AActor *activator)
{
if ((flags3 & MF3_ISMONSTER) && (health > 0 || (flags & MF_ICECORPSE)))
@ -3410,6 +3418,7 @@ void AActor::AdjustFloorClip ()
// Most of the player structure stays unchanged between levels.
//
EXTERN_CVAR (Bool, chasedemo)
extern bool demonew;
void P_SpawnPlayer (mapthing2_t *mthing, bool tempplayer)
@ -3711,19 +3720,7 @@ void P_SpawnMapThing (mapthing2_t *mthing, int position)
return;
}
// check for apropriate skill level
if (gameskill == sk_baby)
{
mask = MTF_EASY;
}
else if (gameskill == sk_nightmare)
{
mask = MTF_HARD;
}
else
{
mask = 1 << (gameskill - 1);
}
mask = G_SkillProperty(SKILLP_SpawnFilter);
if (!(mthing->flags & mask))
{
return;

View File

@ -681,3 +681,16 @@ fixed_t sector_t::FindLowestCeilingPoint (vertex_t **v) const
*v = spot;
return height;
}
void sector_t::SetColor(int r, int g, int b, int desat)
{
PalEntry color = PalEntry (r,g,b);
ColorMap = GetSpecialLights (color, ColorMap->Fade, desat);
}
void sector_t::SetFade(int r, int g, int b)
{
PalEntry fade = PalEntry (r,g,b);
ColorMap = GetSpecialLights (ColorMap->Color, fade, ColorMap->Desaturate);
}

View File

@ -272,6 +272,8 @@ struct sector_t
fixed_t FindLowestCeilingPoint (vertex_t **v) const;
fixed_t FindHighestFloorPoint (vertex_t **v) const;
void AdjustFloorClip () const;
void SetColor(int r, int g, int b, int desat);
void SetFade(int r, int g, int b);
// Member variables
fixed_t CenterFloor () const { return floorplane.ZatPoint (soundorg[0], soundorg[1]); }

View File

@ -218,6 +218,8 @@ static flagdef ActorFlags[]=
DEFINE_FLAG(MF5, NOBLOODDECALS, AActor, flags5),
DEFINE_FLAG(MF5, USESPECIAL, AActor, flags5),
DEFINE_FLAG(MF5, NOPAIN, AActor, flags5),
DEFINE_FLAG(MF5, ALWAYSFAST, AActor, flags5),
DEFINE_FLAG(MF5, NEVERFAST, AActor, flags5),
// Effect flags
DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),

View File

@ -5959,6 +5959,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\g_shared\a_setcolor.cpp"
>
</File>
<File
RelativePath=".\src\g_shared\a_sharedglobal.h"
>