- Added A_ZoomFactor. This lets weapons scale their player's FOV. Each weapon

maintains its own FOV scale independent from any other weapons the player
  may have.
- Fixed: When parsing DECORATE functions that were not exported, the parser
  crashed after giving you the warning.


SVN r1688 (trunk)
This commit is contained in:
Randy Heit 2009-06-30 19:20:39 +00:00
parent f32b95d3cc
commit ed0d804792
6 changed files with 78 additions and 29 deletions

View file

@ -1,4 +1,11 @@
June 27, 2009 June 30, 2009
- Added A_ZoomFactor. This lets weapons scale their player's FOV. Each weapon
maintains its own FOV scale independent from any other weapons the player
may have.
- Fixed: When parsing DECORATE functions that were not exported, the parser
crashed after giving you the warning.
June 27, 2009
- Fixed some improper preprocessor lines in autostart/autozend.cpp. - Fixed some improper preprocessor lines in autostart/autozend.cpp.
- Added XInput support. For the benefit of people compiling with MinGW, - Added XInput support. For the benefit of people compiling with MinGW,
the CMakeLists.txt checks for xinput.h and disables it if it cannot the CMakeLists.txt checks for xinput.h and disables it if it cannot

View file

@ -264,6 +264,7 @@ public:
TObjPtr<AAmmo> Ammo1, Ammo2; TObjPtr<AAmmo> Ammo1, Ammo2;
TObjPtr<AWeapon> SisterWeapon; TObjPtr<AWeapon> SisterWeapon;
bool GivenAsMorphWeapon; bool GivenAsMorphWeapon;
float FOVScale;
bool bAltFire; // Set when this weapon's alternate fire is used. bool bAltFire; // Set when this weapon's alternate fire is used.

View file

@ -59,6 +59,10 @@ void AWeapon::Serialize (FArchive &arc)
<< Ammo1 << Ammo2 << SisterWeapon << GivenAsMorphWeapon << Ammo1 << Ammo2 << SisterWeapon << GivenAsMorphWeapon
<< bAltFire << bAltFire
<< ReloadCounter; << ReloadCounter;
if (SaveVersion >= 1688)
{
arc << FOVScale;
}
} }
//=========================================================================== //===========================================================================
@ -1690,3 +1694,27 @@ const PClass *Net_ReadWeapon(BYTE **stream)
} }
return Weapons_ntoh[index]; return Weapons_ntoh[index];
} }
//===========================================================================
//
// A_ZoomFactor
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
{
ACTION_PARAM_START(2);
ACTION_PARAM_FLOAT(zoom, 0);
ACTION_PARAM_INT(flags, 1);
if (self->player != NULL && self->player->ReadyWeapon != NULL)
{
zoom = 1 / clamp(zoom, 0.1f, 50.f);
self->player->ReadyWeapon->FOVScale = zoom;
if (flags & 1)
{
// Make the zoom instant.
self->player->FOV = self->player->DesiredFOV * zoom;
}
}
}

View file

@ -1996,16 +1996,24 @@ void P_PlayerThink (player_t *player)
} }
// [RH] Zoom the player's FOV // [RH] Zoom the player's FOV
if (player->FOV != player->DesiredFOV) float desired = player->DesiredFOV;
// Adjust FOV using on the currently held weapon.
if (player->playerstate != PST_DEAD && // No adjustment while dead.
player->ReadyWeapon != NULL && // No adjustment if no weapon.
player->ReadyWeapon->FOVScale != 0) // No adjustment if the adjustment is zero.
{ {
if (fabsf (player->FOV - player->DesiredFOV) < 7.f) desired *= player->ReadyWeapon->FOVScale;
}
if (player->FOV != desired)
{
if (fabsf (player->FOV - desired) < 7.f)
{ {
player->FOV = player->DesiredFOV; player->FOV = desired;
} }
else else
{ {
float zoom = MAX(7.f, fabsf (player->FOV - player->DesiredFOV) * 0.025f); float zoom = MAX(7.f, fabsf(player->FOV - desired) * 0.025f);
if (player->FOV > player->DesiredFOV) if (player->FOV > desired)
{ {
player->FOV = player->FOV - zoom; player->FOV = player->FOV - zoom;
} }

View file

@ -857,31 +857,34 @@ static void ParseActionDef (FScanner &sc, PClass *cls)
} }
} }
sc.MustGetToken(';'); sc.MustGetToken(';');
PSymbolActionFunction *sym = new PSymbolActionFunction(funcname); if (afd != NULL)
sym->Arguments = args;
sym->Function = afd->Function;
if (hasdefaults)
{ {
sym->defaultparameterindex = StateParams.Size(); PSymbolActionFunction *sym = new PSymbolActionFunction(funcname);
for(unsigned int i = 0; i < DefaultParams.Size(); i++) sym->Arguments = args;
sym->Function = afd->Function;
if (hasdefaults)
{ {
StateParams.Add(DefaultParams[i], cls, true); sym->defaultparameterindex = StateParams.Size();
for(unsigned int i = 0; i < DefaultParams.Size(); i++)
{
StateParams.Add(DefaultParams[i], cls, true);
}
}
else
{
sym->defaultparameterindex = -1;
}
if (error)
{
FScriptPosition::ErrorCounter++;
}
else if (cls->Symbols.AddSymbol (sym) == NULL)
{
delete sym;
sc.ScriptMessage ("'%s' is already defined in class '%s'.",
funcname.GetChars(), cls->TypeName.GetChars());
FScriptPosition::ErrorCounter++;
} }
}
else
{
sym->defaultparameterindex = -1;
}
if (error)
{
FScriptPosition::ErrorCounter++;
}
else if (cls->Symbols.AddSymbol (sym) == NULL)
{
delete sym;
sc.ScriptMessage ("'%s' is already defined in class '%s'.",
funcname.GetChars(), cls->TypeName.GetChars());
FScriptPosition::ErrorCounter++;
} }
} }

View file

@ -306,7 +306,6 @@ ACTOR PuzzleItem : Inventory native
Actor Weapon : Inventory native Actor Weapon : Inventory native
{ {
Inventory.PickupSound "misc/w_pkup" Inventory.PickupSound "misc/w_pkup"
Weapon.DefaultKickback Weapon.DefaultKickback
States States
@ -315,6 +314,9 @@ Actor Weapon : Inventory native
SHTG E 0 A_Light0 SHTG E 0 A_Light0
Stop Stop
} }
action native A_ZoomFactor(float scale = 1, int flags = 0);
const int ZOOM_INSTANT = 1;
} }
ACTOR WeaponGiver : Weapon native ACTOR WeaponGiver : Weapon native