Skip to content

Commit c6670cb

Browse files
authored
Merge pull request #12 from monkeyman192/update/147323
Update for 147323 and test for pipeline changes
2 parents 638e0be + 5951f3c commit c6670cb

File tree

8 files changed

+115
-621
lines changed

8 files changed

+115
-621
lines changed

.github/scripts/version_check.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
# This script is copied directly from https://github.com/MathieuMoalic/action-python-package-new-version/blob/main/entrypoint.sh
44
# This is just until there is extra functionality as part of that repo to allow specifying a different index.
55

6+
########## helper ##########
7+
error_exit() {
8+
echo "Error: $1" >&2
9+
exit 1
10+
}
11+
612
# Check if pyproject.toml exists
713
PYPROJECT_FILE=pyproject.toml
814

@@ -18,15 +24,15 @@ fi
1824
echo "Version is $VERSION"
1925

2026
# Step 2: Get package name from pyproject.toml
21-
PACKAGE_NAME=$(awk -F'=' '/^name/ {gsub(/[" ]/, "", $2); print $2}' "$PYPROJECT_FILE")
27+
PACKAGE_NAME=$(awk -F'=' '/^name/ {gsub(/[" ]/, "", $2); print $2;exit;}' "$PYPROJECT_FILE")
2228
if [ -z "$PACKAGE_NAME" ]; then
2329
error_exit "Unable to extract package name from $PYPROJECT_FILE"
2430
fi
25-
echo "PACKAGE_NAME is $PACKAGE_NAME"
31+
echo "PACKAGE_NAME is ${PACKAGE_NAME}..."
2632

2733
# Step 3: Get latest release version from PyPI
2834
INDEX="${PYPI_INDEX:-pypi.org}"
29-
PUBLISHED_VERSIONS=$(curl -s "https://$INDEX/pypi/$PACKAGE_NAME/json" | jq -r '.releases | keys | .[]')
35+
PUBLISHED_VERSIONS=$(curl -s "https://${INDEX}/pypi/${PACKAGE_NAME}/json" | jq -r '.releases | keys | .[]')
3036

3137
if [ -z "$PUBLISHED_VERSIONS" ]; then
3238
error_exit "Unable to retrieve published version from $INDEX for $PACKAGE_NAME"
@@ -44,5 +50,5 @@ done
4450

4551
echo "PUBLISHING is $PUBLISHING"
4652
echo "PUBLISHING=$PUBLISHING" >> $GITHUB_ENV
47-
echo "PUBLISHING_${INDEX/./_}=$PUBLISHING" >> $GITHUB_ENV
53+
echo "PUBLISHING_${INDEX//./_}=$PUBLISHING" >> $GITHUB_ENV
4854
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV

