diff --git a/docs/rh-log.txt b/docs/rh-log.txt index adba114d02..043415f0e3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -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. - Added XInput support. For the benefit of people compiling with MinGW, the CMakeLists.txt checks for xinput.h and disables it if it cannot diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index f48289cbb8..3dbf97360b 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -264,6 +264,7 @@ public: TObjPtr Ammo1, Ammo2; TObjPtr SisterWeapon; bool GivenAsMorphWeapon; + float FOVScale; bool bAltFire; // Set when this weapon's alternate fire is used. diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 8698c93421..5a0dc376e5 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -59,6 +59,10 @@ void AWeapon::Serialize (FArchive &arc) << Ammo1 << Ammo2 << SisterWeapon << GivenAsMorphWeapon << bAltFire << ReloadCounter; + if (SaveVersion >= 1688) + { + arc << FOVScale; + } } //=========================================================================== @@ -1690,3 +1694,27 @@ const PClass *Net_ReadWeapon(BYTE **stream) } 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; + } + } +} diff --git a/src/p_user.cpp b/src/p_user.cpp index 6d8f7ace45..73c68c983a 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1996,16 +1996,24 @@ void P_PlayerThink (player_t *player) } // [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 { - float zoom = MAX(7.f, fabsf (player->FOV - player->DesiredFOV) * 0.025f); - if (player->FOV > player->DesiredFOV) + float zoom = MAX(7.f, fabsf(player->FOV - desired) * 0.025f); + if (player->FOV > desired) { player->FOV = player->FOV - zoom; } diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index 68fe77fe29..a45b4dc409 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -857,31 +857,34 @@ static void ParseActionDef (FScanner &sc, PClass *cls) } } sc.MustGetToken(';'); - PSymbolActionFunction *sym = new PSymbolActionFunction(funcname); - sym->Arguments = args; - sym->Function = afd->Function; - if (hasdefaults) + if (afd != NULL) { - sym->defaultparameterindex = StateParams.Size(); - for(unsigned int i = 0; i < DefaultParams.Size(); i++) + PSymbolActionFunction *sym = new PSymbolActionFunction(funcname); + 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++; } } diff --git a/wadsrc/static/actors/shared/inventory.txt b/wadsrc/static/actors/shared/inventory.txt index b7fb534617..07630a0cd3 100644 --- a/wadsrc/static/actors/shared/inventory.txt +++ b/wadsrc/static/actors/shared/inventory.txt @@ -306,7 +306,6 @@ ACTOR PuzzleItem : Inventory native Actor Weapon : Inventory native { - Inventory.PickupSound "misc/w_pkup" Weapon.DefaultKickback States @@ -315,6 +314,9 @@ Actor Weapon : Inventory native SHTG E 0 A_Light0 Stop } + + action native A_ZoomFactor(float scale = 1, int flags = 0); + const int ZOOM_INSTANT = 1; } ACTOR WeaponGiver : Weapon native