Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monthly Pull from Dev Branch - June & July 2022 #62

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8db1a18
added settings
Evhann May 25, 2022
0baafcb
Merge pull request #61 from Chateauvisionn/dev
Evhann May 25, 2022
7b884f9
Merge branch 'master' into dev
davecarrijo May 26, 2022
fda8a7b
fixed build.py
Evhann May 28, 2022
6bffe4e
fixed build
Evhann May 28, 2022
26c7f23
fixed bat and shell scripts
Evhann May 28, 2022
4307a31
Added vitrix engine in python-windows.zip
Evhann May 28, 2022
2c1cff1
Upgrade to Vitrix Engine v1.1
C0rupted May 31, 2022
9cc1188
Fix the swrite() function in the settings file
C0rupted Jun 8, 2022
5f208f9
menu bugfix
Jun 12, 2022
24be8bc
detect commands
Jun 12, 2022
530d233
Add more settings options to the menu for #46
C0rupted Jun 16, 2022
962b579
put the default settings.json back
Jun 17, 2022
4e25229
added "get_last_version" function (letter D mean "development")
Jun 17, 2022
b015a5a
Fix the "shadows" setting in the wrong submenu
C0rupted Jun 18, 2022
59d9074
Implement a banning system for moderators! #64
C0rupted Jun 18, 2022
56d12d3
added "requests" to requirements.txt
Jun 18, 2022
6783127
shadows enabled by default
Jun 18, 2022
a84b7d0
Fix path problems in settings.py
C0rupted Jun 19, 2022
bf428b0
Fix shadows being applied to the crosshair
C0rupted Jun 19, 2022
a8579b0
Clean up and add some singleplayer features to multiplayer
C0rupted Jun 20, 2022
9b214cc
removed preview text
Jun 22, 2022
a0379d0
added server to paths.py and modified anticheat
Jun 22, 2022
2f3cc03
Merge branch 'dev' of https://github.com/ShadityZ/Vitrix into dev
Jun 22, 2022
0fe60d6
added blacklist.json and moderators.json to gitignore
Jun 22, 2022
513f58a
fixed bugs
Jun 22, 2022
5c78467
Basic inventory (not implemented yet)
C0rupted Jun 23, 2022
b88deec
Fix for git mess up
C0rupted Jun 23, 2022
5ff0a4c
Merge branch 'master' into dev
C0rupted Jun 23, 2022
4637b30
Stop mouse and keys detected on pause (with latest vitrix engine commit)
C0rupted Jun 23, 2022
fe36a84
Add /kick moderator command, auto-kick on ban and kick and ban messages
C0rupted Jun 25, 2022
e48b39a
Fixed bug in server.py (can't start server)
Jun 28, 2022
3d52399
changed requirements.txt to download the latest version of vitrix_engine
Jun 28, 2022
214d90b
changed default window size
Jun 28, 2022
4ffe8eb
Fixed fullscreen
Jun 28, 2022
6703033
Added screenshot to README.md
Evhann Jun 30, 2022
2ed1b4f
Remove mention of old documentation
C0rupted Jul 3, 2022
70316b7
Basic inventory implemented opened with "e" and find crates for other…
C0rupted Jul 4, 2022
b1398d3
Fixed settings bug
Jul 5, 2022
50b5a08
Fixed window title bug
Jul 5, 2022
89bcfa1
removed old ban system
Jul 5, 2022
05f383d
Added text at the start of the game
Jul 5, 2022
004a824
add the ammo box and med kit texture
Jul 6, 2022
f34ab43
Removed placeholders from blacklist.json and moderators.json
Jul 6, 2022
871f042
Add Vitrix website source code!
C0rupted Jul 15, 2022
419eeb7
Delete website code in favour of using gh-pages branch
C0rupted Jul 15, 2022
dc57ad4
Advanced Inventory System (Ammo and Aid Kit items)
C0rupted Jul 20, 2022
d3b2529
Show ammo and aid kit in hand when holding it
C0rupted Jul 23, 2022
8029aaa
Fix MAJOR inventory item dragging issue
C0rupted Jul 23, 2022
652fc7e
Upload new screenshot for README
C0rupted Jul 23, 2022
3a92606
Update README with new screenshot
C0rupted Jul 23, 2022
a6ef4dd
Merge branch 'master' into dev
Evhann Oct 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ vitrix/lib/weapons/__pycache__/
vitrix/lib/items/__pycache__/
vitrix/lib/UI/__pycache__/
vitrix/lib/entities/__pycache__/
vitrix/lib/classes/__pycache__/
vitrix/lib/api/__pycache__/
vitrix/test.py
vitrix_engine.egg-info/
venvs-config/
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@

<br><br>

![Vitrix 1.2.0 Singleplayer development version](https://github.com/ShadityZ/Vitrix/raw/dev/screenshot.png)


<br>
Everybody knows lots of diffent FPS shooter games, from Fortnite to CS:GO, the list is longly tiresome. So, what's any different about Vitrix? Well first of all, it has a really cool name. Second of all, it is open-source! No more sneaky malware in your closed-source applications, because the code of Vitrix is fully open and accessible to the community! Well? What are you waiting for? Go ahead and download it if you haven't already, and dive into a world of Vitrix fun!

=======
Frequently Asked Questions (FAQ):

Game Video/Screen Settings:
Expand Down Expand Up @@ -80,3 +82,4 @@ A: Within the directory "Vitrix/vitrix/lib/UI/"

<br>
<h4>You can find out everything you else you need to know in the <a href="https://github.com/ShadityZ/Vitrix/blob/docs-development/docs/mainpage.md">Official Vitrix Documentation</a>!</h4>

5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
git+https://github.com/ShadityZ/Vitrix-Engine.git@v1.0#egg=vitrix_engine
venvctl==1.4.12
git+https://github.com/ShadityZ/Vitrix-Engine.git#egg=vitrix_engine
venvctl==1.4.12
requests
Binary file added screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions server/blacklist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"banned_users": []
}
3 changes: 3 additions & 0 deletions server/moderators.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"moderators": []
}
1 change: 1 addition & 0 deletions server/properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
166 changes: 108 additions & 58 deletions server/server.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
"""
Server version: v1.0.0
Server version: v1.1.0
"""

