Skip to content

Commit

Permalink
Remove game mode FFA
Browse files Browse the repository at this point in the history
The mode is too buggy at the moment.

Signed-off-by: BackRaw <backraw@gmx.de>
  • Loading branch information
BackRaw committed Oct 19, 2018
1 parent 43bfb77 commit 9922800
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 84 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ See the [issues list](https://github.com/backraw/udm/issues) for current bugs.
* Noblock (see the config file below)
* Give back High Explosive grenade (4 options - see the config file below)
* Restore the killer's health to 100HP if they killed an enemy with the knife (see the config file below)
* Free for All mode

Check out the tech demo: https://www.youtube.com/watch?v=srTt0N0AakQ

Expand Down
10 changes: 0 additions & 10 deletions addons/source-python/plugins/udm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@
'The spawn protection delay (in seconds).'
)

config.text('----------------------------------')
config.text(' * Free for All')
config.text('----------------------------------')

cvar_ffa = config.cvar(
'ffa',
1,
'Enable Free for All'
)

config.text('----------------------------------')
config.text(' * Infinite Ammo')
config.text('----------------------------------')
Expand Down
22 changes: 0 additions & 22 deletions addons/source-python/plugins/udm/players/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
# Store personal player random weapons
player_random_weapons = defaultdict(lambda: {tag: list() for tag in weapon_manager.tags})

# Store FFA team changes
player_ffa_team_changes = set()


# =============================================================================
# >> PLAYER ENTITY
Expand Down Expand Up @@ -421,25 +418,6 @@ def get_team_changes(self):
# Set the `team_changes` property for PlayerEntity
team_changes = property(get_team_changes, set_team_changes)

def set_ffa_team_changed(self, value):
"""Handle FFA team changes."""
# Switch the player silently to the other team
self.team_index = 5 - self.team

# Add or remove the player to the list of FFA team changes
# depending on whether it should be enabled or disabled
if value:
player_ffa_team_changes.add(self.userid)

elif self.userid in player_ffa_team_changes:
player_ffa_team_changes.remove(self.userid)

def get_ffa_team_changed(self):
"""Return whether the player's team has been changed due to FFA."""
return self.userid in player_ffa_team_changes

ffa_team_changed = property(get_ffa_team_changed, set_ffa_team_changed)

def set_inventory_selection(self, inventory_index):
"""Set the player's inventory selection to `inventory_index`."""
player_inventories.selections[self.uniqueid] = inventory_index
Expand Down
51 changes: 0 additions & 51 deletions addons/source-python/plugins/udm/udm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
# Cvars
from cvars import cvar
# Entities
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from entities.hooks import EntityPostHook
# Events
from events import Event
from events.hooks import PreEvent
Expand All @@ -45,12 +43,10 @@
from udm.admin import admin_menu
# Colors
from udm.colors import MESSAGE_COLOR_WHITE
from udm.colors import MESSAGE_COLOR_ORANGE
# Config
from udm.config import cvar_enable_infinite_ammo
from udm.config import cvar_enable_noblock
from udm.config import cvar_equip_hegrenade
from udm.config import cvar_ffa
from udm.config import cvar_refill_clip_on_headshot
from udm.config import cvar_respawn_delay
from udm.config import cvar_restore_health_on_knife_kill
Expand All @@ -72,7 +68,6 @@
# Players
from udm.players import player_random_weapons
from udm.players import player_spawn_locations
from udm.players import player_ffa_team_changes
from udm.players import player_team_changes
from udm.players import PlayerEntity
# Spawn Points
Expand Down Expand Up @@ -166,14 +161,6 @@ def on_player_spawn(game_event):
if not player.dead and player.team > 1:
prepare_player(player)

# Tell the player about the Free for All mode setting
# if they haven't configured their inventory yet
if not player.inventory:
player.tell(
f'{MESSAGE_COLOR_WHITE}Free for All mode: {MESSAGE_COLOR_ORANGE}'
f"{'Enabled' if cvar_ffa.get_int() else 'Disabled'}"
)


@Event('player_death')
def on_player_death(game_event):
Expand Down Expand Up @@ -331,41 +318,6 @@ def on_pre_drop_weapon(stack_data):
)


@EntityPreHook(EntityCondition.is_human_player, 'on_take_damage')
@EntityPreHook(EntityCondition.is_bot_player, 'on_take_damage')
def on_pre_take_damage(stack_data):
"""Handle team changes for FFA mode."""
if cvar_ffa.get_int():

# Get a PlayerEntity instance for the victim
victim = make_object(PlayerEntity, stack_data[0])

# Get the take damage info
damage_info = make_object(TakeDamageInfo, stack_data[1])

# Get PlayerEntity instance for the attacker
if damage_info.attacker > 0:
attacker = PlayerEntity(damage_info.attacker)

# Change the victim's team index if both players are on the same team
if attacker.team == victim.team:
victim.ffa_team_changed = True


@EntityPostHook(EntityCondition.is_human_player, 'on_take_damage')
@EntityPostHook(EntityCondition.is_bot_player, 'on_take_damage')
def on_post_take_damage(stack_data, unused):
"""Revert FFA team changes."""
if cvar_ffa.get_int():

# Get a PlayerEntity instance for the victim
victim = make_object(PlayerEntity, stack_data[0])

# Switch the player back to their original team, if a team change happened because of the FFA mode.
if victim.ffa_team_changed:
victim.ffa_team_changed = False


@EntityPreHook(is_silencer_option_primary, 'secondary_attack')
@EntityPreHook(is_silencer_option_secondary, 'secondary_attack')
def on_pre_secondary_fire(stack_data):
Expand Down Expand Up @@ -597,8 +549,5 @@ def unload():
# Clear player team change counts
player_team_changes.clear()

# Clear the list of FFA-caused team changes
player_ffa_team_changes.clear()

# Restart the game after 1 second
mp_restartgame.set_int(1)

0 comments on commit 9922800

Please sign in to comment.