crimsonland 0.1.0.dev9__py3-none-any.whl → 0.1.0.dev10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- crimson/demo.py +77 -35
- crimson/gameplay.py +5 -3
- {crimsonland-0.1.0.dev9.dist-info → crimsonland-0.1.0.dev10.dist-info}/METADATA +1 -1
- {crimsonland-0.1.0.dev9.dist-info → crimsonland-0.1.0.dev10.dist-info}/RECORD +6 -6
- {crimsonland-0.1.0.dev9.dist-info → crimsonland-0.1.0.dev10.dist-info}/WHEEL +0 -0
- {crimsonland-0.1.0.dev9.dist-info → crimsonland-0.1.0.dev10.dist-info}/entry_points.txt +0 -0
crimson/demo.py
CHANGED
|
@@ -475,6 +475,9 @@ class DemoView:
|
|
|
475
475
|
player = self._world.players[idx]
|
|
476
476
|
player.pos_x = float(x)
|
|
477
477
|
player.pos_y = float(y)
|
|
478
|
+
# Keep aim anchored to the spawn position so demo aim starts stable.
|
|
479
|
+
player.aim_x = float(x)
|
|
480
|
+
player.aim_y = float(y)
|
|
478
481
|
weapon_assign_player(player, int(weapon_id))
|
|
479
482
|
self._demo_targets = [None] * len(self._world.players)
|
|
480
483
|
|
|
@@ -549,7 +552,8 @@ class DemoView:
|
|
|
549
552
|
|
|
550
553
|
def _setup_variant_0(self) -> None:
|
|
551
554
|
self._demo_time_limit_ms = 4000
|
|
552
|
-
weapon_id
|
|
555
|
+
# demo_setup_variant_0 uses weapon_id=0x0B.
|
|
556
|
+
weapon_id = 11
|
|
553
557
|
self._setup_world_players(
|
|
554
558
|
[
|
|
555
559
|
(448.0, 384.0, weapon_id),
|
|
@@ -567,7 +571,8 @@ class DemoView:
|
|
|
567
571
|
|
|
568
572
|
def _setup_variant_1(self) -> None:
|
|
569
573
|
self._demo_time_limit_ms = 5000
|
|
570
|
-
weapon_id
|
|
574
|
+
# demo_setup_variant_1 uses weapon_id=0x05.
|
|
575
|
+
weapon_id = 5
|
|
571
576
|
self._setup_world_players(
|
|
572
577
|
[
|
|
573
578
|
(490.0, 448.0, weapon_id),
|
|
@@ -586,7 +591,8 @@ class DemoView:
|
|
|
586
591
|
|
|
587
592
|
def _setup_variant_2(self) -> None:
|
|
588
593
|
self._demo_time_limit_ms = 5000
|
|
589
|
-
weapon_id
|
|
594
|
+
# demo_setup_variant_2 uses weapon_id=0x15.
|
|
595
|
+
weapon_id = 21
|
|
590
596
|
self._setup_world_players([(512.0, 512.0, weapon_id)])
|
|
591
597
|
y = 128
|
|
592
598
|
i = 0
|
|
@@ -601,7 +607,8 @@ class DemoView:
|
|
|
601
607
|
|
|
602
608
|
def _setup_variant_3(self) -> None:
|
|
603
609
|
self._demo_time_limit_ms = 4000
|
|
604
|
-
weapon_id
|
|
610
|
+
# demo_setup_variant_3 uses weapon_id=0x12.
|
|
611
|
+
weapon_id = 18
|
|
605
612
|
self._setup_world_players([(512.0, 512.0, weapon_id)])
|
|
606
613
|
for idx in range(20):
|
|
607
614
|
x = float(self._crand_mod(200) + 32)
|
|
@@ -881,10 +888,10 @@ class DemoView:
|
|
|
881
888
|
def _update_world(self, dt: float) -> None:
|
|
882
889
|
if not self._world.players:
|
|
883
890
|
return
|
|
884
|
-
inputs = self._build_demo_inputs()
|
|
891
|
+
inputs = self._build_demo_inputs(dt)
|
|
885
892
|
self._world.update(dt, inputs=inputs, auto_pick_perks=False, game_mode=0, perk_progression_enabled=False)
|
|
886
893
|
|
|
887
|
-
def _build_demo_inputs(self) -> list[PlayerInput]:
|
|
894
|
+
def _build_demo_inputs(self, dt: float) -> list[PlayerInput]:
|
|
888
895
|
players = self._world.players
|
|
889
896
|
creatures = self._world.creatures.entries
|
|
890
897
|
if len(self._demo_targets) != len(players):
|
|
@@ -892,42 +899,77 @@ class DemoView:
|
|
|
892
899
|
center_x = float(self._world.world_size) * 0.5
|
|
893
900
|
center_y = float(self._world.world_size) * 0.5
|
|
894
901
|
|
|
902
|
+
dt = float(dt)
|
|
903
|
+
|
|
904
|
+
def _turn_towards_heading(cur: float, target: float) -> tuple[float, float]:
|
|
905
|
+
cur = cur % math.tau
|
|
906
|
+
target = target % math.tau
|
|
907
|
+
delta = (target - cur + math.pi) % math.tau - math.pi
|
|
908
|
+
diff = abs(delta)
|
|
909
|
+
if diff <= 1e-9:
|
|
910
|
+
return cur, 0.0
|
|
911
|
+
step = dt * diff * 5.0
|
|
912
|
+
cur = (cur + step) % math.tau if delta > 0.0 else (cur - step) % math.tau
|
|
913
|
+
return cur, diff
|
|
914
|
+
|
|
895
915
|
inputs: list[PlayerInput] = []
|
|
896
916
|
for idx, player in enumerate(players):
|
|
897
917
|
target_idx = self._select_demo_target(idx, player, creatures)
|
|
898
|
-
aim_x = center_x
|
|
899
|
-
aim_y = center_y
|
|
900
918
|
target = None
|
|
901
919
|
if target_idx is not None and 0 <= target_idx < len(creatures):
|
|
902
920
|
candidate = creatures[target_idx]
|
|
903
|
-
if candidate.hp > 0.0:
|
|
921
|
+
if candidate.active and candidate.hp > 0.0:
|
|
904
922
|
target = candidate
|
|
905
|
-
aim_x = candidate.x
|
|
906
|
-
aim_y = candidate.y
|
|
907
|
-
|
|
908
|
-
move_x, move_y = 0.0, 0.0
|
|
909
|
-
to_cx = center_x - player.pos_x
|
|
910
|
-
to_cy = center_y - player.pos_y
|
|
911
|
-
nx, ny, d = _normalize(to_cx, to_cy)
|
|
912
|
-
if d > 120.0:
|
|
913
|
-
move_x += nx
|
|
914
|
-
move_y += ny
|
|
915
923
|
|
|
924
|
+
# Aim: ease the aim point toward the target.
|
|
925
|
+
aim_x = float(player.aim_x)
|
|
926
|
+
aim_y = float(player.aim_y)
|
|
927
|
+
auto_fire = False
|
|
916
928
|
if target is not None:
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
if
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
929
|
+
aim_dx = float(target.x) - aim_x
|
|
930
|
+
aim_dy = float(target.y) - aim_y
|
|
931
|
+
aim_dir_x, aim_dir_y, aim_dist = _normalize(aim_dx, aim_dy)
|
|
932
|
+
if aim_dist >= 4.0:
|
|
933
|
+
step = aim_dist * 6.0 * dt
|
|
934
|
+
aim_x += aim_dir_x * step
|
|
935
|
+
aim_y += aim_dir_y * step
|
|
936
|
+
else:
|
|
937
|
+
aim_x = float(target.x)
|
|
938
|
+
aim_y = float(target.y)
|
|
939
|
+
auto_fire = aim_dist < 128.0
|
|
940
|
+
else:
|
|
941
|
+
ax, ay, amag = _normalize(float(player.pos_x) - center_x, float(player.pos_y) - center_y)
|
|
942
|
+
if amag <= 1e-6:
|
|
943
|
+
ax, ay = 0.0, -1.0
|
|
944
|
+
aim_x = float(player.pos_x) + ax * 60.0
|
|
945
|
+
aim_y = float(player.pos_y) + ay * 60.0
|
|
946
|
+
|
|
947
|
+
# Movement:
|
|
948
|
+
# - orbit center if no target
|
|
949
|
+
# - chase target when near center
|
|
950
|
+
# - return to center when too far
|
|
951
|
+
if target is None:
|
|
952
|
+
move_dx = -(float(player.pos_y) - center_y)
|
|
953
|
+
move_dy = float(player.pos_x) - center_x
|
|
954
|
+
else:
|
|
955
|
+
center_dist = math.hypot(float(player.pos_x) - center_x, float(player.pos_y) - center_y)
|
|
956
|
+
if center_dist <= 300.0:
|
|
957
|
+
move_dx = float(target.x) - float(player.pos_x)
|
|
958
|
+
move_dy = float(target.y) - float(player.pos_y)
|
|
959
|
+
else:
|
|
960
|
+
move_dx = center_x - float(player.pos_x)
|
|
961
|
+
move_dy = center_y - float(player.pos_y)
|
|
962
|
+
|
|
963
|
+
desired_x, desired_y, desired_mag = _normalize(move_dx, move_dy)
|
|
964
|
+
if desired_mag <= 1e-6:
|
|
965
|
+
move_x = 0.0
|
|
966
|
+
move_y = 0.0
|
|
967
|
+
else:
|
|
968
|
+
desired_heading = math.atan2(desired_y, desired_x) + math.pi / 2.0
|
|
969
|
+
smoothed_heading, angle_diff = _turn_towards_heading(float(player.heading), desired_heading)
|
|
970
|
+
move_mag = max(0.001, (math.pi - angle_diff) / math.pi)
|
|
971
|
+
move_x = math.cos(smoothed_heading - math.pi / 2.0) * move_mag
|
|
972
|
+
move_y = math.sin(smoothed_heading - math.pi / 2.0) * move_mag
|
|
931
973
|
|
|
932
974
|
inputs.append(
|
|
933
975
|
PlayerInput(
|
|
@@ -935,8 +977,8 @@ class DemoView:
|
|
|
935
977
|
move_y=move_y,
|
|
936
978
|
aim_x=aim_x,
|
|
937
979
|
aim_y=aim_y,
|
|
938
|
-
fire_down=
|
|
939
|
-
fire_pressed=
|
|
980
|
+
fire_down=auto_fire,
|
|
981
|
+
fire_pressed=auto_fire,
|
|
940
982
|
reload_pressed=False,
|
|
941
983
|
)
|
|
942
984
|
)
|
crimson/gameplay.py
CHANGED
|
@@ -974,8 +974,8 @@ def perk_apply(
|
|
|
974
974
|
weapon_id = int(current)
|
|
975
975
|
for _ in range(100):
|
|
976
976
|
candidate = int(weapon_pick_random_available(state))
|
|
977
|
-
|
|
978
|
-
|
|
977
|
+
weapon_id = candidate
|
|
978
|
+
if candidate != int(WeaponId.PISTOL) and candidate != current:
|
|
979
979
|
break
|
|
980
980
|
weapon_assign_player(owner, weapon_id, state=state)
|
|
981
981
|
return
|
|
@@ -1929,7 +1929,9 @@ def player_update(player: PlayerState, input_state: PlayerInput, dt: float, stat
|
|
|
1929
1929
|
raw_move_x = float(input_state.move_x)
|
|
1930
1930
|
raw_move_y = float(input_state.move_y)
|
|
1931
1931
|
raw_mag = math.hypot(raw_move_x, raw_move_y)
|
|
1932
|
-
|
|
1932
|
+
# Demo/autoplay uses very small analog magnitudes to represent turn-in-place and
|
|
1933
|
+
# heading alignment slowdown; don't apply a deadzone there.
|
|
1934
|
+
moving_input = raw_mag > (0.0 if state.demo_mode_active else 0.2)
|
|
1933
1935
|
|
|
1934
1936
|
if moving_input:
|
|
1935
1937
|
inv = 1.0 / raw_mag if raw_mag > 1e-9 else 0.0
|
|
@@ -12,7 +12,7 @@ crimson/creatures/damage.py,sha256=pjKIX32nGDVPnFaWCce0LNZ-UZXZqJpNvwHwq-DCWbE,3
|
|
|
12
12
|
crimson/creatures/runtime.py,sha256=1FagJNwGWJuOXZEv4VaWak2IktNskSof82WCYJqui-U,40733
|
|
13
13
|
crimson/creatures/spawn.py,sha256=ikgtr4sM2KdA2-eyxYdVmobcuZN6aA7xK7ceaIl7RSw,90059
|
|
14
14
|
crimson/debug.py,sha256=vtfr0_HQHpiB5h57jAsl9cWyYxErSbZQ2uazcL1sJhU,127
|
|
15
|
-
crimson/demo.py,sha256=
|
|
15
|
+
crimson/demo.py,sha256=MqphRCD7dJX092uS2lNRzph3XyEL2ciw8dwnv6p4t9o,54709
|
|
16
16
|
crimson/demo_trial.py,sha256=BuoKB1DB-cPZ8jBp4x9gmxWF6tvhXMYRqJ9hMYrhxH4,4651
|
|
17
17
|
crimson/effects.py,sha256=tjOOZopqTI7TTOBREfIUfUhjoa3YqIoFJAPj5oJlW9Y,34056
|
|
18
18
|
crimson/effects_atlas.py,sha256=Ko1O7z-1jGkH_KSeb8RrR2EtAs4V8vfo70ofhqbFak4,2104
|
|
@@ -31,7 +31,7 @@ crimson/frontend/transitions.py,sha256=-sAJUDqNZ943zXlqtvJ6jCg2YH8dSi8k7qK8caAfO
|
|
|
31
31
|
crimson/game.py,sha256=6rIXJkYO5FL_z-fDZKTdDfJrb4fkKfWSaaxphUros2c,97712
|
|
32
32
|
crimson/game_modes.py,sha256=qW7Tt97lSBmGrt0F17Ni5h8vRyngBzyS9XwWM1TFIEI,255
|
|
33
33
|
crimson/game_world.py,sha256=nfKGcm3LHChPGLHJsurDFAATrHmhRvTmgxcLzUN9m5I,25440
|
|
34
|
-
crimson/gameplay.py,sha256=
|
|
34
|
+
crimson/gameplay.py,sha256=qgOyIed8Y_STBuVHOG8mQnI1Ccncm_ddDLY49YFr3TU,90228
|
|
35
35
|
crimson/input_codes.py,sha256=PmSWFZIit8unTBWk3uwifpHWMuk0qMg1ueKX3MGC7D0,5379
|
|
36
36
|
crimson/modes/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
37
37
|
crimson/modes/base_gameplay_mode.py,sha256=dZwKv6qO0GGVEaUP8fNXNsKdvOko1N-2sQA2U8R2fDA,10092
|
|
@@ -133,7 +133,7 @@ grim/sfx.py,sha256=cpn2Mmeio7BSDgbStSft-eZchO9Ot2MrK6iXJqxlLqU,7836
|
|
|
133
133
|
grim/sfx_map.py,sha256=FM5iBzKkG30Vtu78SRavVNgXMbGK7ZFcQ8i6lgMlzVw,4697
|
|
134
134
|
grim/terrain_render.py,sha256=EZ7ySYJyTZwXcrJx1mKbY3ewZtPi7Y270XnZgGJyZG8,31509
|
|
135
135
|
grim/view.py,sha256=oF4pHZehBqOxPjKMU28TDg3qATh_amMIRJp-vMQnpn4,334
|
|
136
|
-
crimsonland-0.1.0.
|
|
137
|
-
crimsonland-0.1.0.
|
|
138
|
-
crimsonland-0.1.0.
|
|
139
|
-
crimsonland-0.1.0.
|
|
136
|
+
crimsonland-0.1.0.dev10.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
137
|
+
crimsonland-0.1.0.dev10.dist-info/entry_points.txt,sha256=jzzcExxiE9xpt4Iw2nbB1lwTv2Zj4H14WJTIPMkAjoE,77
|
|
138
|
+
crimsonland-0.1.0.dev10.dist-info/METADATA,sha256=xNSAt3Nut0XvHvFtZwIJ15spc2KmWrCJFf_jPhxGkkQ,244
|
|
139
|
+
crimsonland-0.1.0.dev10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|