import os
import sys
import socket
import json
import time
import random
import threading
"""
"properties" file:
line 1: MAX_PLAYERS
"""

import os,sys,socket,json,time,random,threading

script_path = os.path.dirname(os.path.abspath(__file__))
print(script_path)

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from vitrix.lib.classes.anticheat import *
#from vitrix.lib.player import Player
properties = open(f"{script_path}/properties", 'r').read().split("\n")

from vitrix.lib.api.anticheat import *

ADDR = "0.0.0.0"
PORT = 26822
MAX_PLAYERS = 10
MAX_PLAYERS = int(properties[0])
MSG_SIZE = 2048


Expand All @@ -27,6 +30,34 @@


players = {}
kicked_users = []
recently_banned_users = []


def ban_user(user: str):
blacklist_file = open(f"{os.path.dirname(os.path.realpath(__file__))}/blacklist.json", "r")
blacklist = json.loads(blacklist_file.read())
blacklist["banned_users"].append(user)
with open("blacklist.json", "w") as file:
json.dump(blacklist, file)
recently_banned_users.append(user)


def is_moderator(user: str):
moderators_file = open(f"{os.path.dirname(os.path.realpath(__file__))}/moderators.json", "r")
mods = json.loads(moderators_file.read())["moderators"]
if user in mods:
return True
else:
return False

def is_banned(user: str):
blacklist_file = open(f"{os.path.dirname(os.path.realpath(__file__))}/blacklist.json", "r")
blacklist = json.loads(blacklist_file.read())["banned_users"]
if user in blacklist:
return True
else:
return False


def generate_id(player_list: dict, max_players: int):
Expand All @@ -53,6 +84,13 @@ def handle_messages(identifier: str):
username = client_info["username"]

while True:
if username in recently_banned_users:
conn.send("banned".encode("utf8"))
break
if username in kicked_users:
conn.send("kicked".encode("utf8"))
break

try:
msg = conn.recv(MSG_SIZE)
except ConnectionResetError:
Expand All @@ -76,13 +114,17 @@ def handle_messages(identifier: str):
print(e)
continue

print(f"Received message from player {username} with ID {identifier}")

if msg_json["object"] == "player":
players[identifier]["position"] = msg_json["position"]
players[identifier]["rotation"] = msg_json["rotation"]
players[identifier]["health"] = msg_json["health"]

if msg_json["object"] == "command":
if msg_json["type"] == "ban" and is_moderator(msg_json["author"]):
ban_user(msg_json["target"])
if msg_json["type"] == "kick" and is_moderator(msg_json["author"]):
kicked_users.append(msg_json["target"])

for player_id in players:
if player_id != identifier:
player_info = players[player_id]
Expand All @@ -103,6 +145,12 @@ def handle_messages(identifier: str):

print(f"Player {username} with ID {identifier} has left the game...")
del players[identifier]

if username in kicked_users:
kicked_users.remove(username)
if username in recently_banned_users:
recently_banned_users.remove(username)

conn.close()