.github/workflows/pipeline.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
run: uv build
3535
- name: Lint and format code
3636
run: |
37-
uv run ruff check ./nmspy
38-
uv run ruff format --check ./nmspy
37+
uv run ruff check ./nmspy ./example_mods
38+
uv run ruff format --check ./nmspy ./example_mods
3939
uv run python -m twine check ./dist/*
4040
- name: Upload Wheels
4141
uses: actions/upload-artifact@v4
@@ -48,8 +48,9 @@ jobs:
4848
- build_test
4949
runs-on: ubuntu-latest
5050
outputs:
51-
should_release_pypi: ${{ steps.whether_to_release_pypi.outputs.should_release_pypi}}
52-
should_release_test_pypi: ${{ steps.whether_to_release_test_pypi.outputs.should_release_pypi_test}}
51+
package_version: ${{ steps.set_version.outputs.package_version }}
52+
should_release_pypi: ${{ steps.whether_to_release_pypi.outputs.should_release_pypi }}
53+
should_release_test_pypi: ${{ steps.whether_to_release_test_pypi.outputs.should_release_pypi_test }}
5354
permissions:
5455
id-token: write # IMPORTANT: this permission is required to write to github envs
5556
steps:
@@ -63,6 +64,9 @@ jobs:
6364
run: |
6465
export PYPI_INDEX=test.pypi.org
6566
./.github/scripts/version_check.sh
67+
- name: Globalise determined version
68+
id: set_version
69+
run: echo "package_version=${{ env.PACKAGE_VERSION }}" >> "$GITHUB_OUTPUT"
6670
- name: Assign whether to release to pypi to output
6771
id: whether_to_release_pypi
6872
run: echo "should_release_pypi=${{ env.PUBLISHING_pypi_org }}" >> "$GITHUB_OUTPUT"
@@ -71,8 +75,12 @@ jobs:
7175
run: echo "should_release_test_pypi=${{ env.PUBLISHING_test_pypi_org }}" >> "$GITHUB_OUTPUT"
7276
release:
7377
name: Release NMSpy wheels and source build to PyPI
74-
# Only run this job if we merge into master, we need to do a release, and we don't specifically have some tag to skip publishing to pypi.
75-
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release_pypi == 'true' && !startsWith(github.event.head_commit.message, '[skip pypi]') }}
78+
# Only run this job if the following conditions are met:
79+
# 1. We merge into master.
80+
# 2. We need to do a release.
81+
# 3. The commit message doesn't start with [skip pypi].
82+
# 4. The version isn't a dev version.
83+
if: ${{ github.ref == 'refs/heads/master' && needs.release_check.outputs.should_release_pypi == 'true' && !startsWith(github.event.head_commit.message, '[skip pypi]') && !contains(needs.release_check.outputs.package_version, 'dev') }}
7684
needs:
7785
- build_test
7886
- release_check

example_mods/gravityManipulator.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
# /// script
2+
# dependencies = ["pymhf[gui]>=0.1.14"]
3+
#
4+
# [tool.pymhf]
5+
# exe = "NMS.exe"
6+
# steam_gameid = 275850
7+
# start_paused = false
8+
#
9+
# [tool.pymhf.gui]
10+
# always_on_top = true
11+
#
12+
# [tool.pymhf.logging]
13+
# log_dir = "."
14+
# log_level = "info"
15+
# window_name_override = "NMS Example gravity manipulator"
16+
# ///
17+
118
import logging
219
import ctypes
320
from dataclasses import dataclass, field
421

22+
from pymhf import Mod, ModState
523
from pymhf.core.hooking import on_key_pressed
6-
from pymhf.core.mod_loader import ModState
7-
from pymhf import Mod
824
from pymhf.gui import FLOAT
925
import nmspy.data.types as nms
1026

@@ -25,9 +41,8 @@ class gravityManipulator(Mod):
2541
# General "Nice To Have"s
2642
__author__ = ["ThatBomberBoi", "monkeyman192"]
2743
__description__ = "Gravity Manipulator"
28-
__version__ = "0.2"
29-
__NMSPY_required_version__ = "0.7.0"
30-
44+
__version__ = "0.3"
45+
3146
# Create an instance of the persistant ModState Class in your mod class.
3247
state = gravModState()
3348

@@ -44,7 +59,7 @@ def gravMult(self):
4459
# Used to actually update the persisted value with the one input by the user in the GUI.
4560
@gravMult.setter
4661
def gravMult(self, value):
47-
self.state.gravity = value
62+
self.state.gravity = value
4863

4964
# Functions are hooked by specifying the function to be hooked from the list of in game functions
5065
# available. You can specify whether you want your detour to run either before or after the original
@@ -67,4 +82,6 @@ def modifyGravity(self):
6782
# Call an in-game function directly from your mod code.
6883
# You will need to provide the arguments for the in-game function
6984
planet.UpdateGravity(self.state.gravity)
70-
logger.info(f"Set Planetary Gravity Multiplier To {self.state.gravity} For All Planets")
85+
logger.info(
86+
f"Set Planetary Gravity Multiplier To {self.state.gravity} For All Planets"
87+
)

nmspy/data/audiokinetic.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# pyright: reportReturnType=false
2+
# pyright: reportArgumentType=false
3+
4+
# NMS uses AudioKinetic as a 3rd party audio library.
5+
# This exposes a number of useful functions relating to audio.
6+
# These functions are all the direct AK functions which are provided as exports by the binary.
7+
8+
import ctypes
9+
10+
from pymhf.core.hooking import Structure, static_function_hook
11+
12+
13+
class AK(Structure):
14+
class SoundEngine(Structure):
15+
@static_function_hook(
16+
exported_name="?RegisterGameObj@SoundEngine@AK@@YA?AW4AKRESULT@@_KPEBD@Z"
17+
)
18+
@staticmethod
19+
def RegisterGameObj(
20+
in_GameObj: ctypes.c_uint64,
21+
in_pszObjName: ctypes.c_uint64,
22+
) -> ctypes.c_int64:
23+
pass
24+
25+
@static_function_hook(
26+
exported_name=(
27+
"?PostEvent@SoundEngine@AK@@YAII_KIP6AXW4AkCallbackType@@PEAUAkCallbackInfo@@@ZPEAXIPEAUAkExt"
28+
"ernalSourceInfo@@I@Z"
29+
)
30+
)
31+
@staticmethod
32+
def PostEvent(
33+
in_ulEventID: ctypes.c_uint32,
34+
in_GameObjID: ctypes.c_uint64,
35+
in_uiFlags: ctypes.c_uint32 = 0,
36+
callback: ctypes.c_uint64 = 0,
37+
in_pCookie: ctypes.c_void_p = 0,
38+
in_cExternals: ctypes.c_uint32 = 0,
39+
in_pExternalSources: ctypes.c_uint64 = 0,
40+
in_PlayingID: ctypes.c_uint32 = 0,
41+
) -> ctypes.c_uint64:
42+
pass

nmspy/data/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def CheckFallenThroughFloor(self, this: "ctypes._Pointer[cGcPlayer]"):
373373
pass
374374

375375
@function_hook(
376-
"48 8B C4 48 89 58 ?? 4C 89 48 ?? 44 89 40 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8"
376+
"48 8B C4 48 89 58 ? 44 89 40 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 4C 8B 35"
377377
)
378378
def TakeDamage(
379379
self,

pyproject.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[project]
22
name = "NMSpy"
33
description = "No Man's Sky python modding API"
4-
requires-python = ">=3.9"
4+
readme = "README.md"
5+
requires-python = ">=3.9, <3.12"
56
# TODO: Add
67
license = {file = "LICENSE.md"}
78
keywords = ["hooking", "games", "hacking", "modding"]
@@ -22,9 +23,9 @@ classifiers = [
2223
"Programming Language :: Python :: 3 :: Only",
2324
]
2425
dependencies = [
25-
"pymhf[gui]>=0.1.13"
26+
"pymhf[gui]>=0.1.14.dev8"
2627
]
27-
version = "146545.0"
28+
version = "147323.0.dev1"
2829

2930
[dependency-groups]
3031
dev = [
@@ -37,6 +38,14 @@ dev = [
3738
[tool.uv]
3839
python-preference = "only-system"
3940

41+
[tool.uv.sources]
42+
pymhf = { index = "pypi_test" }
43+
44+
[[tool.uv.index]]
45+
name = "pypi_test"
46+
url = "https://test.pypi.org/simple/"
47+
explicit = true
48+
4049
[tool.setuptools.package-dir]
4150
nmspy = "nmspy"
4251

tools/data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
},
332332
{
333333
"name": "cGcPlayer::TakeDamage",
334-
"signature": "48 8B C4 48 89 58 ?? 4C 89 48 ?? 44 89 40 ?? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8",
334+
"signature": "48 8B C4 48 89 58 ? 44 89 40 ? 55 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 4C 8B 35",
335335
"mangled_name": "?TakeDamage@cGcPlayer@@QEAAXMW4eDamageType@@AEBT?$TkID@$0IA@@@AEBVcTkVector3@@PEAVcGcOwnerConcept@@AEBV?$vector@VcGcCombatEffectDamageMultiplier@@V?$TkSTLAllocatorShim@VcGcCombatEffectDamageMultiplier@@$03$0?0@@@std@@@Z"
336336
},
337337
{
@@ -436,7 +436,7 @@
436436
},
437437
{
438438
"name": "cGcPlanet::Generate",
439-
"signature": "48 89 5C 24 ? 57 48 83 EC ? 48 8D 91 ? ? ? ? 33 FF",
439+
"signature": "48 8B C4 4C 89 40 ? 88 50 ? 55 53",
440440
"mangled_name": "?Generate@cGcPlanet@@QEAAX_NAEBVcTkVector3@@AEBVcGcDiscoveryData@@AEBVcGcPlanetGenerationInputData@@@Z"
441441
}
442442
]

0 commit comments

Comments
 (0)