# <path to game directory>/addons/eventscipts/admin/mods/rpg/perks/ # long_jump/long_jump.py # by Adam Cunnington import psyco psyco.full() from esutils import players from rpg import rpg def player_jump(event_var): user_ID = int(event_var["userid"]) long_jump_level = rpg.get_level(user_ID, _long_jump) if long_jump_level == 0: return players.Player(user_ID).push(float(long_jump_level * 0.1), 0) _long_jump = rpg.PerkManager("long_jump", 5, lambda x: x * 0.1, lambda x: x * 20)
def _regenerate(user_ID): health = rpg.PerkManager.data.get("health") if health is None or not health.enabled: max_health = 100 else: health_level = rpg.get_level(user_ID, health) if health_level == 0: max_health = 100 else: max_health = health.perk_calculator(health_level) player = players.Player(user_ID) if player.health >= max_health: return health_to_regenerate = _regeneration.perk_calculator( rpg.get_level(user_ID, _regeneration)) if max_health - player.health <= health_to_regenerate: player.health = max_health else: player.health += health_to_regenerate def unload(): while _delays: user_ID, delay = _delays.popitem() delay.stop() _regeneration = rpg.PerkManager("regeneration", 5, lambda x: x, lambda x: 5 * 2**(x - 1), _level_change)
if delay.running: delay.stop() delay.start(1.5) def _remove_effects(user_ID): player = players.Player(user_ID) player.speed = 1 stealth = rpg.PerkManager.data.get("stealth") if stealth is None or not stealth.enabled: max_alpha = 255 else: stealth_level = rpg.get_level(user_ID, stealth) if stealth_level == 0: max_alpha = 255 else: max_alpha = stealth.perk_calculator(stealth_level) player.colour = (255, 255, 255, max_alpha) def unload(): while _delays: user_ID, delay = _delays.popitem() delay.stop() if delay.running: _remove_effects(user_ID) _ice_stab = rpg.PerkManager("ice_stab", 5, lambda x: 1 - x * 0.1, lambda x: x * 30, _level_change)
from esutils import players from rpg import rpg def player_hurt(event_var): attacker_ID = int(event_var["attacker"]) if attacker_ID == players.WORLD: return vampire_level = rpg.get_level(attacker_ID, _vampire) if vampire_level == 0: return health = rpg.PerkManager.data.get("health") if health is None or not health.enabled: max_health = 100 else: health_level = rpg.get_level(attacker_ID, health) if health_level == 0: max_health = 100 else: max_health = health.perk_calculator(health_level) health_bonus = int(event_var[ "dmg_health"]) * _vampire.perk_calculator(vampire_level) player = players.Player(attacker_ID) if max_health - int(event_var["es_attackerhealth"]) <= health_bonus: player.health = max_health else: player.health += health_bonus _vampire = rpg.PerkManager("vampire", 8, lambda x: x * 0.1, lambda x: x * 20)
player = players.Player(user_ID) if new_level == 0: player.colour = (255, 255, 255, 255) else: _set_colour(player, new_level) def player_spawn(event_var): user_ID = int(event_var["userid"]) player = players.Player(user_ID) if players.Player(user_ID).team_ID not in (players.TERRORIST, players.COUNTER_TERRORIST): return stealth_level = rpg.get_level(user_ID, _stealth) if stealth_level == 0: return _set_colour(player, stealth_level) def _set_colour(player, level): player.colour = (255, 255, 255, _stealth.perk_calculator(level)) def unload(): for player in players.all_players(): player.colour = (255, 255, 255, 255) _stealth = rpg.PerkManager("stealth", 5, lambda x: int(255 * (1 - x * 0.1)), lambda x: x * 30, _level_change)
delay.start(_clip_replenish.perk_calculator(clip_replenish_level), True) elif not delay.running: delay.start(_clip_replenish.perk_calculator(clip_replenish_level), True) def _replenish_clip(player): active_weapon = player.active_weapon if player.active_weapon is None: return if active_weapon.weapon_type.CATEGORY == weapons.CATEGORY_MELEE: active_weapon = player.primary or player.secondary or None if active_weapon is None: return clip_bonus = max(int(active_weapon.weapon_type.clip_size / 10), 1) if active_weapon.weapon_type.clip_size - active_weapon.clip <= clip_bonus: active_weapon.clip = active_weapon.weapon_type.clip_size else: active_weapon.clip += clip_bonus def unload(): while _delays: user_ID, delay = _delays.popitem() delay.stop() _clip_replenish = rpg.PerkManager("clip_replenish", 5, lambda x: 5 * (6 - x), lambda x: 5 * 2**(x - 1), _level_change)
def _level_change(user_ID, player_perk, old_level, new_level): if new_level == 0: new_max_health = 100 else: new_max_health = _health.perk_calculator(new_level) player = players.Player(user_ID) if player.health > new_max_health: player.health = new_max_health def player_spawn(event_var): user_ID = int(event_var["userid"]) player = players.Player(user_ID) if player.team_ID not in (players.TERRORIST, players.COUNTER_TERRORIST): return health_level = rpg.get_level(user_ID, _health) if health_level == 0: return player.health = _health.perk_calculator(health_level) def unload(): all_players = players.all_players() for player in rpg.all_players(all_players.health > 100): player.health = 100 _health = rpg.PerkManager("health", 16, lambda x: (x * 25) + 100, lambda x: x * 15, _level_change)
if delay.running: delay.stop() delay.start(1.2) def _remove_effects(user_ID): player = players.Player(user_ID) player.speed = 1 stealth = rpg.PerkManager.data.get("stealth") if stealth is None or not stealth.enabled: max_alpha = 255 else: stealth_level = rpg.get_level(user_ID, stealth) if stealth_level == 0: max_alpha = 255 else: max_alpha = stealth.perk_calculator(stealth_level) player.colour = (255, 255, 255, max_alpha) def unload(): while _delays: user_ID, delay = _delays.popitem() delay.stop() if delay.running: _remove_effects(user_ID) _adrenaline = rpg.PerkManager("adrenaline", 5, lambda x: 1 + (x * 0.2), lambda x: x * 25, _level_change)
if rpg.get_level(user_ID, _armor_repair) == 0: return delay = _delays.get(user_ID) if delay is None: delay = _delays[user_ID] = delays.Delay(_repair_armor, user_ID) delay.start(5, True) elif not delay.running: delay.start(5, True) def _repair_armor(user_ID): player = players.Player(user_ID) if player.armor >= 100: return armor_bonus = _armor_repair.perk_calculator( rpg.get_level(user_ID, _armor_repair)) if 100 - player.armor < armor_bonus: player.armor = 100 else: player.armor += armor_bonus def unload(): while _delays: user_ID, delay = _delays.popitem() delay.stop() _armor_repair = rpg.PerkManager("armor_repair", 5, lambda x: x, lambda x: 5 * 2**(x - 1), _level_change)