OpenCoD2-Plus
Call of Duty 2 client & server, rebuilt
Loading...
Searching...
No Matches
view_weapon_test Namespace Reference

Functions

 game_log (home)
 parse (text)
 still (frame)
 landings (frames)
 check_damage_kick (text, check)
 check_view_bob (text, check)
 check_view_animation (text, check)
 check_jump_speed (frames, check)
 check_perturb (text, check)
 shock_start (text)
 check_trace (frames, check)
 main ()

Variables

 ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
dict DEFAULT_CLIENT = {115: 'build/check-linux-10/cod2_linux', 118: 'build/check-linux/cod2_linux'}
dict DEFAULT_SERVER = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}
str WEAPON = 'kar98k_mp'
str GAMETYPE
str CONFIG
 LINE
 KICK = re.compile(r'\‍[viewdamage\] t=(-?\d+) dmg=(-?\d+) delta=(-?\d+) pitch=(\S+) roll=(\S+) kick=(\S+) (\S+)')
 BOB = re.compile(r'\‍[viewbob\] hbob=(\S+) fwd=(\S+) right=(\S+)')
 ANIM = re.compile(r'\‍[viewanim\] t=(-?\d+) turn=(\S+) move=(\S+) (\S+) (\S+)')
 PERTURB = re.compile(r'\‍[perturb\] t=(-?\d+) det=(\S+) delta=(\S+) (\S+)')

Detailed Description

A client leans, crouches, jumps, walks, fires and is hit; its view and view weapon move as 1.3's.

    python3 scripts/view_weapon_test.py /path/to/CoD2 --protocol {115|118} [--binary PATH] [--server PATH]

Runs the dedicated server with a mod that spawns each player with a rifle,
and a real client (cod2_linux) with COD2_TRACE_VIEWWEAPON set and a config
that loops: lean right, lean left, crouch, stand, jump. The client prints the
view weapon's offset from the eye along the view axis each frame; the test
reads it. 1.3's CG_CalculateWeaponPosition (0x4d5970) moves the weapon
sideways while leaning, to the weapon's stance offset while crouched, and
down by landChange * 0.25 at most after a landing (150 ms down, 300 ms back).
The mod also hurts the player every few seconds; with COD2_TRACE_VIEWDAMAGE
the client prints the angles the view adds after each hit. 1.3 times that
kick from cg->damageTime minus ps->deltaTime (0x4cee35): it eases to
v_dmg_pitch and v_dmg_roll in 100 ms and back in 400 and never goes past them.
Walking, the eye bobs sideways along the view's right (COD2_TRACE_VIEWBOB).
Firing, reloading and melee move the camera by the view weapon's tag_camera
bone (0x4cf730, COD2_TRACE_VIEWANIM). After 30 s the mod shellshocks the
player; the perturbed view must stay a rotation (0x4d2320, COD2_TRACE_PERTURB);
the view weapon checks read the frames before it.
The client opens a window and needs a CD key in ~/.cod2/preferences; without
one the test is skipped (exit 0). Exits with 0 when all of that holds.

Function Documentation

◆ check_damage_kick()

view_weapon_test.check_damage_kick ( text,
check )
The view's damage kick never goes past v_dmg_pitch and v_dmg_roll (the
idle sway adds well under a degree), and a hit is felt.

◆ check_jump_speed()

view_weapon_test.check_jump_speed ( frames,
check )
1.3's xyspeed (0x4cfa44) is the horizontal speed only: a jump in place
leaves it near 0 in the 300 ms before the landing.

◆ check_perturb()

view_weapon_test.check_perturb ( text,
check )
A shellshock turns the view (0x4d2320) by a rotation: the axis stays
right-handed and orthonormal.

◆ check_trace()

view_weapon_test.check_trace ( frames,
check )

◆ check_view_animation()

view_weapon_test.check_view_animation ( text,
check )
1.3 moves the camera by the view weapon's tag_camera bone (0x4cf730):
firing, reloading and melee animate it.

◆ check_view_bob()

view_weapon_test.check_view_bob ( text,
check )
1.3 moves the eye by the horizontal bob along the view's right
(0x4cef6c), not forward.

◆ game_log()

view_weapon_test.game_log ( home)

◆ landings()

view_weapon_test.landings ( frames)
[(reference u, [(land, u)])] for each landing: the frames 0..450 ms after it.

◆ main()

view_weapon_test.main ( )

◆ parse()

view_weapon_test.parse ( text)
The trace's frames, in order, as dicts.

◆ shock_start()

view_weapon_test.shock_start ( text)
The time of the first shellshocked frame, or None.

◆ still()

view_weapon_test.still ( frame)
Not moving, not aiming, not in a landing.

Variable Documentation

◆ ANIM

view_weapon_test.ANIM = re.compile(r'\‍[viewanim\] t=(-?\d+) turn=(\S+) move=(\S+) (\S+) (\S+)')

◆ BOB

view_weapon_test.BOB = re.compile(r'\‍[viewbob\] hbob=(\S+) fwd=(\S+) right=(\S+)')

◆ CONFIG

str view_weapon_test.CONFIG
Initial value:
1= '''set com_maxfps 100
2set vw_loop "+leanright; wait 300; -leanright; wait 150; +leanleft; wait 300; -leanleft; wait 150; gocrouch; wait 400; +gostand; wait 20; -gostand; wait 150; +moveup; wait 20; -moveup; wait 300; +forward; wait 150; -forward; +back; wait 150; -back; wait 100; +attack; wait 5; -attack; wait 200; +reload; wait 5; -reload; wait 400; +melee; wait 5; -melee; wait 200; vstr vw_loop"
3set vw_start "wait 1000; vstr vw_loop"
4vstr vw_start
5'''

◆ DEFAULT_CLIENT

dict view_weapon_test.DEFAULT_CLIENT = {115: 'build/check-linux-10/cod2_linux', 118: 'build/check-linux/cod2_linux'}

◆ DEFAULT_SERVER

dict view_weapon_test.DEFAULT_SERVER = {115: 'build/check-linux-10/cod2_lnxded', 118: 'build/check-linux/cod2_lnxded'}

◆ GAMETYPE

str view_weapon_test.GAMETYPE

◆ KICK

view_weapon_test.KICK = re.compile(r'\‍[viewdamage\] t=(-?\d+) dmg=(-?\d+) delta=(-?\d+) pitch=(\S+) roll=(\S+) kick=(\S+) (\S+)')

◆ LINE

view_weapon_test.LINE
Initial value:
1= re.compile(r'\‍[viewweapon\‍] t=(-?\d+) lean=(\S+) vht=(-?\d+) xy=(\S+) land=(-?\d+) lc=(\S+) ads=(\S+) '
2 r'ofs=(\S+) (\S+) (\S+)')

◆ PERTURB

view_weapon_test.PERTURB = re.compile(r'\‍[perturb\] t=(-?\d+) det=(\S+) delta=(\S+) (\S+)')

◆ ROOT

view_weapon_test.ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

◆ WEAPON

str view_weapon_test.WEAPON = 'kar98k_mp'