A_ZoomFactor
Jump to navigation
Jump to search
A_ZoomFactor [(float zoom [, int flags)]
- zoom: The amount to zoom in or out. The player's FOV is divided by this value. Default is 1.0.
- flags: Flags to modify the behavior of the zoom.
A_ZoomFactor lets weapons scale their player's FOV. Each weapon maintains its own FOV scale independent from any other weapons the player may have.
Flags may be a combination of either of the following (or omitted):
- ZOOM_INSTANT: The zoom is normally spread out across a few ticks to make a zooming effect. Use this flag to make the zoom instant.
- ZOOM_NOSCALETURNING: Player turning is normally scaled as well by this function. Use this flag to retain the player's unzoomed sensitivity while zoomed.
This codepointer is restricted to Weapon and derived classes.
Examples
This sniper pistol has two levels of zoom, 2x and 4x.
actor SniperPistol_Zoomed : Inventory
{
inventory.maxamount 2
}
actor SniperPistol : Pistol
{
States
{
AltFire:
PISG ABC 6
TNT1 A 0 A_JumpIfInventory("SniperPistol_Zoomed", 2, "ZoomOut")
TNT1 A 0 A_JumpIfInventory("SniperPistol_Zoomed", 1, "Zoom2")
//fall through
Zoom1:
TNT1 A 0 A_ZoomFactor(2.0)
TNT1 A 0 A_GiveInventory ("SniperPistol_Zoomed", 1)
Goto "AltFireDone"
Zoom2:
TNT1 A 0 A_ZoomFactor(4.0)
TNT1 A 0 A_GiveInventory ("SniperPistol_Zoomed", 1)
Goto "AltFireDone"
ZoomOut:
TNT1 A 0 A_ZoomFactor(1.0)
TNT1 A 0 A_TakeInventory ("SniperPistol_Zoomed", 2)
Goto "AltFireDone"
AltFireDone:
PISG C 5 A_ReFire
Goto "Ready"
Deselect:
TNT1 A 0 A_TakeInventory ("SniperPistol_Zoomed", 2)
TNT1 A 0 A_ZoomFactor(1.0)
Goto "Super::Deselect"
}
}
This is a fully functional sniper rifle. The altfire brings up the scope, and then gives a dummy inventory item. There's also an A_JumpIfInventory flag on the ready and fire states to check if the player have this dummy item, so the weapon can go to an alternate ready and fire states if you have pressed the altfire button.
ACTOR HKG3SG1 : Weapon replaces Berserk
{
Inventory.PickupMessage "H&K G3/SG1"
Inventory.PickupSound "misc/w_pkup"
Weapon.AmmoGive 10
Weapon.AmmoType "Clip"
Weapon.AmmoType2 "Clip"
Weapon.Ammouse 1
Weapon.Ammouse2 1
Weapon.Kickback 40
DamageType "FriendlyFire"
+NOAUTOFIRE
+NOALERT
Scale 0.14
States
{
Spawn:
G3SG A -1
LOOP
Ready:
HKG3 A 0 A_JumpIfInventory("G3Zoom", 1, "ReadyScope")
HKG3 A 1 A_WeaponReady
LOOP
ReadyScope:
ASNS A 1 A_WeaponReady(WRF_NoBob)
LOOP
Deselect:
TNT1 A 0 A_TakeInventory ("G3Zoom", 2)
TNT1 A 0 A_ZoomFactor(1.0)
HKG3 A 1 A_Lower
Goto Deselect+2
Select:
HKG3 A 1 A_Raise
TNT1 A 0 A_Raise
LOOP
Fire:
ASNS A 0 A_JumpIfInventory("G3Zoom", 1, "FireScope")
HKGF A 0 A_AlertMonsters
HKGF A 0 A_PlayWeaponSound("weapons/sg550_fire")
HKGF A 0 A_FireProjectile("GunSmokeSpawner",0,0,5,9)
HKGF A 1 Bright A_FireBullets (1.5, 1.5, -1, 24, "Puff2")
HKG3 B 0 A_FireProjectile("556MMCasingSpawner",0,0,14,4)
HKG3 B 0 ACS_Execute(987,0,125,random(2,4),0)
HKG3 BCDEFGHI 1 A_WeaponReady(WRF_NoFire)
HKG3 A 9 A_WeaponReady(WRF_NoFire)
Goto Ready
FireScope:
ASNS A 0 A_AlertMonsters
ASNS A 0 A_PlayWeaponSound("weapons/sg550_fire")
ASNS A 1 Bright A_FireBullets (0, 0, -1, 24, "Puff2")
ASNS A 0 A_FireProjectile("556MMCasingSpawner",0,0,14,4)
ASNS A 0 ACS_Execute(987,0,95,random(2,4),0)
ASNS A 17
Goto ReadyScope
AltFire:
ASNS A 0 A_SetCrosshair(50)
ASNS A 2 A_WeaponReady(WRF_NoBob)
TNT1 A 0 A_JumpIfInventory("G3Zoom", 2, "ZoomOut")
TNT1 A 0 A_JumpIfInventory("G3Zoom", 1, "Zoom2")
//fall through
Zoom1:
TNT1 A 0 A_ZoomFactor(3.0)
TNT1 A 0 A_GiveInventory ("G3Zoom", 1)
Goto "AltFireDone"
Zoom2:
TNT1 A 0 A_ZoomFactor(8.0)
TNT1 A 0 A_GiveInventory ("G3Zoom", 1)
Goto "AltFireDone"
ZoomOut:
TNT1 A 0 A_SetCrosshair(0)
TNT1 A 0 A_ZoomFactor(1.0)
TNT1 A 0 A_TakeInventory ("G3Zoom", 2)
Goto "AltFireDone"
AltFireDone:
ASNS A 1 A_ReFire
Goto "Ready"
}
}
actor G3Zoom : Inventory
{
inventory.maxamount 2
}