Skip to content

Commit

Permalink
Merge pull request #8 from David-Lor/develop
Browse files Browse the repository at this point in the history
2.2.1
  • Loading branch information
David-Lor authored Feb 19, 2021
2 parents 17ddbcb + 20620f7 commit 089eb52
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 122 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/extract_changelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""EXTRACT CHANGELOG Script
This script extracts the changelog for the given version from the README.md file, under the `## Changelog` section.
The version is given as x.y.z (e.g. 0.1.1) as an arg (e.g. running "python extract_changelog.py 0.1.1").
The changelog is saved as markdown on a file.
"""

import sys
import re
from typing import List

from markdown2 import markdown
from bs4 import BeautifulSoup
from bs4.element import Tag

README_FILE = "README.md"
CHANGELOG_OUTPUT_FILE = "changelog_generated.md"


def _is_valid_version(version: str) -> bool:
return bool(re.match(r"^(\d+\.)?(\d+\.)?(\*|\d+)$", version))


def _find_changelog_list(soup: BeautifulSoup, version: str) -> Tag:
all_lists = soup.find_all("li")
return next(li for li in all_lists if li.text.startswith(version))


def _parse_changelog(li: Tag) -> List[str]:
all_changelog_lists = li.find("ul").find_all("li")
return [li.text.strip() for li in all_changelog_lists]


def _format_changelog_output(changelog: List[str]) -> str:
output = ""
for change in changelog:
output += f"\n- {change}"
return output.strip()


def _read(filename: str) -> str:
with open(filename, "r") as f:
return f.read()


def _save(filename: str, content: str):
with open(filename, "w") as f:
f.write(content)


def extract_changelog(version: str):
assert _is_valid_version(version)

readme_content = _read(README_FILE)
readme_html = markdown(readme_content)

soup = BeautifulSoup(readme_html, "html.parser")
changelog_list = _find_changelog_list(soup=soup, version=version)
changelog_changes = _parse_changelog(changelog_list)
changelog_output = _format_changelog_output(changelog_changes)

_save(filename=CHANGELOG_OUTPUT_FILE, content=changelog_output)


if __name__ == '__main__':
extract_changelog(sys.argv[-1])
2 changes: 2 additions & 0 deletions .github/workflows/extract_changelog_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
markdown2==2.3.10
beautifulsoup4==4.9.3
61 changes: 61 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
on:
push:
tags:
- "*.*.*"

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
# Setup
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: 3.7
architecture: x64
- name: Install Python requirements
run: python -m pip install -r .github/workflows/extract_changelog_requirements.txt

# Fetch variables
- name: Extract version from tag
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Fetch changelog for release description
id: get_changelog
run: "python .github/workflows/extract_changelog.py ${{ steps.get_version.outputs.VERSION }}"

# Generate artifact
- name: Create release artifact (zip)
id: create_zip
run: |
cp README.md README.txt
cp LICENSE.md LICENSE.txt
zip release-artifact.zip SimpleGangWar.cs SimpleGangWar.ini README.txt LICENSE.txt
# Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
tag_name: ${{ github.ref }}
release_name: "v${{ github.ref }}"
body_path: changelog_generated.md
draft: false
prerelease: false
- name: Upload release asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "./release-artifact.zip"
asset_name: "GTAV-SimpleGangWar-${{ steps.get_version.outputs.VERSION }}.zip"
asset_content_type: "application/zip"
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bin/
obj/
.vs/
*.csproj
*.config
*.sln
bin/
obj/
.vs/
*.csproj
*.config
*.sln
.idea/
5 changes: 5 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright 2021 David Lorenzo @ github.com/David-Lor

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,22 @@ _All lists of items (models & weapons) are separated by comma (`,`) or semi-colo
- `Health`: health for peds (should not be least than 100)
- `Armor`: armor for peds (from 0)
- `Accuracy`: accuracy for peds (from 0)
- `CombatMovement`: how the peds will move through the battlefield. This can be used to make one team defend its spawnpoint, while the other team tries to attack it. One of following:
- `CombatMovement`: how the peds will move through the battlefield. This can be used to make one team defend its spawnpoint, while the other team tries to attack it. If RunToSpawnpoint=true, this setting most probably will be ignored. One of following:
- `stationary`: not move at all
- `defensive`: stay near the spawnpoint and take cover
- `offensive`: focus on attacking the enemy team
- `suicidal`: more aggresive attack
- _stationary & suicidal seem to take no effect, so is better to stick to just **defensive** and **offensive**_
- `disabled`: do not alter this setting on peds
- `random`: randomize between `defensive` and `offensive` for each spawned ped. This does not always work as expected, since some peds can be stuck on the spawnpoint waiting for other peds to attack, but since they are defending their position, nobody would attack
- `CombatRange`: how far or close the peds will fight against their enemies. This might not have a huge difference, depending on the scenario. One of following:
- `near`
- `medium`
- `far`
- `disabled`: do not alter this setting on peds
- `random`: randomize between `near`, `medium`, `far` for each spawned ped
- `MaxPeds`: maximum alive peds on the team (if not specified, the MaxPedsPerTeam setting will be used)

## SETTINGS
### SETTINGS

- `Hotkey`: the single hotkey used to iterate over the script stages ([Reference](https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.key?view=netcore-3.1#fields))
- `SpawnHotkey`: hotkey used to pause/resume ped spawn in both teams ([Reference](https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.key?view=netcore-3.1#fields))
Expand All @@ -63,13 +66,16 @@ _All lists of items (models & weapons) are separated by comma (`,`) or semi-colo
The task FightAgainstHatedTargets (false) can be interesting when spawnpoints are closer, as peds might have more freedom to flank the enemy?
- `ProcessOtherRelationshipGroups`: if true, get all relationship groups from other existing peds and match these groups with the groups of SimpleGangWar peds.
Set it to true if you experience the spawned peds fighting against other peds (like mission peds) when they should not be (for example, enemy peds of a mission fighting against enemy peds of SimpleGangWar).
- `SpawnpointFloodLimitPeds`: limit how many peds can be near its spawnpoint. If more than this quantity of peds are near the spawnpoint, no more peds on the team will spawn. Disable this feature by setting this variable to `0`.
- `SpawnpointFloodLimitDistance`: in-game distance from a team spawnpoint to keep track of the SpawnpointFloodLimitPeds. Can be integer or decimal (if using decimals, use dot or comma depending on your system regional settings)
- `IdleInterval`: delay between loop runs, when battle is not running, in ms
- `BattleInterval`: delay between loop runs, when battle is running, in ms

## Known bugs

- If spawnpoints are too far away from each other, peds can idle and do nothing
- When using [Watch Your Death](https://gta5-mods.com/scripts/watch-your-death), while player is dead, enemies can run to ally spawnpoint without fighting, or be idle
- Peds can avoid reloads (this is mostly noticeable with muskets)

## TODO

Expand All @@ -82,6 +88,10 @@ _All lists of items (models & weapons) are separated by comma (`,`) or semi-colo

## Changelog

- 2.2.1
- Add spawnpoint anti-flood feature (avoid peds from flooding their spawnpoints)
- Add options to randomize CombatMovement & CombatRange
- Add options to disable altering CombatMovement & CombatRange
- 2.1.1
- Add CombatRange setting
- Add ProcessOtherRelationshipGroups setting
Expand Down
Loading

0 comments on commit 089eb52

Please sign in to comment.