Expand All @@ -114,52 +162,54 @@ def main():
new_id = generate_id(players, MAX_PLAYERS)
conn.send(new_id.encode("utf8"))
username = conn.recv(MSG_SIZE).decode("utf8")
new_player_info = {"socket": conn, "username": username, "position": (0, 1, 0), "rotation": 0, "health": 150}


for player_id in players:
if player_id != new_id:
player_info = players[player_id]
player_conn: socket.socket = player_info["socket"]
try:
player_conn.send(json.dumps({
"id": new_id,
"object": "player",
"username": new_player_info["username"],
"position": new_player_info["position"],
"health": new_player_info["health"],
"joined": True,
"left": False
}).encode("utf8"))
except OSError:
pass

for player_id in players:
if player_id != new_id:
player_info = players[player_id]
try:
conn.send(json.dumps({
"id": player_id,
"object": "player",
"username": player_info["username"],
"position": player_info["position"],
"health": player_info["health"],
"joined": True,
"left": False
}).encode("utf8"))
time.sleep(0.1)
except OSError:
pass

players[new_id] = new_player_info

msg_thread = threading.Thread(target=handle_messages, args=(new_id,), daemon=True)
msg_thread.start()

print(f"New connection from {addr}, assigned ID: {new_id}...")
if is_banned(username):
conn.send("False".encode("utf8"))
else:
conn.send("True".encode("utf8"))
new_player_info = {"socket": conn, "username": username, "position": (0, 1, 0), "rotation": 0, "health": 150}


for player_id in players:
if player_id != new_id:
player_info = players[player_id]
player_conn: socket.socket = player_info["socket"]
try:
player_conn.send(json.dumps({
"id": new_id,
"object": "player",
"username": new_player_info["username"],
"position": new_player_info["position"],
"health": new_player_info["health"],
"joined": True,
"left": False
}).encode("utf8"))
except OSError:
pass

for player_id in players:
if player_id != new_id:
player_info = players[player_id]
try:
conn.send(json.dumps({
"id": player_id,
"object": "player",
"username": player_info["username"],
"position": player_info["position"],
"health": player_info["health"],
"joined": True,
"left": False
}).encode("utf8"))
time.sleep(0.1)
except OSError:
pass

players[new_id] = new_player_info

msg_thread = threading.Thread(target=handle_messages, args=(new_id,), daemon=True)
msg_thread.start()

print(f"New connection from {addr}, assigned ID: {new_id}")

#check_speed(Player.speed)
#check_jump_height(Player.jump_height, 2.5)


if __name__ == "__main__":
Expand Down
Binary file removed vitrix/assets/textures/Inventory/1.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/2.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/3.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/4.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/base template.psd
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/batleaxe.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/glock.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/hammer.png
Binary file not shown.
Binary file removed vitrix/assets/textures/Inventory/sword.png
Binary file not shown.
Binary file added vitrix/assets/textures/items/aid_kit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitrix/assets/textures/items/ammo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitrix/assets/textures/items/base template.psd
Binary file not shown.
Binary file added vitrix/assets/textures/items/battleaxe.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitrix/assets/textures/items/hammer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitrix/assets/textures/items/pistol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vitrix/assets/textures/items/sword.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions vitrix/lib/UI/chat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vitrix_engine import *
from lib.classes.network import Network
from lib.api.network import Network

class Chat(Entity):
def __init__(self, network: Network, username: str, **kwargs):
Expand Down Expand Up @@ -40,9 +40,15 @@ def update(self):
def input(self, key):
if key == "enter":
#temp = self.prefix + self.text_field.text
self.network.send_message(self.prefix + self.text_field.text)
self.list.append(self.prefix + self.text_field.text)
self.text_field.text = ""
if not self.text_field.text[0] == "/": # if message is not a command
self.network.send_message(self.prefix + self.text_field.text)
self.list.append(self.prefix + self.text_field.text)
self.text_field.text = ""
else:
type = self.text_field.text[1:].split()[0] # get command (ex: ban)
user = self.text_field.text[1:].split()[1] # get user (ex: RandomUser1234)
self.text_field.text = ""
self.network.send_command(type, user)

def enable(self):
self.enabled = True
Expand Down
4 changes: 2 additions & 2 deletions vitrix/lib/UI/crosshair.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vitrix_engine import *
from lib.paths import GamePaths
from lib.data import GamePaths


class Crosshair(Entity):
Expand All @@ -9,7 +9,7 @@ def __init__(self):
model=os.path.join(GamePaths.models_dir, "cube.obj"),
scale=.07
)

self.shader = None
self.set_ranged()

def set_ranged(self):
Expand Down
4 changes: 1 addition & 3 deletions vitrix/lib/UI/healthbar.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import math
from turtle import position
from vitrix_engine import *
from lib.paths import GamePaths
from lib.data import GamePaths


class HealthBar(Entity):
Expand Down