Name | Type | is_array | initial_value |
library Constants
globals
constant boolean TEST = false
constant boolean PROTECTION_ENABLED = true
constant string MAP_NAME = "Banjoball"
//Ball
constant integer BALL_RAWCODE = 'h000'
constant real BALL_CATCH_RANGE = 90.0
constant real BALL_KEEP_RANGE = 100.0
real BALL_FRICTION_GROUND = 0.45
real BALL_FRICTION_AIR = 0.07
real BALL_BUMP_SPEED_LOSS = 4.00
constant real BALL_BUMP_SFX_THRESHOLD = 250.0
constant string BALL_BUMP_SFX_PATH = "Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCasterOverhead.mdl"
constant integer BALL_SLOW_BUFF_RAWCODE = 'B002'
//Players
constant integer DOCTRINAL_CAKE_RAWCODE = 'h004'
constant integer KARMA_GREEN_INN_RAWCODE = 'h00P'
constant integer KARMIC_LIVID_LION_RAWCODE = 'h003'
constant integer NISEI_LINESMAN_RAWCODE = 'h005'
constant integer OAK_KING_ZIT_RAWCODE = 'h00R'
constant integer AKARI_SKA_AS_ION_INK_RAWCODE = 'h00F'
constant integer SZURA_COH_RAWCODE = 'h00Y'
constant integer PARCH_NINE_TIE_RAWCODE = 'h010'
constant integer IDEAL_VIZZD_RAKIA_RAWCODE = 'h001'
constant integer DARK_DAWN_OAR_RAWCODE = 'h012'
constant integer CLAY_HAND_NIL_RAWCODE = 'h01I'
constant integer DEAD_HERO_RAWCODE = 'h01N'
constant integer JIG_PER_ACE_RAWCODE = 'h01R'
constant integer SIR_REAL_PUNTS_RAWCODE = 'h026'
constant integer MASTER_AWE_QI_RAWCODE = 'h028'
constant integer MANFUL_LOAF_RAWCODE = 'h029'
constant integer MARZIPAN_USA_BRO_RAWCODE = 'h02C'
constant integer MR_DOLT_AMIGO_RAWCODE = 'h027'
constant real PARCH_NINE_TIE_SCALE = 1.80
constant real OAK_KING_ZIT_SCALE = 1.34
constant real TEMP_SCALE = 1.35
real PLAYER_FRICTION_GROUND = 0.65
constant real PLAYER_FRICTION_AIR = 0.08
constant real PLAYER_BUMP_SPEED_LOSS = 15.0
constant real PLAYER_BUMP_SFX_THRESHOLD = 30.0
constant string PLAYER_BUMP_SFX_PATH = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
constant string GOAL_BLOCK_SFX_PATH = "Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCasterOverhead.mdl"
constant real PLAYER_COLLISION_SIZE = 30.0
// Ice Levels
constant real BALL_FRICTION_ICE = 0.30
constant real PLAYER_FRICTION_ICE = 0.40
constant real PLAYER_SLIDE_SPEED_ICE = 0.70
constant real PLAYER_MAX_SLIDE_SPEED = 20
constant real POSITION_RADIUS = 100.0
// Team Franchises
constant integer LOGO_PLACEHOLDER = 'B006'
constant integer BANNER_PLACEHOLDER_HOME = 'B00C'
constant integer BANNER_PLACEHOLDER_AWAY = 'B00D'
//Hats
constant integer CHEF_HAT_RAWCODE = 'h00A'
constant integer CRUSADER_HELM_RAWCODE = 'h00M'
constant integer MAGE_HAT_RAWCODE = 'h008'
constant integer MILITARY_HAT_RAWCODE = 'h009'
constant integer PIRATE_HAT_RAWCODE = 'h006'
constant integer PUMPKIN_HAT_RAWCODE = 'h00N'
constant integer SAMURAI_HELM_RAWCODE = 'h00L'
constant integer SANTA_HAT_RAWCODE = 'h007'
constant integer SHAMAN_CAP_RAWCODE = 'h00K'
constant integer SPARTAN_HELM_RAWCODE = 'h00J'
constant integer VOODOO_MASK_RAWCODE = 'h00I'
constant integer WITCH_HUNTER_HAT_RAWCODE = 'h00B'
//Helping units
constant integer DUMMY_RAWCODE = 'h00D'
constant integer SFX_DUMMY_RAWCODE = 'h00X'
constant integer GOAL_LINE_RAWCODE = 'h00H'
constant integer PICKER_RAWCODE = 'h00C'
constant integer PUDDLE_RAWCODE = 'h00O'
constant integer BLACK_HOLE_APOCALYPSE_RAWCODE = 'h00U'
constant integer SUMMER_TREE_UNIT_RAWCODE = 'h00V'
constant integer SNOWY_TREE_UNIT_RAWCODE = 'h00W'
constant integer UNIT_SYNC_RAWCODE = 'h00Z'
constant integer HORSE_RAWCODE = 'hhdl'
constant integer EPIC_CHICKEN_RAWCODE = 'h01H'
constant integer SILENCED_DUMMY_RAWCODE = 'h02F'
constant integer SUMMER_TREE_RAWCODE = 'LTlt'
constant integer SNOWY_TREE_RAWCODE = 'WTst'
constant integer BIZ_TREE_SUMMER_RAWCODE = 'h01K'
constant integer BIZ_TREE_SNOW_RAWCODE = 'h01L'
constant integer PLAYER_TAVERN_1_RAWCODE = 'n000'
constant integer PLAYER_TAVERN_2_RAWCODE = 'n004'
constant integer HAT_TAVERN_1_RAWCODE = 'n001'
constant integer HAT_TAVERN_2_RAWCODE = 'n002'
constant integer HAT_TAVERN_3_RAWCODE = 'n003'
//Spells
//Black hole
constant integer BLACK_HOLE_RAWCODE = 'A002'
constant integer BLACK_HOLE_QC_RAWCODE = 'A01K'
constant integer BLACK_HOLE_DUMMY_RAWCODE = 'h002'
constant real BLACK_HOLE_DURATION = 3.50
constant real BLACK_HOLE_AOE = 700.0
real BLACK_HOLE_FORCE = 50000.0
real BLACK_HOLE_INITIAL_FORCE = 0.00
real BLACK_HOLE_LIMIT = 60.0
constant real BLACK_HOLE_HEIGHT = 50.0
constant string BLACK_HOLE_LIGHTNING_CODE = "BKHL"
constant real BLACK_HOLE_INITIAL_SIZE = 0.01
constant real BLACK_HOLE_GROW_TIME = 1.10
constant real BLACK_HOLE_SIZE = 0.50
//Kick
constant integer KICK_RAWCODE = 'A000'
constant integer KICK_QC_RAWCODE = 'A01Q'
constant real KICK_SPEED = 30.0
constant real KICK_Z = 7.00
//Powershot
constant integer POWERSHOT_RAWCODE = 'A003'
constant integer POWERSHOT_QC_RAWCODE = 'A01T'
real POWERSHOT_SPEED = 51.0
constant string POWERSHOT_SFX_PATH = "Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl"
constant string POWERSHOT_BLAST_SFX_PATH = "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl"
constant real POWERSHOT_BLAST_FACTOR = 0.85
constant real POWERSHOT_CHARGE_TIME = 0.50
constant string POWERSHOT_CHARGE_SFX_PATH = "Abilities\\Spells\\Other\\Drain\\ManaDrainTarget.mdl"
constant integer POWERSHOT_SLOW_RAWCODE = 'A00I'
constant integer POWERSHOT_SLOW_BUFF_RAWCODE = 'B00A'
constant integer POWERSHOT_DISABLE_RAWCODE = 'A016'
constant string POWERSHOT_SLOW_ORDER = "slow"
constant real POWERSHOT_SLOW_AOE = 400.0
constant integer POWERSHOT_ANIMATION_INDEX = 6
constant real POWERSHOT_SLOW_COOLDOWN = 5.00
constant integer POWERDASH_RAWCODE = 'A01E'
constant string POWERDASH_SFX_PATH = "Abilities\\Spells\\NightElf\\Taunt\\TauntCaster.mdl"
real POWERDASH_SPEED = 40.00
real POWERDASH_RANGE = 300.0
constant real POWERDASH_PUSH_FORCE = 5.0
//Slam
constant integer SLAM_RAWCODE = 'A00C'
constant real SLAM_AOE = 720.0
constant real SLAM_KNOCKBACK_POINT_Z = -300.0
real SLAM_FORCE = 66.50
constant real SLAM_DISTANCE_FACTOR = 1.00/12.00
constant string SLAM_SFX_PATH = "Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl"
constant integer SLAM_ANIMATION_INDEX = 6
constant real SLAM_DELAY = 0.36
//Sprint
constant integer SPRINT_RAWCODE = 'A001'
constant integer SPRINT_BUFF_RAWCODE = 'B000'
constant real SPRINT_NEW_SPEED = 400.0
//Wisp Sprint
constant integer WISP_SPRINT_RAWCODE = 'A00A'
constant integer WISP_SPRINT_BUFF_RAWCODE = 'B003'
constant real WISP_SPRINT_NEW_SPEED = SPRINT_NEW_SPEED
//Stealth Sprint
constant integer STEALTH_SPRINT_RAWCODE = 'A00E'
constant integer STEALTH_SPRINT_BUFF_RAWCODE = 'B004'
constant real STEALTH_SPRINT_NEW_SPEED = 400.0
constant integer STEALTH_SPRINT_INVIS_RAWCODE = 'A00G'
constant string STEALTH_SPRINT_SFX_PATH = "Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl"
//Super Sprint
constant integer SUPER_SPRINT_RAWCODE = 'A004'
constant integer SUPER_SPRINT_BUFF_RAWCODE = 'B001'
real SUPER_SPRINT_PROPULSION = 20.2
real SUPER_SPRINT_ACCELERATION = 0.72
constant integer SUPER_SPRINT_SHADOW_RAWCODE = 'h00Q'
//Divine Endurance
constant integer DIVINE_ENDURANCE_RAWCODE = 'A01A'
constant integer DIVINE_ENDURANCE_BUFF_RAWCODE = 'B00E'
//Tackle
constant integer TACKLE_RAWCODE = 'A009'
constant integer TACKLE_QC_RAWCODE = 'A01S'
real TACKLE_SPEED = 44.60
real TACKLE_RANGE = 640.0
constant real TACKLE_AOE = 200.0
constant integer TACKLE_SLOW_RAWCODE = 'A00J'
constant integer TACKLE_SLOW_BUFF_RAWCODE = 'B005'
constant integer TACKLE_SHADOW_RAWCODE = 'h00E'
constant real TACKLE_PUSH_FORCE = 10.0
//Backflip
constant integer BACKFLIP_RAWCODE = 'A00D'
constant integer BACKFLIP_DUMMY_RAWCODE = 'h00S'
real BACKFLIP_RANGE = 635.0
real BACKFLIP_TIME = 1.09
//Pull
constant integer PULL_RAWCODE = 'A007'
constant integer PULL_DISABLE_RAWCODE = 'A00M'
real PULL_FORCE = 1.40
constant real PULL_DURATION = 4.50
constant string PULL_LIGHTNING_CODE = "DRAL"
//Possess
constant integer POSSESS_RAWCODE = 'A00K'
constant real POSSESS_SPEED = 30.0
constant real POSSESS_DURATION = 8.00
constant string POSSESS_SFX_PATH = "war3mapImported\\PossessionMissile.mdx"
constant string POSSESS_EJECT_SFX_PATH = "Abilities\\Spells\\Human\\Polymorph\\PolyMorphDoneGround.mdl"
real POSSESS_EJECT_MAGNITUDE = 38.0
constant integer POSSESS_FLAG_RAWCODE = 'h01J'
real POSSESS_JUMP_VELOCITY_REDUCTION = 26.00
real POSSESS_JUMP_SPEED = 31.0
constant real POSSESS_JUMP_ANGLE = 50.0*bj_DEGTORAD
//Swap
constant integer SWAP_RAWCODE = 'A00P'
constant integer SWAP_QC_RAWCODE = 'A01R'
constant integer SWAP_PROJECTILE_RAWCODE = 'h011'
real SWAP_PROJECTILE_SPEED = 44.40
real SWAP_PROJECTILE_DURATION = 1.80
constant real SWAP_PROJECTILE_AOE = 80.0
constant string SWAP_CASTER_SFX_PATH = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
constant string SWAP_TARGET_SFX_PATH = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
constant string SWAP_LIGHTNING_1_CODE = "LINK"
constant string SWAP_LIGHTNING_2_CODE = "SWAP"
//Curveshot
constant integer CURVESHOT_RIGHT_RAWCODE = 'A00Q'
constant integer CURVESHOT_LEFT_RAWCODE = 'A00R'
constant integer CURVESHOT_RIGHT_QC_RAWCODE = 'A00Q'
constant integer CURVESHOT_LEFT_QC_RAWCODE = 'A01M'
real CURVESHOT_RANGE = 1450.0 //Values aren't accurate and have weird effect
real CURVESHOT_DURATION = 1.40 //pls don't change
real CURVESHOT_RADIUS = 1500.0
real CURVESHOT_SPEED_FACTOR = 1.25
constant string CURVESHOT_SFX_PATH = "war3mapImported\\IllidanMissile.mdl"
constant real CURVESHOT_MANA_INCREASE = 100.0
constant integer CURVESHOT_COOLDOWN_LEFT_RAWCODE = 'h01F'
constant integer CURVESHOT_COOLDOWN_RIGHT_RAWCODE = 'h01G'
constant real CURVESHOT_COOLDOWN = 1.00
//Shadow
constant integer SHADOW_RAWCODE = 'A00W'
constant integer SHADOW_RECALL_RAWCODE = 'A01F'
real SHADOW_RANGE = 400.0
real SHADOW_DELAY = 0.50
constant real SHADOW_RECALL_DELAY = 2.00
constant string SHADOW_SFX_PATH = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl"
constant real SHADOW_RECALL_COOLDOWN = 32.00
constant integer SHADOW_SHADOW_RAWCODE = 'h02B'
//Trickster
constant integer TRICKSTER_KEEP_RAWCODE = 'A00F'
constant integer TRICKSTER_KICK_RAWCODE = 'A00H'
constant integer TRICKSTER_COOLDOWN_KEEP_RAWCODE = 'h01O'
constant integer TRICKSTER_COOLDOWN_KICK_RAWCODE = 'h01P'
constant integer TRICKSTER_FAKE_BALL_SFX_RAWCODE = 'h01M'
constant real TRICKSTER_FAKE_BALL_DEATH = 10.00
constant real TRICKSTER_COOLDOWN = 14.00
//Hook
constant integer HOOK_ENEMY_RAWCODE = 'A00Y'
constant integer HOOK_ALLY_RAWCODE = 'A00Z'
constant integer HOOK_ENEMY_QC_RAWCODE = 'A01O'
constant integer HOOK_ALLY_QC_RAWCODE = 'A01P'
constant integer HOOK_PROJECTILE_RAWCODE = 'h01S'
real HOOK_PROJECTILE_SPEED = 40.0
real HOOK_PROJECTILE_RETURN_SPEED = 20.0
real HOOK_PROJECTILE_DURATION = 0.85
constant real HOOK_PROJECTILE_AOE = 100.0
constant real HOOK_RETURN_AOE = 40.0
constant string HOOK_LIGHTNING_CODE = "ROPE"
constant integer HOOK_ANCHOR_RAWCODE = 'A00L'
constant integer HOOK_SILENCE_RAWCODE = 'A010'
constant integer HOOK_SILENCE_VISUAL_RAWCODE = 'A01J'
constant integer HOOK_WITHDRAW_ENEMY_RAWCODE = 'A011'
constant integer HOOK_WITHDRAW_ALLY_RAWCODE = 'A013'
constant integer HOOK_DROP_ENEMY_RAWCODE = 'A012'
constant integer HOOK_DROP_ALLY_RAWCODE = 'A014'
constant integer HOOK_COOLDOWN_ENEMY_RAWCODE = 'h024'
constant integer HOOK_COOLDOWN_ALLY_RAWCODE = 'h025'
constant real HOOK_ENEMY_COOLDOWN = 26.00
constant real HOOK_ALLY_COOLDOWN = 22.00
constant string HOOK_SFX_PATH = "war3mapImported\\Hook SFX.mdx"
constant boolean HOOK_BALL_HOOK_ENABLED = true
//Ogre Smash
constant integer SMASH_RAWCODE = 'A015'
constant integer SMASH_SLOW_RAWCODE = 'A017'
constant integer SMASH_STUN_RAWCODE = 'A018'
constant integer SMASH_OGRE_TIME_RAWCODE = 'A01B'
constant integer SMASH_OGRE_SPEED_RAWCODE = 'A01D'
constant integer SMASH_SPEED_COOLDOWN_RAWCODE = 'h02A'
constant integer SMASH_OGRE_SPEED_BUFF_RAWCODE = 'B00F'
constant integer SMASH_OGRE_SLOW_BUFF_RAWCODE = 'B00D'
constant integer SMASH_OGRE_STUN_BUFF_RAWCODE = 'B00G'
constant real SMASH_DELAY = 0.15
constant real SMASH_OGRE_TIME = 4.00
real SMASH_RANGE = 350.0
constant real SMASH_RANGE_BALL = 350.0
constant real SMASH_WIDTH_INNER = 200.00
constant real SMASH_WIDTH_OUTER = 200.00
real SMASH_PUSH_FORCE = 45.0
real SMASH_BALL_PUSH_FORCE = 55.0
constant string SMASH_SFX_PATH = "WarStompCasterNoUberSplat.mdx"
constant real SMASH_COOLDOWN = 24.00
constant real SMASH_OGRE_TIME_COOLDOWN = 30.00
constant integer SMASH_ANIMATION_INDEX = 6
//Metamorph
constant integer METAMORPH_RAWCODE = 'A01G'
constant integer METAMORPH_COOLDOWN_RAWCODE = 'A01H'
constant integer METAMORPH_ANIMATION_INDEX = 8
constant string METAMORPH_SFX_PATH = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageDeathCaster.mdl"
constant real METAMORPH_CAST_TIME = 2.50
constant real METAMORPH_ROLL_TIME = 0.10
constant real METAMORPH_COOLDOWN = 30.00
//Angelic Kick
constant integer ANGELIC_KICK_RAWCODE = 'A019'
constant integer ANGELIC_KICK_QC_RAWCODE = 'A01J'
constant real ANGELIC_KICK_SPEED = 35.0
constant string ANGELIC_KICK_SFX_PATH = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl"
// Earth Pillar
constant integer EARTH_PILLAR_RAWCODE = 'A01I'
constant integer EARTH_PILLAR_QC_RAWCODE = 'A01N'
constant integer EARTH_PILLAR_DUMMY_RAWCODE = 'h02D'
constant string EARTH_PILLAR_ANIMATION_INDEX = "attack slam"
constant real EARTH_PILLAR_ANIMATION_TIME = 0.30
constant real EARTH_PILLAR_DELAY = 0.40
constant real EARTH_PILLAR_DURATION = 3.00
constant real EARTH_PILLAR_RANGE = 700.0
constant real EARTH_PILLAR_RADIUS = 60.0
constant real EARTH_PILLAR_AOE = 380.0
constant real EARTH_PILLAR_DEFLECT_DAMPEN = 0.90
constant real EARTH_PILLAR_BALL_DAMPEN = 3.00
constant real EARTH_PILLAR_HEIGHT = 300.0
real EARTH_PILLAR_KNOCKBACK_FORCE = 5.0
real EARTH_PILLAR_KNOCKUP_FORCE = 35.0
constant real EARTH_PILLAR_DISTANCE_FACTOR = 0.1
constant string EARTH_PILLAR_SFX_PATH = "WarStompCasterNoUberSplat.mdx"
constant string EARTH_PILLAR_END_SFX_PATH = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
constant integer PILLAR_BIRTH_ANIMATION_INDEX = 0
constant integer PILLAR_DEATH_ANIMATION_INDEX = 2
// Rift
constant integer RIFT_RAWCODE = 'A01C'
constant integer RIFT_REFUND_RAWCODE = 'A01K'
constant integer RIFT_DUMMY_RAWCODE = 'h02E'
constant integer RIFT_PROJECTILE_RAWCODE = 'h02A'
constant string RIFT_LIGHTNING_RAWCODE = "RIFT"
constant real RIFT_COOLDOWN = 32.0
constant real RIFT_REFUND_COOLDOWN = 10.0
constant real RIFT_GROUND_THRESHOLD = 25.0
constant real RIFT_RADIUS = 50.0
constant real RIFT_TIMEOUT_DURATION = 5.00
constant real RIFT_DURATION = 3.00
constant real RIFT_PROJECTILE_START_HEIGHT = 100.0
real RIFT_PROJECTILE_SPEED = 1000.0 / 32
real RIFT_MAX_RANGE = 750.0
constant real RIFT_PROJECTILE_GRAVITY_FORCE = RIFT_PROJECTILE_START_HEIGHT / 32
real RIFT_BUMP_FORCE = 12.5
//Misc spells
constant integer PASS_ME_RAWCODE = 'A006'
constant real PASS_ME_COOLDOWN = 1.00
constant string PASS_ME_ORDER_STRING = "windwalk"
constant integer TAUNT_RAWCODE = 'A005'
constant real TAUNT_COOLDOWN = 5.00
constant string TAUNT_ORDER = "berserk"
constant integer SADFACE_RAWCODE = 'A00T'
constant real SADFACE_COOLDOWN = 5.00
constant string SADFACE_ORDER_1 = "defend"
constant string SADFACE_ORDER_2 = "undefend"
constant integer SHOUT_RAWCODE = 'A00S'
constant integer SHOUT_ADRENALINE_RAWCODE = 'A00X'
constant string SHOUT_ADRENALINE_ORDER = "cripple"
constant integer BALL_SLOW_RAWCODE = 'A008'
constant integer HERO_GLOW_RAWCODE = 'A00B'
constant integer RIDE_HORSE_RAWCODE = 'A00N'
constant integer HORSE_DANCE_RAWCODE = 'A00O'
constant real JUMP_COOLDOWN = 2.00
constant real JUMP_ANGLE = 80.0*bj_DEGTORAD
constant real JUMP_INTENSITY = 29.00
constant string JUMP_SFX_PATH = "Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCaster.mdl"
constant integer DISABLE_BUFF_RAWCODE = '&DIS'
//Metamorph Heroes
constant integer METAMORPH_REMOVE_ABILITY_RAWCODE = 'RAAA'
constant integer METAMORPH_SLAM_RAWCODE = 'R000'
constant integer METAMORPH_BLACKHOLE_RAWCODE = 'R001'
constant integer METAMORPH_TACKLE_RAWCODE = 'R002'
constant integer METAMORPH_BACKFLIP_RAWCODE = 'R003'
constant integer METAMORPH_POWERSHOT_RAWCODE = 'R004'
constant integer METAMORPH_PULL_RAWCODE = 'R005'
constant integer METAMORPH_SWAP_RAWCODE = 'R006'
constant integer METAMORPH_CURVESHOT_RAWCODE = 'R007'
constant integer METAMORPH_SHADOW_RAWCODE = 'R008'
constant integer METAMORPH_HOOK_RAWCODE = 'R009'
constant integer METAMORPH_SMASH_RAWCODE = 'R00A'
constant integer METAMORPH_EARTH_PILLAR_RAWCODE = 'R00B'
//Misc
constant unittype UNIT_TYPE_VISUAL = UNIT_TYPE_TAUREN
constant unittype UNIT_TYPE_DUMMY = UNIT_TYPE_MECHANICAL
constant unittype UNIT_TYPE_OBJECT = UNIT_TYPE_ANCIENT
constant unittype UNIT_TYPE_PLAYER = UNIT_TYPE_GIANT
constant string DEFAULT_COLOR_CODE = "|c00468BFF"
constant string HINT_COLOR_CODE = "|c009FFFE4"
constant string VALID_COLOR_CODE = "|c0004FF04"
constant string INVALID_COLOR_CODE = "|c00FF0000"
constant string REFEREE_COLOR_CODE = "|c007AA0E9"
constant string EMOTE_COLOR_CODE = "|c00A9D5F5"
constant string HOTKEY_COLOR_CODE = "|cffffcc00"
constant string EMPHASIZE_COLOR_CODE = "|c008ED6DB"
constant string WHITE_COLOR_CODE = "|c00ffffff"
constant real EMOTE_Z_OFFSET = 150.0
constant real ASSIST_TIME = 6.00
constant real GRAVITY_ACCELERATION = 1.50
constant real EXTENSION_TIME = 120.0
constant integer REFEREE_RAWCODE = 'h00T'
constant player REFEREE_PLAYER = Player(PLAYER_NEUTRAL_PASSIVE)
constant real CAMERA_DEFAULT_DISTANCE = 3000.0
constant real CAMERA_ALTERNATE_ANGLE_DIFFERENCE = 11.50
constant real DEFAULT_Z = 1024.0
constant integer WATER_RAWCODE = 'B000'
constant player DUMMY_OWNER = REFEREE_PLAYER
constant real GOAL_HEIGHT = 300.0
constant real BOUNDARY_DEFAULT_Z = 32468.0
constant integer MAX_PLAYERS = 12
constant integer MAX_BALLS = 13
constant real TOURNAMENT_HALF_TIME = 600.0
constant real DUMMY_X = 1600.0
constant real DUMMY_Y = 2200.0
constant real VOTE_TIME = 30.0
constant real VOTE_EXTENSION = 2.00
constant string SWITCH_SFX_PATH = "Abilities\\Spells\\Human\\Resurrect\\ResurrectTarget.mdl"
constant real HALF_DELAY = 15.0
constant real GOAL_BLOCK_FACTOR = 0.50
constant integer STATS_MIN_PLAYERS = 4
constant real ATMOSPHERE_HEIGHT = 10000.00
constant real RECOLOR_ENABLED_DURATION = 91.0
constant integer PATHING_BLOCKER_RAWCODE = 'YTob'
endglobals
endlibrary
library TimerUtils initializer init
//*********************************************************************
//* TimerUtils (red+blue+orange flavors for 1.24b+) 2.0
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3c.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* set t=NewTimerEx(x) : Get a timer (alternative to CreateTimer), call
//* Initialize timer data as x, instead of 0.
//*
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Multi-flavor:
//* Set USE_HASH_TABLE to true if you don't want to complicate your life.
//*
//* If you like speed and giberish try learning about the other flavors.
//*
//********************************************************************
//================================================================
globals
//How to tweak timer utils:
// USE_HASH_TABLE = true (new blue)
// * SAFEST
// * SLOWEST (though hash tables are kind of fast)
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = true (orange)
// * kinda safe (except there is a limit in the number of timers)
// * ALMOST FAST
//
// USE_HASH_TABLE = false, USE_FLEXIBLE_OFFSET = false (red)
// * THE FASTEST (though is only faster than the previous method
// after using the optimizer on the map)
// * THE LEAST SAFE ( you may have to tweak OFSSET manually for it to
// work)
//
private constant boolean USE_HASH_TABLE = false
private constant boolean USE_FLEXIBLE_OFFSET = true
private constant integer OFFSET = 0x100000
private integer VOFFSET = OFFSET
//Timers to preload at map init:
private constant integer QUANTITY = 256
//Changing this to something big will allow you to keep recycling
// timers even when there are already AN INCREDIBLE AMOUNT of timers in
// the stack. But it will make things far slower so that's probably a bad idea...
private constant integer ARRAY_SIZE = 8190
endglobals
//==================================================================================================
globals
private integer array data[ARRAY_SIZE]
private hashtable ht
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
static if(USE_HASH_TABLE) then
// new blue
call SaveInteger(ht,0,GetHandleId(t), value)
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-VOFFSET]=value
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
set data[GetHandleId(t)-OFFSET]=value
endif
endfunction
function GetTimerData takes timer t returns integer
static if(USE_HASH_TABLE) then
// new blue
return LoadInteger(ht,0,GetHandleId(t) )
elseif (USE_FLEXIBLE_OFFSET) then
// orange
static if (DEBUG_MODE) then
if(GetHandleId(t)-VOFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-VOFFSET]
else
// new red
static if (DEBUG_MODE) then
if(GetHandleId(t)-OFFSET<0) then
call BJDebugMsg("SetTimerData: Wrong handle id, only use SetTimerData on timers created by NewTimer")
endif
endif
return data[GetHandleId(t)-OFFSET]
endif
endfunction
//==========================================================================================
globals
private timer array tT[ARRAY_SIZE]
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
private boolean didinit = false
endglobals
private keyword init
//==========================================================================================
// I needed to decide between duplicating code ignoring the "Once and only once" rule
// and using the ugly textmacros. I guess textmacros won.
//
//! textmacro TIMERUTIS_PRIVATE_NewTimerCommon takes VALUE
// On second thought, no.
//! endtextmacro
function NewTimerEx takes integer value returns timer
if (tN==0) then
if (not didinit) then
//This extra if shouldn't represent a major performance drawback
//because QUANTITY rule is not supposed to be broken every day.
call init.evaluate()
set tN = tN - 1
else
//If this happens then the QUANTITY rule has already been broken, try to fix the
// issue, else fail.
debug call BJDebugMsg("NewTimer: Warning, Exceeding TimerUtils_QUANTITY, make sure all timers are getting recycled correctly")
set tT[0]=CreateTimer()
static if( not USE_HASH_TABLE) then
debug call BJDebugMsg("In case of errors, please increase it accordingly, or set TimerUtils_USE_HASH_TABLE to true")
static if( USE_FLEXIBLE_OFFSET) then
if (GetHandleId(tT[0])-VOFFSET<0) or (GetHandleId(tT[0])-VOFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
else
if (GetHandleId(tT[0])-OFFSET<0) or (GetHandleId(tT[0])-OFFSET>=ARRAY_SIZE) then
//all right, couldn't fix it
call BJDebugMsg("NewTimer: Unable to allocate a timer, you should probably set TimerUtils_USE_HASH_TABLE to true or fix timer leaks.")
return null
endif
endif
endif
endif
else
set tN=tN-1
endif
call SetTimerData(tT[tN],value)
return tT[tN]
endfunction
function NewTimer takes nothing returns timer
return NewTimerEx(0)
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==ARRAY_SIZE) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
local integer i=0
local integer o=-1
local boolean oops = false
if ( didinit ) then
return
else
set didinit = true
endif
static if( USE_HASH_TABLE ) then
set ht = InitHashtable()
loop
exitwhen(i==QUANTITY)
set tT[i]=CreateTimer()
call SetTimerData(tT[i], HELD)
set i=i+1
endloop
set tN = QUANTITY
else
loop
set i=0
loop
exitwhen (i==QUANTITY)
set tT[i] = CreateTimer()
if(i==0) then
set VOFFSET = GetHandleId(tT[i])
static if(USE_FLEXIBLE_OFFSET) then
set o=VOFFSET
else
set o=OFFSET
endif
endif
if (GetHandleId(tT[i])-o>=ARRAY_SIZE) then
exitwhen true
endif
if (GetHandleId(tT[i])-o>=0) then
set i=i+1
endif
endloop
set tN = i
exitwhen(tN == QUANTITY)
set oops = true
exitwhen not USE_FLEXIBLE_OFFSET
debug call BJDebugMsg("TimerUtils_init: Failed a initialization attempt, will try again")
endloop
if(oops) then
static if ( USE_FLEXIBLE_OFFSET) then
debug call BJDebugMsg("The problem has been fixed.")
//If this message doesn't appear then there is so much
//handle id fragmentation that it was impossible to preload
//so many timers and the thread crashed! Therefore this
//debug message is useful.
elseif(DEBUG_MODE) then
call BJDebugMsg("There were problems and the new timer limit is "+I2S(i))
call BJDebugMsg("This is a rare ocurrence, if the timer limit is too low:")
call BJDebugMsg("a) Change USE_FLEXIBLE_OFFSET to true (reduces performance a little)")
call BJDebugMsg("b) or try changing OFFSET to "+I2S(VOFFSET) )
endif
endif
endif
endfunction
endlibrary
//TESH.scrollpos=10
//TESH.alwaysfold=0
library xebasic
//**************************************************************************
//
// xebasic 0.4
// =======
// XE_DUMMY_UNITID : Rawcode of the dummy unit in your map. It should
// use the dummy.mdx model, so remember to import it as
// well, just use copy&paste to copy the dummy from the
// xe map to yours, then change the rawcode.
//
// XE_HEIGHT_ENABLER: Medivh's raven form ability, you may need to change
// this rawcode to another spell that morphs into a flier
// in case you modified medivh's spell in your map.
//
// XE_TREE_RECOGNITION: The ancients' Eat tree ability, same as with medivh
// raven form, you might have to change it.
//
// XE_ANIMATION_PERIOD: The global period of animation used by whatever
// timer that depends on it, if you put a low value
// the movement will look good but it may hurt your
// performance, if instead you use a high value it
// will not lag but will be fast.
//
// XE_MAX_COLLISION_SIZE: The maximum unit collision size in your map, if
// you got a unit bigger than 197.0 it would be
// a good idea to update this constant, since some
// enums will not find it. Likewise, if none of
// your units can go bellow X and X is much smaller
// than 197.0, it would be a good idea to update
// as well, since it will improve the performance
// those enums.
//
// Notice you probably don't have to update this library, unless I specify
// there are new constants which would be unlikely.
//
//**************************************************************************
//===========================================================================
globals
constant integer XE_DUMMY_UNITID = DUMMY_RAWCODE
constant integer XE_HEIGHT_ENABLER = 'Amrf'
constant integer XE_TREE_RECOGNITION = 'Aeat'
constant real XE_ANIMATION_PERIOD = 0.025
constant real XE_MAX_COLLISION_SIZE = 197.0
endglobals
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library AutoIndex
//===========================================================================
// Information:
//==============
//
// AutoIndex is a very simple script to utilize. Just call GetUnitId(unit)
// to get get the unique value assigned to a particular unit. The GetUnitId
// function is extremely fast because it inlines directly to a GetUnitUserData
// call. AutoIndex automatically assigns an ID to each unit as it enters the
// map, and instantly frees that ID as the unit leaves the map. Detection of
// leaving units is accomplished in constant time without a periodic scan.
//
// AutoIndex uses UnitUserData by default. If something else in your map
// would conflict with that, you can set the UseUnitUserData configuration
// constant to false, and a hashtable will be used instead. Note that hash-
// tables are about 60% slower.
//
// If you turn on debug mode, AutoIndex will be able to display several
// helpful error messages. The following issues will be detected:
// -Passing a removed or decayed unit to GetUnitId
// -Code outside of AutoIndex has overwritten a unit's UserData value.
// -GetUnitId was used on a filtered unit (a unit you don't want indexed).
//
// AutoIndex provides events upon indexing or deindexing units. This
// effectively allows you to notice when units enter or leave the game. Also
// included are the AutoData, AutoCreate, and AutoDestroy modules, which allow
// you to fully utilize AutoIndex's enter/leave detection capabilities in
// conjunction with your structs.
//
//===========================================================================
// How to install AutoIndex:
//===========================
//
// 1.) Copy and paste this script into your map.
// 2.) Save it to allow the ObjectMerger macro to generate the "Leave Detect"
// ability for you. Close and re-open the map. After that, disable the macro
// to prevent the delay while saving.
//
//===========================================================================
// How to use AutoIndex:
//=======================
//
// So you can get a unique integer for each unit, but how do you use that to
// attach data to a unit? GetUnitId will always return a number in the range of
// 1-8190. This means it can be used as an array index, as demonstrated below:
/*
globals
integer array IntegerData
real array RealData
SomeStruct array SomeStructData
englobals
function Example takes nothing returns nothing
local unit u = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
local integer id = GetUnitId(u)
//You now have a unique index for the unit, so you can
//attach or retrieve data about the unit using arrays.
set IntegerData[id] = 5
set RealData[id] = 25.0
set SomeStructData[id] = SomeStruct.create()
//If you have access to the same unit in another function, you can
//retrieve the data by using GetUnitId() and reading the arrays.
endfunction
*/
// The UnitFilter function in the configuration section is provided so that
// you can make AutoIndex completely ignore certain unit-types. Ignored units
// won't be indexed or fire indexed/deindexed events. You may want to filter out
// dummy casters or system-private units, especially ones that use UnitUserData
// internally. xe dummy units are automatically filtered.
//
//===========================================================================
// How to use OnUnitIndexed / OnUnitDeindexed:
//=============================================
//
// AutoIndex will fire the OnUnitIndexed event when a unit enters the map,
// and the OnUnitDeindexed event when a unit leaves the map. Functions used
// as events must take a unit and return nothing. An example is given below:
/*
function UnitEntersMap takes unit u returns nothing
call BJDebugMsg(GetUnitName(u)+" with ID "+I2S(GetUnitId(u))+" entered the map.")
endfunction //Using GetUnitId() during Indexed events works fine...
function UnitLeavesMap takes unit u returns nothing
call BJDebugMsg(GetUnitName(u)+" with ID "+I2S(GetUnitId(u))+" left the map.")
endfunction //So does using GetUnitId() during Deindexed events.
function Init takes nothing returns nothing
call OnUnitIndexed(UnitEntersMap)
call OnUnitDeindexed(UnitLeavesMap)
endfunction
*/
// If you call OnUnitIndexed during map initialization, every existing
// unit will be considered as entering the map. This saves you from the need
// to manually enumerate preplaced units (or units created by initialization
// code that ran before OnUnitIndexed was called).
//
// OnUnitDeindexed runs while a unit still exists, which means you can
// still do things such as destroy special effects attached to the unit.
// The unit will cease to exist immediately after the event is over.
//
//===========================================================================
// AutoIndex API:
//================
//
// GetUnitId(unit) -> integer
// This function returns a unique ID in the range of 1-8190 for the
// specified unit. Returns 0 if a null unit was passed. This function
// inlines directly to GetUnitUserData or LoadInteger if debug mode
// is disabled. If debug mode is enabled, this function will print
// an error message when passed a decayed or filtered unit.
//
// IsUnitIndexed(unit) -> boolean
// This function returns a boolean indicating whether the specified
// unit has been indexed. The only time this will return false is
// for units you have filtered using the UnitFilter function, or
// for xe dummy units. You can use this function to easily detect
// dummy units and avoid performing certain actions on them.
//
// OnUnitIndexed(IndexFunc)
// This function accepts an IndexFunc, which must take a unit and
// return nothing. The IndexFunc will be fired instantly whenever
// a unit enters the map. You may use GetUnitId on the unit. When
// you call this function during map initialization, every existing
// unit will be considered as entering the map.
//
// OnUnitDeindexed(IndexFunc)
// Same as above, but runs whenever a unit is leaving the map. When
// this event runs, the unit still exists, but it will cease to exist
// as soon as the event ends. You may use GetUnitId on the unit.
//
//===========================================================================
// How to use AutoData:
//======================
//
// The AutoData module allows you to associate one or more instances
// of the implementing struct with units, as well as iterate through all
// of the instances associated with each unit.
//
// This association is accomplished through the "me" instance member,
// which the module will place in the implementing struct. Whichever unit
// you assign to "me" becomes the owner of that instance. You may change
// ownership by reassigning "me" to another unit at any time, or you may
// make the instance unowned by assigning "me" to null.
//
// AutoData implements the static method operator [] in your struct
// to allow you to access instances from their owning units. For example,
// you may type: local StructName s = StructName[u]. If u has been set
// to own an instance of StructName, s will be set to that instance.
//
// So, what happens if you assign the same owning unit to multiple
// instances? You may use 2D array syntax to access instances assigned to
// the same unit: local StructName s = StructName[u][n], where u is the
// owning unit, and n is the index beginning with 0 for each unit. You
// can access the size of a unit's instance list (i.e. the number of
// instances belonging to the unit) by using the .size instance member.
/*
struct Example
implement AutoData
static method create takes unit u returns Example
local Example this = allocate()
set me = u //Assigning the "me" member from AutoData.
return this
endmethod
endstruct
function Test takes nothing returns nothing
local unit u = CreateUnit(Player(0), 'hpea', 0., 0., 0.)
local Example e1 = Example.create(u)
local Example e2 = Example.create(u)
local Example e3 = Example.create(u)
local Example e
call BJDebugMsg(I2S(Example[u].size)) //Prints 3 because u owns e1, e2, and e3.
set e = Example[u][GetRandomInt(0, Example[u].size - 1)] //Random instance belonging to u.
set e = Example[u] //This is the fastest way to iterate the instances belonging
loop //to a specific unit, starting with the first instance.
exitwhen e == 0 //e will be assigned to 0 when no instances remain.
call BJDebugMsg(I2S(e)) //Prints the values of e1, e2, e3.
set e = e[e.index + 1] //"e.index" refers to the e's position in u's instance list.
endloop //Thus, index + 1 is next, and index - 1 is previous.
endfunction //This trick allows you to avoid a local counter.
*/
// AutoData restrictions:
// -You may not implement AutoData in any struct which has already
// declared static or non-static method operator [].
// -AutoData will conflict with anything named "me", "size", or
// "index" in the implementing struct.
// -AutoData may not be implemented in structs that extend array.
// -You may not declare your own destroy method. (This restriction
// can be dropped as soon as JassHelper supports module onDestroy).
//
// AutoData information:
// -You do not need to null the "me" member when destroying an
// instance. That is done for you automatically during destroy().
// (But if you use deallocate(), you must null "me" manually.)
// -StructName[u] and StructName[u][0] refer to the same instance,
// which is the first instance that was associated with unit u.
// -StructName[u][StructName[u].size - 1] refers to the instance that
// was most recently associated with unit u.
// -Instances keep their relative order in the list when one is removed.
//
//===========================================================================
// How to use AutoCreate:
//=======================
//
// The AutoCreate module allows you to automatically create instances
// of the implementing struct for units as they enter the game. AutoCreate
// automatically implements AutoData into your struct. Any time an instance
// is automatically created for a unit, that instance's "me" member will be
// assigned to the entering unit.
//
// AutoCreate restrictions:
// -All of the same restrictions as AutoData.
// -If your struct's allocate() method takes parameters (i.e. the parent
// type's create method takes parameters), you must declare a create
// method and pass those extra parameters to allocate yourself.
//
// AutoCreate information:
// -You may optionally declare the createFilter method, which specifies
// which units should recieve an instance as they enter the game. If
// you do not declare it, all entering units will recieve an instance.
// -You may optionally declare the onCreate method, which will run when
// AutoCreate automatically creates an instance. (This is just a stand-
// in until JassHelper supports the onCreate method.)
// -You may declare your own create method, but it must take a single
// unit parameter (the entering unit) if you do so.
/*
struct Example
private static method createFilter takes unit u returns boolean
return GetUnitTypeId(u) == 'hfoo' //Created only for Footmen.
endmethod
private method onCreate takes nothing returns nothing
call BJDebugMsg(GetUnitName(me)+" entered the game!")
endmethod
implement AutoCreate
endstruct
*/
//===========================================================================
// How to use AutoDestroy:
//=========================
//
// The AutoDestroy module allows you to automatically destroy instances
// of the implementing struct when their "me" unit leaves the game. AutoDestroy
// automatically implements AutoData into your struct. You must assign a unit
// to the "me" member of an instance for this module to have any effect.
//
// AutoDestroy restrictions:
// -All of the same restrictions as AutoData.
//
// AutoDestroy information:
// -If you also implement AutoCreate in the same struct, remember that it
// assigns the "me" unit automatically. That means you can have fully
// automatic creation and destruction.
/*
struct Example
static method create takes unit u returns Example
local Example this = allocate()
set me = u //You should assign a unit to "me",
return this //otherwise AutoDestroy does nothing.
endmethod //Not necessary if using AutoCreate.
private method onDestroy takes nothing returns nothing
call BJDebugMsg(GetUnitName(me)+" left the game!")
endmethod
implement AutoDestroy
endstruct
*/
//===========================================================================
// Configuration:
//================
// external ObjectMerger w3a Adef lvdt anam "Leave Detect" aart "" arac 0
//Save your map with this Object Merger call enabled, then close and reopen your
//map. Disable it by removing the exclamation to remove the delay while saving.
globals
private constant integer LeaveDetectAbilityID = 'lvdt'
//This rawcode must match the parameter after "Adef" in the
//ObjectMerger macro above. You may change both if you want.
private constant boolean UseUnitUserData = true
//If this is set to true, UnitUserData will be used. You should only set
//this to false if something else in your map already uses UnitUserData.
//A hashtable will be used instead, but it is about 60% slower.
private constant boolean SafeMode = true
//This is set to true by default so that GetUnitId() will ALWAYS work.
//If if this is set to false, GetUnitId() may fail to work in a very
//rare circumstance: creating a unit that has a default-on autocast
//ability, and using GetUnitId() on that unit as it enters the game,
//within a trigger that detects any order. Set this to false for a
//performance boost only if you think you can avoid this issue.
private constant boolean AutoDataFastMode = true
//If this is set to true, AutoData will utilize one hashtable per time
//it is implemented. If this is set to false, all AutoDatas will share
//a single hashtable, but iterating through the instances belonging to
//a unit will become about 12.5% slower. Your map will break if you
//use more than 255 hashtables simultaneously. Only set this to false
//if you suspect you will run out of hashtable instances.
endglobals
private function UnitFilter takes unit u returns boolean
return not IsUnitType(u, UNIT_TYPE_DUMMY)
endfunction
//Make this function return false for any unit-types you want to ignore.
//Ignored units won't be indexed or fire OnUnitIndexed/OnUnitDeindexed
//events. The unit parameter "u" to refers to the unit being filtered.
//Do not filter out xe dummy units; they are automatically filtered.
//===========================================================================
// AutoData / AutoCreate / AutoDestroy modules:
//==============================================
function interface AutoCreator takes unit u returns nothing
function interface AutoDestroyer takes unit u returns nothing
globals
hashtable AutoData = null //If AutoDataFastMode is disabled, this hashtable will be
endglobals //initialized and shared between all AutoData implementations.
module AutoData
private static hashtable ht
private static thistype array data
private static integer array listsize
private static key typeid //Good thing keys exist to identify each implementing struct.
private unit meunit
private integer id
readonly integer index //The user can avoid using a local counter because this is accessable.
static method operator [] takes unit u returns thistype
return data[GetUnitId(u)]
endmethod //This is as fast as retrieving an instance from a unit gets.
method operator [] takes integer index returns thistype
static if AutoDataFastMode then //If fast mode is enabled...
return LoadInteger(ht, id, index)
else //Each instance has its own hashtable to associate unit and index.
return LoadInteger(AutoData, id, index*8190+typeid)
endif //Otherwise, simulate a 3D array associating unit, struct-type ID, and index.
endmethod //Somehow, this version is 12.5% slower just because of the math.
private method setIndex takes integer index, thistype data returns nothing
static if AutoDataFastMode then //Too bad you can't have a module-private operator []=.
call SaveInteger(ht, id, index, data)
else
call SaveInteger(AutoData, id, index*8190+typeid, data)
endif
endmethod
private method remove takes nothing returns nothing
if meunit == null then //If the struct doesn't have an owner...
return //Nothing needs to be done.
endif
loop
exitwhen index == listsize[id] //The last value gets overwritten by 0.
call setIndex(index, this[index + 1]) //Shift each element down by one.
set this[index].index = index //Update the shifted instance's index.
set index = index + 1
endloop
set listsize[id] = listsize[id] - 1
set data[id] = this[0] //Ensure thistype[u] returns the same value as thistype[u][0].
set meunit = null
endmethod
private method add takes unit u returns nothing
if meunit != null then //If the struct has an owner...
call remove() //remove it first.
endif
set meunit = u
set id = GetUnitId(u) //Cache GetUnitId for slight performance boost.
if data[id] == 0 then //If this is the first instance for this unit...
set data[id] = this //Update the value that thistype[u] returns.
endif
set index = listsize[id] //Remember the index for removal.
call setIndex(index, this) //Add to the array.
set listsize[id] = index + 1
endmethod
method operator me takes nothing returns unit
return meunit
endmethod
method operator me= takes unit u returns nothing
if u != null then //If assigning "me" a non-null value...
call add(u) //Add this instance to that unit's array.
else //If assigning "me" a null value...
call remove() //Remove this instance from that unit's array.
endif
endmethod
method operator size takes nothing returns integer
return listsize[id]
endmethod
method destroy takes nothing returns nothing
call deallocate()
call remove() //This makes removal automatic when an instance is destroyed.
endmethod
private static method onInit takes nothing returns nothing
static if AutoDataFastMode then //If fast mode is enabled...
set ht = InitHashtable() //Initialize one hashtable per instance.
else //If fast mode is disabled...
if AutoData == null then //If the hashtable hasn't been initialized yet...
set AutoData = InitHashtable() //Initialize the shared hashtable.
endif
endif
endmethod
endmodule
module AutoCreate
implement AutoData //AutoData is necessary for AutoCreate.
private static method creator takes unit u returns nothing
local thistype this
local boolean b = true //Assume that the instance will be created.
static if thistype.createFilter.exists then //If createFilter exists...
set b = createFilter(u) //evaluate it and update b.
endif
if b then //If the instance should be created...
static if thistype.create.exists then //If the create method exists...
set this = create(u) //Create the instance, passing the entering unit.
else //If the create method doesn't exist...
set this = allocate() //Just allocate the instance.
endif
set me = u //Assign the instance's owner as the entering unit.
static if thistype.onCreate.exists then //If onCreate exists...
call onCreate() //Call it, because JassHelper should do this anyway.
endif
endif
endmethod
private static method onInit takes nothing returns nothing
call AutoIndex.addAutoCreate(thistype.creator)
endmethod //During module initialization, pass the creator function to AutoIndex.
endmodule
module AutoDestroy
implement AutoData //AutoData is necessary for AutoDestroy.
static method destroyer takes unit u returns nothing
loop
exitwhen thistype[u] == 0
call thistype[u].destroy()
endloop
endmethod //Destroy each instance owned by the unit until none are left.
private static method onInit takes nothing returns nothing
call AutoIndex.addAutoDestroy(thistype.destroyer)
endmethod //During module initialization, pass the destroyer function to AutoIndex.
endmodule
//===========================================================================
// AutoIndex struct:
//===================
function interface IndexFunc takes unit u returns nothing
hook RemoveUnit AutoIndex.hook_RemoveUnit
hook ReplaceUnitBJ AutoIndex.hook_ReplaceUnitBJ
debug hook SetUnitUserData AutoIndex.hook_SetUnitUserData
private keyword getIndex
private keyword getIndexDebug
private keyword isUnitIndexed
private keyword onUnitIndexed
private keyword onUnitDeindexed
struct AutoIndex
private static trigger enter = CreateTrigger()
private static trigger order = CreateTrigger()
private static trigger creepdeath = CreateTrigger()
private static group preplaced = CreateGroup()
private static timer allowdecay = CreateTimer()
private static hashtable ht
private static boolean array dead
private static boolean array summoned
private static boolean array animated
private static boolean array nodecay
private static boolean array removing
private static IndexFunc array indexfuncs
private static integer indexfuncs_n = -1
private static IndexFunc array deindexfuncs
private static integer deindexfuncs_n = -1
private static IndexFunc indexfunc
private static AutoCreator array creators
private static integer creators_n = -1
private static AutoDestroyer array destroyers
private static integer destroyers_n = -1
private static unit array allowdecayunit
private static integer allowdecay_n = -1
private static boolean duringinit = true
private static boolean array altered
private static unit array idunit
//===========================================================================
static method getIndex takes unit u returns integer
static if UseUnitUserData then
return GetUnitUserData(u)
else
return LoadInteger(ht, 0, GetHandleId(u))
endif
endmethod //Resolves to an inlinable one-liner after the static if.
static method getIndexDebug takes unit u returns integer
if u == null then
return 0
elseif GetUnitTypeId(u) == 0 then
call BJDebugMsg("AutoIndex error: Removed or decayed unit passed to GetUnitId.")
elseif idunit[getIndex(u)] != u and GetIssuedOrderId() != 852056 then
call BJDebugMsg("AutoIndex error: "+GetUnitName(u)+" is a filtered unit.")
endif
return getIndex(u)
endmethod //If debug mode is enabled, use the getIndex method that shows errors.
private static method setIndex takes unit u, integer index returns nothing
static if UseUnitUserData then
call SetUnitUserData(u, index)
else
call SaveInteger(ht, 0, GetHandleId(u), index)
endif
endmethod //Resolves to an inlinable one-liner after the static if.
static method isUnitIndexed takes unit u returns boolean
return u != null and idunit[getIndex(u)] == u
endmethod
static method isUnitAnimateDead takes unit u returns boolean
return animated[getIndex(u)]
endmethod //Don't use this; use IsUnitAnimateDead from AutoEvents instead.
//===========================================================================
private static method onUnitIndexed_sub takes nothing returns nothing
call indexfunc.evaluate(GetEnumUnit())
endmethod
static method onUnitIndexed takes IndexFunc func returns nothing
set indexfuncs_n = indexfuncs_n + 1
set indexfuncs[indexfuncs_n] = func
if duringinit then //During initialization, evaluate the indexfunc for every preplaced unit.
set indexfunc = func
call ForGroup(preplaced, function AutoIndex.onUnitIndexed_sub)
endif
endmethod
static method onUnitDeindexed takes IndexFunc func returns nothing
set deindexfuncs_n = deindexfuncs_n + 1
set deindexfuncs[deindexfuncs_n] = func
endmethod
static method addAutoCreate takes AutoCreator func returns nothing
set creators_n = creators_n + 1
set creators[creators_n] = func
endmethod
static method addAutoDestroy takes AutoDestroyer func returns nothing
set destroyers_n = destroyers_n + 1
set destroyers[destroyers_n] = func
endmethod
//===========================================================================
private static method hook_RemoveUnit takes unit whichUnit returns nothing
set removing[getIndex(whichUnit)] = true
endmethod //Intercepts whenever RemoveUnit is called and sets a flag.
private static method hook_ReplaceUnitBJ takes unit whichUnit, integer newUnitId, integer unitStateMethod returns nothing
set removing[getIndex(whichUnit)] = true
endmethod //Intercepts whenever ReplaceUnitBJ is called and sets a flag.
private static method hook_SetUnitUserData takes unit whichUnit, integer data returns nothing
static if UseUnitUserData then
if idunit[getIndex(whichUnit)] == whichUnit then
if getIndex(whichUnit) == data then
call BJDebugMsg("AutoIndex error: Code outside AutoIndex attempted to alter "+GetUnitName(whichUnit)+"'s index.")
else
call BJDebugMsg("AutoIndex error: Code outside AutoIndex altered "+GetUnitName(whichUnit)+"'s index.")
if idunit[data] != null then
call BJDebugMsg("AutoIndex error: "+GetUnitName(whichUnit)+" and "+GetUnitName(idunit[data])+" now have the same index.")
endif
set altered[data] = true
endif
endif
endif //In debug mode, intercepts whenever SetUnitUserData is used on an indexed unit.
endmethod //Displays an error message if outside code tries to alter a unit's index.
//===========================================================================
private static method allowDecay takes nothing returns nothing
local integer n = allowdecay_n
loop
exitwhen n < 0
set nodecay[getIndex(allowdecayunit[n])] = false
set allowdecayunit[n] = null
set n = n - 1
endloop
set allowdecay_n = -1
endmethod //Iterate through all the units in the stack and allow them to decay again.
private static method detectStatus takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer index = getIndex(u)
local integer n
if idunit[index] == u then //Ignore non-indexed units.
if not IsUnitType(u, UNIT_TYPE_DEAD) then
if dead[index] then //The unit was dead, but now it's alive.
set dead[index] = false //The unit has been resurrected.
//! runtextmacro optional RunAutoEvent("Resurrect")
//If AutoEvents is in the map, run the resurrection events.
if IsUnitType(u, UNIT_TYPE_SUMMONED) and not summoned[index] then
set summoned[index] = true //If the unit gained the summoned flag,
set animated[index] = true //it's been raised with Animate Dead.
//! runtextmacro optional RunAutoEvent("AnimateDead")
//If AutoEvents is in the map, run the Animate Dead events.
endif
endif
else
if not removing[index] and not dead[index] and not animated[index] then
set dead[index] = true //The unit was alive, but now it's dead.
set nodecay[index] = true //A dead unit can't decay for at least 0. seconds.
set allowdecay_n = allowdecay_n + 1 //Add the unit to a stack. After the timer
set allowdecayunit[allowdecay_n] = u //expires, allow the unit to decay again.
call TimerStart(allowdecay, 0., false, function AutoIndex.allowDecay)
//! runtextmacro optional RunAutoEvent("Death")
//If AutoEvents is in the map, run the Death events.
elseif removing[index] or (dead[index] and not nodecay[index]) or (not dead[index] and animated[index]) then
//If .nodecay was false and the unit is dead and was previously dead, the unit decayed.
//If .animated was true and the unit is dead, the unit died and exploded.
//If .removing was true, the unit is being removed or replaced.
set n = deindexfuncs_n
loop //Run the OnUnitDeindexed events.
exitwhen n < 0
call deindexfuncs[n].evaluate(u)
set n = n - 1
endloop
set n = destroyers_n
loop //Destroy AutoDestroy structs for the leaving unit.
exitwhen n < 0
call destroyers[n].evaluate(u)
set n = n - 1
endloop
call AutoIndex(index).destroy() //Free the index by destroying the AutoIndex struct.
set idunit[index] = null //Null this unit reference to prevent a leak.
endif
endif
endif
set u = null
return false
endmethod
//===========================================================================
private static method unitEntersMap takes unit u returns nothing
local integer index
local integer n = 0
if getIndex(u) != 0 then
return //Don't index a unit that already has an ID.
endif
static if LIBRARY_xebasic then
if GetUnitTypeId(u) == XE_DUMMY_UNITID then
return //Don't index xe dummy units.
endif
endif
if not UnitFilter(u) then
return //Don't index units that fail the unit filter.
endif
set index = create()
call setIndex(u, index) //Assign an index to the entering unit.
call UnitAddAbility(u, LeaveDetectAbilityID) //Add the leave detect ability to the entering unit.
call UnitMakeAbilityPermanent(u, true, LeaveDetectAbilityID) //Prevent it from disappearing on morph.
set dead[index] = IsUnitType(u, UNIT_TYPE_DEAD) //Reset all of the flags for the entering unit.
set summoned[index] = IsUnitType(u, UNIT_TYPE_SUMMONED) //Each of these flags are necessary to detect
set animated[index] = false //when a unit leaves the map.
set nodecay[index] = false
set removing[index] = false
debug set altered[index] = false //In debug mode, this flag tracks wheter a unit's index was altered.
set idunit[index] = u //Attach the unit that is supposed to have this index to the index.
if duringinit then //If a unit enters the map during initialization...
call GroupAddUnit(preplaced, u) //Add the unit to the preplaced units group. This ensures that
endif //all units are noticed by OnUnitIndexed during initialization.
loop //Create AutoCreate structs for the entering unit.
exitwhen n > creators_n
call creators[n].evaluate(u)
set n = n + 1
endloop
set n = 0
loop //Run the OnUnitIndexed events.
exitwhen n > indexfuncs_n
call indexfuncs[n].evaluate(u)
set n = n + 1
endloop
endmethod
private static method onIssuedOrder takes nothing returns boolean
static if SafeMode then //If SafeMode is enabled, perform this extra check.
if getIndex(GetTriggerUnit()) == 0 then //If the unit doesn't already have
call unitEntersMap(GetTriggerUnit()) //an index, then assign it one.
endif
endif
return GetIssuedOrderId() == 852056 //If the order is Undefend, allow detectStatus to run.
endmethod
private static method initEnteringUnit takes nothing returns boolean
call unitEntersMap(GetFilterUnit())
return false
endmethod
//===========================================================================
private static method afterInit takes nothing returns nothing
set duringinit = false //Initialization is over; set a flag.
call DestroyTimer(GetExpiredTimer()) //Destroy the timer.
call GroupClear(preplaced) //The preplaced units group is
call DestroyGroup(preplaced) //no longer needed, so clean it.
set preplaced = null
endmethod
private static method onInit takes nothing returns nothing
local region maparea = CreateRegion()
local rect bounds = GetWorldBounds()
local group g = CreateGroup()
local integer i = 15
static if not UseUnitUserData then
set ht = InitHashtable() //Only create a hashtable if it will be used.
endif
loop
exitwhen i < 0
call SetPlayerAbilityAvailable(Player(i), LeaveDetectAbilityID, false)
//Make the LeaveDetect ability unavailable so that it doesn't show up on the command card of every unit.
call TriggerRegisterPlayerUnitEvent(order, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
//Register the "EVENT_PLAYER_UNIT_ISSUED_ORDER" event for each player.
call GroupEnumUnitsOfPlayer(g, Player(i), function AutoIndex.initEnteringUnit)
//Enum every non-filtered unit on the map during initialization and assign it a unique
//index. By using GroupEnumUnitsOfPlayer, even units with Locust can be detected.
set i = i - 1
endloop
call TriggerAddCondition(order, And(function AutoIndex.onIssuedOrder, function AutoIndex.detectStatus))
//The detectStatus method will fire every time a non-filtered unit recieves an undefend order.
//And() is used here to avoid using a trigger action, which starts a new thread and is slower.
call TriggerRegisterPlayerUnitEvent(creepdeath, Player(12), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition(creepdeath, function AutoIndex.detectStatus)
//The detectStatus method must also fire when a neutral hostile creep dies, in case it was
//sleeping. Sleeping creeps don't fire undefend orders on non-damaging deaths.
call RegionAddRect(maparea, bounds) //GetWorldBounds() includes the shaded boundry areas.
call TriggerRegisterEnterRegion(enter, maparea, function AutoIndex.initEnteringUnit)
//The filter function of an EnterRegion trigger runs instantly when a unit is created.
call TimerStart(CreateTimer(), 0., false, function AutoIndex.afterInit)
//After any time elapses, perform after-initialization actions.
call GroupClear(g)
call DestroyGroup(g)
call RemoveRect(bounds)
set g = null
set bounds = null
endmethod
endstruct
//===========================================================================
// User functions:
//=================
function GetUnitId takes unit u returns integer
static if DEBUG_MODE then //If debug mode is enabled...
return AutoIndex.getIndexDebug(u) //call the debug version of GetUnitId.
else //If debug mode is disabled...
return AutoIndex.getIndex(u) //call the normal, inlinable version.
endif
endfunction
function IsUnitIndexed takes unit u returns boolean
return AutoIndex.isUnitIndexed(u)
endfunction
function OnUnitIndexed takes IndexFunc func returns nothing
call AutoIndex.onUnitIndexed(func)
endfunction
function OnUnitDeindexed takes IndexFunc func returns nothing
call AutoIndex.onUnitDeindexed(func)
endfunction
endlibrary
//TESH.scrollpos=108
//TESH.alwaysfold=0
library UnitStatus initializer Init requires TimerUtils, AutoIndex, optional xebasic
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This library exists because oftentimes, a mapmaker needs to apply a specific
//* status effect to a unit. If he were to do it on his own, he'd need to find a
//* way to get the status effects to stack properly with one another and with
//* multiple instances of themselves. This script does just that with the five
//* most useful status options in WC3 that cannot be reproduced perfectly with
//* just code and not actual in-game buffs.
//*
//* WARNING: This library uses the following buffs. If you use any of the listed
//* buffs in your map, they will not stack with this script's buffs and
//* it may not work. If you need these effects, then only use this
//* script to achieve them.
//* - Drunken Haze
//* - Soul Burn
//* - Ensnare
//* - Storm Bolt
//* - Hurl Boulder
//*
//******************************************************************************
//*
//* The following status effects are supported by this library.
//*
//* - Silence
//* This status disables a given unit's ability to cast spells. This works
//* properly on spell immune and normal units.
//*
//* Example Usage:
//* call SilenceUnit(u, true) //Silences a unit
//* call SilenceUnit(u, false) //Removes silence from a unit
//* call SilenceUnitTimed(u, 4.0) //Adds a timed silence to a unit
//*
//* - Disarm
//* This status disables a given unit's ability to attack and attack ground.
//* This will not work properly on spell immune units because of a Blizzard
//* bug. The function calls will return false when used on units that are
//* spell immune. This status disables both ranged and melee attacks.
//*
//* Example Usage:
//* call DisarmUnit(u, true) //Disarms a unit
//* call DisarmUnit(u, false) //Removes disarm from a unit
//* call DisarmUnitTimed(u, 4.0) //Adds a timed disarm to a unit
//*
//* - Ensnare
//* This status disables a given unit's ability to move. This works properly
//* on spell immune and normal units. Because of the nature of the ability
//* this is based upon, it will exhibit strange behavior on flying units. If
//* this is used on flying units, they will retain their flying height, but
//* be treated as ground units by the game. There is unfortunately no
//* workaround for this behavior. It is recommended to not use it on flying
//* units because for that reason.
//*
//* Example Usage:
//* call EnsnareUnit(u, true) //Ensnares a unit
//* call EnsnareUnit(u, false) //Removes ensnare from a unit
//* call EnsnareUnitTimed(u, 4.0) //Adds a timed ensnare to a unit
//*
//* - Stun
//* This status is identical in nature to the standard melee stun. A stunned
//* unit cannot move, attack, or cast spells. Both spell immune and normal
//* units can be stunned.
//*
//* Example Usage:
//* call StunUnit(u, true) //Ensnares a unit
//* call StunUnit(u, false) //Removes stun from a unit
//* call StunUnitTimed(u, 4.0) //Adds a timed stun to a unit
//*
//* - Disable
//* Disable is a unique status meant to be used as a replacement for pausing a
//* unit using the PauseUnit native. Pausing a unit has the negative side
//* effects of removing the unit's command card and not preserving queued
//* orders. Disabling a unit retains both of those sought features. Disable is
//* a non-graphical stun at its core that is always 'underneath' stun when
//* both are applied on a unit at once as listed below.
//*
//* Disable also interacts with stun in a unique way.
//* - If stun is used on a disabled unit, the unit becomes stunned instead.
//* - If stun ends on a disabled unit, the unit is disabled until the disable
//* ends.
//* - If disable is used on a stunned unit, the unit remains visibly stunned.
//*
//* Example Usage:
//* call DisableUnit(u, true) //Disables a unit
//* call DisableUnit(u, false) //Removes disable from a unit
//* call DisableUnitTimed(u, 4.0) //Adds a timed disable to a unit
//*
//* WARNING: These status effects, when used on invulnerable units, will have
//* absolutely no effect.
//*
//******************************************************************************
//*
//* There is a textmacro call below that runs a series of ObjectMerger calls
//* inside of an embedded .lua script. This sub-script generates all of the
//* abilities and buffs required by this library automatically for you. Enable
//* it by uncommenting the textmacro, saving your map, closing your map,
//* reopening your map, and commenting the macro again.
//*
//* Note that you, as the user, may edit any of the buff icons or tooltips to
//* your liking. It is not recommended to edit the data fields for the spells,
//* though. They are the way they are so that they will work.
//*
//* WARNING: The ObjectMerger call for Disarm's ability seems to be unable to
//* properly configure the "Data - Attacks Prevented" field. If you
//* find that the DisarmUnit call isn't functioning as intended, then
//* set that field to "None", save your map, set the field back to
//* "Melee, Ranged", and then save your map again. It should now work
//* properly.
//*
//* You may change the raw ids of any of the generated abilities as needed for
//* your map. (If there are conflicts) If you want to do so, then make sure that
//* you change the raw ids inside all affected ObjectMerger calls and the
//* constants in the globals block below.
//*
//* WARNING: If you choose to change the raw id for the Silence ability, do NOT
//* let the buff raw id match the ability raw id. If you do, the buff's
//* special effect fields will not show in-game. (This may or may not
//* even affect you, but it is worth noting regardless)
//*
//* xebasic is an optional requirement. If you have xebasic in your map, this
//* script will use xebasic's dummy unit id instead of the constant below. If
//* you do not have xebasic in your map, for this to work you will need to make
//* (if you have not already) a dummy unit caster for your map. Put its raw id
//* below in the DUMMY_UNITID constant field.
//*
//* Enjoy!
//*
//* Uncomment the following textmacro to create the abilities.
////! runtextmacro GenerateAbilities()
//! textmacro GenerateAbilities
//! externalblock extension=lua ObjectMerger $FILENAME$
//! i
//! i function set(field, value)
//! i makechange(current, field, value)
//! i end
//! i function setl(field, level, value)
//! i makechange(current, field, level, value)
//! i end
//! i
//! i setobjecttype("abilities")
//! i
//! i createobject("AHtb", "stun"); set("anam", "Stun Ability")
//! i set ("aani", "") ; set ("aart", "") ; set ("amat", "") ; set ("amsp", 0) ; setl("Htb1", 1, 0.0);
//! i setl("aran", 1, 99999.0); setl("acdn", 1, 0.0); setl("ahdu", 1, 0.0) ; setl("adur", 1, 0.0) ; set ("arlv", 6) ;
//! i set ("alev", 1) ; setl("amcs", 1, 0) ; set ("arac", "other"); setl("atar", 1, "notself");
//! i
//! i createobject("ANso", "&sil"); set("anam", "Silence Ability")
//! i set ("aart", "") ; setl("Nso1", 1, 0.0); setl("Nso3", 1, 0.0) ; setl("Nso2", 1, 99999.0) ; setl("aran", 1, 99999.0);
//! i setl("abuf", 1, "&SIL"); setl("acdn", 1, 0.0); setl("ahdu", 1, 0.0) ; setl("adur", 1, 0.0) ; set ("arlv", 1);
//! i set ("alev", 1) ; setl("amcs", 1, 0) ; set ("arac", "other"); setl("atar", 1, "notself");
//! i
//! i createobject("ANdh", "&arm"); set("anam", "Disarm Ability")
//! i set ("aart", "") ; set ("amat", "") ; set ("amac", 0.0) ; set ("amsp", 0) ; setl("Nsi1", 1, 3) ;
//! i setl("Nsi2", 1, 0.0) ; setl("Nsi3", 1, 0.0) ; setl("aare", 1, 0.0); setl("aran", 1, 99999.0); setl("abuf", 1, "&ARM");
//! i setl("acdn", 1, 0.0) ; setl("ahdu", 1, 0.0) ; setl("adur", 1, 0.0); set ("arlv", 6) ; set ("alev", 1) ;
//! i setl("amcs", 1, 0) ; set ("arac", "other") ; setl("atar", 1, "notself");
//! i
//! i createobject("ACen", "&ens"); set("anam", "Ensnare Ability")
//! i set ("aart", "") ; set ("amat", "") ; set ("amsp", 0) ; setl("Ens1", 1, -1.0); setl("Ens2", 1, -1.0);
//! i setl("aran", 1, 99999.0) ; setl("abuf", 1, "&EN1,&EN2"); setl("acdn", 1, 0.0); setl("ahdu", 1, 0.0) ; set ("aher", 1) ;
//! i setl("adur", 1, 0.0) ; set ("arlv", 6) ; set ("alev", 1) ; setl("amcs", 1, 0) ; set ("arac", "other");
//! i setl("atar", 1, "notself"); set ("areq", "") ; set("ansf", "") ;
//! i
//! i createobject("ACtb", "&dis"); set("anam", "Disable Ability")
//! i set ("aani", "") ; set ("aart", "") ; set ("amat", "") ; set ("amsp", 0) ; setl("Ctb1", 1, 0.0) ;
//! i setl("aran", 1, 99999.0) ; setl("abuf", 1, "&DIS"); setl("acdn", 1, 0.0); setl("ahdu", 1, 0.0); setl("adur", 1, 0.0) ;
//! i set ("aher", 1) ; set ("arlv", 6) ; set ("alev", 1) ; setl("amcs", 1, 0) ; set ("arac", "other");
//! i setl("atar", 1, "notself");
//! i
//! i setobjecttype("buffs")
//! i
//! i createobject("BNso", "&SIL"); set("fnam", "Disabled (Spells)")
//! i set("ftip", "Disabled (Spells)") ; set("fube", "This unit cannot cast spells.");
//! i set("fart", "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"); set("ftat", "") ; set("fta0", "");
//! i
//! i createobject("BNdh", "&ARM"); set("fnam", "Disabled (Attacks)")
//! i set("ftip", "Disabled (Attacks)") ; set("fube", "This unit cannot attack.");
//! i set("fart", "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"); set("ftat", "") ; set("fta0", "");
//! i
//! i createobject("Beng", "&EN1"); set("fnam", "Disabled (Movement)")
//! i set("ftip", "Disabled (Movement)") ; set("fube", "This unit cannot move." );
//! i set("fart", "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"); set("ftat", "") ; set("frac", "other");
//! i
//! i createobject("Bena", "&EN2"); set("fnam", "Disabled (Movement)")
//! i set("ftip", "Disabled (Movement)") ; set("fube", "This unit cannot move.");
//! i set("fart", "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"); set("ftat", "") ; set("fta0", "");
//! i set("frac", "other");
//! i
//! i createobject("BPSE", "&DIS"); set("fnam", "Disabled")
//! i set("ftip", "Disabled") ; set("fube", "This unit cannot do anything.");
//! i set("fart", "ReplaceableTextures\\CommandButtons\\BTNCancel.blp"); set("ftat", "") ; set("fta0", "")
//! i
//! endexternalblock
//! endtextmacro GenerateAbilities
globals
//General constants
private constant integer DUMMY_UNITID = 'e000' //Replace this with your dummy's id
//Stun constants
private constant integer STUN_ID = 'stun' //This needs to match the ObjectMerger call above
private constant integer STUN_ORDER_ID = 852095 //Order id to stun a unit
private constant integer STUN_BUFF_ID = 'BPSE' //Normal storm bolt stun buff
//Silence constants
private constant integer SILENCE_ID = '&sil' //This needs to match the ObjectMerger call above
private constant integer SILENCE_ORDER_ID = 852668 //Order id to soul burn a unit
private constant integer SILENCE_BUFF_ID = '&SIL' //Generated soul burn based buff
//Disarm constants
private constant integer DISARM_ID = '&arm' //This needs to match the ObjectMerger call above
private constant integer DISARM_ORDER_ID = 852585 //Order id to drunken haze a unit
private constant integer DISARM_BUFF_ID = '&ARM' //Generated drunken haze based buff
//Ensnare constants
private constant integer ENSNARE_ID = '&ens' //This needs to match the ObjectMerger call above
private constant integer ENSNARE_ORDER_ID = 852106 //Order id to ensnare a unit
private constant integer ENSNARE_BUFF_ID = '&EN1' //Generated ensnare based buff (ground)
private constant integer ENSNARE_BUFF_ID2 = '&EN2' //Generated ensnare based buff (air)
//Disable constants
private constant integer DISABLE_ID = '&dis' //This needs to match the ObjectMerger call above
private constant integer DISABLE_ORDER_ID = 852252 //Order id to hurl boulder at a unit
private constant integer DISABLE_BUFF_ID = '&DIS' //Generated hurl boulder based buff
endglobals
globals
private unit Caster = null //Dummy caster
private timer Temp = null //For callback referencing
endglobals
//******************************************************************************
//! textmacro UnitStatus_GenerateBase takes TYPE, CONSTANT, STRUCTNAME, INJECTPOSTBUFF, INJECTCHECK, INJECTPREBUFF
private struct clear$TYPE$
unit u = null
//Exists only for clearing on Add/Remove situations
static method create takes unit t returns thistype
local thistype c = thistype.allocate()
set c.u = t
return c
endmethod
endstruct
private function TimerRemove$TYPE$ takes nothing returns nothing
local clear$TYPE$ c = clear$TYPE$(GetTimerData(GetExpiredTimer()))
local unit whichUnit = c.u
if $TYPE$Counter[GetUnitId(c.u)] == 0 then
//Make sure we should still remove it
call UnitRemoveAbility(c.u, $CONSTANT$_BUFF_ID)
$INJECTPOSTBUFF$
endif
call ReleaseTimer(GetExpiredTimer())
call c.destroy()
set whichUnit = null
endfunction
function $TYPE$Unit takes unit whichUnit, boolean flag returns boolean
local integer id = GetUnitId(whichUnit)
local boolean b = true
if whichUnit == null then
//Target can't be null
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Null unit given to $TYPE$Unit")
return false
endif
if flag then
if $TYPE$Counter[id] == 0 $INJECTCHECK$ then
//Buff the unit
$INJECTPREBUFF$
call UnitShareVision(whichUnit, GetOwningPlayer(Caster), true)
set b = IssueTargetOrderById(Caster, $CONSTANT$_ORDER_ID, whichUnit)
call UnitShareVision(whichUnit, GetOwningPlayer(Caster), false)
endif
if not b then
//Cast failed somehow
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Unit could not be buffed ($TYPE$Unit)")
return false
endif
set $TYPE$Counter[id] = $TYPE$Counter[id] + 1
elseif $TYPE$Counter[id] > 0 then //Only run this if unit is buffed at all
//Decrement Counter
set $TYPE$Counter[id] = $TYPE$Counter[id] - 1
if $TYPE$Counter[id] == 0 then
//Clear the buff
if GetUnitAbilityLevel(whichUnit, $CONSTANT$_BUFF_ID) == 0 then
//Remove it in a 0.01s callback because it hasn't been applied yet
set Temp = NewTimer()
call SetTimerData(Temp, integer(clear$TYPE$.create(whichUnit)))
call TimerStart(Temp, 0.01, false, function TimerRemove$TYPE$)
else
call UnitRemoveAbility(whichUnit, $CONSTANT$_BUFF_ID)
$INJECTPOSTBUFF$
endif
endif
else
//Unit doesn't have the buff we're trying to remove
return false
endif
return true
endfunction
private struct $STRUCTNAME$
timer t
unit tar
real dur
private static method end takes nothing returns nothing
call thistype(GetTimerData(GetExpiredTimer())).destroy()
endmethod
static method start takes unit target, real duration returns boolean
local thistype s
local boolean b = $TYPE$Unit(target, true)
if not b then
//Failed, return false
return false
endif
set s = thistype.allocate()
set s.tar = target
set s.dur = duration
set s.t = NewTimer()
call SetTimerData(s.t, integer(s))
call TimerStart(s.t, duration, false, function $STRUCTNAME$.end)
return true
endmethod
private method onDestroy takes nothing returns nothing
call $TYPE$Unit(.tar, false)
call ReleaseTimer(.t)
endmethod
endstruct
function $TYPE$UnitTimed takes unit whichUnit, real duration returns boolean
if duration <= 0.01 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Less than 0.01 duration given to $TYPE$UnitTimed")
return false
endif
return $STRUCTNAME$.start(whichUnit, duration)
endfunction
//! endtextmacro
//******************************************************************************
//Declare all necessary globals first
globals
private integer array StunCounter
private integer array SilenceCounter
private integer array DisarmCounter
private integer array EnsnareCounter
private integer array DisableCounter
endglobals
//Special functions for Stun
private function StunLingeringDisable takes unit u returns nothing
local integer id = GetUnitId(u)
if DisableCounter[id] > 0 then
//Add the disabled buff because it lingers on
call UnitShareVision(u, GetOwningPlayer(Caster), true)
call IssueTargetOrderById(Caster, DISABLE_ORDER_ID, u)
call UnitShareVision(u, GetOwningPlayer(Caster), false)
endif
endfunction
private function StunFinishDisable takes unit u returns nothing
local integer id = GetUnitId(u)
if DisableCounter[id] > 0 then
//Remove the disable buff for first refcount stun
call UnitRemoveAbility(u, DISABLE_BUFF_ID)
endif
endfunction
//Generates all of the base code
//! runtextmacro UnitStatus_GenerateBase("Stun" , "STUN" , "stun" , "call StunLingeringDisable(whichUnit)", "", "call StunFinishDisable(whichUnit)")
//! runtextmacro UnitStatus_GenerateBase("Silence", "SILENCE", "silence", "", "", "")
//! runtextmacro UnitStatus_GenerateBase("Disarm" , "DISARM" , "disarm" , "", "", "")
//! runtextmacro UnitStatus_GenerateBase("Ensnare", "ENSNARE", "ensnare", "call UnitRemoveAbility(whichUnit, ENSNARE_BUFF_ID2)", "", "")
//! runtextmacro UnitStatus_GenerateBase("Disable", "DISABLE", "disable", "", "and StunCounter[id] == 0", "")
private function Init takes nothing returns nothing
static if LIBRARY_xebasic then
set Caster = CreateUnit(Player(15), XE_DUMMY_UNITID, 0., 0., 0.)
else
set Caster = CreateUnit(Player(15), DUMMY_UNITID , 0., 0., 0.)
endif
call UnitRemoveAbility(Caster, 'Amov')
if GetUnitAbilityLevel(Caster, 'Aloc') == 0 then
call UnitAddAbility(Caster, 'Aloc') //xe dummies don't have this automatically
endif
//Add the abilities
call UnitAddAbility(Caster, STUN_ID)
call UnitAddAbility(Caster, SILENCE_ID)
call UnitAddAbility(Caster, DISARM_ID)
call UnitAddAbility(Caster, ENSNARE_ID)
call UnitAddAbility(Caster, DISABLE_ID)
endfunction
endlibrary
library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 3.1.0.1
One map, one hashtable. Welcome to NewTable 3.1
This library was originally called NewTable so it didn't conflict with
the API of Table by Vexorian. However, the damage is done and it's too
late to change the library name now. To help with damage control, I
have provided an extension library called TableBC, which bridges all
the functionality of Vexorian's Table except for 2-D string arrays &
the ".flush(integer)" method. I use ".flush()" to flush a child hash-
table, because I wanted the API in NewTable to reflect the API of real
hashtables (I thought this would be more intuitive).
API
------------
struct Table
| static method create takes nothing returns Table
| create a new Table
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush all stored values inside of it
|
| method remove takes integer key returns nothing
| remove the value at index "key"
|
| method operator []= takes integer key, $TYPE$ value returns nothing
| assign "value" to index "key"
|
| method operator [] takes integer key returns $TYPE$
| load the value at index "key"
|
| method has takes integer key returns boolean
| whether or not the key was assigned
|
----------------
struct TableArray
| static method operator [] takes integer array_size returns TableArray
| create a new array of Tables of size "array_size"
|
| method destroy takes nothing returns nothing
| destroy it
|
| method flush takes nothing returns nothing
| flush and destroy it
|
| method operator size takes nothing returns integer
| returns the size of the TableArray
|
| method operator [] takes integer key returns Table
| returns a Table accessible exclusively to index "key"
*/
globals
private integer less = 0 //Index generation for TableArrays (below 0).
private integer more = 8190 //Index generation for Tables.
//Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
private hashtable ht = InitHashtable()
private key sizeK
private key listK
endglobals
private struct dex extends array
static method operator size takes nothing returns Table
return sizeK
endmethod
static method operator list takes nothing returns Table
return listK
endmethod
endstruct
private struct handles extends array
method has takes integer key returns boolean
return HaveSavedHandle(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSavedHandle(ht, this, key)
endmethod
endstruct
private struct agents extends array
method operator []= takes integer key, agent value returns nothing
call SaveAgentHandle(ht, this, key, value)
endmethod
endstruct
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$(ht, this, key, value)
endmethod
method has takes integer key returns boolean
return HaveSaved$SUPER$(ht, this, key)
endmethod
method remove takes integer key returns nothing
call RemoveSaved$SUPER$(ht, this, key)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
method operator [] takes integer key returns $TYPE$
return Load$FUNC$Handle(ht, this, key)
endmethod
method operator []= takes integer key, $TYPE$ value returns nothing
call Save$FUNC$Handle(ht, this, key, value)
endmethod
endstruct
private module $TYPE$m
method operator $TYPE$ takes nothing returns $TYPE$s
return this
endmethod
endmodule
//! endtextmacro
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
struct Table extends array
// Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
implement realm
implement booleanm
implement stringm
implement playerm
implement widgetm
implement destructablem
implement itemm
implement unitm
implement abilitym
implement timerm
implement triggerm
implement triggerconditionm
implement triggeractionm
implement eventm
implement forcem
implement groupm
implement locationm
implement rectm
implement boolexprm
implement soundm
implement effectm
implement unitpoolm
implement itempoolm
implement questm
implement questitemm
implement defeatconditionm
implement timerdialogm
implement leaderboardm
implement multiboardm
implement multiboarditemm
implement trackablem
implement dialogm
implement buttonm
implement texttagm
implement lightningm
implement imagem
implement ubersplatm
implement regionm
implement fogstatem
implement fogmodifierm
implement hashtablem
method operator handle takes nothing returns handles
return this
endmethod
method operator agent takes nothing returns agents
return this
endmethod
//set this = tb[GetSpellAbilityId()]
method operator [] takes integer key returns Table
return LoadInteger(ht, this, key)
endmethod
//set tb[389034] = 8192
method operator []= takes integer key, Table tb returns nothing
call SaveInteger(ht, this, key, tb)
endmethod
//set b = tb.has(2493223)
method has takes integer key returns boolean
return HaveSavedInteger(ht, this, key)
endmethod
//call tb.remove(294080)
method remove takes integer key returns nothing
call RemoveSavedInteger(ht, this, key)
endmethod
//Remove all data from a Table instance
method flush takes nothing returns nothing
call FlushChildHashtable(ht, this)
endmethod
//local Table tb = Table.create()
static method create takes nothing returns Table
local Table this = dex.list[0]
if this == 0 then
set this = more + 1
set more = this
else
set dex.list[0] = dex.list[this]
call dex.list.remove(this) //Clear hashed memory
endif
debug set dex.list[this] = -1
return this
endmethod
// Removes all data from a Table instance and recycles its index.
//
// call tb.destroy()
//
method destroy takes nothing returns nothing
debug if dex.list[this] != -1 then
debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
debug return
debug endif
call this.flush()
set dex.list[this] = dex.list[0]
set dex.list[0] = this
endmethod
//! runtextmacro optional TABLE_BC_METHODS()
endstruct
//! runtextmacro optional TABLE_BC_STRUCTS()
struct TableArray extends array
//Returns a new TableArray to do your bidding. Simply use:
//
// local TableArray ta = TableArray[array_size]
//
static method operator [] takes integer array_size returns TableArray
local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
local TableArray this = tb[0] //The last-destroyed TableArray that had this array size
debug if array_size <= 0 then
debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
debug return 0
debug endif
if this == 0 then
set this = less - array_size
set less = this
else
set tb[0] = tb[this] //Set the last destroyed to the last-last destroyed
call tb.remove(this) //Clear hashed memory
endif
set dex.size[this] = array_size //This remembers the array size
return this
endmethod
//Returns the size of the TableArray
method operator size takes nothing returns integer
return dex.size[this]
endmethod
//This magic method enables two-dimensional[array][syntax] for Tables,
//similar to the two-dimensional utility provided by hashtables them-
//selves.
//
//ta[integer a].unit[integer b] = unit u
//ta[integer a][integer c] = integer d
//
//Inline-friendly when not running in debug mode
//
method operator [] takes integer key returns Table
static if DEBUG_MODE then
local integer i = this.size
if i == 0 then
call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
return 0
elseif key < 0 or key >= i then
call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
return 0
endif
endif
return this + key
endmethod
//Destroys a TableArray without flushing it; I assume you call .flush()
//if you want it flushed too. This is a public method so that you don't
//have to loop through all TableArray indices to flush them if you don't
//need to (ie. if you were flushing all child-keys as you used them).
//
method destroy takes nothing returns nothing
local Table tb = dex.size[this.size]
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
debug return
debug endif
if tb == 0 then
//Create a Table to index recycled instances with their array size
set tb = Table.create()
set dex.size[this.size] = tb
endif
call dex.size.remove(this) //Clear the array size from hash memory
set tb[this] = tb[0]
set tb[0] = this
endmethod
private static Table tempTable
private static integer tempEnd
//Avoids hitting the op limit
private static method clean takes nothing returns nothing
local Table tb = .tempTable
local integer end = tb + 0x1000
if end < .tempEnd then
set .tempTable = end
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
else
set end = .tempEnd
endif
loop
call tb.flush()
set tb = tb + 1
exitwhen tb == end
endloop
endmethod
//Flushes the TableArray and also destroys it. Doesn't get any more
//similar to the FlushParentHashtable native than this.
//
method flush takes nothing returns nothing
debug if this.size == 0 then
debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
debug return
debug endif
set .tempTable = this
set .tempEnd = this + this.size
call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
call this.destroy()
endmethod
endstruct
endlibrary
//TESH.scrollpos=30
//TESH.alwaysfold=0
library TableBC requires Table
/*
Backwards-compatibility add-on for scripts employing Vexorian's Table.
Disclaimer:
The following error does not occur with HandleTables & StringTables, only
with the standard, integer-based Table, so you do not need to make any
changes to StringTable/HandleTable-employing scripts.
The this.flush(key) method from the original Table cannot be parsed with
the new Table. For the scripts that use this method, they need to be up-
dated to use the more fitting this.remove(key) method.
Please don't try using StringTables/HandleTables with features exclusive
to the new Table as they will cause syntax errors. I do not have any plan
to endorse these types of Tables because delegation in JassHelper is not
advanced enough for three types of Tables without copying every single
method over again (as you can see this already generates plenty of code).
StringTable & HandleTable are wrappers for StringHash & GetHandleId, so
just type them out.
*/
//! textmacro TABLE_BC_METHODS
method reset takes nothing returns nothing
call this.flush()
endmethod
method exists takes integer key returns boolean
return this.has(key)
endmethod
//! endtextmacro
//! textmacro TABLE_BC_STRUCTS
struct HandleTable extends array
method operator [] takes handle key returns integer
return Table(this)[GetHandleId(key)]
endmethod
method operator []= takes handle key, integer value returns nothing
set Table(this)[GetHandleId(key)] = value
endmethod
method flush takes handle key returns nothing
call Table(this).remove(GetHandleId(key))
endmethod
method exists takes handle key returns boolean
return Table(this).has(GetHandleId(key))
endmethod
method reset takes nothing returns nothing
call Table(this).flush()
endmethod
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
struct StringTable extends array
method operator [] takes string key returns integer
return Table(this)[StringHash(key)]
endmethod
method operator []= takes string key, integer value returns nothing
set Table(this)[StringHash(key)] = value
endmethod
method flush takes string key returns nothing
call Table(this).remove(StringHash(key))
endmethod
method exists takes string key returns boolean
return Table(this).has(StringHash(key))
endmethod
method reset takes nothing returns nothing
call Table(this).flush()
endmethod
method destroy takes nothing returns nothing
call Table(this).destroy()
endmethod
static method create takes nothing returns thistype
return Table.create()
endmethod
endstruct
//! endtextmacro
endlibrary
/**************************************************************
*
* RegisterPlayerUnitEvent
* v5.1.0.1
* By Magtheridon96
*
* I would like to give a special thanks to Bribe, azlier
* and BBQ for improving this library. For modularity, it only
* supports player unit events.
*
* Functions passed to RegisterPlayerUnitEvent must either
* return a boolean (false) or nothing. (Which is a Pro)
*
* Warning:
* --------
*
* - Don't use TriggerSleepAction inside registered code.
* - Don't destroy a trigger unless you really know what you're doing.
*
* API:
* ----
*
* - function RegisterPlayerUnitEvent takes playerunitevent whichEvent, code whichFunction returns nothing
* - Registers code that will execute when an event fires.
* - function RegisterPlayerUnitEventForPlayer takes playerunitevent whichEvent, code whichFunction, player whichPlayer returns nothing
* - Registers code that will execute when an event fires for a certain player.
* - function GetPlayerUnitEventTrigger takes playerunitevent whichEvent returns trigger
* - Returns the trigger corresponding to ALL functions of a playerunitevent.
*
**************************************************************/
library RegisterPlayerUnitEvent // Special Thanks to Bribe and azlier
globals
private trigger array t
endglobals
function RegisterPlayerUnitEvent takes playerunitevent p, code c returns nothing
local integer i = GetHandleId(p)
local integer k = 27
if t[i] == null then
set t[i] = CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(t[i], Player(k), p, null)
exitwhen k == 0
set k = k - 1
endloop
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function RegisterPlayerUnitEventForPlayer takes playerunitevent p, code c, player pl returns nothing
local integer i = 16 * GetHandleId(p) + GetPlayerId(pl)
if t[i] == null then
set t[i] = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t[i], pl, p, null)
endif
call TriggerAddCondition(t[i], Filter(c))
endfunction
function GetPlayerUnitEventTrigger takes playerunitevent p returns trigger
return t[GetHandleId(p)]
endfunction
endlibrary
//TESH.scrollpos=27
//TESH.alwaysfold=0
//============================================================================
// SpellEffectEvent
// - Version 1.1.0.0
//
// API
// ---
// RegisterSpellEffectEvent(integer abil, code onCast)
//
// Requires
// --------
// RegisterPlayerUnitEvent: hiveworkshop.com/forums/showthread.php?t=203338
//
// Optional
// --------
// Table: hiveworkshop.com/forums/showthread.php?t=188084
//
library SpellEffectEvent requires RegisterPlayerUnitEvent, optional Table
//============================================================================
private module M
static if LIBRARY_Table then
static Table tb
else
static hashtable ht = InitHashtable()
endif
static method onCast takes nothing returns nothing
static if LIBRARY_Table then
call TriggerEvaluate(.tb.trigger[GetSpellAbilityId()])
else
call TriggerEvaluate(LoadTriggerHandle(.ht, 0, GetSpellAbilityId()))
endif
endmethod
private static method onInit takes nothing returns nothing
static if LIBRARY_Table then
set .tb = Table.create()
endif
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.onCast)
endmethod
endmodule
//============================================================================
private struct S extends array
implement M
endstruct
//============================================================================
function RegisterSpellEffectEvent takes integer abil, code onCast returns nothing
static if LIBRARY_Table then
if not S.tb.handle.has(abil) then
set S.tb.trigger[abil] = CreateTrigger()
endif
call TriggerAddCondition(S.tb.trigger[abil], Filter(onCast))
else
if not HaveSavedHandle(S.ht, 0, abil) then
call SaveTriggerHandle(S.ht, 0, abil, CreateTrigger())
endif
call TriggerAddCondition(LoadTriggerHandle(S.ht, 0, abil), Filter(onCast))
endif
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library TerrainPathability initializer Init
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This script can be used to detect the type of pathing at a specific point.
//* It is valuable to do it this way because the IsTerrainPathable is very
//* counterintuitive and returns in odd ways and aren't always as you would
//* expect. This library, however, facilitates detecting those things reliably
//* and easily.
//*
//******************************************************************************
//*
//* > function IsTerrainDeepWater takes real x, real y returns boolean
//* > function IsTerrainShallowWater takes real x, real y returns boolean
//* > function IsTerrainLand takes real x, real y returns boolean
//* > function IsTerrainPlatform takes real x, real y returns boolean
//* > function IsTerrainWalkable takes real x, real y returns boolean
//*
//* These functions return true if the given point is of the type specified
//* in the function's name and false if it is not. For the IsTerrainWalkable
//* function, the MAX_RANGE constant below is the maximum deviation range from
//* the supplied coordinates that will still return true.
//*
//* The IsTerrainPlatform works for any preplaced walkable destructable. It will
//* return true over bridges, destructable ramps, elevators, and invisible
//* platforms. Walkable destructables created at runtime do not create the same
//* pathing hole as preplaced ones do, so this will return false for them. All
//* other functions except IsTerrainWalkable return false for platforms, because
//* the platform itself erases their pathing when the map is saved.
//*
//* After calling IsTerrainWalkable(x, y), the following two global variables
//* gain meaning. They return the X and Y coordinates of the nearest walkable
//* point to the specified coordinates. These will only deviate from the
//* IsTerrainWalkable function arguments if the function returned false.
//*
//* Variables that can be used from the library:
//* [real] TerrainPathability_X
//* [real] TerrainPathability_Y
//*
globals
private constant real MAX_RANGE = 10.
private constant integer DUMMY_ITEM_ID = 'wolg'
endglobals
globals
private item Item = null
private rect Find = null
private item array Hid
private integer HidMax = 0
public real X = 0.
public real Y = 0.
endglobals
function IsTerrainDeepWater takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
endfunction
function IsTerrainShallowWater takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
endfunction
function IsTerrainLand takes real x, real y returns boolean
return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
endfunction
function IsTerrainPlatform takes real x, real y returns boolean
return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_BUILDABILITY)
endfunction
private function HideItem takes nothing returns nothing
if IsItemVisible(GetEnumItem()) then
set Hid[HidMax] = GetEnumItem()
call SetItemVisible(Hid[HidMax], false)
set HidMax = HidMax + 1
endif
endfunction
function IsTerrainWalkable takes real x, real y returns boolean
//Hide any items in the area to avoid conflicts with our item
call MoveRectTo(Find, x, y)
call EnumItemsInRect(Find ,null, function HideItem)
//Try to move the test item and get its coords
call SetItemPosition(Item, x, y) //Unhides the item
set X = GetItemX(Item)
set Y = GetItemY(Item)
static if LIBRARY_IsTerrainWalkable then
//This is for compatibility with the IsTerrainWalkable library
set IsTerrainWalkable_X = X
set IsTerrainWalkable_Y = Y
endif
call SetItemVisible(Item, false)//Hide it again
//Unhide any items hidden at the start
loop
exitwhen HidMax <= 0
set HidMax = HidMax - 1
call SetItemVisible(Hid[HidMax], true)
set Hid[HidMax] = null
endloop
//Return walkability
return (X-x)*(X-x)+(Y-y)*(Y-y) <= MAX_RANGE*MAX_RANGE and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
endfunction
private function Init takes nothing returns nothing
set Find = Rect(0., 0., 128., 128.)
set Item = CreateItem(DUMMY_ITEM_ID, 0, 0)
call SetItemVisible(Item, false)
endfunction
endlibrary
//TESH.scrollpos=292
//TESH.alwaysfold=0
library Multiboard /* v2.0.0.1
*************************************************************************************
*
* Multiboard Struct API that actually works and is actually easy to use.
*
*************************************************************************************
*
* */uses/*
*
* */ Table /* hiveworkshop.com/forums/jass-functions-413/snippet-new-table-188084/
*
************************************************************************************
*
* struct Multiboard
*
* string title
* boolean display
* boolean minimize
* boolean suppress
*
* real width= (set only)
* string icon= (set only)
* string text= (set only)
*
* readonly MultiboardRow row
* readonly MultiboardColumn column
*
* this[row][column] -> MultiboardItem
*
* static method create takes integer rowCount, integer columnCount returns Multiboard
* method destroy takes nothing returns nothing
*
* method clear takes nothing returns nothing
*
* method setTitleColor takes integer red, integer green, integer blue, integer alpha returns nothing
* method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
* method setStyle takes boolean showValues, boolean showIcons returns nothing
*
************************************************************************************
*
* struct MultiboardRow extends array
* struct MultiboardColumn extends array
*
* integer count
* - row.count
*
* string text
* string icon=
* real width=
* - row[0].width
*
* method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
* method setStyle takes boolean showValue, boolean showIcon returns nothing
* - row[0].setStyle
*
************************************************************************************
*
* struct MultiboardItem extends array
*
* string text= (set only)
* string icon= (set only)
* real width= (set only)
*
* method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
* method setStyle takes boolean showValue, boolean showIcon returns nothing
*
************************************************************************************/
globals
private Table table
private Table table2
private integer array r
private integer ic = 0
private multiboard array boardp
private integer array rc
private integer array cc
private boolean array suppressed
endglobals
private module Init
private static method onInit takes nothing returns nothing
set table = Table.create()
set table2 = Table.create()
endmethod
endmodule
struct MultiboardItem extends array
method operator text= takes string value returns nothing
call MultiboardSetItemValue(table.multiboarditem[this], value)
endmethod
method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
call MultiboardSetItemValueColor(table.multiboarditem[this], red, green, blue, alpha)
endmethod
method setStyle takes boolean showValue, boolean showIcon returns nothing
call MultiboardSetItemStyle(table.multiboarditem[this], showValue, showIcon)
endmethod
method operator icon= takes string str returns nothing
call MultiboardSetItemIcon(table.multiboarditem[this], str)
endmethod
method operator width= takes real percent returns nothing
call MultiboardSetItemWidth(table.multiboarditem[this], percent)
endmethod
implement Init
endstruct
//! textmacro MULTIBOARD_LOOPER takes ROW, TABLE, CODE
local multiboarditem mb
loop
exitwhen 0 == $ROW$
set mb = $TABLE$.multiboarditem[this]
call $CODE$
set this = this + 1
set $ROW$ = $ROW$ - 1
endloop
set mb = null
//! endtextmacro
private keyword Multiboard2D
private keyword getItems
private keyword clearItems
struct Multiboard extends array
method getItems takes nothing returns nothing
local integer row = rc[this]
local integer column
local multiboarditem mb
loop
set column = cc[this]
loop
set mb = MultiboardGetItem(boardp[this], row, column)
set table.multiboarditem[(this*500+row)*500+column] = mb
set table2.multiboarditem[(this*500+column)*500+row] = mb
exitwhen 0 == column
set column = column - 1
endloop
exitwhen 0 == row
set row = row - 1
endloop
set mb = null
endmethod
method clearItems takes nothing returns nothing
local integer row = rc[this]
local integer column
loop
set column = cc[this]
loop
call MultiboardReleaseItem(table.multiboarditem[(this*500+row)*500+column])
call table.handle.remove((this*500+row)*500+column)
call table2.handle.remove((this*500+column)*500+row)
exitwhen 0 == column
set column = column - 1
endloop
exitwhen 0 == row
set row = row - 1
endloop
endmethod
static method create takes integer rowCount, integer columnCount returns thistype
local thistype this = r[0]
if (0 == this) then
set this = ic + 1
set ic = this
else
set suppressed[this] = false
set r[0] = r[this]
endif
set boardp[this] = CreateMultiboard()
call MultiboardSetColumnCount(boardp[this], columnCount)
call MultiboardSetRowCount(boardp[this], rowCount)
set rc[this] = rowCount
set cc[this] = columnCount
call getItems()
return this
endmethod
method destroy takes nothing returns nothing
set r[this] = r[0]
set r[0] = this
call clearItems()
call DestroyMultiboard(boardp[this])
set boardp[this] = null
endmethod
method clear takes nothing returns nothing
call MultiboardClear(boardp[this])
endmethod
method operator display takes nothing returns boolean
return IsMultiboardDisplayed(boardp[this])
endmethod
method operator display= takes boolean b returns nothing
call MultiboardDisplay(boardp[this], b)
endmethod
method operator minimize takes nothing returns boolean
return IsMultiboardMinimized(boardp[this])
endmethod
method operator minimize= takes boolean b returns nothing
call MultiboardMinimize(boardp[this], b)
endmethod
method operator title takes nothing returns string
return MultiboardGetTitleText(boardp[this])
endmethod
method operator title= takes string txt returns nothing
call MultiboardSetTitleText(boardp[this], txt)
endmethod
method setTitleColor takes integer red, integer green, integer blue, integer alpha returns nothing
call MultiboardSetTitleTextColor(boardp[this], red, green, blue, alpha)
endmethod
method operator suppress takes nothing returns boolean
return suppressed[this]
endmethod
method operator suppress= takes boolean b returns nothing
set suppressed[this] = b
call MultiboardSuppressDisplay(b)
endmethod
method operator width= takes real percent returns nothing
call MultiboardSetItemsWidth(boardp[this], percent)
endmethod
method operator row takes nothing returns MultiboardRow
return this
endmethod
method operator column takes nothing returns MultiboardColumn
return this
endmethod
method operator [] takes integer row returns Multiboard2D
return this*500+row
endmethod
method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
call MultiboardSetItemsValueColor(boardp[this], red, green, blue, alpha)
endmethod
method setStyle takes boolean showValues, boolean showIcons returns nothing
call MultiboardSetItemsStyle(boardp[this], showValues, showIcons)
endmethod
method operator icon= takes string txt returns nothing
call MultiboardSetItemsIcon(boardp[this], txt)
endmethod
method operator text= takes string txt returns nothing
call MultiboardSetItemsValue(boardp[this], txt)
endmethod
endstruct
private struct MultiboardSet extends array
method text takes string v, integer c, Table t returns nothing
//! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemValue(mb, v)")
endmethod
method color takes integer red, integer green, integer blue, integer alpha, integer c, Table t returns nothing
//! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemValueColor(mb, red, green, blue, alpha)")
endmethod
method style takes boolean v, boolean i, integer c, Table t returns nothing
//! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemStyle(mb, v, i)")
endmethod
method icon takes string s, integer c, Table t returns nothing
//! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemIcon(mb, s)")
endmethod
method width takes real p, integer c, Table t returns nothing
//! runtextmacro MULTIBOARD_LOOPER("c", "t", "MultiboardSetItemWidth(mb, p)")
endmethod
endstruct
struct MultiboardColumn extends array
method operator count takes nothing returns integer
return MultiboardGetColumnCount(boardp[this])
endmethod
method operator count= takes integer columns returns nothing
call Multiboard(this).clearItems()
call MultiboardSetColumnCount(boardp[this], columns)
set cc[this] = columns
call Multiboard(this).getItems()
endmethod
method operator text= takes string value returns nothing
call MultiboardSet(this).text(value, rc[this/250000], table2)
endmethod
method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
call MultiboardSet(this).color(red, green, blue, alpha, rc[this/250000], table2)
endmethod
method setStyle takes boolean showValue, boolean showIcon returns nothing
call MultiboardSet(this).style(showValue, showIcon, rc[this/250000], table2)
endmethod
method operator icon= takes string str returns nothing
call MultiboardSet(this).icon(str, rc[this/250000], table2)
endmethod
method operator width= takes real percent returns nothing
call MultiboardSet(this).width(percent, rc[this/250000], table2)
endmethod
method operator [] takes integer column returns thistype
return (this*500+column)*500
endmethod
endstruct
struct MultiboardRow extends array
method operator count takes nothing returns integer
return MultiboardGetRowCount(boardp[this])
endmethod
method operator count= takes integer rows returns nothing
call Multiboard(this).clearItems()
call MultiboardSetRowCount(boardp[this], rows)
set rc[this] = rows
call Multiboard(this).getItems()
endmethod
method operator text= takes string value returns nothing
call MultiboardSet(this).text(value, cc[this/250000], table)
endmethod
method setColor takes integer red, integer green, integer blue, integer alpha returns nothing
call MultiboardSet(this).color(red, green, blue, alpha, cc[this/250000], table)
endmethod
method setStyle takes boolean showValue, boolean showIcon returns nothing
call MultiboardSet(this).style(showValue, showIcon, cc[this/250000], table)
endmethod
method operator icon= takes string str returns nothing
call MultiboardSet(this).icon(str, cc[this/250000], table)
endmethod
method operator width= takes real percent returns nothing
call MultiboardSet(this).width(percent,cc[this/250000], table)
endmethod
method operator [] takes integer row returns thistype
return (this*500+row)*500
endmethod
endstruct
private struct Multiboard2D extends array
method operator [] takes integer column returns MultiboardItem
return this*500+column
endmethod
endstruct
endlibrary
//TESH.scrollpos=17
//TESH.alwaysfold=0
library Event /* v2.0.0.1
************************************************************************************
*
* Functions
*
* function CreateEvent takes nothing returns integer
* function TriggerRegisterEvent takes trigger t, integer ev returns nothing
*
************************************************************************************
*
* struct Event extends array
*
* static method create takes nothing returns thistype
* method registerTrigger takes trigger t returns nothing
* method register takes boolexpr c returns nothing
* method fire takes nothing returns nothing
*
************************************************************************************/
globals
private real q=0
endglobals
struct Event extends array
private static integer w=0
private static trigger array e
static method create takes nothing returns thistype
set w=w+1
set e[w]=CreateTrigger()
return w
endmethod
method registerTrigger takes trigger t returns nothing
call TriggerRegisterVariableEvent(t,SCOPE_PRIVATE+"q",EQUAL,this)
endmethod
method register takes code c returns nothing
call TriggerAddCondition(e[this],Condition(c))
endmethod
method fire takes nothing returns nothing
set q=0
set q=this
call TriggerEvaluate(e[this])
endmethod
endstruct
function CreateEvent takes nothing returns Event
return Event.create()
endfunction
function TriggerRegisterEvent takes trigger t,Event ev returns nothing
call ev.registerTrigger(t)
endfunction
function RegisterEvent takes code c,Event ev returns nothing
call ev.register(c)
endfunction
function FireEvent takes Event ev returns nothing
call ev.fire()
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Dummy initializer init requires Constants
globals
private unit dummy
endglobals
function dummyCast takes unit u, integer a, string o returns nothing
call UnitAddAbility(dummy, a)
call IssueTargetOrder(dummy, o, u)
call UnitRemoveAbility(dummy, a)
endfunction
private function init takes nothing returns nothing
set dummy = CreateUnit(DUMMY_OWNER, DUMMY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
call SetUnitPathing(dummy, false)
call SetUnitX(dummy, DUMMY_X)
call SetUnitY(dummy, DUMMY_Y)
endfunction
endlibrary
library Utilities initializer init requires AutoIndex, UnitStatus, Dummy, GetTerrainZ, UnitZ
globals
constant group enumGroup = CreateGroup()
endglobals
//! textmacro TEMP takes type, name
globals
$type$ temp$name$
$type$ temp$name$2
endglobals
//! endtextmacro
//! runtextmacro TEMP("unit", "Unit")
//! runtextmacro TEMP("integer", "Integer")
//! runtextmacro TEMP("boolean", "Boolean")
//! runtextmacro TEMP("real", "Real")
//! runtextmacro TEMP("trigger", "Trigger")
//! runtextmacro TEMP("widget", "Widget")
//! runtextmacro TEMP("string", "String")
//! runtextmacro TEMP("player", "Player")
//! runtextmacro TEMP("rect", "Rect")
function IsUnitDisabled takes unit u returns boolean
return GetUnitAbilityLevel(u, DISABLE_BUFF_RAWCODE) > 0
endfunction
function Seconds2Time takes real r returns string
local integer h
local integer m
local integer s = R2I(r)
local string t
set h = s/3600
set m = (s - h*3600)/60
set s = s - h*3600 - m*60
set t = I2S(h)+":"
if m < 10 then
set t = t+"0"+I2S(m)+":"
else
set t = t+I2S(m)+":"
endif
if s < 10 then
set t = t+"0"+I2S(s)
else
set t = t+I2S(s)
endif
if h == 0 then
set t = SubString(t, 2, 7)
endif
return t
endfunction
function Time2Seconds takes string t returns real
local integer array f
local integer i = StringLength(t)
local integer n = 2
loop
loop
exitwhen i == 0 or SubString(t, i - 1, i) == ":"
set i = i - 1
endloop
set f[n] = S2I(SubString(t, i, StringLength(t)))
exitwhen i == 0
set i = i - 1
set t = SubString(t, 0, i)
set n = n - 1
endloop
return f[0]*3600.0 + f[1]*60.0 + f[2]
endfunction
function Sfx takes string path, real x, real y, real z, real facing, real pitch, real size returns nothing
local unit d = CreateUnit(DUMMY_OWNER, SFX_DUMMY_RAWCODE, x, y, facing)
call SetUnitX(d, x)
call SetUnitY(d, y)
call SetUnitZ(d, z)
call SetUnitScale(d, size, size, size)
call UnitApplyTimedLife(d, 'BTLF', 8.00)
call SetUnitAnimationByIndex(d, R2I(pitch))
call DestroyEffect(AddSpecialEffectTarget(path, d, "origin"))
endfunction
function TestUnit takes real x, real y returns unit
return CreateUnit(Player(0), 'hfoo', x, y, 0.00)
endfunction
function Print takes string s returns nothing
call BJDebugMsg(s)
endfunction
function PrintInt takes integer i returns nothing
call BJDebugMsg(I2S(i))
endfunction
function PrintReal takes real r returns nothing
call BJDebugMsg(R2S(r))
endfunction
function DistanceBetweenUnits takes unit u1, unit u2 returns real
local real x = GetUnitX(u2) - GetUnitX(u1)
local real y = GetUnitY(u2) - GetUnitY(u1)
return SquareRoot(x*x + y*y)
endfunction
globals
private texttag t
endglobals
function TextTag takes string text, real size, real x, real y, real z, real ls returns texttag
set t = CreateTextTag()
call SetTextTagText(t, text, size)
call SetTextTagPos(t, x, y, z - GetTerrainZ(x, y))
call SetTextTagLifespan(t, ls)
call SetTextTagFadepoint(t, ls - 0.50)
call SetTextTagPermanent(t, false)
call SetTextTagVelocity(t, 0.00, 130.0 * 0.071 / 128)
return t
endfunction
function sgn takes real r returns integer
if r < 0 then
return -1
elseif r > 0 then
return 1
endif
return 0
endfunction
function Digits takes integer i returns integer
local integer d = 1
set d = d + 1*sgn(i/10)
set d = d + 1*sgn(i/100)
return d
endfunction
function Spaces takes integer i returns string
local string s = ""
loop
exitwhen i == 0
set s = s + " "
set i = i - 1
endloop
return s
endfunction
globals
private unit array units
endglobals
function GetUnitById takes integer id returns unit
return units[id]
endfunction
private function index takes unit u returns nothing
set units[GetUnitId(u)] = u
endfunction
private function deindex takes unit u returns nothing
set units[GetUnitId(u)] = null
endfunction
private function init takes nothing returns nothing
call OnUnitIndexed(index)
call OnUnitDeindexed(deindex)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Sounds initializer init requires Table
globals
private TableArray sounds
endglobals
function Play takes string s returns nothing
local integer h = StringHash(s)
call StartSound(sounds[sounds[0][h]].sound[h])
if sounds[0][h] == 9 then
set sounds[0][h] = 0
else
set sounds[0][h] = sounds[0][h] + 1
endif
endfunction
function InitSound takes string s returns nothing
local integer i = 0
local integer h = StringHash(s)
local sound snd = CreateSound(s, false, false, false, 12700, 12700, "")
loop
set sounds[i].sound[h] = snd
set sounds[0][h] = 0
set i = i + 1
exitwhen i == 10
endloop
endfunction
private function init takes nothing returns nothing
set sounds = TableArray[10]
endfunction
endlibrary
//TESH.scrollpos=27
//TESH.alwaysfold=0
library Camera initializer init requires Constants, Players
globals
private real camDistance = CAMERA_DEFAULT_DISTANCE
private real camAngleOfAttack = bj_CAMERA_DEFAULT_AOA
private real camRotation = bj_CAMERA_DEFAULT_ROTATION
boolean camAdjustment = false
private boolean altCam = false
endglobals
function camAdjust takes nothing returns nothing
if camAdjustment and camDistance != 0.00 then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, camDistance, 0.00)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, camAngleOfAttack, 0.00)
call SetCameraField(CAMERA_FIELD_ROTATION, camRotation, 0.00)
endif
endfunction
private function camSet takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local Ball ball = Ball.balls[0]
local integer n
local player p = null
if SubString(s, 0, 5) == "-cam " then
set camDistance = S2R(SubString(s, 5, 9))
if not camAdjustment and camDistance == 0.00 then
set camDistance = CAMERA_DEFAULT_DISTANCE
endif
elseif SubString(s, 0, 6) == "-zoom " then
set camDistance = S2R(SubString(s, 6, 10))
if not camAdjustment and camDistance == 0.00 then
set camDistance = CAMERA_DEFAULT_DISTANCE
endif
endif
if s == "-alt cam" then
if altCam then
set camRotation = bj_CAMERA_DEFAULT_ROTATION
set camAngleOfAttack = bj_CAMERA_DEFAULT_AOA
set altCam = false
else
set camRotation = 180.0*GetPlayerTeam(GetLocalPlayer())
set camAngleOfAttack = camAngleOfAttack + CAMERA_ALTERNATE_ANGLE_DIFFERENCE
set altCam = true
endif
endif
if camAdjustment then
if camDistance == 0.00 then
call CameraSetSourceNoiseEx(10000.00, 1000.00, false)
else
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, camDistance, 0.00)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, camAngleOfAttack, 0.00)
call SetCameraField(CAMERA_FIELD_ROTATION, camRotation, 0.00)
call CameraSetSourceNoiseEx(0.00, 0.00, false)
endif
endif
return false
endfunction
private function init takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), "-cam", false)
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), "-zoom", false)
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), "-alt cam", false)
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), "-lock", false)
call TriggerRegisterPlayerChatEvent(t, GetLocalPlayer(), "-unlock", false)
call TriggerAddCondition(t, function camSet)
static if not TEST then
call TimerStart(CreateTimer(), 0.50, true, function camAdjust)
endif
set t = null
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library AutoFly initializer init requires AutoIndex, xebasic
private function enableFlight takes unit u returns nothing
if UnitAddAbility(u, XE_HEIGHT_ENABLER) then
call UnitRemoveAbility(u, XE_HEIGHT_ENABLER)
endif
endfunction
private function init takes nothing returns nothing
call OnUnitIndexed(enableFlight)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library GetTerrainZ /* v1.0.0.0
********************************************************************
*
* function GetTerrainZ takes real x, real y returns real
*
********************************************************************/
globals
private constant location L = Location(0, 0)
endglobals
function GetTerrainZ takes real x, real y returns real
call MoveLocation(L, x, y)
return GetLocationZ(L)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library UnitZ /* v1.0.0.0
********************************************************************
*
* */uses/*
* */ GetTerrainZ /*
* */optional/*
* */ AutoFly /* hiveworkshop.com/forums/jass-resources-412/snippet-autofly-unitindexer-version-195563/
*
* function GetUnitZ takes unit whichUnit returns real
* function SetUnitZ takes unit whichUnit, real z returns real
*
********************************************************************/
function GetUnitZ takes unit u returns real
return GetTerrainZ(GetUnitX(u), GetUnitY(u)) + GetUnitFlyHeight(u)
endfunction
function SetUnitZ takes unit u, real z returns nothing
call SetUnitFlyHeight(u, z - GetTerrainZ(GetUnitX(u), GetUnitY(u)), 0)
endfunction
endlibrary
library Vector requires GetTerrainZ, UnitZ
struct Vector
real x
real y
real z
static method create takes real x, real y, real z returns thistype
local thistype this = thistype.allocate()
set .x = x
set .y = y
set .z = z
return this
endmethod
method add takes thistype v returns nothing
set .x = .x + v.x
set .y = .y + v.y
set .z = .z + v.z
endmethod
static method sum takes thistype a, thistype b returns thistype
local thistype v = thistype.allocate()
set v.x = a.x + b.x
set v.y = a.y + b.y
set v.z = a.z + b.z
return v
endmethod
method scale takes real f returns nothing
set .x = .x * f
set .y = .y * f
set .z = .z * f
endmethod
method getLength takes nothing returns real
return SquareRoot(.x*.x + .y*.y + .z*.z)
endmethod
method setLength takes real l returns nothing
if .getLength() != 0.00 then
set l = l / .getLength()
set .x = .x * l
set .y = .y * l
set .z = .z * l
endif
endmethod
static method dotProduct takes thistype a, thistype b returns real
return (a.x*b.x + a.y*b.y + a.z*b.z)
endmethod
static method createTerrainPoint takes real x, real y returns thistype
local thistype this = thistype.allocate()
set .x = x
set .y = y
set .z = GetTerrainZ(x, y)
return this
endmethod
static method createUnitPoint takes unit u returns thistype
local thistype this = thistype.allocate()
set .x = GetUnitX(u)
set .y = GetUnitY(u)
set .z = GetUnitZ(u)
return this
endmethod
static method projectionVector takes thistype p, thistype d returns thistype
local thistype v = thistype.allocate()
local real l = (p.x*d.x + p.y*d.y + p.z*d.z) / (d.x*d.x + d.y*d.y + d.z*d.z)
set v.x = d.x * l
set v.y = d.y * l
set v.z = d.z * l
return v
endmethod
method isInSphere takes thistype o, real r returns boolean
if r*r > ((.x - o.x)*(.x - o.x) + (.y - o.y)*(.y - o.y) + (.z - o.z)*(.z - o.z)) then
return true
endif
return false
endmethod
endstruct
endlibrary
library AddSpecialEffectZ
function AddSpecialEffectZ takes string modelName, real x, real y, real z returns effect
//Creates a invisible platform at the given x/y/z coordinates.
local destructable d = CreateDestructableZ('OTip', x, y, z, 0., 1, 0)
//The created special effect will now appear on top of the platform.
set bj_lastCreatedEffect = AddSpecialEffect(modelName, x, y)
//Removing platform and null the variable. The effect will still keep its height.
call RemoveDestructable(d)
set d = null
//Return effect.
return bj_lastCreatedEffect
endfunction
endlibrary
library LinkedList //v1.0.0.0
private module initNodes
private static method onInit takes nothing returns nothing
local integer i = 1
loop
set Node[i].n = Node[i + 1]
set i = i + 1
exitwhen i == 8190
endloop
endmethod
endmodule
struct Node extends array
private static thistype avail = 1
private thistype n
integer data
thistype next
thistype prev
static method get takes nothing returns thistype
local thistype this = avail
set avail = avail.n
set this.next = 0
set this.prev = 0
return this
endmethod
method free takes nothing returns nothing
set this.n = avail
set avail = this
endmethod
implement initNodes
endstruct
struct List
Node head
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set head = Node.get()
set head.next = head
set head.prev = head
return this
endmethod
method addElement takes integer e returns Node
local Node node = Node.get()
set node.data = e
set node.next = head
set node.prev = head.prev
set head.prev.next = node
set head.prev = node
return node
endmethod
static method removeElement takes Node position returns nothing
set position.prev.next = position.next
set position.next.prev = position.prev
call position.free()
endmethod
endstruct
module ObjectList
static List list
private Node position
method listAdd takes nothing returns nothing
set position = list.addElement(this)
endmethod
method listRemove takes nothing returns nothing
call list.removeElement(position)
endmethod
private static method onInit takes nothing returns nothing
set list = List.create()
endmethod
endmodule
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library InstanceIterator requires LinkedList //v2.1.0.0
//! textmacro II takes FREQUENCY, PERIOD
globals
private trigger trigger$FREQUENCY$ = CreateTrigger()
private integer globalCount$FREQUENCY$ = 0
private timer timer$FREQUENCY$ = CreateTimer()
constant real II$FREQUENCY$period = $PERIOD$
endglobals
private function eval$FREQUENCY$ takes nothing returns nothing
call TriggerEvaluate(trigger$FREQUENCY$)
endfunction
module II$FREQUENCY$
private static List list
private static integer localCount = 0
private static conditionfunc iterationFunction
private static triggercondition iterationCondition
private Node position
boolean enabled$FREQUENCY$ = false
private static method iteration takes nothing returns boolean
local Node head = list.head
local Node node = head.next
loop
call thistype(node.data).iterate$FREQUENCY$()
set node = node.next
exitwhen node == head
endloop
return false
endmethod
implement ObjectList
method start$FREQUENCY$ takes nothing returns boolean
if not enabled$FREQUENCY$ then
set position = list.addElement(this)
if localCount == 0 then
set iterationCondition = TriggerAddCondition(trigger$FREQUENCY$, iterationFunction)
endif
set localCount = localCount + 1
if globalCount$FREQUENCY$ == 0 then
call TimerStart(timer$FREQUENCY$, $PERIOD$, true, function eval$FREQUENCY$)
endif
set globalCount$FREQUENCY$ = globalCount$FREQUENCY$ + 1
set enabled$FREQUENCY$ = true
return true
endif
return false
endmethod
method stop$FREQUENCY$ takes nothing returns boolean
if enabled$FREQUENCY$ then
call list.removeElement(position)
set localCount = localCount - 1
if localCount == 0 then
call TriggerRemoveCondition(trigger$FREQUENCY$, iterationCondition)
set iterationCondition = null
endif
set globalCount$FREQUENCY$ = globalCount$FREQUENCY$ - 1
if globalCount$FREQUENCY$ == 0 then
call PauseTimer(timer$FREQUENCY$)
endif
set enabled$FREQUENCY$ = false
return true
endif
return false
endmethod
private static method onInit takes nothing returns nothing
set iterationFunction = Condition(function thistype.iteration)
set list = List.create()
endmethod
endmodule
//! endtextmacro
//! runtextmacro II("32", "0.031250")
// runtextmacro II("16", "0.062500")
//! runtextmacro II("10", "0.100000")
// runtextmacro II("8", "0.125000")
// runtextmacro II("5", "0.200000")
// runtextmacro II("2", "0.500000")
// runtextmacro II("1", "1.000000")
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library UnitCollision
function DisableUnitCollision takes unit u returns boolean
call SetUnitPathing(u, false)
return UnitAddAbility(u, 'Aeth')
endfunction
function EnableUnitCollision takes unit u returns boolean
call SetUnitPathing(u, true)
return UnitRemoveAbility(u, 'Aeth')
endfunction
endlibrary
library Alpha requires InstanceIterator //Handles alpha change over time
struct Alpha
unit u
integer alpha
integer delta
boolean revert
integer red = 255
integer green = 255
integer blue = 255
method iterate32 takes nothing returns nothing
set .alpha = .alpha + .delta
if .alpha > 255 or .alpha < 0 then
if .revert then
set .delta = -1*.delta
set .revert = false
else
call .stop32()
call .destroy()
endif
if .alpha > 255 then
set .alpha = 255
else
set .alpha = 0
endif
endif
call SetUnitVertexColor(u, red, green, blue, .alpha)
endmethod
implement II32
static method create takes unit u, integer a, integer d, boolean r returns thistype
local thistype this = thistype.allocate()
set .u = u
set .alpha = a
set .delta = d
set .revert = r
call SetUnitVertexColor(u, 255, 255, 255, a)
call .start32()
return this
endmethod
method setColor takes integer r, integer g, integer b returns nothing
set .red = r
set .green = g
set .blue = b
endmethod
endstruct
endlibrary
//TESH.scrollpos=25
//TESH.alwaysfold=0
library ErrorMessage /* v1.0.1.4
*************************************************************************************
*
* Issue THW Compliant Error Messages
*
************************************************************************************
*
* debug function ThrowError takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
* - In the event of an error the game will be permanently paused
*
* debug function ThrowWarning takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
*
************************************************************************************/
static if DEBUG_MODE then
private struct Fields extends array
static constant string COLOR_RED = "|cffff0000"
static constant string COLOR_YELLOW = "|cffffff00"
static string lastError = null
endstruct
private function Pause takes nothing returns nothing
call PauseGame(true)
endfunction
private function ThrowMessage takes string libraryName, string functionName, string objectName, integer objectInstance, string description, string errorType, string color returns nothing
local string str
local string color_braces = "|cff66FF99"
local string orange = "|cffff6600"
set str = "->\n-> " + color_braces + "{|r " + "Library" + color_braces + "(" + orange + libraryName + color_braces + ")"
if (objectName != null) then
if (objectInstance > 0) then
set str = str + "|r.Object" + color_braces + "(" + orange + objectName + color_braces + " (|rinstance = " + orange + I2S(objectInstance) + color_braces + ") )" + "|r." + "Method" + color_braces + "(" + orange + functionName + color_braces + ")"
else
set str = str + "|r.Object" + color_braces + "(" + orange + objectName + color_braces + ")|r." + "Method" + color_braces + "(" + orange + functionName + color_braces + ")"
endif
else
set str = str + "|r." + "Function" + color_braces + "(" + orange + functionName + color_braces + ")"
endif
set str = str + color_braces + " }|r " + "has thrown an exception of type " + color_braces + "(" + color + errorType + color_braces + ")|r."
set Fields.lastError = str + "\n->\n" + "-> " + color + description + "|r\n->"
endfunction
function ThrowError takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
if (Fields.lastError != null) then
set objectInstance = 1/0
endif
if (expression) then
call ThrowMessage(libraryName, functionName, objectName, objectInstance, description, "Error", Fields.COLOR_RED)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,Fields.lastError)
call TimerStart(CreateTimer(), 0, true, function Pause)
set objectInstance = 1/0
endif
endfunction
function ThrowWarning takes boolean expression, string libraryName, string functionName, string objectName, integer objectInstance, string description returns nothing
if (Fields.lastError != null) then
set objectInstance = 1/0
endif
if (expression) then
call ThrowMessage(libraryName, functionName, objectName, objectInstance, description, "Warning", Fields.COLOR_YELLOW)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,Fields.lastError)
set Fields.lastError = null
endif
endfunction
endif
endlibrary
//TESH.scrollpos=150
//TESH.alwaysfold=0
library ARGB initializer init
//******************************************************************************
//*
//* ARGB 1.2
//* ====
//* For your color needs.
//*
//* An ARGB object is a by-value struct, this means that assigning copies the
//* contents of the struct and that you don't have to use .destroy(), the
//* downside is that you cannot assign its members (can't do set c.r= 123 )
//*
//* This library should have plenty of uses, for example, if your spell involves
//* some unit recoloring you can allow users to input the color in the config
//* section as 0xAARRGGBB and you can then use this to decode that stuff.
//*
//* You can also easily merge two colors and make fading effects using ARGB.mix
//*
//* There's ARGB.fromPlayer which gets an ARGB object containing the player's
//* color. Then you can use the previous utilities on it.
//*
//* The .str() instance method can recolor a string, and the recolorUnit method
//* will apply the ARGB on a unit
//*
//* For other uses, you can use the .red, .green, .blue and .alpha members to get
//* an ARGB object's color value (from 0 to 255).
//*
//* structs that have a recolor method that takes red,green,blue and alpha as 0.255
//* integers can implement the ARGBrecolor module to gain an ability to quickly
//* recolor using an ARGB object.
//*
//********************************************************************************
//=================================================================================
globals
private string array i2cc
endglobals
//this double naming stuff is beginning to make me insane, if only TriggerEvaluate() wasn't so slow...
struct ARGB extends array
static method create takes integer a, integer r, integer g, integer b returns ARGB
return ARGB(b + g*0x100 + r*0x10000 + a*0x1000000)
endmethod
// not really part of the exported stuff, I may remove it in the future, so please don't call this textmacro
//! textmacro ARGB_PLAYER_COLOR_2_ARGB
if(pc==PLAYER_COLOR_RED) then
return 0xFFFF0303
elseif(pc==PLAYER_COLOR_BLUE) then
return 0xFF0042FF
elseif(pc==PLAYER_COLOR_CYAN) then
return 0xFF1CE6B9
elseif(pc==PLAYER_COLOR_PURPLE) then
return 0xFF540081
elseif(pc==PLAYER_COLOR_YELLOW) then
return 0xFFFFFC01
elseif(pc==PLAYER_COLOR_ORANGE) then
return 0xFFFE8A0E
elseif(pc==PLAYER_COLOR_GREEN) then
return 0xFF20C000
elseif(pc==PLAYER_COLOR_PINK) then
return 0xFFE55BB0
elseif(pc==PLAYER_COLOR_LIGHT_GRAY) then
return 0xFF959697
elseif(pc==PLAYER_COLOR_LIGHT_BLUE) then
return 0xFF7EBFF1
elseif(pc==PLAYER_COLOR_AQUA) then
return 0xFF106246
elseif(pc==PLAYER_COLOR_BROWN) then
return 0xFF4E2A04
endif
return 0xFF111111
//! endtextmacro
static method fromPlayerColor takes playercolor pc returns ARGB
//! runtextmacro ARGB_PLAYER_COLOR_2_ARGB()
endmethod
static method fromPlayer takes player p returns ARGB
local playercolor pc=GetPlayerColor(p)
//! runtextmacro ARGB_PLAYER_COLOR_2_ARGB()
endmethod
method operator alpha takes nothing returns integer
if( integer(this) <0) then
return 0x80+(-(-integer(this)+0x80000000))/0x1000000
else
return (integer(this))/0x1000000
endif
endmethod
method operator alpha= takes integer na returns ARGB
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
return ARGB(b + g*0x100 + r*0x10000 + na*0x1000000)
endmethod
method operator red takes nothing returns integer
local integer c=integer(this)*0x100
if(c<0) then
return 0x80+(-(-c+0x80000000))/0x1000000
else
return c/0x1000000
endif
endmethod
method operator red= takes integer nr returns ARGB
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
return ARGB(b + g*0x100 + nr*0x10000 + a*0x1000000)
endmethod
method operator green takes nothing returns integer
local integer c=integer(this)*0x10000
if(c<0) then
return 0x80+(-(-c+0x80000000))/0x1000000
else
return c/0x1000000
endif
endmethod
method operator green= takes integer ng returns ARGB
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
return ARGB(b + ng*0x100 + r*0x10000 + a*0x1000000)
endmethod
//=======================================================
//
//
method operator blue takes nothing returns integer
local integer c=integer(this)*0x1000000
if(c<0) then
return 0x80+(-(-c+0x80000000))/0x1000000
else
return c/0x1000000
endif
endmethod
method operator blue= takes integer nb returns ARGB
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
return ARGB(nb + g*0x100 + r*0x10000 + a*0x1000000)
endmethod
//====================================================================
// Mixes two colors, s would be a number 0<=s<=1 that determines
// the weight given to color c2.
//
// mix(c1,c2,0) = c1
// mix(c1,c2,1) = c2
// mix(c1,c2,0.5) = Mixing the colors c1 and c2 in equal proportions.
//
static method mix takes ARGB c1, ARGB c2, real s returns ARGB
//widest function ever
return ARGB( R2I(c2.blue*s+c1.blue*(1-s)+0.5) + R2I(c2.green*s+c1.green*(1-s)+0.5)*0x100 + R2I(c2.red*s+c1.red*(1-s)+0.5)*0x10000 + R2I(c2.alpha*s+c1.alpha*(1-s)+0.5)*0x1000000)
endmethod
method str takes string s returns string
return "|c"+i2cc[.alpha]+i2cc[.red]+i2cc[.green]+i2cc[.blue]+s+"|r"
endmethod
method recolorUnit takes unit u returns nothing
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
call SetUnitVertexColor(u,r,g,b,a)
endmethod
endstruct
module ARGBrecolor
method ARGBrecolor takes ARGB color returns nothing
local integer a
local integer r
local integer g
local integer b
local integer col=integer(this)
if (col<0) then
set col=-(-col+0x80000000)
set a=0x80+col/0x1000000
set col=col-(a-0x80)*0x1000000
else
set a=col/0x1000000
set col=col-a*0x1000000
endif
set r=col/0x10000
set col=col-r*0x10000
set g=col/0x100
set b=col-g*0x100
call this.recolor(r, g , b, a)
endmethod
endmodule
private function init takes nothing returns nothing
local integer i=0
// Don't run textmacros you don't own!
//! textmacro ARGB_CHAR takes int, chr
set i=0
loop
exitwhen i==16
set i2cc[$int$*16+i]="$chr$"+i2cc[$int$*16+i]
set i2cc[i*16+$int$]=i2cc[i*16+$int$]+"$chr$"
set i=i+1
endloop
//! endtextmacro
//! runtextmacro ARGB_CHAR( "0","0")
//! runtextmacro ARGB_CHAR( "1","1")
//! runtextmacro ARGB_CHAR( "2","2")
//! runtextmacro ARGB_CHAR( "3","3")
//! runtextmacro ARGB_CHAR( "4","4")
//! runtextmacro ARGB_CHAR( "5","5")
//! runtextmacro ARGB_CHAR( "6","6")
//! runtextmacro ARGB_CHAR( "7","7")
//! runtextmacro ARGB_CHAR( "8","8")
//! runtextmacro ARGB_CHAR( "9","9")
//! runtextmacro ARGB_CHAR("10","A")
//! runtextmacro ARGB_CHAR("11","B")
//! runtextmacro ARGB_CHAR("12","C")
//! runtextmacro ARGB_CHAR("13","D")
//! runtextmacro ARGB_CHAR("14","E")
//! runtextmacro ARGB_CHAR("15","F")
endfunction
endlibrary
//TESH.scrollpos=74
//TESH.alwaysfold=0
library UnitAppearanceTracker requires ARGB, Table, optional AutoIndex
//*****************************************************************
//* UNIT APPEARANCE TRACKER
//*
//* written by: Anitarf
//* original implementation: Tot
//* requires: -ARGB
//* -Table
//* optional: -AutoIndex
//*
//* There is no native way to get a unit's current vertex colour
//* or scale in WC3. This library was written to work around this
//* limitation. The library tracks changes made to the vertex
//* colour and scale of individual units so that those values can
//* be obtained for a specific unit at any time. Vertex color is
//* described using ARGB. This library now also tracks the
//* animation speed of units.
//*
//* local ARGB c = GetUnitVertexColor(u)
//* local real s = GetUnitScale(u)
//* local real s = GetUnitTimeScale(u)
//*
//* If a unit type has a vertex colour or scale defined in the
//* object editor that is different from the DEFAULT_COLOR/SCALE,
//* UnitAppearanceTracker must be informed of this using the
//* following functions in order for it to correctly assume these
//* values for newly created units:
//*
//* call SetUnitTypeVertexColor('nzom', 0xFFFF9696) // zombie
//* call SetUnitTypeScale('hgry', 1.2) // gryphon rider
//*
//* Finally, to be able to reset a unit's color and scale, the
//* library provides the following functions that return the
//* default values for a given unit type:
//*
//* set c = GetUnitTypeVertexColor(GetUnitTypeId(u))
//* set s = GetUnitTypeScale(GetUnitTypeId(u))
//*
//* This library optionally requires AutoIndex. Without AutoIndex,
//* the library still has full functionality, AutoIndex only makes
//* it slightly faster, however it will only be able to track the
//* appearance of indexed units.
//*****************************************************************
globals
// Set this to false if you want to track the appearance of units ignored by AutoIndex.
private constant boolean USE_AUTOINDEX_IF_PRESENT = true
// Multiplication factor used when converting reals to integers so they can be stored in Table.
private constant real PRECISION = 1000.0
// You do not need to call SetUnitTypeVertexColor/SetUnitTypeScale for units that use these default values,
// so the values should match the most commonly used scale/colour in your map. Speed should always be 1.0.
private ARGB DEFAULT_COLOR = 0xFFFFFFFF
private real DEFAULT_SCALE = 1.0
private real DEFAULT_SPEED = 1.0
// END OF CALIBRATION SECTION
// ================================================================
private ARGB array unitsColor
private real array unitsScale
private real array unitsSpeed
private HandleTable unitColor
private HandleTable unitScale
private HandleTable unitSpeed
private Table unittypeColor
private Table unittypeScale
endglobals
// ================================================================
// Hooks:
private function SetUnitVertexColor_hook takes unit whichUnit, integer red, integer green, integer blue, integer alpha returns nothing
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(whichUnit) then
set unitsColor[GetUnitId(whichUnit)] = ARGB.create(alpha, red, green, blue)
endif
else
set unitColor[whichUnit] = integer(ARGB.create(alpha, red, green, blue))
endif
endfunction
private function SetUnitVertexColorBJ_hook takes unit whichUnit, real red, real green, real blue, real transparency returns nothing
call SetUnitVertexColor_hook(whichUnit, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency))
endfunction
hook SetUnitVertexColor SetUnitVertexColor_hook
hook SetUnitVertexColorBJ SetUnitVertexColorBJ_hook
// ----------------------------------------------------------------
private function SetUnitScale_hook takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(whichUnit) then
set unitsScale[GetUnitId(whichUnit)] = scaleX
endif
else
set unitScale[whichUnit] = R2I(scaleX*PRECISION)
endif
endfunction
private function SetUnitScalePercent_hook takes unit whichUnit, real percentScaleX, real percentScaleY, real percentScaleZ returns nothing
call SetUnitScale_hook(whichUnit, percentScaleX * 0.01, 0.0, 0.0)
endfunction
hook SetUnitScale SetUnitScale_hook
hook SetUnitScalePercent SetUnitScalePercent_hook
// ----------------------------------------------------------------
private function SetUnitTimeScale_hook takes unit whichUnit, real timeScale returns nothing
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(whichUnit) then
set unitsSpeed[GetUnitId(whichUnit)] = timeScale
endif
else
set unitSpeed[whichUnit] = R2I(timeScale*PRECISION)
endif
endfunction
private function SetUnitTimeScalePercent_hook takes unit whichUnit, real percentScale returns nothing
call SetUnitTimeScale_hook(whichUnit, percentScale * 0.01)
endfunction
hook SetUnitTimeScale SetUnitTimeScale_hook
hook SetUnitTimeScalePercent SetUnitTimeScalePercent_hook
// ================================================================
// User functions:
function GetUnitVertexColor takes unit u returns ARGB
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(u) then
return unitsColor[GetUnitId(u)]
else
return DEFAULT_COLOR
endif
else
return ARGB(unitColor[u])
endif
endfunction
function GetUnitScale takes unit u returns real
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(u) then
return unitsScale[GetUnitId(u)]
else
return DEFAULT_SCALE
endif
else
return unitScale[u]/PRECISION
endif
endfunction
function GetUnitTimeScale takes unit u returns real
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
if IsUnitIndexed(u) then
return unitsSpeed[GetUnitId(u)]
else
return DEFAULT_SPEED
endif
else
return unitSpeed[u]/PRECISION
endif
endfunction
// ----------------------------------------------------------------
function GetUnitTypeVertexColor takes integer unitID returns ARGB
if unittypeColor.exists(unitID) then
return ARGB(unittypeColor[unitID])
endif
return DEFAULT_COLOR
endfunction
function GetUnitTypeScale takes integer unitID returns real
if unittypeScale.exists(unitID) then
return unittypeScale[unitID]/PRECISION
endif
return DEFAULT_SCALE
endfunction
// ----------------------------------------------------------------
function SetUnitTypeVertexColor takes integer unitID, ARGB c returns nothing
set unittypeColor[unitID]=integer(c)
endfunction
function SetUnitTypeScale takes integer unitID, real s returns nothing
set unittypeScale[unitID]=R2I(s*PRECISION)
endfunction
// ================================================================
// Initialization:
private struct Initializer extends array
private static method UnitEntersMap takes unit u returns nothing
static if USE_AUTOINDEX_IF_PRESENT and LIBRARY_AutoIndex then
set unitsScale[GetUnitId(u)] = GetUnitTypeScale(GetUnitTypeId(u))
set unitsColor[GetUnitId(u)] = GetUnitTypeVertexColor(GetUnitTypeId(u))
set unitsSpeed[GetUnitId(u)] = DEFAULT_SPEED
else
set unitScale[u] = R2I(GetUnitTypeScale(GetUnitTypeId(u))*PRECISION)
set unitColor[u] = integer(GetUnitTypeVertexColor(GetUnitTypeId(u)))
set unitSpeed[u] = R2I(DEFAULT_SPEED*PRECISION)
endif
endmethod
private static method UnitEntersMapTrigger takes nothing returns boolean
call .UnitEntersMap(GetFilterUnit())
return false
endmethod
// ----------------------------------------------------------------
private static method onInit takes nothing returns nothing
local rect rc
local region rg
local trigger t
set unittypeColor=Table.create()
set unittypeScale=Table.create()
static if LIBRARY_AutoIndex then
call OnUnitIndexed(UnitEntersMap)
static if not USE_AUTOINDEX_IF_PRESENT then
set unitScale=Table.create()
set unitColor=Table.create()
set unitSpeed=Table.create()
endif
else
set unitScale=Table.create()
set unitColor=Table.create()
set unitSpeed=Table.create()
set rc=GetWorldBounds()
set rg=CreateRegion()
set t=CreateTrigger()
call RegionAddRect(rg, rc)
call RemoveRect(rc)
call TriggerRegisterEnterRegion( t, rg, Condition(function Initializer.UnitEntersMapTrigger) )
set rc=null
set rg=null
endif
endmethod
endstruct
endlibrary
scope SureInvisibility
private struct SureInvisibility
boolean invis
method onCreate takes nothing returns nothing
set .invis = false
call .start32()
endmethod
static method createFilter takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_PLAYER)
endmethod
method iterate32 takes nothing returns nothing
if (not .invis) and (IsUnitInvisible(.me, GetLocalPlayer())) then
set .invis = true
call SetUnitVertexColor(.me, GetUnitVertexColor(.me).red, GetUnitVertexColor(.me).green, GetUnitVertexColor(.me).blue, 0)
elseif (.invis) and (not IsUnitInvisible(.me, GetLocalPlayer())) then
set .invis = false
call SetUnitVertexColor(.me, GetUnitVertexColor(.me).red, GetUnitVertexColor(.me).green, GetUnitVertexColor(.me).blue, 255)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
endstruct
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
library Ascii /* v1.1.0.0 Nestharus/Bribe
************************************************************************************
*
* function Char2Ascii takes string s returns integer
* integer ascii = Char2Ascii("F")
*
* function Ascii2Char takes integer a returns string
* string char = Ascii2Char('F')
*
* function A2S takes integer a returns string
* string rawcode = A2S('CODE')
*
* function S2A takes string s returns integer
* integer rawcode = S2A("CODE")
*
************************************************************************************/
globals
private integer array i //hash
private integer array h //hash2
private integer array y //hash3
private string array c //char
endglobals
function Char2Ascii takes string p returns integer
local integer z = i[StringHash(p)/0x1F0748+0x40D]
if (c[z] != p) then
if (c[z - 32] != p) then
if (c[h[z]] != p) then
if (c[y[z]] != p) then
if (c[83] != p) then
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"ASCII ERROR: INVALID CHARACTER: " + p)
return 0
endif
return 83
endif
return y[z]
endif
return h[z]
endif
return z - 32
endif
return z
endfunction
function Ascii2Char takes integer a returns string
return c[a]
endfunction
function A2S takes integer a returns string
local string s=""
loop
set s=c[a-a/256*256]+s
set a=a/256
exitwhen 0==a
endloop
return s
endfunction
function S2A takes string s returns integer
local integer a=0
local integer l=StringLength(s)
local integer j=0
local string m
local integer h
loop
exitwhen j==l
set a = a*256 + Char2Ascii(SubString(s,j,j+1))
set j=j+1
endloop
return a
endfunction
private module Init
private static method onInit takes nothing returns nothing
set i[966] = 8
set i[1110] = 9
set i[1621] = 10
set i[1375] = 12
set i[447] = 13
set i[233] = 32
set i[2014] = 33
set i[1348] = 34
set i[1038] = 35
set i[1299] = 36
set i[1018] = 37
set i[1312] = 38
set i[341] = 39
set i[939] = 40
set i[969] = 41
set i[952] = 42
set i[2007] = 43
set i[1415] = 44
set i[2020] = 45
set i[904] = 46
set i[1941] = 47
set i[918] = 48
set i[1593] = 49
set i[719] = 50
set i[617] = 51
set i[703] = 52
set i[573] = 53
set i[707] = 54
set i[1208] = 55
set i[106] = 56
set i[312] = 57
set i[124] = 58
set i[1176] = 59
set i[74] = 60
set i[1206] = 61
set i[86] = 62
set i[340] = 63
set i[35] = 64
set i[257] = 65
set i[213] = 66
set i[271] = 67
set i[219] = 68
set i[1330] = 69
set i[1425] = 70
set i[1311] = 71
set i[238] = 72
set i[1349] = 73
set i[244] = 74
set i[1350] = 75
set i[205] = 76
set i[1392] = 77
set i[1378] = 78
set i[1432] = 79
set i[1455] = 80
set i[1454] = 81
set i[1431] = 82
set i[1409] = 83
set i[1442] = 84
set i[534] = 85
set i[1500] = 86
set i[771] = 87
set i[324] = 88
set i[1021] = 89
set i[73] = 90
set i[1265] = 91
set i[1941] = 92
set i[1671] = 93
set i[1451] = 94
set i[1952] = 95
set i[252] = 96
set i[257] = 97
set i[213] = 98
set i[271] = 99
set i[219] = 100
set i[1330] = 101
set i[1425] = 102
set i[1311] = 103
set i[238] = 104
set i[1349] = 105
set i[244] = 106
set i[1350] = 107
set i[205] = 108
set i[1392] = 109
set i[1378] = 110
set i[1432] = 111
set i[1455] = 112
set i[1454] = 113
set i[1431] = 114
set i[1409] = 115
set i[1442] = 116
set i[534] = 117
set i[1500] = 118
set i[771] = 119
set i[324] = 120
set i[1021] = 121
set i[73] = 122
set i[868] = 123
set i[1254] = 124
set i[588] = 125
set i[93] = 126
set i[316] = 161
set i[779] = 162
set i[725] = 163
set i[287] = 164
set i[212] = 165
set i[7] = 166
set i[29] = 167
set i[1958] = 168
set i[1009] = 169
set i[1580] = 170
set i[1778] = 171
set i[103] = 172
set i[400] = 174
set i[1904] = 175
set i[135] = 176
set i[1283] = 177
set i[469] = 178
set i[363] = 179
set i[550] = 180
set i[1831] = 181
set i[1308] = 182
set i[1234] = 183
set i[1017] = 184
set i[1093] = 185
set i[1577] = 186
set i[606] = 187
set i[1585] = 188
set i[1318] = 189
set i[980] = 190
set i[1699] = 191
set i[1292] = 192
set i[477] = 193
set i[709] = 194
set i[1600] = 195
set i[2092] = 196
set i[50] = 197
set i[546] = 198
set i[408] = 199
set i[853] = 200
set i[205] = 201
set i[411] = 202
set i[1311] = 203
set i[1422] = 204
set i[1808] = 205
set i[457] = 206
set i[1280] = 207
set i[614] = 208
set i[1037] = 209
set i[237] = 210
set i[1409] = 211
set i[1023] = 212
set i[1361] = 213
set i[695] = 214
set i[161] = 215
set i[1645] = 216
set i[1822] = 217
set i[644] = 218
set i[1395] = 219
set i[677] = 220
set i[1677] = 221
set i[881] = 222
set i[861] = 223
set i[1408] = 224
set i[1864] = 225
set i[1467] = 226
set i[1819] = 227
set i[1971] = 228
set i[949] = 229
set i[774] = 230
set i[1828] = 231
set i[865] = 232
set i[699] = 233
set i[786] = 234
set i[1806] = 235
set i[1286] = 236
set i[1128] = 237
set i[1490] = 238
set i[1720] = 239
set i[1817] = 240
set i[729] = 241
set i[1191] = 242
set i[1164] = 243
set i[413] = 244
set i[349] = 245
set i[1409] = 246
set i[660] = 247
set i[2016] = 248
set i[1087] = 249
set i[1497] = 250
set i[753] = 251
set i[1579] = 252
set i[1456] = 253
set i[606] = 254
set i[1625] = 255
set h[92] = 47
set h[201] = 108
set h[201] = 76
set h[203] = 103
set h[203] = 71
set h[246] = 115
set h[246] = 83
set h[246] = 211
set h[254] = 187
set y[201] = 108
set y[203] = 103
set y[246] = 115
set c[8]="\b"
set c[9]="\t"
set c[10]="\n"
set c[12]="\f"
set c[13]="\r"
set c[32]=" "
set c[33]="!"
set c[34]="\""
set c[35]="#"
set c[36]="$"
set c[37]="%"
set c[38]="&"
set c[39]="'"
set c[40]="("
set c[41]=")"
set c[42]="*"
set c[43]="+"
set c[44]=","
set c[45]="-"
set c[46]="."
set c[47]="/"
set c[48]="0"
set c[49]="1"
set c[50]="2"
set c[51]="3"
set c[52]="4"
set c[53]="5"
set c[54]="6"
set c[55]="7"
set c[56]="8"
set c[57]="9"
set c[58]=":"
set c[59]=";"
set c[60]="<"
set c[61]="="
set c[62]=">"
set c[63]="?"
set c[64]="@"
set c[65]="A"
set c[66]="B"
set c[67]="C"
set c[68]="D"
set c[69]="E"
set c[70]="F"
set c[71]="G"
set c[72]="H"
set c[73]="I"
set c[74]="J"
set c[75]="K"
set c[76]="L"
set c[77]="M"
set c[78]="N"
set c[79]="O"
set c[80]="P"
set c[81]="Q"
set c[82]="R"
set c[83]="S"
set c[84]="T"
set c[85]="U"
set c[86]="V"
set c[87]="W"
set c[88]="X"
set c[89]="Y"
set c[90]="Z"
set c[91]="["
set c[92]="\\"
set c[93]="]"
set c[94]="^"
set c[95]="_"
set c[96]="`"
set c[97]="a"
set c[98]="b"
set c[99]="c"
set c[100]="d"
set c[101]="e"
set c[102]="f"
set c[103]="g"
set c[104]="h"
set c[105]="i"
set c[106]="j"
set c[107]="k"
set c[108]="l"
set c[109]="m"
set c[110]="n"
set c[111]="o"
set c[112]="p"
set c[113]="q"
set c[114]="r"
set c[115]="s"
set c[116]="t"
set c[117]="u"
set c[118]="v"
set c[119]="w"
set c[120]="x"
set c[121]="y"
set c[122]="z"
set c[123]="{"
set c[124]="|"
set c[125]="}"
set c[126]="~"
set c[128] = "€"
set c[130] = "‚"
set c[131] = "ƒ"
set c[132] = "„"
set c[133] = "…"
set c[134] = "†"
set c[135] = "‡"
set c[136] = "ˆ"
set c[137] = "‰"
set c[138] = "Š"
set c[139] = "‹"
set c[140] = "Œ"
set c[142] = "Ž"
set c[145] = "‘"
set c[146] = "’"
set c[147] = "“"
set c[148] = "”"
set c[149] = "•"
set c[150] = "–"
set c[151] = "—"
set c[152] = "˜"
set c[153] = "™"
set c[154] = "š"
set c[155] = "›"
set c[156] = "œ"
set c[158] = "ž"
set c[159] = "Ÿ"
set c[160] = " "
set c[161] = "¡"
set c[162] = "¢"
set c[163] = "£"
set c[164] = "¤"
set c[165] = "¥"
set c[166] = "¦"
set c[167] = "§"
set c[168] = "¨"
set c[169] = "©"
set c[170] = "ª"
set c[171] = "«"
set c[172] = "¬"
set c[174] = "®"
set c[175] = "¯"
set c[176] = "°"
set c[177] = "±"
set c[178] = "²"
set c[179] = "³"
set c[180] = "´"
set c[181] = "µ"
set c[182] = "¶"
set c[183] = "·"
set c[184] = "¸"
set c[185] = "¹"
set c[186] = "º"
set c[187] = "»"
set c[188] = "¼"
set c[189] = "½"
set c[190] = "¾"
set c[191] = "¿"
set c[192] = "À"
set c[193] = "Á"
set c[194] = "Â"
set c[195] = "Ã"
set c[196] = "Ä"
set c[197] = "Å"
set c[198] = "Æ"
set c[199] = "Ç"
set c[200] = "È"
set c[201] = "É"
set c[202] = "Ê"
set c[203] = "Ë"
set c[204] = "Ì"
set c[205] = "Í"
set c[206] = "Î"
set c[207] = "Ï"
set c[208] = "Ð"
set c[209] = "Ñ"
set c[210] = "Ò"
set c[211] = "Ó"
set c[212] = "Ô"
set c[213] = "Õ"
set c[214] = "Ö"
set c[215] = "×"
set c[216] = "Ø"
set c[217] = "Ù"
set c[218] = "Ú"
set c[219] = "Û"
set c[220] = "Ü"
set c[221] = "Ý"
set c[222] = "Þ"
set c[223] = "ß"
set c[224] = "à"
set c[225] = "á"
set c[226] = "â"
set c[227] = "ã"
set c[228] = "ä"
set c[229] = "å"
set c[230] = "æ"
set c[231] = "ç"
set c[232] = "è"
set c[233] = "é"
set c[234] = "ê"
set c[235] = "ë"
set c[236] = "ì"
set c[237] = "í"
set c[238] = "î"
set c[239] = "ï"
set c[240] = "ð"
set c[241] = "ñ"
set c[242] = "ò"
set c[243] = "ó"
set c[244] = "ô"
set c[245] = "õ"
set c[246] = "ö"
set c[247] = "÷"
set c[248] = "ø"
set c[249] = "ù"
set c[250] = "ú"
set c[251] = "û"
set c[252] = "ü"
set c[253] = "ý"
set c[254] = "þ"
set c[255] = "ÿ"
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
//TESH.scrollpos=9
//TESH.alwaysfold=0
library Dialog /* v.1.1.0.0
**************************************************
*
* A struct wrapper for easy dialog creation.
*
**************************************************
*
*/ requires Table /* [url]http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/[/url]
*
**************************************************
*
* struct Dialog
*
* static method create() returns thistype
*
* Creates a new dialog and returns its instance.
*
* method operator title= takes string s
*
* Sets the title message for the dialog.
*
* method addButton( string text, integer hotkey ) returns button
*
* Adds a button to the dialog that reads <text>.
* The hotkey serves as a shortcut to press a dialog
* button. Example input: 'a', 'b', 512 (esc).
*
* method display( player p, boolean flag )
*
* Shows/hides a dialog for a particular player.
*
* method displayAll( boolean flag )
*
* Shows/hides a dialog for all players.
*
* method clear()
*
* Clears a dialog of its message and buttons.
*
* method destroy()
*
* Destroys a dialog and its instance.
*
* -- Event API --
*
* method registerClickEvent( boolexpr b )
*
* Registers when a dialog button is clicked.
*
* static method getClickedDialog() returns Dialog
* static method getClickedButton() returns button
* static method getPlayer() returns player
*
* Event responses.
*
**************************************************
*
* Constants - Credits to DysfunctionaI for the list!
*/
globals
constant integer KEY_SPACEBAR = 32
/* Number Pad */
constant integer KEY_NUMPAD_0 = 257
constant integer KEY_NUMPAD_1 = 258
constant integer KEY_NUMPAD_2 = 259
constant integer KEY_NUMPAD_3 = 260
constant integer KEY_NUMPAD_4 = 261
constant integer KEY_NUMPAD_5 = 262
constant integer KEY_NUMPAD_6 = 263
constant integer KEY_NUMPAD_7 = 264
constant integer KEY_NUMPAD_8 = 265
constant integer KEY_NUMPAD_9 = 266
constant integer KEY_NUMPAD_PLUS = 267
constant integer KEY_NUMPAD_MINUS = 268
constant integer KEY_NUMPAD_ASTERISK = 269
constant integer KEY_NUMPAD_SLASH = 270
constant integer KEY_NUMPAD_PERIOD = 271
constant integer KEY_EQUALS = 272
constant integer KEY_MINUS = 273
constant integer KEY_LEFT_BRACKET = 274
constant integer KEY_RIGHT_BRACKET = 275
constant integer KEY_BACKSLASH = 276
constant integer KEY_SEMICOLON = 277
constant integer KEY_APOSTROPHE = 278
constant integer KEY_COMMA = 279
constant integer KEY_PERIOD = 280
constant integer KEY_SLASH = 281
constant integer KEY_ESCAPE = 512
constant integer KEY_BACKSPACE = 514
/* Arrows */
constant integer KEY_LEFT_ARROW = 516
constant integer KEY_UP_ARROW = 517
constant integer KEY_RIGHT_ARROW = 518
constant integer KEY_DOWN_ARROW = 519
constant integer KEY_INSERT = 520
constant integer KEY_DELETE = 521
constant integer KEY_HOME = 522
constant integer KEY_END = 523
constant integer KEY_PAGE_UP = 524
constant integer KEY_PAGE_DOWN = 525
constant integer KEY_CAPS_LOCK = 526
constant integer KEY_NUM_LOCK = 527
constant integer KEY_SCROLL_LOCK = 528
constant integer KEY_PAUSE = 529
/* Function Buttons */
constant integer KEY_F1 = 768
constant integer KEY_F2 = 769
constant integer KEY_F3 = 770
constant integer KEY_F4 = 771
constant integer KEY_F5 = 772
constant integer KEY_F6 = 773
constant integer KEY_F7 = 774
constant integer KEY_F8 = 775
constant integer KEY_F9 = 776
constant integer KEY_F10 = 777
constant integer KEY_F11 = 778
constant integer KEY_F12 = 779
endglobals
/*
**************************************************/
globals
private Table instance = 0
endglobals
private module DialogInit
private static method onInit takes nothing returns nothing
set instance = Table.create()
endmethod
endmodule
struct Dialog
private dialog dg
private trigger click
private string msg
static method getClickedDialog takes nothing returns thistype
return instance[GetHandleId(GetClickedDialog())]
endmethod
static method getClickedButton takes nothing returns button
return GetClickedButton()
endmethod
static method getPlayer takes nothing returns player
return GetTriggerPlayer()
endmethod
method operator title= takes string text returns nothing
call DialogSetMessage(this.dg, text)
set this.msg = text
endmethod
method addButton takes string text, integer hotkey returns button
return DialogAddButton(this.dg, text, hotkey)
endmethod
method display takes player p, boolean flag returns nothing
call DialogDisplay(p, this.dg, flag)
call DialogSetMessage(this.dg, this.msg)
endmethod
method displayAll takes boolean flag returns nothing
call DialogDisplay(GetLocalPlayer(), this.dg, flag)
call DialogSetMessage(this.dg, this.msg)
endmethod
method clear takes nothing returns nothing
call DialogClear(this.dg)
set this.msg = ""
endmethod
method registerClickEvent takes boolexpr b returns nothing
if this.click == null then
set instance[GetHandleId(this.dg)] = this
set this.click = CreateTrigger()
call TriggerRegisterDialogEvent(this.click, this.dg)
endif
call TriggerAddCondition(this.click, b)
endmethod
method destroy takes nothing returns nothing
debug if this.dg == null then
debug call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "[Dialog] Attempted to destroy null dialog.")
debug endif
if this.click != null then
call DestroyTrigger(this.click)
call instance.remove(GetHandleId(this.dg))
set this.click = null
endif
call DialogClear(this.dg)
call DialogDestroy(this.dg)
set this.dg = null
call this.deallocate()
endmethod
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
set this.dg = DialogCreate()
return this
endmethod
implement DialogInit
endstruct
endlibrary
library PlayerColors
globals
private string array colorNames
private string array colorCodes
endglobals
function ColorCode2Index takes string c returns integer
local integer i = 0
loop
if c == colorCodes[i] then
return i
endif
set i = i + 1
exitwhen i == 24
endloop
return -1
endfunction
function GetColorCode takes integer i returns string
return colorCodes[i]
endfunction
function GetColorName takes integer i returns string
return colorNames[i]
endfunction
private module initModule
private static method onInit takes nothing returns nothing
set colorNames[0] = "Red"
set colorCodes[0] = "|c00FF0202"
set colorNames[1] = "Blue"
set colorCodes[1] = "|c000041FF"
set colorNames[2] = "Teal"
set colorCodes[2] = "|c001BE5B8"
set colorNames[3] = "Purple"
set colorCodes[3] = "|c00530080"
set colorNames[4] = "Yellow"
set colorCodes[4] = "|c00FFFF00"
set colorNames[5] = "Orange"
set colorCodes[5] = "|c00FE890D"
set colorNames[6] = "Green"
set colorCodes[6] = "|c001FBF00"
set colorNames[7] = "Pink"
set colorCodes[7] = "|c00E45AAA"
set colorNames[8] = "Gray"
set colorCodes[8] = "|c00949596"
set colorNames[9] = "Light blue"
set colorCodes[9] = "|c007DBEF1"
set colorNames[10] = "Dark green"
set colorCodes[10] = "|c000F6145"
set colorNames[11] = "Brown"
set colorCodes[11] = "|c004D2903"
set colorNames[12] = "Maroon"
set colorCodes[12] = "|C009B0000"
set colorNames[13] = "Navy"
set colorCodes[13] = "|C000000C3"
set colorNames[14] = "Turquoise"
set colorCodes[14] = "|C0000EAFF"
set colorNames[15] = "Violet"
set colorCodes[15] = "|C00BE00FE"
set colorNames[16] = "Wheat"
set colorCodes[16] = "|C00EBCD87"
set colorNames[17] = "Peach"
set colorCodes[17] = "|C00F8A48B"
set colorNames[18] = "Mint"
set colorCodes[18] = "|C00BFFF80"
set colorNames[19] = "Lavender"
set colorCodes[19] = "|C00BFFF80"
set colorNames[20] = "Coal"
set colorCodes[20] = "|C00282828"
set colorNames[21] = "Snow"
set colorCodes[21] = "|C00EBF0FF"
set colorNames[22] = "Emerald"
set colorCodes[22] = "|C0000781E"
set colorNames[23] = "Peanut"
set colorCodes[23] = "|C00A46F33"
set colorNames[24] = "Black"
set colorCodes[24] = "|C00252525"
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
endlibrary
///////////////////////////////////////////
/// HostBot Command Library
/// Last Modified: September 14, 2009
/// Authors: Strilanc,
/// v1.01
///////////////////////////////////////////
/// Reads a command string transparently encoded into player handicaps by hostbots.
/// Allows at most one character from "abcdefghijklmnopqrstuvwxyz0123456789 -=,." per player.
/// Empty slots don't count towards the player count, but computers do.
///////////////////////////////////////////
library HCL initializer init
globals
private string command = ""
endglobals
function GetCommandString takes nothing returns string
return command
endfunction
private function init takes nothing returns nothing
local integer i
local integer j
local integer h
local integer v
local string chars = "abcdefghijklmnopqrstuvwxyz0123456789 -=,."
local integer array map
local boolean array blocked
//precompute mapping [have to avoid invalid and normal handicaps]
set blocked[0] = true
set blocked[50] = true
set blocked[60] = true
set blocked[70] = true
set blocked[80] = true
set blocked[90] = true
set blocked[100] = true
set i = 0
set j = 0
loop
if blocked[j] then
set j = j + 1
endif
exitwhen j >= 256
set map[j] = i
set i = i + 1
set j = j + 1
endloop
//Extract command string from player handicaps
set i = 0
loop
exitwhen i >= 12
set h = R2I(100*GetPlayerHandicap(Player(i)) + 0.5)
if not blocked[h] then
set h = map[h]
set v = h/6
set h = h-v*6
call SetPlayerHandicap(Player(i), 0.5 + h/10.0)
set command = command + SubString(chars, v, v+1)
endif
set i = i + 1
endloop
endfunction
endlibrary
library StatsTracking requires Game, Observe, SaveCode, SaveFile, LoadCode, LoadFile, Encoder, CryptoHash, FormatBitInt, FileIO
globals
private boolean trackStats = false
private constant integer ENCRYPTION_STRENGTH = 2 //1 to 16
private constant string ENCRYPTION_PASSWORD = "TRIGSTR_71"
private constant boolean APPLY_HASH = true
private constant integer STATS_VERSION = 1
private Encoder array encoder
private integer array wins
private integer array losses
private integer array scores
private integer array assists
private boolean loaded = false
endglobals
function GetEncoder takes integer playerId returns Encoder
return encoder[playerId]
endfunction
//========================== Saving ==========================
private function save takes integer playerId, SaveCode data returns nothing
call data.write(wins[playerId])
call data.write(losses[playerId])
call data.write(scores[playerId])
call data.write(assists[playerId])
endfunction
private function interface Aftersave takes integer playerId returns nothing
private function saveStats takes integer playerId, Aftersave after returns nothing
local SaveCode data = 0
local Thread thread
local boolean saving = false
set thread = Thread.create()
if (GetPlayerId(GetLocalPlayer()) != playerId) then
call thread.sync()
endif
loop
if (GetPlayerId(GetLocalPlayer()) == playerId) and not saving then
set data = SaveCode.create()
call data.write(STATS_VERSION)
call save(playerId, data)
set saving = true
call thread.sync()
endif
call TriggerSyncReady()
exitwhen thread.synced
endloop
call thread.destroy()
call FormatBitInt.evaluate(data)
call TriggerSyncReady()
if (APPLY_HASH) then
call ApplyHash(data)
endif
call GetEncoder(playerId).encrypt(data, ENCRYPTION_STRENGTH)
call SaveFile(MAP_NAME, GetPlayerName(GetLocalPlayer()), data)
if (0 != data) then
call data.destroy()
endif
call after.execute(playerId)
endfunction
private function saveStatsAll takes Aftersave after returns nothing
local integer i = 0
loop
if (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and /*
*/ GetPlayerController(Player(i)) == MAP_CONTROL_USER and /*
*/ not IsPlayerObserving(Player(i))) then
call saveStats.execute(i, after)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endfunction
private function returnLoss takes integer playerId returns nothing
set losses[playerId] = losses[playerId] - 1
endfunction
function EnableStatsTracking takes nothing returns boolean
local integer i
if not trackStats and loaded then
if humanPlayerCount >= STATS_MIN_PLAYERS then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Stats are being tracked for this game.")
else
call DisplayTimedTextToPlayer(host, 0.00, 0.00, 10.0, INVALID_COLOR_CODE+"Stats tracking requires atleast 4 players.")
endif
set trackStats = true
set i = 0
loop
set losses[i] = losses[i] + 1
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call saveStatsAll(returnLoss)
return true
endif
return false
endfunction
private function confirmWinLoss takes integer playerId returns nothing
if IsPlayerVictor(Player(playerId)) then
call DisplayTimedTextToPlayer(Player(playerId),0,0,60000,DEFAULT_COLOR_CODE+"Win saved.")
else
call DisplayTimedTextToPlayer(Player(playerId),0,0,60000,DEFAULT_COLOR_CODE+"Loss saved.")
endif
endfunction
private function gameEnd takes nothing returns nothing
local integer i = 0
if trackStats then
loop
if IsPlayerVictor(Player(i)) then
set wins[i] = wins[i] + 1
else
set losses[i] = losses[i] + 1
endif
set scores[i] = scores[i] + GetPlayerScores(Player(i))
set assists[i] = assists[i] + GetPlayerAssists(Player(i))
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call saveStatsAll(confirmWinLoss)
endif
endfunction
//========================== Loading ==========================
private function interface Loader takes LoadCode data returns nothing
globals
private Loader array loaders
endglobals
private function RegisterLoader takes Loader c, integer ver returns nothing
set loaders[ver] = c
endfunction
private function loadStats takes nothing returns nothing
local LoadStream stream
local LoadCode data
local boolean validated
local integer codeVersion
set stream = LoadFile(MAP_NAME, GetPlayerName(GetLocalPlayer()))
if (not File.enabled) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60.0,INVALID_COLOR_CODE+/*
*/"Stats are currently disabled for you.\nTo enable stats, you need to allow local files.")
endif
loop
set data = stream.read()
exitwhen 0 == data
call GetEncoder(data.playerId).decrypt(data, ENCRYPTION_STRENGTH)
set validated = not APPLY_HASH or ValidateHash(data)
if (validated) then
set codeVersion = data.read()
if (codeVersion > 0 and codeVersion <= STATS_VERSION) then
call loaders[codeVersion].execute(data)
endif
endif
call data.destroy()
call TriggerSyncReady()
endloop
call stream.destroy()
set loaded = true
call RegisterEvent(function gameEnd, EVENT_GAME_END)
endfunction
private function Load1 takes LoadCode data returns nothing
set wins[data.playerId] = data.read()
set losses[data.playerId] = data.read()
set scores[data.playerId] = data.read()
set assists[data.playerId] = data.read()
endfunction
private function showStats takes nothing returns boolean
local integer id = GetPlayerId(GetTriggerPlayer())
call DisplayTimedTextToPlayer(GetTriggerPlayer(),0,0,15.0,DEFAULT_COLOR_CODE+/*
*/"Wins Losses Scores Assists\n"+/*
*/VALID_COLOR_CODE+" "+I2S(wins[id])+Spaces(10 - Digits(wins[id]))+/*
*/INVALID_COLOR_CODE+" "+I2S(losses[id])+Spaces(10 - Digits(losses[id]))+/*
*/VALID_COLOR_CODE+" "+I2S(scores[id])+Spaces(11 - Digits(scores[id]))+/*
*/VALID_COLOR_CODE+" "+I2S(assists[id])+Spaces(12 - Digits(assists[id])))
return false
endfunction
private struct Init extends array
private static method initEncoders takes nothing returns nothing
local integer playerId
if (ENCRYPTION_STRENGTH > 0) then
set playerId = 11
loop
if (/*
*/GetPlayerSlotState(Player(playerId)) == PLAYER_SLOT_STATE_PLAYING and /*
*/GetPlayerController(Player(playerId)) == MAP_CONTROL_USER /*
*/) then
set encoder[playerId] = Encoder.create(GetPlayerName(Player(playerId)) + ENCRYPTION_PASSWORD)
endif
exitwhen 0 == playerId
set playerId = playerId - 1
endloop
endif
endmethod
private static method init2 takes nothing returns nothing
call WaitForGameToStart()
call loadStats()
endmethod
private static method init takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call init2.execute()
endmethod
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call initEncoders.execute()
call RegisterLoader(Load1, 1)
call TimerStart(CreateTimer(),0.00,false,function thistype.init)
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-stats", true)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function showStats)
endmethod
endstruct
endlibrary
library UnitProperties requires Table /*
******************************************************************
*
* function SetUnitTypeCollisionSize takes integer rawcode, real collisionSize returns nothing
* function GetUnitCollisionSize takes unit u returns real
*
* function SetUnitTypeHeight takes integer rawcode, real height returns nothing
* function GetUnitHeight takes unit u returns real
*
* function SetUnitTypeMass takes integer rawcode, real mass returns nothing
* function GetUnitMass takes unit u returns real
*
* function SetUnitTypeProperties takes integer rawcode, real collisionSize, real height, real mass returns nothing
*
******************************************************************/
globals
private TableArray properties
endglobals
function SetUnitTypeCollisionSize takes integer rawcode, real collisionSize returns nothing
set properties[0].real[rawcode] = collisionSize
endfunction
function GetUnitCollisionSize takes unit u returns real
return properties[0].real[GetUnitTypeId(u)]
endfunction
function SetUnitTypeHeight takes integer rawcode, real height returns nothing
set properties[1].real[rawcode] = height
endfunction
function GetUnitHeight takes unit u returns real
return properties[1].real[GetUnitTypeId(u)]
endfunction
function SetUnitTypeMass takes integer rawcode, real mass returns nothing
set properties[2].real[rawcode] = mass
endfunction
function GetUnitMass takes unit u returns real
return properties[2].real[GetUnitTypeId(u)]
endfunction
function SetUnitTypeProperties takes integer rawcode, real collisionSize, real height, real mass returns nothing
call SetUnitTypeCollisionSize(rawcode, collisionSize)
call SetUnitTypeHeight(rawcode, height)
call SetUnitTypeMass(rawcode, mass)
endfunction
private module InitModule
private static method onInit takes nothing returns nothing
set properties = TableArray[3]
endmethod
endmodule
private struct InitStruct
implement InitModule
endstruct
endlibrary
library Boundary initializer init requires Vector, ErrorMessage, Game
globals
private Vector array V
private region array bounds
private TableArray boundaryData
endglobals
function GetBoundaryRegion takes real x, real y returns region
local integer i = 0
loop
if IsPointInRegion(bounds[i], x, y) then
return bounds[i]
endif
set i = i + 1
exitwhen bounds[i] == null
endloop
return null
endfunction
function BoundaryCheck takes unit u, Vector b, real speedLoss returns nothing
local Vector v
local integer i = 0
local real x
local real y
local integer id
if IsUnitType(u, UNIT_TYPE_OBJECT) or GetUnitTypeId(u) == BALL_RAWCODE then
set x = GetUnitX(u)
set y = GetUnitY(u)
loop
if IsPointInRegion(bounds[i], x, y) then
set id = GetHandleId(bounds[i])
if GetUnitZ(u) >= boundaryData[0].real[id] and GetUnitZ(u) <= boundaryData[1].real[id] and Vector.dotProduct(b, V[boundaryData[0][id]]) < 0.00 then
set v = Vector.projectionVector(b, V[boundaryData[0][id]])
if IsUnitType(u, UNIT_TYPE_PLAYER) and v.getLength() > PLAYER_BUMP_SFX_THRESHOLD then
call Sfx(PLAYER_BUMP_SFX_PATH, GetUnitX(u), GetUnitY(u), GetUnitZ(u), bj_RADTODEG*Atan2(v.y, v.x) + 180.0, 0, 0.7)
endif
call v.scale(-1.00)
call b.add(v)
if speedLoss > 0.00 and b.getLength() > speedLoss then
call b.setLength(b.getLength() - speedLoss)
call b.add(v)
endif
call v.destroy()
endif
endif
set i = i + 1
exitwhen bounds[i] == null
endloop
else
//call ThrowWarning(true, "Boundary", "BoundaryCheck", null, 0, "Checked unit isn't an object.")
endif
endfunction
private function deflection takes nothing returns boolean
local Vector v
local unit u = GetTriggerUnit()
local Ball ball = getBall(u)
local integer id = GetHandleId(GetTriggeringRegion())
local location loc
if GetUnitTypeId(u) == BALL_RAWCODE then
if not ball.hold then
if GetUnitZ(ball.ball) >= boundaryData[0].real[id] and GetUnitZ(ball.ball) <= boundaryData[1].real[id] and Vector.dotProduct(ball.vel, V[boundaryData[0][id]]) < 0.00 then
set v = Vector.projectionVector(ball.vel, V[boundaryData[0][id]])
if GetUnitFlyHeight(ball.ball) > BALL_BUMP_SFX_THRESHOLD then
call Sfx(BALL_BUMP_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), bj_RADTODEG*Atan2(v.y, v.x), 180.0, 1.00)
endif
call v.scale(-1.00)
call ball.applyVector(v)
if v.getLength() > BALL_BUMP_SPEED_LOSS then
call v.setLength(v.getLength() - BALL_BUMP_SPEED_LOSS)
call ball.applyVector(v)
endif
call v.destroy()
endif
endif
elseif IsUnitType(u, UNIT_TYPE_OBJECT) then
if GetUnitZ(u) >= boundaryData[0].real[id] and GetUnitZ(u) <= boundaryData[1].real[id] and Vector.dotProduct(Object[u].velocity, V[boundaryData[0][id]]) < 0.00 then
if GetUnitAbilityLevel(u, SMASH_OGRE_SLOW_BUFF_RAWCODE) > 0 then
call Object[u].velocity.scale(0.00)
call UnitRemoveAbility(u, SMASH_OGRE_SLOW_BUFF_RAWCODE)
if goalEnabled and not IsUnitInRegion(goalRegion[GetPlayerTeam(GetOwningPlayer(u))], u) then
call dummyCast(u, SMASH_STUN_RAWCODE, "thunderbolt")
call Sfx(PLAYER_BUMP_SFX_PATH, GetUnitX(u), GetUnitY(u), GetUnitZ(u), bj_RADTODEG*Atan2(v.y, v.x) + 180.0, 0, 0.7)
endif
else
if GetUnitAbilityLevel(u, SUPER_SPRINT_BUFF_RAWCODE) > 0 then
//call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 2.00, R2S(GetUnitX(u)) + " " + R2S(GetUnitY(u)))
endif
set v = Vector.projectionVector(Object[u].velocity, V[boundaryData[0][id]])
if IsUnitType(u, UNIT_TYPE_PLAYER) and v.getLength() > PLAYER_BUMP_SFX_THRESHOLD then
call Sfx(PLAYER_BUMP_SFX_PATH, GetUnitX(u), GetUnitY(u), GetUnitZ(u), bj_RADTODEG*Atan2(v.y, v.x) + 180.0, 0, 0.7)
endif
call v.scale(-1.00)
call Object[u].applyVector(v)
if IsUnitType(u, UNIT_TYPE_PLAYER) and v.getLength() > PLAYER_BUMP_SPEED_LOSS then
call v.setLength(v.getLength() - PLAYER_BUMP_SPEED_LOSS)
endif
call Object[u].applyVector(v)
call v.destroy()
if not IsUnitType(u, UNIT_TYPE_PLAYER) then
set loc = Location(GetUnitX(u) + Object[u].getVector().x, GetUnitY(u) + Object[u].getVector().y)
call SetUnitFacingToFaceLocTimed(u, loc, 0.00)
call RemoveLocation(loc)
endif
endif
endif
endif
set u = null
return false
endfunction
//! textmacro BOUNDARY_INITIALIZATION takes index, angle, suffix
set bounds[$index$] = CreateRegion()
call RegionAddRect(bounds[$index$], gg_rct_$angle$$suffix$)
set boundaryData[0][GetHandleId(bounds[$index$])] = $angle$
set boundaryData[0].real[GetHandleId(bounds[$index$])] = 0.00
set boundaryData[1].real[GetHandleId(bounds[$index$])] = BOUNDARY_DEFAULT_Z
call TriggerRegisterEnterRegion(t, bounds[$index$], null)
//! endtextmacro
private function setupBounds takes nothing returns boolean
local trigger t = CreateTrigger()
//! runtextmacro BOUNDARY_INITIALIZATION("0", "0", "_1")
//! runtextmacro BOUNDARY_INITIALIZATION("1", "0", "_2")
//! runtextmacro BOUNDARY_INITIALIZATION("2", "0", "_3")
//! runtextmacro BOUNDARY_INITIALIZATION("3", "135", "")
//! runtextmacro BOUNDARY_INITIALIZATION("4", "180", "_1")
//! runtextmacro BOUNDARY_INITIALIZATION("5", "180", "_2")
//! runtextmacro BOUNDARY_INITIALIZATION("6", "180", "_3")
//! runtextmacro BOUNDARY_INITIALIZATION("7", "225", "")
//! runtextmacro BOUNDARY_INITIALIZATION("8", "270", "_1")
//! runtextmacro BOUNDARY_INITIALIZATION("9", "270", "_2")
//! runtextmacro BOUNDARY_INITIALIZATION("10", "270", "_3")
//! runtextmacro BOUNDARY_INITIALIZATION("11", "315", "")
//! runtextmacro BOUNDARY_INITIALIZATION("12", "45", "")
//! runtextmacro BOUNDARY_INITIALIZATION("13", "90", "_1")
//! runtextmacro BOUNDARY_INITIALIZATION("14", "90", "_2")
//! runtextmacro BOUNDARY_INITIALIZATION("15", "90", "_3")
set bounds[16] = CreateRegion()
call RegionAddRect(bounds[16], gg_rct_Goal_1)
set boundaryData[0][GetHandleId(bounds[16])] = 0
set boundaryData[0].real[GetHandleId(bounds[16])] = DEFAULT_Z + GOAL_HEIGHT
set boundaryData[1].real[GetHandleId(bounds[16])] = BOUNDARY_DEFAULT_Z
call TriggerRegisterEnterRegion(t, bounds[16], null)
set bounds[17] = CreateRegion()
call RegionAddRect(bounds[17], gg_rct_Goal_2)
set boundaryData[0][GetHandleId(bounds[17])] = 180
set boundaryData[0].real[GetHandleId(bounds[17])] = DEFAULT_Z + GOAL_HEIGHT
set boundaryData[1].real[GetHandleId(bounds[17])] = BOUNDARY_DEFAULT_Z
call TriggerRegisterEnterRegion(t, bounds[17], null)
call TriggerAddCondition(t, function deflection)
set t = null
return false
endfunction
private function init takes nothing returns nothing
set boundaryData = TableArray[2]
set V[0] = Vector.create(1.00, 0.00, 0.00)
set V[45] = Vector.create(1.00, 1.00, 0.00)
set V[90] = Vector.create(0.00, 1.00, 0.00)
set V[135] = Vector.create(-1.00, 1.00, 0.00)
set V[180] = Vector.create(-1.00, 0.00, 0.00)
set V[225] = Vector.create(-1.00, -1.00, 0.00)
set V[270] = Vector.create(0.00, -1.00, 0.00)
set V[315] = Vector.create(1.00, -1.00, 0.00)
call EVENT_FIELD_CHOOSE.register(function setupBounds)
endfunction
endlibrary
library ObjectInit requires UnitProperties
private module initModule
private static method onInit takes nothing returns nothing
call SetUnitTypeProperties(AKARI_SKA_AS_ION_INK_RAWCODE, 30.0, 140.0, 59.0)
call SetUnitTypeProperties(DOCTRINAL_CAKE_RAWCODE, 30.0, 145.0, 61.0)
call SetUnitTypeProperties(KARMA_GREEN_INN_RAWCODE, 30.0, 170.0, 68.0)
call SetUnitTypeProperties(KARMIC_LIVID_LION_RAWCODE, 30.0, 145.0, 62.0)
call SetUnitTypeProperties(NISEI_LINESMAN_RAWCODE, 30.0, 140.0, 62.0)
call SetUnitTypeProperties(OAK_KING_ZIT_RAWCODE, 30.0, 145.0, 61.0)
call SetUnitTypeProperties(PARCH_NINE_TIE_RAWCODE, 30.0, 120.0, 56.0)
call SetUnitTypeProperties(SZURA_COH_RAWCODE, 30.0, 160.0, 58.0)
call SetUnitTypeProperties(IDEAL_VIZZD_RAKIA_RAWCODE, 30.0, 145.0, 59.0)
call SetUnitTypeProperties(DARK_DAWN_OAR_RAWCODE, 30.0, 150.0, 62.0)
call SetUnitTypeProperties(CLAY_HAND_NIL_RAWCODE, 30.0, 155.0, 61.0)
call SetUnitTypeProperties(DEAD_HERO_RAWCODE, 30.0, 150.0, 61.0)
call SetUnitTypeProperties(JIG_PER_ACE_RAWCODE, 30.0, 150.0, 61.0)
call SetUnitTypeProperties(SIR_REAL_PUNTS_RAWCODE, 30.0, 165.0, 67.0)
call SetUnitTypeProperties(MASTER_AWE_QI_RAWCODE, 30.0, 150.0, 62.0)
call SetUnitTypeProperties(MANFUL_LOAF_RAWCODE, 30.0, 140.0, 58.0)
call SetUnitTypeProperties(MARZIPAN_USA_BRO_RAWCODE, 30.0, 160.0, 65.0)
call SetUnitTypeProperties(MR_DOLT_AMIGO_RAWCODE, 30.0, 155.0, 58.0)
call SetUnitTypeProperties(REFEREE_RAWCODE, 30.0, 140.0, 63.0)
call SetUnitTypeProperties(TACKLE_SHADOW_RAWCODE, 0.00, 140.0, 62.0)
call SetUnitTypeProperties(BALL_RAWCODE, 25.0, 40.0, 15.0)
call SetUnitTypeProperties(SUMMER_TREE_RAWCODE, 35.0, 726.0, 360.0)
call SetUnitTypeProperties(SNOWY_TREE_RAWCODE, 35.0, 726.0, 360.0)
call SetUnitTypeProperties(SWAP_PROJECTILE_RAWCODE, 0.00, 0.00, 8.00)
call SetUnitTypeProperties(EARTH_PILLAR_DUMMY_RAWCODE, 50.0, 200.00, 500.00)
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
endlibrary
library Objects requires UnitZ, InstanceIterator, Vector, Boundary, UnitCollision, ObjectInit, LinkedList
struct Object //Treated as cylinders
static thistype dis
real radius
real height
real mass
Vector velocity
real lastX
real lastY
real lastZ
real movementX
real movementY
boolean moving
/*static method EnumObjectsInRange takes real x, real y, real radius, code c returns nothing
endmethod*/
implement ObjectList
static method createFilter takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_OBJECT)
endmethod
method onCreate takes nothing returns nothing
set radius = GetUnitCollisionSize(me)
set height = GetUnitHeight(me)
set mass = GetUnitMass(me)
set velocity = Vector.create(0.00, 0.00, 0.00)
call listAdd()
endmethod
method onDestroy takes nothing returns nothing
call stop32()
call velocity.destroy()
call listRemove()
endmethod
implement AutoCreate
implement AutoDestroy
static method collision takes nothing returns boolean
local thistype this = dis
local thistype that
local unit f = GetFilterUnit()
local Vector d
local Vector v1
local Vector v2
local Vector v3
local Vector v4
local real l1
local real l2
if f != .me and IsUnitType(f, UNIT_TYPE_OBJECT) and RAbsBJ(GetUnitZ(.me) - GetUnitZ(f)) <= 100.0 then
set d = Vector.create(GetUnitX(f) - GetUnitX(.me), GetUnitY(f) - GetUnitY(.me), GetUnitZ(f) - GetUnitZ(.me))
set that = thistype[f]
if Vector.dotProduct(this.velocity, that.velocity) <= 0.00 then
if Vector.dotProduct(this.velocity, d) <= 0.00 then
set f = null
call d.destroy()
return false
endif
else
if Vector.dotProduct(this.velocity, d) <= 0.00 then
set l1 = this.velocity.getLength()
set l2 = that.velocity.getLength()
else
set l1 = that.velocity.getLength()
set l2 = this.velocity.getLength()
endif
if l1 >= l2 then
set f = null
call d.destroy()
return false
endif
endif
set v1 = Vector.projectionVector(that.velocity, d)
set v2 = Vector.projectionVector(this.velocity, d)
if RAbsBJ(v2.getLength() - sgn(Vector.dotProduct(v1, v2))*v1.getLength()) > PLAYER_BUMP_SFX_THRESHOLD then
call d.setLength(d.getLength()/2)
call Sfx(PLAYER_BUMP_SFX_PATH, GetUnitX(.me) + d.x, GetUnitY(.me) + d.y, GetUnitZ(.me), Atan2(d.y, d.x)*bj_RADTODEG + 180.0, 0.00, 0.7)
endif
set l1 = d.x
set d.x = -d.y
set d.y = l1
set v3 = Vector.projectionVector(this.velocity, d)
set v4 = Vector.projectionVector(that.velocity, d)
call this.velocity.destroy()
call that.velocity.destroy()
set this.velocity = v1
call this.applyVector(v3)
set that.velocity = v2
call that.applyVector(v4)
call d.destroy()
call v3.destroy()
call v4.destroy()
set f = null
endif
return false
endmethod
method iterate32 takes nothing returns nothing
local real z
local Vector v
if ((selection == 3 or selection == 4) and .moving and IsUnitType(.me, UNIT_TYPE_PLAYER)) then
if (.velocity.getLength() < PLAYER_MAX_SLIDE_SPEED) then
set v = Vector.create(PLAYER_SLIDE_SPEED_ICE * Cos(GetUnitFacing(.me) * bj_DEGTORAD), PLAYER_SLIDE_SPEED_ICE * Sin(GetUnitFacing(.me) * bj_DEGTORAD), 0.00)
call .applyVector(v)
call v.destroy()
call GroupEnumUnitsInRange(enumGroup, .movementX, .movementY, POSITION_RADIUS, Filter(function thistype.checkEnd))
endif
endif
if radius > 0.00 then
if GetUnitFlyHeight(me) < 1.00 then
call EnableUnitCollision(me)
if velocity.getLength() > PLAYER_FRICTION_GROUND then
call .velocity.setLength(.velocity.getLength() - PLAYER_FRICTION_GROUND)
else
call SetUnitFlyHeight(.me, 0.00, 0.00)
call .velocity.setLength(0.00)
call .stop32()
return
endif
else
set .velocity.z = .velocity.z - GRAVITY_ACCELERATION
if .velocity.getLength() > PLAYER_FRICTION_AIR then
call .velocity.setLength(.velocity.getLength() - PLAYER_FRICTION_AIR)
else
call .velocity.setLength(0.00)
endif
endif
endif
if RectContainsCoords(bj_mapInitialPlayableArea , GetUnitX(.me) + .velocity.x, GetUnitY(.me) + .velocity.y) then
if GetUnitFlyHeight(.me) < 1.00 then
call SetUnitX(.me, GetUnitX(.me) + .velocity.x)
call SetUnitY(.me, GetUnitY(.me) + .velocity.y)
else
call SetUnitX(.me, .lastX + .velocity.x)
call SetUnitY(.me, .lastY + .velocity.y)
endif
endif
if (not IsPointInRegion(playable, GetUnitX(.me), GetUnitY(.me))) or (not IsTerrainWalkable(GetUnitX(.me), GetUnitY(.me))) then
call SetUnitPosition(.me, GetUnitX(.me), GetUnitY(.me))
endif
set .lastX = GetUnitX(.me)
set .lastY = GetUnitY(.me)
set z = GetUnitZ(.me) + .velocity.z
if z < GetTerrainZ(GetUnitX(.me), GetUnitY(.me)) and .velocity.z < 0.00 then
call SetUnitFlyHeight(.me, 0.00, 0.00)
if IsUnitType(me, UNIT_TYPE_PLAYER) and .velocity.z < -PLAYER_BUMP_SFX_THRESHOLD then
call Sfx(PLAYER_BUMP_SFX_PATH, GetUnitX(.me), GetUnitY(.me), 0.00, 0.00, 90, 0.7)
endif
set .velocity.z = -.velocity.z
if radius > 0.00 then
set .velocity.z = .velocity.z - PLAYER_BUMP_SPEED_LOSS
if .velocity.z < 0.00 then
set .velocity.z = 0.00
endif
endif
else
call SetUnitZ(.me, z)
if radius > 0.00 and z >= 1.00 then
call DisableUnitCollision(me)
endif
endif
if .velocity.getLength() != 0.00 and radius > 0.00 then
set .dis = this
call GroupEnumUnitsInRange(enumGroup, GetUnitX(.me), GetUnitY(.me), 80.0, Filter(function thistype.collision))
endif
endmethod
implement II32
method setX takes real x returns nothing
call SetUnitX(me, x)
set lastX = x
endmethod
method setY takes real y returns nothing
call SetUnitY(me, y)
set lastY = y
endmethod
method setZ takes real z returns nothing
call SetUnitZ(me, z)
set lastZ = z
endmethod
method applyVector takes Vector v returns nothing
local real loss = 0.00
if IsUnitType(me, UNIT_TYPE_PLAYER) then
set loss = PLAYER_BUMP_SPEED_LOSS
endif
call velocity.add(v)
call BoundaryCheck(me, velocity, loss)
if start32() then
set lastX = GetUnitX(me)
set lastY = GetUnitY(me)
set lastZ = GetUnitZ(me)
endif
endmethod
method setVector takes Vector v returns nothing
set velocity.x = v.x
set velocity.y = v.y
set velocity.z = v.z
endmethod
method getVector takes nothing returns Vector
return velocity
endmethod
/*method exertForce takes Vector f returns nothing
local real l = f.getLength()
call f.setLength(f.getLength()/mass)
call applyVector(f)
call f.setLength(l)
endmethod*/
private static method checkEnd takes nothing returns boolean
local unit f = GetFilterUnit()
local real x = GetUnitX(f)
local real y = GetUnitY(f)
if (IsUnitType(f, UNIT_TYPE_PLAYER)) then
set x = Pow(thistype[f].movementX - x, 2)
set y = Pow(thistype[f].movementY - y, 2)
if (SquareRoot(x + y) <= POSITION_RADIUS) then
set thistype[f].moving = false
endif
endif
set f = null
return false
endmethod
static method isMoving takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s = OrderId2String(GetIssuedOrderId())
local Ball ball = Ball.balls[0]
if IsUnitType(u, UNIT_TYPE_PLAYER) and unitActive[GetPlayerId(GetOwningPlayer(u))] then
if s == "smart" then
set thistype[u].moving = true
set thistype[u].movementX = GetOrderPointX()
set thistype[u].movementY = GetOrderPointY()
call thistype[u].start32()
else
set thistype[u].moving = false
endif
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.isMoving)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function thistype.isMoving)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function thistype.isMoving)
endmethod
endstruct
endlibrary
library Taverns
globals
private unit characterTavern1 = null
private unit characterTavern2 = null
private unit hatTavern1 = null
private unit hatTavern2 = null
private unit hatTavern3 = null
endglobals
function GetCharacterTavern1 takes nothing returns unit
return characterTavern1
endfunction
function GetCharacterTavern2 takes nothing returns unit
return characterTavern2
endfunction
function GetHatTavern1 takes nothing returns unit
return hatTavern1
endfunction
function GetHatTavern2 takes nothing returns unit
return hatTavern2
endfunction
function GetHatTavern3 takes nothing returns unit
return hatTavern3
endfunction
private module InitModule
private static method onInit takes nothing returns nothing
local texttag t
set characterTavern1 = CreateUnit(REFEREE_PLAYER, PLAYER_TAVERN_1_RAWCODE, GetStartLocationX(0) + 210.0, GetStartLocationY(0)+135, 270.000)
call SetUnitColor(characterTavern1, ConvertPlayerColor(4))
set characterTavern2 = CreateUnit(REFEREE_PLAYER, PLAYER_TAVERN_2_RAWCODE, GetStartLocationX(0) + 210.0, GetStartLocationY(0)-135, 270.000)
call SetUnitColor(characterTavern2, ConvertPlayerColor(4))
set t = CreateTextTag()
call SetTextTagPermanent(t, true)
call SetTextTagPos(t, GetUnitX(characterTavern1) - 120.0, GetStartLocationY(0) + 50.0, 250.0)
call SetTextTagText(t, DEFAULT_COLOR_CODE+"Pick a character", TextTagSize2Height(20.00))
set hatTavern1 = CreateUnit(REFEREE_PLAYER, HAT_TAVERN_1_RAWCODE, GetStartLocationX(0) - 280.0, GetStartLocationY(0) + 220.0, 270.000)
call SetUnitColor(hatTavern1, ConvertPlayerColor(1))
set hatTavern2 = CreateUnit(REFEREE_PLAYER, HAT_TAVERN_2_RAWCODE, GetStartLocationX(0) - 280.0, GetStartLocationY(0) - 225.0, 270.000)
call SetUnitColor(hatTavern2, ConvertPlayerColor(9))
set hatTavern3 = CreateUnit(REFEREE_PLAYER, HAT_TAVERN_3_RAWCODE, GetStartLocationX(0) - 280.0, GetStartLocationY(0) - 15.0, 305.000)
call SetUnitColor(hatTavern2, ConvertPlayerColor(9))
set t = CreateTextTag()
call SetTextTagPermanent(t, true)
call SetTextTagPos(t, GetUnitX(hatTavern1) - 50.0, GetStartLocationY(0) + 50.0, 250.0)
call SetTextTagText(t, DEFAULT_COLOR_CODE+"Pick a hat", TextTagSize2Height(20.00))
set t = null
endmethod
endmodule
private struct InitStruct
implement InitModule
endstruct
endlibrary
library Teams
/*
*
* function GetTeamName takes integer team returns string
* function SetTeamName takes integer team, string name returns nothing
* function GetTeamColorCode takes integer team returns string
* function SetTeamColorCode takes integer team, string colorCode returns nothing
* function GetTeamCaptain takes integer team returns player
* function SetTeamCaptain takes integer team, player captain returns nothing
*
*/
globals
private string array teamName
private string array teamColorCode
private player array teamCaptain
endglobals
function GetTeamName takes integer team returns string
return teamName[team]
endfunction
function SetTeamName takes integer team, string name returns nothing
set teamName[team] = name
endfunction
function GetTeamColorCode takes integer team returns string
return teamColorCode[team]
endfunction
function SetTeamColorCode takes integer team, string colorCode returns nothing
set teamColorCode[team] = colorCode
endfunction
function GetTeamCaptain takes integer team returns player
return teamCaptain[team]
endfunction
function SetTeamCaptain takes integer team, player captain returns nothing
set teamCaptain[team] = captain
endfunction
private module initModule
private static method onInit takes nothing returns nothing
local integer i
call SetTeamName(0, "Team 1")
call SetTeamName(1, "Team 2")
call SetTeamColorCode(0, "|c00FF0202")
call SetTeamColorCode(1, "|c000041FF")
set i = 0
loop
exitwhen (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) or (i == MAX_PLAYERS/2)
set i = i + 1
endloop
if i == MAX_PLAYERS/2 then
call SetTeamCaptain(0, null)
else
call SetTeamCaptain(0, Player(i))
endif
set i = MAX_PLAYERS/2
loop
exitwhen (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) or (i == MAX_PLAYERS)
set i = i + 1
endloop
if i == MAX_PLAYERS then
call SetTeamCaptain(1, null)
else
call SetTeamCaptain(1, Player(i))
endif
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
endlibrary
library Players initializer init requires TimerUtils, Multiboard, Utilities, Observe, ErrorMessage, Teams
/*********************************************************************
*
* function Get/SetPlayer
* StartX
* StartY
* Facing
* ColorCode
* HatPath
* Hat
* Unit
* Scores
* Assists
* Number
* NumberInTeam
* OriginalName
*
*
* function GetPlayerCount takes nothing returns integer
* function GetPlayerCountAll takes nothing returns integer
* function GetTeamPlayerCount takes integer team returns integer
* function GetHumanPlayerCount takes nothing returns integer
*
* function interface PlayerIterator takes player p returns nothing
*
* function IteratePlayers takes PlayerIterator iterator returns nothing
* function IteratePlayersByTeam takes PlayerIterator iterator, integer team returns nothing
* function IteratePlayersPlaying takes PlayerIterator iterator returns nothing
* function IteratePlayersAll takes PlayerIterator iterator returns nothing
*
* function GetPlayerByNumber takes integer n returns player
*
* function GetPlayerTeamName takes player p returns string
*
* function GetPlayerNamed takes string input returns player
*
* function UpdatePlayer takes player p returns nothing
*
* function ChangePlayerTeam takes player p, integer team returns nothing
*
* function ArrangeStartPositions takes nothing returns nothing
* function ArrangePlayers takes nothing returns nothing
*
*********************************************************************/
globals
private integer playerCount = 0
private integer playerCountHuman = 0
private integer secondsPlayed = 0
private integer array playerCountTeam
private player array players
private Multiboard playerBoard
boolean array unitActive
boolean array fakeInjuryEnabled
endglobals
//! textmacro PLAYER_PROPERTY takes property, type
globals
private $type$ array player$property$
endglobals
function GetPlayer$property$ takes player p returns $type$
return player$property$[GetPlayerId(p)]
endfunction
function SetPlayer$property$ takes player p, $type$ t returns nothing
set player$property$[GetPlayerId(p)] = t
endfunction
//! endtextmacro
//! runtextmacro PLAYER_PROPERTY("StartX", "real")
//! runtextmacro PLAYER_PROPERTY("StartY", "real")
//! runtextmacro PLAYER_PROPERTY("Facing", "real")
//! runtextmacro PLAYER_PROPERTY("ColorCode", "string")
//! runtextmacro PLAYER_PROPERTY("HatPath", "string")
//! runtextmacro PLAYER_PROPERTY("Hat", "effect")
//! runtextmacro PLAYER_PROPERTY("Unit", "unit")
//! runtextmacro PLAYER_PROPERTY("Scores", "integer")
//! runtextmacro PLAYER_PROPERTY("Assists", "integer")
//! runtextmacro PLAYER_PROPERTY("Number", "integer")
//! runtextmacro PLAYER_PROPERTY("NumberInTeam", "integer")
//! runtextmacro PLAYER_PROPERTY("OriginalName", "string")
function GetPlayerCount takes nothing returns integer
return playerCount
endfunction
function GetPlayerCountAll takes nothing returns integer
return GetPlayerCount() + GetObserverCount()
endfunction
function GetTeamPlayerCount takes integer team returns integer
return playerCountTeam[team]
endfunction
function GetHumanPlayerCount takes nothing returns integer
return playerCountHuman
endfunction
function interface PlayerIterator takes player p returns nothing
function IteratePlayersAll takes PlayerIterator iterator returns nothing
local integer i = 0
loop
exitwhen i == MAX_PLAYERS
call iterator.execute(Player(i))
set i = i + 1
endloop
endfunction
function IteratePlayersPlaying takes PlayerIterator iterator returns nothing
local integer i = 0
loop
exitwhen i == MAX_PLAYERS
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call iterator.execute(Player(i))
endif
set i = i + 1
endloop
endfunction
function IteratePlayers takes PlayerIterator iterator returns nothing
local integer i = 0
loop
exitwhen i == playerCount
call iterator.execute(players[i])
set i = i + 1
endloop
endfunction
function IteratePlayersByTeam takes PlayerIterator iterator, integer team returns nothing
local integer i = team*GetTeamPlayerCount(team - 1)
local integer t = i + GetTeamPlayerCount(team)
loop
exitwhen i == t
call iterator.execute(players[i])
set i = i + 1
endloop
endfunction
function IteratePlayersByTeamAll takes PlayerIterator iterator, integer team returns nothing
local integer i = 0
loop
exitwhen i == MAX_PLAYERS
if GetPlayerTeam(Player(i)) == team then
call iterator.execute(Player(i))
endif
set i = i + 1
endloop
endfunction
function GetPlayerByNumber takes integer n returns player
return players[n]
endfunction
function GetPlayerTeamName takes player p returns string
return GetTeamName(GetPlayerTeam(p))
endfunction
private function searchWholeName takes player p returns nothing
local string input = tempString
if StringCase(GetPlayerName(p), false) == input then
set tempPlayer = p
elseif StringCase(GetPlayerOriginalName(p), false) == input then
set tempPlayer2 = p
endif
endfunction
private function searchSubName takes player p returns nothing
local string input = tempString
local integer inputLength = tempInteger
local integer nameLength = StringLength(GetPlayerName(p))
local integer i
set i = 0
loop
exitwhen (i + inputLength) > nameLength
if StringCase(SubString(GetPlayerName(p), i, i + inputLength), false) == input then
set tempPlayer = p
endif
set i = i + 1
endloop
if tempPlayer2 == null then
set nameLength = StringLength(GetPlayerOriginalName(p))
set i = 0
loop
exitwhen (i + inputLength) > nameLength
if StringCase(SubString(GetPlayerOriginalName(p), i, i + inputLength), false) == input then
set tempPlayer2 = p
endif
set i = i + 1
endloop
endif
endfunction
function GetPlayerNamed takes string input returns player
set input = StringCase(input, false)
set tempString = input
set tempInteger = StringLength(input)
set tempPlayer = null
set tempPlayer2 = null
call IteratePlayersPlaying(searchWholeName)
if tempPlayer != null then
return tempPlayer
endif
if tempInteger > 2 then
call IteratePlayersPlaying(searchSubName)
if tempPlayer != null then
return tempPlayer
endif
endif
return tempPlayer2
endfunction
private function setPlayerCoordinates takes player p returns nothing
call SetPlayerStartX(p, GetRectCenterX(tempRect))
call SetPlayerStartY(p, GetRectMaxY(tempRect) - (GetPlayerNumberInTeam(p) + 1)*tempReal)
call SetPlayerFacing(p, 90.0 - 90.0*sgn(currentField.centerX - GetRectCenterX(tempRect)))
endfunction
function ArrangeStartPositions takes nothing returns boolean
set tempRect = gg_rct_Start_1
set tempReal = (GetRectMaxY(tempRect) - GetRectMinY(tempRect))/(playerCountTeam[0] + 1)
call IteratePlayersByTeam(setPlayerCoordinates, 0)
set tempRect = gg_rct_Start_2
set tempReal = (GetRectMaxY(tempRect) - GetRectMinY(tempRect))/(playerCountTeam[1] + 1)
call IteratePlayersByTeam(setPlayerCoordinates, 1)
return false
endfunction
function UpdatePlayer takes player p returns nothing
if not IsPlayerObserving(p) then
set playerBoard[GetPlayerNumber(p) + 1][0].text = DEFAULT_COLOR_CODE+I2S(GetPlayerNumber(p) + 1)+".|r"
set playerBoard[GetPlayerNumber(p) + 1][1].text = GetPlayerColorCode(p)+GetPlayerName(p)+"|r"
set playerBoard[GetPlayerNumber(p) + 1][2].text = " "+GetPlayerColorCode(p)+I2S(GetPlayerScores(p))
set playerBoard[GetPlayerNumber(p) + 1][3].text = " "+GetPlayerColorCode(p)+I2S(GetPlayerAssists(p))
endif
endfunction
private function setAlliances takes player p returns nothing
if p != tempPlayer then
if GetPlayerTeam(p) == GetPlayerTeam(tempPlayer) then
call SetPlayerAllianceStateBJ(p, tempPlayer, bj_ALLIANCE_ALLIED_VISION)
call SetPlayerAllianceStateBJ(tempPlayer, p, bj_ALLIANCE_ALLIED_VISION)
else
call SetPlayerAllianceStateBJ(p, tempPlayer, bj_ALLIANCE_UNALLIED)
call SetPlayerAllianceStateBJ(tempPlayer, p, bj_ALLIANCE_UNALLIED)
endif
endif
endfunction
function ChangePlayerTeam takes player p, integer team returns nothing
local unit u
local real x
local real y
local playercolor color
if p != null and GetPlayerTeam(p) != team then
call SetPlayerTeam(p, team)
call SetPlayerColorCode(p, GetTeamColorCode.evaluate(team))
set color = ConvertPlayerColor(ColorCode2Index.evaluate(GetTeamColorCode.evaluate(team)))
call SetPlayerColor(p, color)
set u = GetPlayerUnit(p)
if GetUnitTypeId(u) != 0 then
call SetUnitColor(u, color)
if not IsPlayerObserving(p) then
set x = GetUnitX(u)
set y = GetUnitY(u)
call SetUnitX(u, DUMMY_X)
call SetUnitY(u, DUMMY_Y)
call SetUnitX(u, x)
call SetUnitY(u, y)
endif
endif
set u = null
set tempPlayer = p
call IteratePlayersAll(setAlliances)
endif
endfunction
private function countPlayerIn takes player p returns nothing
local integer team
if not IsPlayerObserving(p) then
set playerCount = playerCount + 1
if GetPlayerController(p) == MAP_CONTROL_USER then
set playerCountHuman = playerCountHuman + 1
endif
set team = GetPlayerTeam(p)
call SetPlayerNumberInTeam(p, playerCountTeam[team])
set playerCountTeam[team] = playerCountTeam[team] + 1
endif
endfunction
private function mod takes integer x, integer y returns integer
return x - (x / y) * y
endfunction
private function timeRunning takes nothing returns string
local integer h = mod(secondsPlayed / 3600, 24)
local integer m = mod(secondsPlayed / 60, 60)
local integer s = mod(secondsPlayed, 60)
local string hours = I2S(h)
local string minutes = I2S(m)
local string seconds = I2S(s)
if h / 10 == 0 then
set hours = "0" + hours
endif
if m / 10 == 0 then
set minutes = "0" + minutes
endif
if s / 10 == 0 then
set seconds = "0" + seconds
endif
if secondsPlayed > 86400 then // Over a day of one banjo game? wtf
return "Too Long. Stahp"
else
return hours + ":" + minutes + ":" + seconds
endif
endfunction
private function updatePlayerPosition takes player p returns nothing
local integer n
if not IsPlayerObserving(p) then
set n = GetPlayerTeam(p)*GetTeamPlayerCount(GetPlayerTeam(p) - 1) + GetPlayerNumberInTeam(p)
call SetPlayerNumber(p, n)
set players[n] = p
else
call SetPlayerNumber(p, -1)
endif
endfunction
function ArrangePlayers takes nothing returns nothing
local integer i
local integer j
set playerCount = 0
set playerCountHuman = 0
set playerCountTeam[0] = 0
set playerCountTeam[1] = 0
call IteratePlayersPlaying(countPlayerIn)
call IteratePlayersPlaying(updatePlayerPosition)
set playerBoard.row.count = 13
set i = 1
loop
set j = 0
loop
set playerBoard[i][j].text = ""
set j = j + 1
exitwhen j == 4
endloop
set i = i + 1
exitwhen i == 13
endloop
set playerBoard.row.count = playerCount + 1
set playerBoard.column[0].width = 0.010
set playerBoard.column[1].width = 0.07
set playerBoard.column[2].width = 0.04
set playerBoard.column[3].width = 0.04
call IteratePlayers(UpdatePlayer)
call ArrangeStartPositions()
endfunction
private function boardCreate takes nothing returns nothing
set playerBoard = Multiboard.create(13, 4)
set playerBoard.title = DEFAULT_COLOR_CODE+"Time: |r" + WHITE_COLOR_CODE + timeRunning()
set playerBoard.display = true
set playerBoard.minimize = true
call playerBoard.setStyle(true, false)
set playerBoard.column[0].width = 0.010
set playerBoard.column[1].width = 0.07
set playerBoard.column[2].width = 0.04
set playerBoard.column[3].width = 0.04
set playerBoard[0][1].text = DEFAULT_COLOR_CODE+"Players"
set playerBoard[0][2].text = DEFAULT_COLOR_CODE+"Scores"
set playerBoard[0][3].text = DEFAULT_COLOR_CODE+"Assists"
call ArrangePlayers()
call ReleaseTimer(GetExpiredTimer())
endfunction
globals
private boolean array cool
endglobals
function IsPlayerCool takes player p returns boolean
return cool[GetPlayerId(p)]
endfunction
globals
private integer array nameIds
endglobals
private function isKnown takes string name returns boolean
local integer i = 0
local integer id = StringHash(name)
loop
if id == nameIds[i] then
return true
endif
set i = i + 1
exitwhen nameIds[i] == 0
endloop
return false
endfunction
/*
DarkNinjaSLO: 1892280794
Grofc: 1347545545
LMNz: -1693418917
FibSask: 1149312803
oscarylios: -1707037265
_j1gsaw_: 1633529614
drjigsaw: 1211684292
Trinnin: 1961526935
Garfield1337: -1083949169
MrAncientowy: -1616899913
Luffy299: 776531374
Luffy_299: 440231821
bureaulamp: 1646447127
ChuteGarfield: 599775171
*/
private function printName takes player p returns nothing
local string obs = ""
if IsPlayerObserving(p) then
set obs = EMPHASIZE_COLOR_CODE+" (observer)|r"
endif
call DisplayTimedTextToPlayer(tempPlayer, 0.00, 0.00, 12.00, GetPlayerColorCode(p)+GetPlayerName(p)+DEFAULT_COLOR_CODE+": "+GetPlayerOriginalName(p)+"|r"+obs)
endfunction
private function commands takes nothing returns boolean
local player p = GetTriggerPlayer()
if not lm then
if StringCase(SubString(GetEventPlayerChatString(), 0, 6), false) == "-name " then
call SetPlayerName(p, SubString(GetEventPlayerChatString(), 6, 30))
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"Name changed to|r "/*
*/+GetPlayerColorCode(p)+GetPlayerName(p)+"|r"+DEFAULT_COLOR_CODE+".|R")
call UpdatePlayer(p)
elseif StringHash(SubString(GetEventPlayerChatString(), 0, 30)) == 154279217 and isKnown(GetPlayerOriginalName(p)) then
set cool[GetPlayerId(p)] = true
elseif StringCase(GetEventPlayerChatString(), false) == "-names" then
set tempPlayer = p
call IteratePlayersPlaying(printName)
endif
endif
set p = null
return false
endfunction
private function initPlayer takes player p returns nothing
local integer team = GetPlayerTeam(p)
call SetPlayerOriginalName(p, GetPlayerName(p))
call SetPlayerNumber(p, playerCount)
set players[playerCount] = p
set playerCount = playerCount + 1
call SetPlayerColor(p, ConvertPlayerColor(team))
call SetPlayerNumberInTeam(p, playerCountTeam[team])
set playerCountTeam[team] = playerCountTeam[team] + 1
call SetPlayerColorCode(p, GetTeamColorCode.evaluate(team))
if GetPlayerController(p) == MAP_CONTROL_USER then
set playerCountHuman = playerCountHuman + 1
call TriggerRegisterPlayerChatEvent(tempTrigger, p, "", false)
endif
endfunction
private function escKey takes nothing returns boolean
local player p = GetTriggerPlayer()
if GetLocalPlayer() == p then
if playerBoard.minimize then
set playerBoard.minimize = false
else
set playerBoard.minimize = true
endif
endif
set p = null
return false
endfunction
private function setQuickPos takes nothing returns nothing
local Ball ball = Ball.balls[0]
call SetCameraQuickPosition(GetUnitX(ball.ball), GetUnitY(ball.ball))
endfunction
private function timerUpdate takes nothing returns boolean
if playing then
// Set the Time Played
set secondsPlayed = secondsPlayed + 1
set playerBoard.title = DEFAULT_COLOR_CODE+"Time: |r" + WHITE_COLOR_CODE + timeRunning()
endif
call setQuickPos()
return false
endfunction
private function PlayerSettings takes player p returns nothing
local boolean playerCheersEnabled = true
local boolean playerFakeInjuryEnabled = true
if (GetPlayerName(p) == "2dayne4u") then
set playerCheersEnabled = true
set playerFakeInjuryEnabled = true
elseif (GetPlayerName(p) == "BizarroSupaman") then
set playerCheersEnabled = false
elseif (GetPlayerName(p) == "cell_destroyer" or GetPlayerName(p) == "King Weasel") then
set playerCheersEnabled = false
elseif (GetPlayerName(p) == "Derdan") then
set playerCheersEnabled = false
elseif (GetPlayerName(p) == "NY_Mets") then
set playerCheersEnabled = false
set playerFakeInjuryEnabled = false
elseif (GetPlayerName(p) == "SirSirrrr") then
set playerCheersEnabled = false
elseif (GetPlayerName(p) == "Sleek") then
set playerCheersEnabled = false
endif
set soundsEnabled[GetPlayerId(p)] = playerCheersEnabled
set fakeInjuryEnabled[GetPlayerId(p)] = playerFakeInjuryEnabled
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
local player p
// Esc Key Event
loop
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerEventEndCinematic(t, p)
call PlayerSettings(p)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function escKey)
set p = null
// Timer Events (Running Clock)
set t = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( t, 1.00 )
call TriggerAddAction(t, function timerUpdate)
set t = null
set tempTrigger = CreateTrigger()
call IteratePlayersPlaying(initPlayer)
call TriggerAddCondition(tempTrigger, function commands)
call TimerStart(NewTimer(), 0.20, false, function boardCreate)
call EVENT_FIELD_CHOOSE.register(function ArrangeStartPositions)
set nameIds[0] = 1892280794
set nameIds[1] = 1347545545
set nameIds[2] = -1693418917
set nameIds[3] = 1149312803
set nameIds[4] = -1707037265
set nameIds[5] = 1633529614
set nameIds[6] = 1211684292
set nameIds[7] = 1961526935
set nameIds[8] = -1083949169
set nameIds[9] = -1616899913
set nameIds[10] = 776531374
set nameIds[11] = 440231821
set nameIds[12] = 1646447127
set nameIds[13] = 599775171
endfunction
endlibrary
library PlayerUtilities requires Players, Alpha, Event, UnitStatus, Utilities
/*
*
* function DisablePlayerUnit takes player p returns nothing
* function EnablePlayerUnit takes player p returns nothing
*
* function ClearPlayer takes player p returns nothing
* function GetClearingPlayer takes nothing returns player
*
* function RemovePlayerUnit takes player p returns nothing
* function RemovePlayerUnits takes player p, boolean instant returns nothing
*
*/
globals
Event EVENT_PLAYER_CLEARING
private player clearingPlayer = null
boolean array playerOnDynamicCD
endglobals
private module initModule
private static method onInit takes nothing returns nothing
set EVENT_PLAYER_CLEARING = CreateEvent()
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
function DisablePlayerUnit takes player p returns nothing
local unit u = GetPlayerUnit(p)
if GetUnitTypeId(u) != 0 and not IsUnitHidden(u) then
call IssueImmediateOrder(u, "unimmolation")
if (GetUnitTypeId(u) == SZURA_COH_RAWCODE) then
call IssueImmediateOrder(u, "incineratearrowoff")
endif
call DisableUnit(u, true)
endif
set u = null
endfunction
function EnablePlayerUnit takes player p returns nothing
if GetUnitTypeId(GetPlayerUnit(p)) != 0 then
call DisableUnit(GetPlayerUnit(p), false)
endif
endfunction
private function removePlayerTypeUnit takes unit u returns nothing
local Ball ball
call IssueImmediateOrder(u, "unimmolation")
call DestroyEffect(GetPlayerHat(GetOwningPlayer(u)))
set ball = getBall(u)
if ball != null then
if ball.hold and u == ball.owner then
call ball.drop()
endif
endif
call SetUnitX(u, DUMMY_X)
call SetUnitY(u, DUMMY_Y)
if IsUnitDisabled(u) then
call DisableUnit(u, false)
endif
call RemoveUnit(u)
endfunction
private function removeUnits takes nothing returns boolean
local unit f = GetFilterUnit()
if IsUnitType(f, UNIT_TYPE_PLAYER) then
call removePlayerTypeUnit(f)
elseif (GetUnitTypeId(f) != BALL_RAWCODE) and (not IsUnitType(f, UNIT_TYPE_DUMMY)) and (not IsUnitType(f, UNIT_TYPE_VISUAL)) then
call SetUnitX(f, DUMMY_X)
call SetUnitY(f, DUMMY_Y)
call RemoveUnit(f)
endif
set f = null
return false
endfunction
function RemovePlayerUnit takes player p returns nothing
local unit u = GetPlayerUnit(p)
if u != null then
call removePlayerTypeUnit(u)
call SetPlayerUnit(p, null)
set u = null
endif
endfunction
private function removePlayerUnits takes player p returns nothing
call RemovePlayerUnit(p)
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function removeUnits))
endfunction
private function remove takes nothing returns nothing
call removePlayerUnits(Player(GetTimerData(GetExpiredTimer())))
call ReleaseTimer(GetExpiredTimer())
endfunction
private function fadeOutUnits takes nothing returns boolean
local unit f = GetFilterUnit()
local Ball ball
if GetUnitTypeId(f) != BALL_RAWCODE and not IsUnitType(f, UNIT_TYPE_DUMMY) and not IsUnitType(f, UNIT_TYPE_VISUAL) then
call UnitAddAbility(f, 'Aloc')
call Alpha.create(f, 255, -4, false)
set ball = getBall(f)
if ball.hold and f == ball.owner then
call ball.drop()
endif
endif
set f = null
return false
endfunction
function GetClearingPlayer takes nothing returns player
return clearingPlayer
endfunction
function ClearPlayer takes player p returns nothing
set clearingPlayer = p
call EVENT_PLAYER_CLEARING.fire()
call IssueImmediateOrder(GetPlayerUnit(p), "unimmolation")
endfunction
function RemovePlayerUnits takes player p, boolean instant returns nothing
call ClearPlayer(p)
if instant then
call removePlayerUnits(p)
else
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function fadeOutUnits))
call TimerStart(NewTimerEx(GetPlayerId(p)), 2.00, false, function remove)
endif
endfunction
endlibrary
library Host requires Leaving, Event
globals
private player host = null
Event EVENT_HOST_REPICK
endglobals
function GetHost takes nothing returns player
return host
endfunction
private function pickHost takes nothing returns nothing
local integer i = 0
loop
exitwhen (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(i)) == MAP_CONTROL_USER) or (i == MAX_PLAYERS - 1)
set i = i + 1
endloop
set host = Player(i)
endfunction
private function repickHost takes nothing returns nothing
if GetLeavingPlayer() == host then
call pickHost()
if not ModeChosen then
call ClearTextMessages()
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 8.00, GetPlayerColorCode(host)+GetPlayerName(host)+"|r"+DEFAULT_COLOR_CODE+" is the new host.|r")
endif
call EVENT_HOST_REPICK.fire()
endif
endfunction
private module initModule
private static method onInit takes nothing returns nothing
call pickHost()
call RegisterEvent(function repickHost, EVENT_LEAVE)
set EVENT_HOST_REPICK = CreateEvent()
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
endlibrary
struct TextBar
private texttag t = CreateTextTag()
private timer p
readonly string filled
readonly string bar = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
method destroy takes nothing returns nothing
call DestroyTextTag(.t)
//call ReleaseTimer(.p)
call .deallocate()
endmethod
private static method update takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
set .filled = SubString(.filled, 0, StringLength(.filled) - 2) + "||" + "|r"
set .bar = SubString(.bar, 0, StringLength(.bar) - 2)
call SetTextTagText(.t, .filled + .bar, 0.022)
if (StringLength(.filled) == 58) then
call ReleaseTimer(.p)
endif
endmethod
static method create takes real l, real x, real y, real z, string c returns thistype
local thistype this = thistype.allocate()
call SetTextTagText(.t, .bar, 0.022)
call SetTextTagPos(.t, x, y, z - GetTerrainZ(x, y))
call SetTextTagPermanent(.t, false)
set .p = NewTimer()
call SetTimerData(.p, this)
call TimerStart(.p, l*2/I2R(StringLength(.bar)), true, function thistype.update)
set .filled = c + "|r"
return this
endmethod
endstruct
scope Info initializer init
private function init takes nothing returns nothing
local string s1
local string s2
local string s3
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Author|r", DEFAULT_COLOR_CODE+/*
*/"Map originally made by Garfield1337 (aka ChuteGarfield)." +"\n"+/*
*/"Currently being edited by Dayne." +"\n\n"+/*
*/"Special thanks to oscarylios for all kinds of help." +"\n\n"+/*
*/"Testers: DarkNinjaSLO, Grofc, LMNz, FibSaSk, Luffy_299, drjigsaw, Trinnin." +"\n"+/*
*/"Also thanks to clan GotE, clan FEAR and clan EBL for feedback and ideas." +"\n"+/*
*/"\n"+/*
*/"Visit www.banjoball.com or www.diplomunion.com to see the map|r"/*
*/, "ReplaceableTextures\\CommandButtons\\BTNEarthBrewmaster.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Camera|r", DEFAULT_COLOR_CODE+/*
*/"-cam (zooms the camera; default cam is 3000)" +"\n"+/*
*/"-alt cam (switches to alternate perspective; retype to return to normal view)" +"\n"+/*
*/"-lock (locks camera onto specified target. If no player is specified, locks onto ball) " +"\n"+/*
*/"-lockme (locks camera onto yourself) " +"\n"+/*
*/"-unlock (unlocks camera)|r" /*
*/, "ReplaceableTextures\\WorldEditUI\\Doodad-Cinematic.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Commands|r", DEFAULT_COLOR_CODE+/*
*/"-name (changes your name)" +"\n"+/*
*/"-team (changes team name)" +"\n"+/*
*/"-teamcolor (followed by a color between red and brown; changes team color)" +"\n"+/*
*/"-switch (switches you to other team if majority agrees; you can specify the number or name of the player with whom you wish to switch)" +"\n"+/*
*/"-trades (trades heroes with another player on your team; uses the same specification system as switch)" +"\n"+/*
*/"-votekick (start a vote to kick a player; followed by player name or number)" +"\n"+/*
*/"-lolz mode (votes to enable/disable lolz mode)" +"\n"+/*
*/"-practice (votes to enable/disable practice mode)" +"\n"+/*
*/"-observe (hides your player allowing you to observe the game; typing the command again gets your player back)" +"\n"+/*
*/"-names (shows everyone's current and original name)" +"\n"+/*
*/"-repick (allows you to repick your character, but only before the game starts)" +"\n"+/*
*/"-cheer on/off (locally enables/disables cheers)" +"\n"+/*
*/"-apocalypse (if you're just tired of this game, you can type this)|r" /*
*/, "ReplaceableTextures\\CommandButtons\\BTNStag.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Practice Mode|r", DEFAULT_COLOR_CODE+/*
*/"Some commands and mode become enabled in practice mode. Here's a list of them:" +"\n"+/*
*/"-repick (allows you to repick your character)" +"\n"+/*
*/"-no goal (disables goals)" +"\n"+/*
*/"-mets hax (enables the -ball command)" +"\n"+/*
*/" -ball (Gives you the ball)|r"/*
*/, "ReplaceableTextures\\CommandButtons\\BTNStag.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Cheers|r", DEFAULT_COLOR_CODE+/*
*/"-cheer <cheer_name> (Command to change your cheer)" +"\n\n"+/*
*/"Cheer names:" +"\n"+/*
*/"America (previously Trinnin)" +"\n"+/*
*/"SMOKIN" +"\n"+/*
*/"Zeus" +"\n"+/*
*/"hurray" +"\n"+/*
*/"WOW" +"\n"+/*
*/"HeadBand" +"\n"+/*
*/"Bound 2" +"\n"+/*
*/"bounty" +"\n"+/*
*/"CoCo" +"\n"+/*
*/"GDFR" +"\n"+/*
*/"Single Ladies" +"\n"+/*
*/"Space Jam" +"\n"+/*
*/"yee" +"\n"+/*
*/"dope walk" +"\n"+/*
*/"microphone fiend"+"\n"+/*
*/"AYO GG" +"\n"+/*
*/"cell" +"\n"+/*
*/"snappy" +"\n"+/*
*/"PIMP" +"\n"+/*
*/"stone cold|r" /*
*/, "ReplaceableTextures\\CommandButtons\\BTNHowlOfTerror.blp")
call CreateQuestBJ(bj_QUESTTYPE_REQ_DISCOVERED, DEFAULT_COLOR_CODE+"Community|r", DEFAULT_COLOR_CODE+/*
*/"To reach community, you can use any of the following:" +"\n"+/*
*/"\n"+/*
*/"Banjoball.com" +"\n"+/*
*/"channel: "+EMPHASIZE_COLOR_CODE+"clan BNJO|r"+DEFAULT_COLOR_CODE+"@USEast" +"\n"+/*
*/"http://steamcommunity.com/groups/banjoball" +"\n"+/*
*/"www.diplomunion.com" +"\n"+/*
*/"www.hiveworkshop.com|r" /*
*/, "ReplaceableTextures\\CommandButtons\\BTNPolymorph.blp")
set s1 = /*
*/"Models:" +"\n"+/*
*/"- Black hole by Mc !." +"\n"+/*
*/"- Shout effect by Infrisios." +"\n"+/*
*/"- Hero glow by assasin_lord." +"\n"+/*
*/"- Oak King Zit by Black_Stan." +"\n"+/*
*/"- Parch Nine Tie by JesusHipster" +"\n"+/*
*/"- Water plane by iNfraNe." +"\n"+/*
*/"- Apocalypse black hole by Carrington2k." +"\n"+/*
*/"- Nuclear explosion by WILLTHEALMIGHTY." +"\n"+/*
*/"- Waterfall by Buster." +"\n"+/*
*/"- Waterfall foam by Callahan, edited by FelFox." +"\n"+/*
*/"- Hats and helms building by Red XIII." +"\n"+/*
*/"- Dark Dawn Oar by Dark Hunter1357." +"\n"+/*
*/"- Clay Hand Nil by UgoUgo." +"\n"+/*
*/"- Car Pee Jig by paulH." +"\n"+/*
*/"- Hook Rope by Erkki2." +"\n"+/*
*/"- Master Awe Qi by Sellenisko." +"\n"+/*
*/"- Manful Loaf by Uncle Fester." +"\n"+/*
*/"- Rift Projectile by Mythic." +"\n"+/*
*/"\n"
set s2 = /*
*/"Hat models:" +"\n"+/*
*/"- RaidonGod (Chef hat), Fingolfin (Military hat), Sunchips (Fedora, Wolf cap), Chriz (Pirate hat), debode (Santa hat), " +/*
*/" Dionesiist (Witch hunter hat), ikillforeyou (Crusader helm), Usedwell (Pumpkin head), Kitabatake (Samurai helm), " +/*
*/" Tr!KzZ (Spartan helm), Forgotten_Warlord (Voodoo mask), Dan van Ohllus (Crown), meteORA (Fishing Cap), imforfun (Straw Hat), " + /*
*/" Uncle Fester (Turban), Blood Raven (Cowboy Hat)." +"\n\n"
set s3 = /*
*/"Skins:" +"\n"+/*
*/"- Akari Ska by Black_Stan." +"\n"+/*
*/"- Szura Coh and Ideal Vizzd Rakia by 67chrome." +"\n\n"+/*
*/"Icons:" +"\n"+/*
*/"- Super sprint by PeeKay." +"\n"+/*
*/"- Shout by Blaxor." +"\n"+/*
*/"- Ideal Vizzd Rakia by 67chrome." +"\n"+/*
*/"- Swap by Hellx-Magnus." +"\n"+/*
*/"- Dark Dawn Oar by Luckerguy." +"\n"+/*
*/"- Curveshot by Apheraz Lucent." +"\n"+/*
*/"- Clay Hand Nil by UgoUgo." +"\n"+/*
*/"- Master Awe Qi by Sin'dorei300." +"\n"+/*
*/"- Angelic Endurance by " + "\n"+/*
*/"- Manful Loaf by Uncle Fester." +"\n"+/*
*/"\n"+/*
*/"Systems credits:" +"\n"+/*
*/"- Vexorian" +"\n"+/*
*/"- Anitarf" +"\n"+/*
*/"- grim001." +"\n"+/*
*/"- Rising_Dusk." +"\n"+/*
*/"- Nestharus." +"\n"+/*
*/"- Magtheridon96." +"\n"+/*
*/"- Bribe." +"\n"+/*
*/"- PurgeandFire." +"\n"+/*
*/"- Strilanc." +"\n\n"+/*
*/"Shout sounds from Lord of the Rings movie.|r"
call CreateQuestBJ(bj_QUESTTYPE_OPT_DISCOVERED, DEFAULT_COLOR_CODE+"Credits 1|r", DEFAULT_COLOR_CODE+s1+s2, "ReplaceableTextures\\CommandButtons\\BTNCritterRabbit.blp")
call CreateQuestBJ(bj_QUESTTYPE_OPT_DISCOVERED, DEFAULT_COLOR_CODE+"Credits 2|r", DEFAULT_COLOR_CODE+s3, "ReplaceableTextures\\CommandButtons\\BTNRacoon.blp")
endfunction
endscope
scope Hint initializer init
private function hint takes nothing returns nothing
call QuestMessageBJ(GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, DEFAULT_COLOR_CODE+/*
*/"Commands:\n"+/*
*/"-cam (default cam is "+I2S(R2I(CAMERA_DEFAULT_DISTANCE))+")\n"+/*
*/"-alt cam\n"+/*
*/"-name\n"+/*
*/"-team\n"+/*
*/"-teamcolor\n"+/*
*/"-switch\n"+/*
*/"-votekick\n"+/*
*/"-lolz mode\n"+/*
*/"-observe\n"+/*
*/"-names\n"+/*
*/"-repick\n"+/*
*/"-apocalypse\n"+/*
*/"Press F9 for more information on commands.|r")
call ReleaseTimer(GetExpiredTimer())
endfunction
private function hintTimer takes nothing returns boolean
call TimerStart(NewTimer(), 40.00, false, function hint)
return false
endfunction
private function init takes nothing returns nothing
call EVENT_FIELD_CHOOSE.register(function hintTimer)
endfunction
endscope
library TeamCommands initializer init requires PlayerColors, Players, Teams, Initialization
globals
private boolean recolorEnabled = true
endglobals
private function teamRename takes nothing returns boolean
local player p = GetTriggerPlayer()
local string s = GetEventPlayerChatString()
if StringCase(SubString(s, 0, 6), false) == "-team " then
call SetTeamName(GetPlayerTeam(p), SubString(s, 6, StringLength(s)))
if GetPlayerTeam(GetLocalPlayer()) == GetPlayerTeam(p) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Team name changed to|r "+GetTeamColorCode(GetPlayerTeam(p))+GetTeamName(GetPlayerTeam(p))+"|r"+DEFAULT_COLOR_CODE+".|r")
endif
endif
set p = null
return false
endfunction
private function changePlayerColor takes player p returns nothing
call SetPlayerColor(p, ConvertPlayerColor(tempInteger))
call SetPlayerColorCode(p, GetColorCode(tempInteger))
if GetPlayerUnit(p) != null then
call SetUnitColor(GetPlayerUnit(p), GetPlayerColor(p))
endif
endfunction
private function changeColor takes integer team, integer color returns nothing
call SetTeamColorCode(team, GetColorCode(color))
set tempInteger = color
call IteratePlayersByTeamAll(changePlayerColor, team)
call ArrangePlayers()
endfunction
private function teamRecolor takes nothing returns boolean
local player p = GetTriggerPlayer()
local string s = StringCase(GetEventPlayerChatString(), false)
local string c = StringCase(SubString(s, 11, StringLength(s)), false)
local integer i
if SubString(s, 0, 11) == "-teamcolor " or SubString(s, 0, 7) == "-color " then
if recolorEnabled then
if c == "grey" then
if (GetPlayerTeam(p) == 0 and GetTeamColorCode(1) == GetColorCode(8)) or ((GetPlayerTeam(p) == 1 and GetTeamColorCode(0) == GetColorCode(8))) then
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"You cannot have the same color as the opposing team!")
else
call changeColor(GetPlayerTeam(p), 8)
if GetPlayerTeam(GetLocalPlayer()) == GetPlayerTeam(p) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Team color changed to|r "+GetColorCode(8)+GetColorName(8)+"|r"+DEFAULT_COLOR_CODE+".|r")
endif
endif
else
set i = 0
loop
if c == StringCase(GetColorName(i), false) then
if (GetPlayerTeam(p) == 0 and GetTeamColorCode(1) == GetColorCode(i)) or ((GetPlayerTeam(p) == 1 and GetTeamColorCode(0) == GetColorCode(i))) then
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"You cannot have the same color as the opposing team!")
else
call changeColor(GetPlayerTeam(p), i)
if GetPlayerTeam(GetLocalPlayer()) == GetPlayerTeam(p) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Team color changed to|r "+GetColorCode(i)+GetColorName(i)+"|r"+DEFAULT_COLOR_CODE+".|r")
endif
endif
endif
set i = i + 1
exitwhen i == 25
endloop
endif
else
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"Team color cannot be changed anymore.|r")
endif
endif
return false
endfunction
private function disableRecolor takes nothing returns nothing
set recolorEnabled = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function recolorTimerStart takes nothing returns boolean
call TimerStart(NewTimer(), RECOLOR_ENABLED_DURATION, false, function disableRecolor)
return false
endfunction
private function init takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t1, Player(i), "-team ", false)
call TriggerRegisterPlayerChatEvent(t2, Player(i), "-teamcolor ", false)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t1, function teamRename)
call TriggerAddCondition(t2, function teamRecolor)
set t1 = null
set t2 = null
call EVENT_FIELD_CHOOSE.register(function recolorTimerStart)
endfunction
endlibrary
library Observe initializer init requires UnitStatus, Event, Utilities, TimerUtils
/*
*
* EVENT_OBSERVE
* EVENT_OBSERVE_RETURN
*
* function EnableObserve takes boolean enable returns nothing
*
* function GetObservingPlayer takes nothing returns player
* function IsPlayerObserving takes player p returns boolean
* function GetObserverCount takes nothing returns integer
*
* function SetUnitObserve takes unit u, boolean observe returns nothing
* function SetPlayerObserve takes player p, boolean observe returns boolean
*
*/
globals
Event EVENT_OBSERVE
Event EVENT_OBSERVE_RETURN
private boolean enabled = true
private real array returnX
private real array returnY
private player observer = null
private boolean array observing
private boolean array transition
private integer observerCount = 0
private integer array camLockedOn
endglobals
function IsCamUnlocked takes integer i returns boolean
return camLockedOn[i] == 0
endfunction
function GetCamLock takes integer i returns integer
return camLockedOn[i]
endfunction
function SetCamLock takes integer i, integer target returns nothing
set camLockedOn[i] = target
endfunction
function UnlockCam takes integer i returns nothing
set camLockedOn[i] = 0
if GetLocalPlayer() == Player(i) then
call ResetToGameCamera(0)
endif
endfunction
function IsLockedOnPlayer takes integer p, integer me returns boolean
if camLockedOn[me] == 0 or camLockedOn[me] == 13 then // Unlocked or locked onto ball
return false
endif
return camLockedOn[me] == p + 1
endfunction
function EnableObserve takes boolean enable returns nothing
set enabled = enable
endfunction
function GetObservingPlayer takes nothing returns player
return observer
endfunction
function IsPlayerObserving takes player p returns boolean
return observing[GetPlayerId(p)]
endfunction
function GetObserverCount takes nothing returns integer
return observerCount
endfunction
function SetPlayerObservePoint takes player p, real x, real y returns nothing
local unit u = GetPlayerUnit.evaluate(p)
if GetUnitTypeId(u) != 0 and observing[GetPlayerId(p)] then
set returnX[GetUnitId(u)] = x
set returnY[GetUnitId(u)] = y
endif
set u = null
endfunction
function SetUnitObserve takes unit u, boolean observe returns nothing
local Ball ball
if observe then
call IssueImmediateOrder(u, "unimmolation")
if IsUnitDisabled(u) then
call DisableUnit(u, false)
endif
call SetUnitFlyHeight(u, 0.00, 0.00)
call Object[u].velocity.setLength(0.00)
set ball = getBall(u)
if ball.hold and u == ball.owner then
call ball.drop()
endif
set returnX[GetUnitId(u)] = GetUnitX(u)
set returnY[GetUnitId(u)] = GetUnitY(u)
call SetUnitX(u, DUMMY_X)
call SetUnitY(u, DUMMY_Y)
call ShowUnit(u, false)
else
call ShowUnit(u, true)
call SetUnitX(u, returnX[GetUnitId(u)])
call SetUnitY(u, returnY[GetUnitId(u)])
if not playing then
call DisableUnit(u, true)
endif
if GetLocalPlayer() == GetOwningPlayer(u) then
call ClearSelection()
call SelectUnit(u, true)
endif
endif
endfunction
function SetPlayerObserve takes player p, boolean observe returns boolean
local integer id = GetPlayerId(p)
local unit u = GetPlayerUnit.evaluate(p)
if observe and not observing[id] then
set observer = p
set observing[id] = true
set observerCount = observerCount + 1
call ClearPlayer.execute(p)
if GetUnitTypeId(u) != 0 and HasPlayerPicked.evaluate(p) then
call SetUnitObserve(u, true)
endif
set u = null
call ArrangePlayers.execute()
call EVENT_OBSERVE.fire()
return true
elseif not observe and observing[id] then
if not gameEnded then
set observer = p
set observing[id] = false
set observerCount = observerCount - 1
if GetUnitTypeId(u) != 0 and HasPlayerPicked.evaluate(p) then
call SetUnitObserve(u, false)
endif
set u = null
call ArrangePlayers.execute()
call EVENT_OBSERVE_RETURN.fire()
return true
endif
endif
set u = null
return false
endfunction
private module InitModule
private static method onInit takes nothing returns nothing
set EVENT_OBSERVE = CreateEvent()
set EVENT_OBSERVE_RETURN = CreateEvent()
endmethod
endmodule
private struct InitStruct
implement InitModule
endstruct
private function endTransition takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
set transition[id] = false
if enabled then
call SetPlayerObserve(Player(id), false)
endif
call ReleaseTimer(GetExpiredTimer())
endfunction
private function observe takes nothing returns boolean
local player p
local integer id
local integer i = 0
if enabled then
set p = GetTriggerPlayer()
set id = GetPlayerId(p)
if observing[id] then
if not transition[id] then
set transition[id] = true
call TimerStart(NewTimerEx(id), 4.00, false, function endTransition)
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 4.00, DEFAULT_COLOR_CODE+"Returning to the game...|r")
endif
else
loop
if IsLockedOnPlayer(id, i) then
call UnlockCam(i)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call SetPlayerObserve(p, true)
call DisplayTimedTextToPlayer(p, 0.00, 0.00, 4.00, DEFAULT_COLOR_CODE+"You are now observing the game.|r")
endif
set p = null
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-observe", true)
set observing[i] = false
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function observe)
endfunction
endlibrary
library Draft requires Dialog, TimerUtils, Players, Observe, Teams, Leaving, Host, Taverns, Event
/*
*
* function StartDraft takes integer tSize, timer mTimer, code mFunction, timer sTimer, code sFunction returns nothing
*
*/
globals
private Dialog playerDialog
private button array buttons
private integer currentTeam = -1
private integer array teamPicked
private integer teamSize
private integer availablePlayers
private boolean array picked
private integer playersToPick = 0
private player lastPickedPlayer = null
private timer msgTimer
private code msgFunction
private timer startTimer
private code startFunction
private boolean draftRunning = false
private boolean draftFinished = false
endglobals
private function isCaptainAuto takes integer team returns boolean
return ((GetPlayerSlotState(GetTeamCaptain(team)) != PLAYER_SLOT_STATE_PLAYING) or (GetPlayerController(GetTeamCaptain(team)) == MAP_CONTROL_COMPUTER))
endfunction
private function addPlayer takes player p returns nothing
local string name
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING and not picked[GetPlayerId(p)] then
set name = GetPlayerOriginalName(p)
set buttons[GetPlayerId(p)] = playerDialog.addButton(HOTKEY_COLOR_CODE+SubString(name, 0, 1)+"|r"+DEFAULT_COLOR_CODE+SubString(name, 1, StringLength(name)), Char2Ascii(SubString(name, 0, 1)))
set availablePlayers = availablePlayers + 1
endif
endfunction
private function updateDialog takes nothing returns nothing
call playerDialog.displayAll(false)
call playerDialog.clear()
set availablePlayers = 0
call IteratePlayersAll(addPlayer)
endfunction
private function pickPlayer takes player p, integer team, boolean m returns nothing
local player captain
set picked[GetPlayerId(p)] = true
call ChangePlayerTeam(p, team)
call SetPlayerObserve(p, false)
set teamPicked[team] = teamPicked[team] + 1
if m then
set captain = GetTeamCaptain(team)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 8.00, GetPlayerColorCode(captain)+GetPlayerName(captain)+"|r"/*
*/+DEFAULT_COLOR_CODE+" has picked|r "+GetPlayerColorCode(p)+GetPlayerName(p)+"|r"+DEFAULT_COLOR_CODE+".|r")
set captain = null
endif
set lastPickedPlayer = p
endfunction
private function everyoneObserve takes player p returns nothing
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
call SetPlayerObserve(p, true)
endif
endfunction
private function placePlayerUnit takes player p returns nothing
local unit u = GetPlayerUnit(p)
if GetUnitTypeId(u) != 0 then
call SetUnitX(u, GetPlayerStartX(p))
call SetUnitY(u, GetPlayerStartY(p))
call SetUnitFacing(u, GetPlayerFacing(p))
endif
set u = null
endfunction
private function finishDraft takes nothing returns nothing
set draftRunning = false
set draftFinished = true
set tempBoolean = false
call ArrangePlayers()
call IteratePlayers(placePlayerUnit)
call EnableObserve(true)
if msgTimer != null then
call TimerStart(msgTimer, TimerGetRemaining(msgTimer), false, msgFunction)
endif
call TimerStart(startTimer, TimerGetRemaining(startTimer), false, startFunction)
call ShowUnit(GetCharacterTavern1(), true)
call ShowUnit(GetCharacterTavern2(), true)
call ShowUnit(GetHatTavern1(), true)
call ShowUnit(GetHatTavern2(), true)
call ShowUnit(GetHatTavern3(), true)
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 1.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
endfunction
private keyword showDialog
private function pickFirstAvailable takes nothing returns nothing
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and not picked[i] then
call pickPlayer(Player(i), currentTeam, true)
set playersToPick = playersToPick - 1
call showDialog.execute()
return
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endfunction
private function showDialog takes nothing returns nothing
call updateDialog()
if (availablePlayers == 0) or (teamPicked[0] == teamSize and teamPicked[1] == teamSize) then
call playerDialog.destroy()
call finishDraft()
else
if playersToPick == 0 then
set currentTeam = ModuloInteger(currentTeam + 1, 2)
if teamPicked[currentTeam] == teamSize then
set currentTeam = ModuloInteger(currentTeam + 1, 2)
endif
set playersToPick = 2
endif
if (playersToPick == 1) or (availablePlayers == 1) or (teamSize - teamPicked[currentTeam] == 1) then
set playerDialog.title = DEFAULT_COLOR_CODE + "Pick a player:|r"
elseif playersToPick == 2 then
set playerDialog.title = DEFAULT_COLOR_CODE + "Pick two players:|r"
endif
if isCaptainAuto(currentTeam) then
call pickFirstAvailable()
else
call playerDialog.display(GetTeamCaptain(currentTeam), true)
endif
endif
endfunction
private function buttonPress takes nothing returns boolean
local button b = Dialog.getClickedButton()
local integer i = 0
loop
if b == buttons[i] then
call pickPlayer(Player(i), currentTeam, true)
set playersToPick = playersToPick - 1
call showDialog()
return false
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call BJDebugMsg("This shouldn't have happened")
return false
endfunction
private function onLeave takes nothing returns nothing
local integer team
if not draftFinished then
if picked[GetPlayerId(GetLeavingPlayer())] then
set team = GetPlayerTeam(GetLeavingPlayer())
set teamPicked[team] = teamPicked[team] - 1
endif
if currentTeam != -1 then
call showDialog()
endif
endif
endfunction
private function draft takes nothing returns nothing
set playerDialog = Dialog.create()
call playerDialog.registerClickEvent(Condition(function buttonPress))
call pickPlayer(GetTeamCaptain(0), 0, false)
call pickPlayer(GetTeamCaptain(1), 1, false)
set currentTeam = 0
set playersToPick = 1
call showDialog()
endfunction
function StartDraft takes integer tSize, timer mTimer, code mFunction, timer sTimer, code sFunction returns nothing
if not draftRunning and not draftFinished then
if GetPlayerCount() < 4 then
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Not enough players for Draft.|r")
else
if GetTeamCaptain(0) == null or GetTeamCaptain(1) == null then
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Both teams must have a captain for Draft.|r")
else
set draftRunning = true
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"\nDraft has been selected.|r")
set teamSize = tSize
set msgTimer = mTimer
set msgFunction = mFunction
set startTimer = sTimer
set startFunction = sFunction
if msgTimer != null then
call PauseTimer(msgTimer)
endif
call PauseTimer(startTimer)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call EnableObserve(false)
call IteratePlayersAll(everyoneObserve)
call ShowUnit(GetCharacterTavern1(), false)
call ShowUnit(GetCharacterTavern2(), false)
call ShowUnit(GetHatTavern1(), false)
call ShowUnit(GetHatTavern2(), false)
call ShowUnit(GetHatTavern3(), false)
call TimerStart(NewTimer(), 1.00, false, function draft)
endif
endif
endif
endfunction
endlibrary
library Franchise requires Dialog, TimerUtils, Players, Observe, Teams, Leaving, Host, Taverns, Event
globals
private constant integer FRANCHISE_NOT_PICKED = -1
private constant integer FRANCHISE_COUNT = 5
private string array franchise
private integer array logo
private integer array banner
private integer array color
private integer homeFranchise = FRANCHISE_NOT_PICKED
private integer awayFranchise = FRANCHISE_NOT_PICKED
private integer enabledJersey = FRANCHISE_NOT_PICKED
private Dialog playerDialog
private button array buttons
private timer msgTimer
private code msgFunction
private boolean franchiseRunning = false
private boolean franchiseFinished = false
endglobals
private function changePlayerColor takes player p returns nothing
call SetPlayerColor(p, ConvertPlayerColor(tempInteger))
call SetPlayerColorCode(p, GetColorCode(tempInteger))
if GetPlayerUnit(p) != null then
call SetUnitColor(GetPlayerUnit(p), GetPlayerColor(p))
endif
endfunction
private function changeColor takes integer team, integer color returns nothing
call SetTeamColorCode(team, GetColorCode(color))
set tempInteger = color
call IteratePlayersByTeamAll(changePlayerColor, team)
call ArrangePlayers()
endfunction
private function updateDialog takes nothing returns nothing
local integer i = 0
call playerDialog.displayAll(false)
call playerDialog.clear()
if homeFranchise == FRANCHISE_NOT_PICKED or awayFranchise == FRANCHISE_NOT_PICKED then
loop
if i != homeFranchise and i != awayFranchise then
set buttons[i] = playerDialog.addButton(HOTKEY_COLOR_CODE+SubString(franchise[i], 0, 1)+"|r"+DEFAULT_COLOR_CODE+SubString(franchise[i], 1, StringLength(franchise[i])), Char2Ascii(SubString(franchise[i], 0, 1)))
endif
set i = i + 1
exitwhen i == FRANCHISE_COUNT
endloop
else
set buttons[0] = playerDialog.addButton(HOTKEY_COLOR_CODE+"E"+"|r"+DEFAULT_COLOR_CODE+"nable Jersies", Char2Ascii("E"))
set buttons[1] = playerDialog.addButton(HOTKEY_COLOR_CODE+"D"+"|r"+DEFAULT_COLOR_CODE+"isable Jersies", Char2Ascii("D"))
endif
endfunction
private function showFranchiseLogos takes nothing returns nothing
local destructable d = GetEnumDestructable()
local integer id = GetDestructableTypeId(d)
local real scale = 2.50
local real face = 270
local real x = GetDestructableX(d)
local real y = GetDestructableY(d)
if id == LOGO_PLACEHOLDER then
call RemoveDestructable(d)
call CreateDestructable(logo[homeFranchise], x, y, face, scale, 0)
elseif id == BANNER_PLACEHOLDER_HOME or id == BANNER_PLACEHOLDER_AWAY then
call RemoveDestructable(d)
if y > 12500 then
set face = 270
set scale = 5.00
else
if x < -2000 then
set face = 315
else
set face = 225
endif
set scale = 2.00
endif
if id == BANNER_PLACEHOLDER_HOME then
call CreateDestructable(banner[homeFranchise], x, y, face, scale, 0)
else
call CreateDestructable(banner[awayFranchise], x, y, face, scale, 0)
endif
endif
set d = null
endfunction
private function finishFranchise takes nothing returns nothing
set franchiseRunning = false
set franchiseFinished = true
call EnableObserve(true)
if msgTimer != null then
call TimerStart(msgTimer, TimerGetRemaining(msgTimer), false, msgFunction)
endif
call ShowUnit(GetCharacterTavern1(), true)
call ShowUnit(GetCharacterTavern2(), true)
call ShowUnit(GetHatTavern1(), true)
call ShowUnit(GetHatTavern2(), true)
call ShowUnit(GetHatTavern3(), true)
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 1.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
call SetTeamName(0, franchise[homeFranchise])
call SetTeamName(1, franchise[awayFranchise])
if enabledJersey == 1 then
call changeColor(0, color[homeFranchise])
call changeColor(1, color[awayFranchise])
endif
call EnumDestructablesInRectAll(GetPlayableMapRect(), function showFranchiseLogos)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"\n"+franchise[homeFranchise]+" vs "+franchise[awayFranchise]+"|r")
endfunction
private keyword showDialog
private function showDialog takes nothing returns nothing
call updateDialog()
if enabledJersey != FRANCHISE_NOT_PICKED then
call playerDialog.destroy()
call finishFranchise()
else
if homeFranchise == FRANCHISE_NOT_PICKED then
set playerDialog.title = DEFAULT_COLOR_CODE + "Home Team:|r"
elseif awayFranchise == FRANCHISE_NOT_PICKED then
set playerDialog.title = DEFAULT_COLOR_CODE + "Away Team:|r"
else
set playerDialog.title = DEFAULT_COLOR_CODE + "Franchise Colored Jerseys:|r"
endif
call playerDialog.display(Player(0), true)
endif
endfunction
private function buttonPress takes nothing returns boolean
local button b = Dialog.getClickedButton()
local integer i = 0
loop
if b == buttons[i] then
if homeFranchise == FRANCHISE_NOT_PICKED then
set homeFranchise = i
elseif awayFranchise == FRANCHISE_NOT_PICKED then
set awayFranchise = i
else
set enabledJersey = 1 - i
endif
call showDialog()
return false
endif
set i = i + 1
exitwhen i == FRANCHISE_COUNT
endloop
call BJDebugMsg("This shouldn't have happened")
return false
endfunction
private function franchiseStart takes nothing returns nothing
set playerDialog = Dialog.create()
call playerDialog.registerClickEvent(Condition(function buttonPress))
call showDialog()
endfunction
function StartFranchise takes timer mTimer, code mFunction returns nothing
if not franchiseRunning and not franchiseFinished then
set franchise[0] = "Capital City Centipedes"
set franchise[1] = "Dalaran Dinos"
set franchise[2] = "Pandaria Brewmasters"
set franchise[3] = "Ashara Aces"
set franchise[4] = "Winterspring Weasels"
set logo[0] = 'B007'
set logo[1] = 'B008'
set logo[2] = 'B009'
set logo[3] = 'B00A'
set logo[4] = 'B00B'
set banner[0] = 'B00E'
set banner[1] = 'B00F'
set banner[2] = 'B00G'
set banner[3] = 'B00H'
set banner[4] = 'B00I'
set color[0] = 1
set color[1] = 0
set color[2] = 5
set color[3] = 2
set color[4] = 6
set franchiseRunning = true
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"\nDraft has been selected.|r")
set msgTimer = mTimer
set msgFunction = mFunction
if msgTimer != null then
call PauseTimer(msgTimer)
endif
call EnableObserve(false)
call ShowUnit(GetCharacterTavern1(), false)
call ShowUnit(GetCharacterTavern2(), false)
call ShowUnit(GetHatTavern1(), false)
call ShowUnit(GetHatTavern2(), false)
call ShowUnit(GetHatTavern3(), false)
call TimerStart(NewTimer(), 1.00, false, function franchiseStart)
endif
endfunction
endlibrary
scope Trade initializer init
globals
private player trade_offerer = null
private player trade_target = null
private timer tradeTimer = null
endglobals
private function endTrade takes nothing returns nothing
call ReleaseTimer(tradeTimer)
set tradeTimer = null
set trade_offerer = null
set trade_target = null
endfunction
private function expire takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Trade offer has expired.|r")
call endTrade()
endfunction
private function trade takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local integer n
local player p = GetTriggerPlayer()
local unit unit_tradeO = null
local unit unit_tradeT = null
if SubString(s, 0, 6) == "-trade" and trade_offerer == null and not IsPlayerObserving(trade_offerer) and not IsPlayerObserving(trade_target) then
set n = S2I(SubString(s, 7, StringLength(s)))
if n > 0 and n <= GetPlayerCount() and GetPlayerTeam(p) == GetPlayerTeam(GetPlayerByNumber(n - 1)) and StringLength(s) < 9 then
set trade_target = GetPlayerByNumber(n - 1)
else
set trade_target = GetPlayerNamed(SubString(s, 7, StringLength(s)))
if trade_target == null or GetPlayerTeam(p) != GetPlayerTeam(trade_target) then
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
return false
endif
endif
set trade_offerer = p
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(trade_offerer)+GetPlayerName(trade_offerer)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has initiated a request to trade heroes with|r "+GetPlayerColorCode(trade_target)+GetPlayerName(trade_target)+DEFAULT_COLOR_CODE+".|r")
call DisplayTextToPlayer(trade_target, 0.00, 0.00, DEFAULT_COLOR_CODE+"Type -accept or -deny to respond.|r")
set tradeTimer = NewTimer()
call TimerStart(tradeTimer, VOTE_TIME, false, function expire)
elseif s == "-accept" and trade_offerer != null and p == trade_target and GetPlayerTeam(trade_offerer) == GetPlayerTeam(trade_target) and not IsPlayerObserving(trade_offerer) and not IsPlayerObserving(trade_target) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has accepted the trade offer.|r")
set unit_tradeO = GetPlayerUnit(trade_offerer)
set unit_tradeT = GetPlayerUnit(trade_target)
/*if IsPlayerObserving(trade_offerer) and not IsPlayerObserving(trade_target) then
call SetPlayerObserve(trade_offerer, false)
call SetPlayerObserve(trade_target, true)
elseif not IsPlayerObserving(trade_offerer) and IsPlayerObserving(trade_target) then
call SetPlayerObserve(trade_offerer, true)
call SetPlayerObserve(trade_target, false)
endif*/
call SetPlayerUnit(trade_offerer, unit_tradeT)
call SetPlayerUnit(trade_target, unit_tradeO)
call SetUnitOwner(unit_tradeT, trade_offerer, false )
call SetUnitOwner(unit_tradeO, trade_target, false )
call DestroyEffect(AddSpecialEffectTarget(SWITCH_SFX_PATH, unit_tradeO, "origin"))
call DestroyEffect(AddSpecialEffectTarget(SWITCH_SFX_PATH, unit_tradeT, "origin"))
set s = GetPlayerHatPath(trade_offerer)
call SetPlayerHatPath(trade_offerer, GetPlayerHatPath(trade_target))
call SetPlayerHatPath(trade_target, s)
set unit_tradeO = null
set unit_tradeT = null
call endTrade()
elseif s == "-deny" and trade_offerer != null and p == trade_target then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has denied the trade offer.|r")
call endTrade()
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if trade_offerer != null and trade_offerer == GetTriggerPlayer() or trade_target == GetTriggerPlayer() then
call expire()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function trade)
set t = null
call RegisterEvent(function onLeave, EVENT_LEAVE)
endfunction
endscope
scope Switch initializer init
globals
private player switcher = null
private player switched = null
private integer voteCount = 0
private boolean array voted
private timer voteTimer = null
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function expire takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Switch vote has expired.|r")
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
set switcher = null
call ReleaseTimer(voteTimer)
set voteTimer = null
endfunction
private function checkSwitch takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
if GetPlayerTeam(switcher) == 0 then
call ChangePlayerTeam(switcher, 1)
call ChangePlayerTeam(switched, 0)
else
call ChangePlayerTeam(switcher, 0)
call ChangePlayerTeam(switched, 1)
endif
if GetUnitTypeId(GetPlayerUnit(switcher)) != 0 then
if IsPlayerObserving(switcher) then
if GetPlayerTeam(switcher) == 0 then
call SetPlayerObservePoint(switcher, GetRectCenterX(gg_rct_Start_1), GetRectCenterY(gg_rct_Start_1))
else
call SetPlayerObservePoint(switcher, GetRectCenterX(gg_rct_Start_2), GetRectCenterY(gg_rct_Start_2))
endif
else
call DestroyEffect(AddSpecialEffectTarget(SWITCH_SFX_PATH, GetPlayerUnit(switcher), "origin"))
endif
endif
if switched != null and GetUnitTypeId(GetPlayerUnit(switched)) != 0 then
if IsPlayerObserving(switched) then
if GetPlayerTeam(switched) == 0 then
call SetPlayerObservePoint(switched, GetRectCenterX(gg_rct_Start_1), GetRectCenterY(gg_rct_Start_1))
else
call SetPlayerObservePoint(switched, GetRectCenterX(gg_rct_Start_2), GetRectCenterY(gg_rct_Start_2))
endif
else
call DestroyEffect(AddSpecialEffectTarget(SWITCH_SFX_PATH, GetPlayerUnit(switched), "origin"))
endif
endif
if switched == null then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(switcher)+GetPlayerName(switcher)+"|r "+DEFAULT_COLOR_CODE+"has been switched to other team.|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(switcher)+GetPlayerName(switcher)+"|r "+DEFAULT_COLOR_CODE+"has switched with|r "+GetPlayerColorCode(switched)+GetPlayerName(switched)+DEFAULT_COLOR_CODE+".|r")
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
set switcher = null
set switched = null
if voteTimer != null then
call PauseTimer(voteTimer)
call ReleaseTimer(voteTimer)
set voteTimer = null
endif
call ArrangePlayers()
return true
endif
return false
endfunction
private function switch takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local integer n
local player p = GetTriggerPlayer()
if SubString(s, 0, 7) == "-switch" and switcher == null then
if s == "-switch" then
set switcher = p
set voted[GetPlayerId(p)] = true
if not IsPlayerObserving(p) then
set voteCount = voteCount + 1
endif
if not checkSwitch() then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(switcher)+GetPlayerName(switcher)+"|r "+DEFAULT_COLOR_CODE+"has initiated a switch vote. Type -ok to approve.|r")
set voteTimer = NewTimer()
call TimerStart(voteTimer, VOTE_TIME, false, function expire)
endif
else
set n = S2I(SubString(s, 8, StringLength(s)))
if n > 0 and n <= GetPlayerCount() and GetPlayerTeam(p) != GetPlayerTeam(GetPlayerByNumber(n - 1)) and StringLength(s) <= 10 then
set switched = GetPlayerByNumber(n - 1)
else
set switched = GetPlayerNamed(SubString(s, 8, StringLength(s)))
if switched == null or GetPlayerTeam(p) == GetPlayerTeam(switched) then
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
return false
endif
endif
set switcher = p
set voted[GetPlayerId(p)] = true
if not IsPlayerObserving(p) then
set voteCount = voteCount + 1
endif
if not checkSwitch() then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(switcher)+GetPlayerName(switcher)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has initiated a vote to switch with|r "+GetPlayerColorCode(switched)+GetPlayerName(switched)+DEFAULT_COLOR_CODE+". Type -ok to approve.|r")
set voteTimer = NewTimer()
call TimerStart(voteTimer, VOTE_TIME, false, function expire)
endif
endif
elseif s == "-ok" and switcher != null and not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has voted for switch ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
if not checkSwitch() then
call TimerStart(voteTimer, TimerGetRemaining(voteTimer) + VOTE_EXTENSION, false, function expire)
endif
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 and switcher != null then
call checkSwitch()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 and switcher != null then
call checkSwitch()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 and switcher != null then
call checkSwitch()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
//! runtextmacro protectionCheck1()
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function switch)
set t = null
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
endfunction
endscope
scope Votekick initializer init
globals
private player kicked = null
private integer voteCount = 0
private boolean array voted
private timer voteTimer = null
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function expire takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Votekick has expired.|r")
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
set kicked = null
call ReleaseTimer(voteTimer)
set voteTimer = null
endfunction
globals
private boolean kicking = false
endglobals
private function checkKick takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
set voteCount = 0
set kicking = true
call KickPlayer(kicked)
set kicking = false
set kicked = null
call IteratePlayersAll(revertPlayerVote)
if voteTimer != null then
call PauseTimer(voteTimer)
call ReleaseTimer(voteTimer)
set voteTimer = null
endif
return true
endif
return false
endfunction
private function votekick takes nothing returns boolean
local string s = GetEventPlayerChatString()
local integer n
local player p = GetTriggerPlayer()
if SubString(s, 0, 10) == "-votekick " and kicked == null and not IsPlayerObserving(p) then
set n = S2I(SubString(s, 10, StringLength(s)))
if n > 0 and n <= GetPlayerCount() and StringLength(s) <= 12 then
set kicked = GetPlayerByNumber(n - 1)
else
set kicked = GetPlayerNamed(SubString(s, 10, StringLength(s)))
if kicked == null then
call DisplayTextToPlayer(GetTriggerPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
return false
endif
endif
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
if not checkKick() then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has initiated a vote to kick|r "+GetPlayerColorCode(kicked)+GetPlayerName(kicked)+DEFAULT_COLOR_CODE+". Type -kick to approve.|r")
set voteTimer = NewTimer()
call TimerStart(voteTimer, VOTE_TIME, false, function expire)
endif
elseif s == "-kick" and kicked != null and not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has voted for kick ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
if not checkKick() then
call TimerStart(voteTimer, TimerGetRemaining(voteTimer) + VOTE_EXTENSION, false, function expire)
endif
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if not kicking and GetPlayerCount() > 0 and kicked != null then
call checkKick()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 and kicked != null then
call checkKick()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 and kicked != null then
call checkKick()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function votekick)
set t = null
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
endfunction
endscope
library Repick initializer init requires Pick, PlayerUtilities, Players
globals
private boolean array repickAvailable
private integer voteCount = 0
private boolean array voted
private timer voteTimer = null
private player repicker = null
endglobals
function Repick takes nothing returns nothing
local player p = Player((GetTimerData(GetExpiredTimer())))
if (not playerOnDynamicCD[GetPlayerId(p)]) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"is now repicking.|r")
set unitActive[GetPlayerId(p)] = false
call ClearPlayer(p)
call RemovePlayerUnit(p)
call SetPickReady(p)
else
call TimerStart(NewTimerEx(GetPlayerId(p)), 1.00, false, function Repick)
endif
call ReleaseTimer(GetExpiredTimer())
set p = null
endfunction
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function checkRepick takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
call TimerStart(NewTimerEx(GetPlayerId(repicker)),01.00, false, function Repick)
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
set repicker = null
if voteTimer != null then
call PauseTimer(voteTimer)
call ReleaseTimer(voteTimer)
set voteTimer = null
endif
return true
endif
return false
endfunction
private function expire takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Repick vote has expired.|r")
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
set repicker = null
call ReleaseTimer(voteTimer)
set voteTimer = null
endfunction
function GiveRepick takes player p returns nothing
set repickAvailable[GetPlayerId(p)] = true
endfunction
private function repick takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local player p = GetTriggerPlayer()
if s == "-repick" then
if repickAvailable[GetPlayerId(p)] or practiceMode then
set repickAvailable[GetPlayerId(p)] = false
call TimerStart(NewTimerEx(GetPlayerId(p)), 0.00, false, function Repick)
elseif (repicker == null) then
set repicker = p
set voted[GetPlayerId(p)] = true
if not IsPlayerObserving(p) then
set voteCount = voteCount + 1
endif
if not checkRepick() then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(repicker)+GetPlayerName(repicker)+"|r "+DEFAULT_COLOR_CODE+"wants to repick. Type -allow to approve.|r")
set voteTimer = NewTimer()
call TimerStart(voteTimer, VOTE_TIME, false, function expire)
endif
endif
elseif s == "-allow" and repicker != null and not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has voted for repick ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
if not checkRepick() then
call TimerStart(voteTimer, TimerGetRemaining(voteTimer) + VOTE_EXTENSION, false, function expire)
endif
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 and repicker != null then
call checkRepick()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 and repicker != null then
call checkRepick()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 and repicker != null then
call checkRepick()
endif
endfunction
private function registerChatCommand takes player p returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, p, "", true)
call TriggerAddCondition(t, Condition(function repick))
set t = null
endfunction
private function removeRepick takes player p returns nothing
set repickAvailable[GetPlayerId(p)] = false
endfunction
private function removeRepicks takes nothing returns nothing
call IteratePlayersAll(removeRepick)
endfunction
private function init takes nothing returns nothing
call IteratePlayersPlaying(registerChatCommand)
call RegisterEvent(function removeRepicks, EVENT_GAME_START)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
endfunction
endlibrary
scope LolzMode initializer init
globals
private boolean lollery = false
private real array constants
private integer voteCount = 0
private boolean array voted
private boolean enabled = true
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
function enableLolzMode takes boolean e returns nothing
if e then
set enabled = true
else
set enabled = false
if lollery then
set BLACK_HOLE_FORCE = constants[0]
set BLACK_HOLE_LIMIT = constants[1]
set TACKLE_SPEED = constants[2]
set TACKLE_RANGE = constants[3]
set SLAM_FORCE = constants[4]
set SUPER_SPRINT_PROPULSION = constants[5]
set SUPER_SPRINT_ACCELERATION = constants[6]
set BACKFLIP_RANGE = constants[7]
set BACKFLIP_TIME = constants[8]
set POWERSHOT_SPEED = constants[9]
set PULL_FORCE = constants[10]
set POSSESS_EJECT_MAGNITUDE = constants[11]
set POSSESS_JUMP_VELOCITY_REDUCTION = constants[12]
set POSSESS_JUMP_SPEED = constants[13]
set SWAP_PROJECTILE_SPEED = constants[14]
set SWAP_PROJECTILE_DURATION = constants[15]
set CURVESHOT_RANGE = constants[16]
set CURVESHOT_DURATION = constants[17]
set CURVESHOT_RADIUS = constants[18]
set CURVESHOT_SPEED_FACTOR = constants[19]
call Curveshot_initValues.execute()
set SHADOW_RANGE = constants[20]
set HOOK_PROJECTILE_SPEED = constants[21]
set HOOK_PROJECTILE_RETURN_SPEED = constants[22]
set HOOK_PROJECTILE_DURATION = constants[23]
set SMASH_RANGE = constants[24]
set SMASH_PUSH_FORCE = constants[25]
set lollery = false
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
endif
endfunction
private function checkLolz takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
if lollery then
set BLACK_HOLE_FORCE = constants[0]
set BLACK_HOLE_LIMIT = constants[1]
set TACKLE_SPEED = constants[2]
set TACKLE_RANGE = constants[3]
set SLAM_FORCE = constants[4]
set SUPER_SPRINT_PROPULSION = constants[5]
set SUPER_SPRINT_ACCELERATION = constants[6]
set BACKFLIP_RANGE = constants[7]
set BACKFLIP_TIME = constants[8]
set POWERSHOT_SPEED = constants[9]
set PULL_FORCE = constants[10]
set POSSESS_EJECT_MAGNITUDE = constants[11]
set POSSESS_JUMP_VELOCITY_REDUCTION = constants[12]
set POSSESS_JUMP_SPEED = constants[13]
set SWAP_PROJECTILE_SPEED = constants[14]
set SWAP_PROJECTILE_DURATION = constants[15]
set CURVESHOT_RANGE = constants[16]
set CURVESHOT_DURATION = constants[17]
set CURVESHOT_RADIUS = constants[18]
set CURVESHOT_SPEED_FACTOR = constants[19]
call Curveshot_initValues.execute()
set SHADOW_RANGE = constants[20]
set HOOK_PROJECTILE_SPEED = constants[21]
set HOOK_PROJECTILE_RETURN_SPEED = constants[22]
set HOOK_PROJECTILE_DURATION = constants[23]
set SMASH_RANGE = constants[24]
set SMASH_PUSH_FORCE = constants[25]
set lollery = false
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Lollery|r "+INVALID_COLOR_CODE+"OFF|r")
else
set BLACK_HOLE_FORCE = 70000.0
set BLACK_HOLE_LIMIT = 200.0
set TACKLE_SPEED = 70.0
set TACKLE_RANGE = 2000.0
set SLAM_FORCE = 120.0
set SUPER_SPRINT_PROPULSION = 50.0
set SUPER_SPRINT_ACCELERATION = 2.00
set BACKFLIP_RANGE = 2000.0
set BACKFLIP_TIME = 1.00
set POWERSHOT_SPEED = 100.0
set PULL_FORCE = 10.0
set POSSESS_EJECT_MAGNITUDE = 100.0
set POSSESS_JUMP_VELOCITY_REDUCTION = 100.0
set POSSESS_JUMP_SPEED = 100.0
set SWAP_PROJECTILE_SPEED = 70.0
set SWAP_PROJECTILE_DURATION = 8.00
set CURVESHOT_RANGE = CURVESHOT_RANGE*2.00
set CURVESHOT_DURATION = CURVESHOT_DURATION*3.00
set CURVESHOT_RADIUS = CURVESHOT_RANGE/2.00*1.20
set CURVESHOT_SPEED_FACTOR = 8.00
call Curveshot_initValues.execute()
set SHADOW_RANGE = 1600.0
set HOOK_PROJECTILE_SPEED = 70.0
set HOOK_PROJECTILE_RETURN_SPEED = 60.0
set HOOK_PROJECTILE_DURATION = 2.0
set SMASH_RANGE = 600.0
set SMASH_PUSH_FORCE = 60.0
set lollery = true
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Lollery|r "+VALID_COLOR_CODE+"ON|r")
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
return true
endif
return false
endfunction
private function lolz takes nothing returns boolean
local player p = GetTriggerPlayer()
if enabled and not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
if lollery then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to disable lolz mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to enable lolz mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
endif
call checkLolz()
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 then
call checkLolz()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 then
call checkLolz()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 then
call checkLolz()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "-lolz mode", true)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function lolz)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
set t = null
set constants[0] = BLACK_HOLE_FORCE
set constants[1] = BLACK_HOLE_LIMIT
set constants[2] = TACKLE_SPEED
set constants[3] = TACKLE_RANGE
set constants[4] = SLAM_FORCE
set constants[5] = SUPER_SPRINT_PROPULSION
set constants[6] = SUPER_SPRINT_ACCELERATION
set constants[7] = BACKFLIP_RANGE
set constants[8] = BACKFLIP_TIME
set constants[9] = POWERSHOT_SPEED
set constants[10] = PULL_FORCE
set constants[11] = POSSESS_EJECT_MAGNITUDE
set constants[12] = POSSESS_JUMP_VELOCITY_REDUCTION
set constants[13] = POSSESS_JUMP_SPEED
set constants[14] = SWAP_PROJECTILE_SPEED
set constants[15] = SWAP_PROJECTILE_DURATION
set constants[16] = CURVESHOT_RANGE
set constants[17] = CURVESHOT_DURATION
set constants[18] = CURVESHOT_RADIUS
set constants[19] = CURVESHOT_SPEED_FACTOR
set constants[20] = SHADOW_RANGE
set constants[21] = HOOK_PROJECTILE_SPEED
set constants[22] = HOOK_PROJECTILE_RETURN_SPEED
set constants[23] = HOOK_PROJECTILE_DURATION
set constants[24] = SMASH_RANGE
set constants[25] = SMASH_PUSH_FORCE
endfunction
endscope
scope Apocalypse initializer init
globals
private boolean on = false
private timer t1
private timer t2
private timer t3
private unit bh
private integer transparency = 0
private real scale = 1.00
private real pullForce = 0.00
private real pullForceDelta = 1.00
private trigger trig = CreateTrigger()
private real shakeMagnitude = 0.00
private real shakeVelocity = 0.00
private real treePullPeriod = 3.50
private integer count
private boolean array voted
private integer voteCount = 0
private string array voteMsg
private boolean array msgUsed
private integer skeletonTeam
private integer array skeletonCounter
private integer array skeletonBottom
private integer array skeletonTop
endglobals
private function unitPull takes nothing returns boolean
local unit f = GetFilterUnit()
local Vector v
local real d
if IsUnitType(f, UNIT_TYPE_OBJECT) then
set v = Vector.create(currentField.centerX - GetUnitX(f), currentField.centerY - GetUnitY(f), 200.0 + DEFAULT_Z - GetUnitZ(f))
set d = v.getLength()
call v.setLength(pullForce/d)
if d > 9.00*scale then
call Object[f].applyVector(v)
else
call Sfx("Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl", currentField.centerX, currentField.centerY, DEFAULT_Z + 210.0, GetRandomReal(0.00, 360.0), 0.00, 3.00)
call RemoveUnit(f)
endif
call v.destroy()
endif
set f = null
return false
endfunction
private function treePull takes nothing returns nothing
local destructable d = RandomDestructableInRectBJ(currentField.zone, null)
if d != null then
if GetDestructableTypeId(d) != 0 and (GetDestructableTypeId(d) == SUMMER_TREE_RAWCODE or GetDestructableTypeId(d) == SNOWY_TREE_RAWCODE) then
call CreateDeadDestructable(GetDestructableTypeId(d), GetWidgetX(d), GetWidgetY(d), 270.0, 1.20, GetRandomInt(0, 9))
if GetDestructableTypeId(d) == SUMMER_TREE_RAWCODE then
call CreateUnit(DUMMY_OWNER, SUMMER_TREE_UNIT_RAWCODE, GetWidgetX(d), GetWidgetY(d), 270.0)
else
call CreateUnit(DUMMY_OWNER, SNOWY_TREE_UNIT_RAWCODE, GetWidgetX(d), GetWidgetY(d), 270.0)
endif
call RemoveDestructable(d)
endif
set d = null
if treePullPeriod > 0.131250 then
set treePullPeriod = treePullPeriod - 0.03125
else
set treePullPeriod = 0.1000
endif
call TimerStart(t2, treePullPeriod, false, function treePull)
endif
endfunction
private function bhAppearance takes nothing returns nothing
local Ball ball = Ball.balls[0]
local integer i
local Vector v
local real d
if transparency <= 254 then
set transparency = transparency + 1
call SetUnitVertexColor(bh, 255, 255, 255, transparency)
endif
set scale = scale + 0.01
call SetUnitScale(bh, scale, scale, scale)
set pullForce = pullForce + pullForceDelta
set pullForceDelta = pullForceDelta + 0.00625
set i = 0
loop
call GroupEnumUnitsOfPlayer(enumGroup, Player(i), Filter(function unitPull))
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call GroupEnumUnitsOfPlayer(enumGroup, REFEREE_PLAYER, Filter(function unitPull))
if GetUnitTypeId(ball.ball) != 0 then
set v = Vector.create(currentField.centerX - GetUnitX(ball.ball), currentField.centerY - GetUnitY(ball.ball), 200.0 + DEFAULT_Z - GetUnitZ(ball.ball))
set d = v.getLength()
call v.setLength(pullForce/d)
if d > v.getLength() then
call ball.applyVector(v)
else
call Sfx("Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl", GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), GetRandomReal(0.00, 360.0), 90.0, 1.00)
call RemoveUnit(ball.ball)
endif
call v.destroy()
endif
endfunction
private function blockerRemoval takes nothing returns nothing
local destructable d = GetEnumDestructable()
if GetDestructableTypeId(d) == 'YTpb' then
call RemoveDestructable(d)
endif
endfunction
private function shake takes nothing returns nothing
set shakeMagnitude = shakeMagnitude + 0.55
set shakeVelocity = shakeVelocity + 1300.0
call CameraSetTargetNoiseEx(shakeMagnitude, shakeVelocity, false)
endfunction
private function treeDestruction takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
private function unitRemoval takes nothing returns boolean
call RemoveUnit(GetFilterUnit())
return false
endfunction
private function spawn takes nothing returns nothing
local real x = GetRandomReal(GetRectMinX(gg_rct_Field), GetRectMaxX(gg_rct_Field))
local real y = GetRandomReal(GetRectMinY(gg_rct_Field), GetRectMaxY(gg_rct_Field))
local player p
if GetTeamPlayerCount(skeletonTeam) == 0 then
set skeletonTeam = ModuloInteger(skeletonTeam + 1, 2)
endif
set skeletonBottom[0] = 0
set skeletonTop[0] = GetTeamPlayerCount(0) - 1
set skeletonBottom[1] = GetTeamPlayerCount(0)
set skeletonTop[1] = GetPlayerCount() - 1
if skeletonCounter[skeletonTeam] > skeletonTop[skeletonTeam] then
set skeletonCounter[skeletonTeam] = skeletonBottom[skeletonTeam]
endif
set p = GetPlayerByNumber(skeletonCounter[skeletonTeam])
set skeletonCounter[skeletonTeam] = skeletonCounter[skeletonTeam] + 1
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", x, y))
if GetRandomInt(0, 1) == 0 then
call CreateUnit(p, 'nske', x, y, GetRandomReal(0.00, 360.0))
else
call CreateUnit(p, 'nska', x, y, GetRandomReal(0.00, 360.0))
endif
set count = count - 1
if count == 0 then
call PauseTimer(GetExpiredTimer())
call ReleaseTimer(GetExpiredTimer())
endif
set skeletonTeam = ModuloInteger(skeletonTeam + 1, 2)
endfunction
private function skeletonSpawn takes nothing returns nothing
set skeletonTeam = 0
set skeletonCounter[0] = 0
set skeletonCounter[1] = GetTeamPlayerCount(0)
call TimerStart(GetExpiredTimer(), 0.15, true, function spawn)
endfunction
private function revelation takes nothing returns nothing
call CinematicFadeCommonBJ(30.0, 10.0, 0.00, 5.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 100.0)
call FinishCinematicFadeAfterBJ(5.00)
set count = GetPlayerCount()*10
call TimerStart(GetExpiredTimer(), 5.00, false, function skeletonSpawn)
endfunction
globals
private real randomX
private real randomY
private integer Type
private boolean repeat = false
endglobals
private function apocSfx takes string path, real size, real x, real y, integer typ returns nothing
local unit d = CreateUnit(DUMMY_OWNER, SFX_DUMMY_RAWCODE, x, y, GetRandomReal(0.00, 360.0))
call SetUnitX(d, x)
call SetUnitY(d, y)
call SetUnitZ(d, DEFAULT_Z)
call SetUnitScale(d, size, size, size)
call SetUnitAnimationByIndex(d, R2I(90.0))
call AddSpecialEffectTarget(path, d, "origin")
call SetUnitUserData(d, typ)
endfunction
private function checkCollision takes nothing returns boolean
local unit f = GetFilterUnit()
if GetUnitTypeId(f) == SFX_DUMMY_RAWCODE and GetUnitUserData(f) == Type then
set repeat = true
endif
set f = null
return false
endfunction
private function findCoordinates takes integer i, real aoe returns nothing
local real a = GetRandomReal(0.00, 2 * bj_PI)
local real d = GetRandomReal(0.00, 2048.0)
set randomX = currentField.centerX + d*Cos(a)
set randomY = currentField.centerY + d*Sin(a)
set Type = i
call GroupEnumUnitsInRange(enumGroup, randomX, randomY, aoe, Filter(function checkCollision))
if repeat then
set repeat = false
call findCoordinates(i, aoe)
endif
endfunction
private function largeFire takes nothing returns nothing
call findCoordinates(1, 150.0)
call apocSfx("Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl", 1.00, randomX, randomY, 1)
endfunction
private function smallFire takes nothing returns nothing
call findCoordinates(2, 100.0)
call apocSfx("Doodads\\Cinematic\\FireRockSmall\\FireRockSmall.mdl", 1.00, randomX, randomY, 2)
endfunction
private function rubble takes nothing returns nothing
local integer random
call findCoordinates(3, 50.0)
set random = GetRandomInt(0, 3)
call apocSfx("Doodads\\Outland\\Rocks\\RubbleRock\\RubbleRock"+I2S(random)+".mdl", 0.60, randomX, randomY, 3)
endfunction
private function randomDestruction takes nothing returns nothing
local integer random = GetRandomInt(0, 10)
if random == 0 then
call largeFire()
elseif random == 1 or random == 2 then
call smallFire()
else
call rubble()
endif
endfunction
private function cleanup takes nothing returns nothing
local integer i = 0
call CameraSetTargetNoiseEx(0.00, 0.00, false)
call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function treeDestruction)
loop
call GroupEnumUnitsOfPlayer(enumGroup, Player(i), Filter(function unitRemoval))
set i = i + 1
exitwhen i == 12
endloop
call GroupEnumUnitsOfPlayer(enumGroup, REFEREE_PLAYER, Filter(function unitRemoval))
set i = 230
loop
call ExecuteFunc(randomDestruction.name)
set i = i - 1
exitwhen i == 0
endloop
call TimerStart(GetExpiredTimer(), 2.50, false, function revelation)
endfunction
private function filter takes nothing returns nothing
call CinematicFadeCommonBJ(30.0, 10.0, 0.00, 2.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 100.0, 0.00)
call TimerStart(GetExpiredTimer(), 4.00, false, function cleanup)
endfunction
private function explosionBlast takes nothing returns boolean
local unit f = GetFilterUnit()
local Vector v
if IsUnitType(f, UNIT_TYPE_OBJECT) then
set v = Vector.create(GetUnitX(f) - currentField.centerX, GetUnitY(f) - currentField.centerY, GetUnitZ(f) + 100.0)
call v.setLength(75.0)
call Object[f].applyVector(v)
call v.destroy()
endif
set f = null
return false
endfunction
private function explosion takes nothing returns nothing
local integer i = 0
call PauseTimer(t1)
call ReleaseTimer(t1)
call PauseTimer(t2)
call ReleaseTimer(t2)
call PauseTimer(t3)
call ReleaseTimer(t3)
loop
call GroupEnumUnitsOfPlayer(enumGroup, Player(i), Filter(function explosionBlast))
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call GroupEnumUnitsOfPlayer(enumGroup, REFEREE_PLAYER, Filter(function explosionBlast))
call Sfx("war3mapImported\\NuclearExplosion.mdx", currentField.centerX, currentField.centerY, 0.00, GetRandomReal(0.00, 360.0), 90.0, 3.50)
call TimerStart(GetExpiredTimer(), 0.50, false, function filter)
endfunction
private function shakeStart takes nothing returns nothing
set treePullPeriod = treePullPeriod - 2.60
set t3 = NewTimer()
call TimerStart(t3, 0.1000, true, function shake)
call TimerStart(GetExpiredTimer(), 25.0, false, function explosion)
endfunction
/*
/fuck everything: -1075834314
-fuck everything: 1722990276
*/
private function getRandomMsg takes nothing returns string
local integer i
loop
set i = GetRandomInt(0, 8)
exitwhen not msgUsed[i]
endloop
set msgUsed[i] = true
return voteMsg[i]
endfunction
private function apoc takes nothing returns boolean
local string s = GetEventPlayerChatString()
local player p = GetTriggerPlayer()
if (StringHash(s) == -1075834314 or StringHash(s) == 1722990276 or s == "-apocalypse") and (not on) and (not voted[GetPlayerId(p)]) and (not IsPlayerObserving(p)) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+getRandomMsg()+"|r")
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
set on = true
static if not TEST then
if gameTimeTotal > 0.00 and gameTimer != null then
call PauseTimer(gameTimer)
endif
endif
set bh = CreateUnit(DUMMY_OWNER, BLACK_HOLE_APOCALYPSE_RAWCODE, currentField.centerX, currentField.centerY, GetRandomReal(0.00, 360.0))
call SetUnitVertexColor(bh, 255, 255, 255, 0)
call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function blockerRemoval)
set t1 = NewTimer()
call TimerStart(t1, 0.0312500, true, function bhAppearance)
set t2 = NewTimer()
call TimerStart(t2, 6.00, false, function treePull)
call TimerStart(NewTimer(), 22.0, false, function shakeStart)
endif
endif
set p = null
return false
endfunction
private function enable takes nothing returns nothing
call EnableTrigger(trig)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function wait takes nothing returns nothing
call TimerStart(NewTimer(), 40.00, false, function enable)
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 then
call apoc()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 then
call apoc()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 then
call apoc()
endif
endfunction
private function init takes nothing returns nothing
local integer i = 0
loop
call TriggerRegisterPlayerChatEvent(trig, Player(i), "", false)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(trig, function apoc)
static if not TEST then
call DisableTrigger(trig)
call RegisterEvent(function wait, EVENT_FIELD_CHOOSE)
endif
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
set voteMsg[0] = "wants to end this."
set voteMsg[1] = "is getting real tired of your s%#t."
set voteMsg[2] = "thinks what's enough is enough."
set voteMsg[3] = "..."
set voteMsg[4] = "thinks apocalypse is the only solution."
set voteMsg[5] = "votes yes for whatever."
set voteMsg[6] = "has had it with this game."
set voteMsg[7] = "doesn't care anymore."
set voteMsg[8] = "has given up."
endfunction
endscope
scope PracticeMode initializer init
globals
boolean practiceMode = false
private integer voteCount = 0
private boolean array voted
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function checkPractice takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
if practiceMode then
set practiceMode = false
set noGoalMode = false
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Practice Mode|r "+INVALID_COLOR_CODE+"OFF|r")
else
set practiceMode = true
if noGoals then
set noGoalMode = true
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Practice Mode|r "+VALID_COLOR_CODE+"ON|r")
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
return true
endif
return false
endfunction
private function practice takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local player p = GetTriggerPlayer()
local Ball ball = Ball.balls[0]
if s == "-practice" then
if not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
if practiceMode then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to disable practice mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to enable practice mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
endif
call checkPractice()
endif
elseif s == "-ball" and practiceMode and not IsPlayerObserving(p) and metsHax then
call ball.takeOwnership(GetPlayerUnit(p))
endif
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 then
call checkPractice()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 then
call checkPractice()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 then
call checkPractice()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function practice)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
set t = null
endfunction
endscope
scope NoGoalMode initializer init
globals
boolean noGoalMode = false
boolean noGoals = false
private integer voteCount = 0
private boolean array voted
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function checkNoGoal takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
if noGoals then
set noGoals = false
set noGoalMode = false
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"No Goal Mode (in Practice Mode)|r "+INVALID_COLOR_CODE+"OFF|r")
else
set noGoals = true
if practiceMode then
set noGoalMode = true
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"No Goal Mode (in Practice Mode)|r "+VALID_COLOR_CODE+"ON|r")
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
return true
endif
return false
endfunction
private function noGoal takes nothing returns boolean
local player p = GetTriggerPlayer()
if not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
if noGoals then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to renable goals in practice mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to disable goals in practice mode ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
endif
endif
call checkNoGoal()
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 then
call checkNoGoal()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 then
call checkNoGoal()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 then
call checkNoGoal()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "-no goal", true)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function noGoal)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
set t = null
endfunction
endscope
scope MetsHaxMode initializer init
globals
boolean metsHax = false
private integer voteCount = 0
private boolean array voted
endglobals
private function revertPlayerVote takes player p returns nothing
set voted[GetPlayerId(p)] = false
endfunction
private function checkMetsHax takes nothing returns boolean
if voteCount >= R2I(GetHumanPlayerCount()*0.75 + 0.50) then
if metsHax then
set metsHax = false
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Ball command (in Practice Mode)|r "+INVALID_COLOR_CODE+"OFF|r")
else
set metsHax = true
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 7.00, DEFAULT_COLOR_CODE+"Ball command (in Practice Mode)|r "+VALID_COLOR_CODE+"ON|r")
endif
set voteCount = 0
call IteratePlayersAll(revertPlayerVote)
return true
endif
return false
endfunction
private function MetsHax takes nothing returns boolean
local player p = GetTriggerPlayer()
if not voted[GetPlayerId(p)] and not IsPlayerObserving(p) then
set voted[GetPlayerId(p)] = true
set voteCount = voteCount + 1
if metsHax then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to disable the -ball command ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "/*
*/+DEFAULT_COLOR_CODE+"has voted to enable the -ball command ["+I2S(voteCount)+"/"+I2S(R2I(GetHumanPlayerCount()*0.75 + 0.50))+"].|r")
endif
endif
call checkMetsHax()
set p = null
return false
endfunction
private function onLeave takes nothing returns nothing
if voted[GetPlayerId(GetLeavingPlayer())] then
set voted[GetPlayerId(GetLeavingPlayer())] = false
if not IsPlayerObserving(GetLeavingPlayer()) then
set voteCount = voteCount - 1
endif
endif
if GetPlayerCount() > 0 then
call checkMetsHax()
endif
endfunction
private function onObserve takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount - 1
endif
if GetPlayerCount() > 0 then
call checkMetsHax()
endif
endfunction
private function onObserveReturn takes nothing returns nothing
if voted[GetPlayerId(GetObservingPlayer())] then
set voteCount = voteCount + 1
endif
if GetPlayerCount() > 0 then
call checkMetsHax()
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "-mets hax", true)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function MetsHax)
call RegisterEvent(function onLeave, EVENT_LEAVE)
call RegisterEvent(function onObserve, EVENT_OBSERVE)
call RegisterEvent(function onObserveReturn, EVENT_OBSERVE_RETURN)
set t = null
endfunction
endscope
library Cheer initializer init requires Sounds, Players
globals
string array playerSound
boolean array soundsEnabled
endglobals
private function resumeMusic takes nothing returns nothing
call ResumeMusic()
call ReleaseTimer(GetExpiredTimer())
endfunction
scope Trinnin
globals
private boolean firstGoal = true
endglobals
function CheerTrinnin takes player p returns real
local integer i = GetRandomInt(0, 1)
if (soundsEnabled[GetPlayerId(GetLocalPlayer())] or GetLocalPlayer() == p) then
call StopMusic(false)
if firstGoal or i == 0 then
call Play("war3mapImported\\trinnin1 [High quality].mp3")
else
call Play("war3mapImported\\trinnin2 [High quality].mp3")
endif
endif
if firstGoal or i == 0 then
set firstGoal = false
endif
call TimerStart(NewTimer(), 3.00, false, function resumeMusic)
return 4.00
endfunction
endscope
function CheerSound takes player p, string str returns real
local integer rand = 0
local string tempStr = str
local real time = 0.00
if str == "smokin.wav" then
set time = 2.25
elseif str == "lightning.mp3" then
set time = 5.25
elseif str == "hurray.mp3" then
set time = 4.00
elseif str == "triple.mp3" then
set time = 5.00
elseif str == "joffrey.mp3" then
set time = 2.20
elseif str == "HeadBand.mp3" then
set time = 11.50
elseif str == "bound 2.mp3" then
set time = 12.50
elseif str == "coco.mp3" then
set time = 7.50
elseif str == "down.mp3" then
set time = 4.00
elseif str == "leeroy.mp3" then
set time = .50
elseif str == "shake it off.mp3" then
set time = 6.50
elseif str == "single ladies.mp3" then
set time = 7.50
elseif str == "space jam.mp3" then
set time = 6.50
elseif str == "winning.mp3" then
set time = 6.50
elseif str == "watermelon.mp3" then
set time = 7.50
elseif str == "yee.mp3" then
set time = 7.50
elseif str == "bump n grind.mp3" then
set time = 11.50
elseif str == "bounty.mp3" then
set time = 7.00
elseif str == "Dope Walk.mp3" then
set time = 5.00
elseif str == "Microphone Fiend.mp3" then
set time = 11.00
elseif str == "Gee.mp3" then
set time = 4.50
elseif str == "really.mp3" then
set time = 4.00
elseif str == "AYO GG.mp3" then
set time = 4.00
elseif str == "dawg.mp3" then
set time = 6.00
elseif str == "cell.mp3" then
set time = 9.50
elseif str == "snappy.mp3" then
set time = 9.50
elseif str == "PIMP.mp3" then
set time = 9.50
elseif str == "stone cold.mp3" then
set time = 10.00
elseif str == "ram ranch.mp3" then
set time = 6.50
elseif str == "bump n grind.mp3" then
set time = 10.50
elseif str == "dancedance.mp3" then
set time = 9.50
elseif str == "flyers.mp3" then
set time = 7.50
elseif str == "gee.mp3" then
set time = 5.50
elseif str == "nyanko.mp3" then
set time = 8.50
elseif str == "odd future.mp3" then
set time = 7.50
elseif str == "shake it off.mp3" then
set time = 6.50
elseif str == "sk8erboi.mp3" then
set time = 7.50
elseif str == "tenkz.mp3" then
set time = 4.50
elseif str == "triple.mp3" then
set time = 5.50
elseif str == "wolfpls.mp3" then
set time = 6.50
elseif str == "ptg2.mp3" then
set time = 9.50
elseif str == "aussie" then
set rand = GetRandomInt(0, 7)
set tempStr = str + I2S(rand) + ".mp3"
if rand == 0 or rand == 1 or rand == 7 then
set time = 3.50
elseif rand == 2 or rand == 5 or rand == 6 then
set time = 6.50
elseif rand == 3 or rand == 4 then
set time = 9.50
endif
endif
if (soundsEnabled[GetPlayerId(GetLocalPlayer())] or GetLocalPlayer() == p) then
call StopMusic(false)
call Play("war3mapImported\\" + tempStr)
endif
call TimerStart(NewTimer(), time, false, function resumeMusic)
if (time <= 7.00) then
return 4.00
else
//return 7.00
return 4.00
endif
endfunction
function Cheer takes player p, boolean autoscore returns real
local string str = playerSound[GetPlayerId(p)]
if not autoscore and str != "none" then
if str == "america" then
return CheerTrinnin(p)
elseif str != "" then
return CheerSound(p, str)
elseif GetPlayerOriginalName(p) == "Trinnin" then
return CheerTrinnin(p)
elseif GetPlayerOriginalName(p) == "PROMASTER" then
return CheerSound(p, "smokin.wav")
elseif (GetPlayerOriginalName(p) == "SirSirrrr" and sirSlam) then
return CheerSound(p, "lightning.mp3")
elseif GetPlayerOriginalName(p) == "SS4Gotenkzz" or GetPlayerOriginalName(p) == "Fade_" or GetPlayerOriginalName(p) == "tenkzz" then
return CheerSound(p, "tenkz.mp3")
elseif GetPlayerOriginalName(p) == "CallToArms" then
return CheerSound(p, "headband.mp3")
elseif GetPlayerOriginalName(p) == "Spankfurt" then
return CheerSound(p, "yee.mp3")
elseif GetPlayerOriginalName(p) == "bountykillah" then
return CheerSound(p, "bounty.mp3")
elseif GetPlayerOriginalName(p) == "Cotton" or GetPlayerOriginalName(p) == "CANTTHINKOFNAME" then
return CheerSound(p, "Dope Walk.mp3")
elseif GetPlayerOriginalName(p) == "NY_Mets" then
return CheerSound(p, "Microphone Fiend.mp3")
elseif GetPlayerOriginalName(p) == "winning)" then
return CheerSound(p, "dawg.mp3")
elseif GetPlayerOriginalName(p) == "cell_destroyer" or GetPlayerOriginalName(p) == "King Weasel" then
return CheerSound(p, "cell.mp3")
elseif GetPlayerOriginalName(p) == "2dayne4u" then
return CheerSound(p, "aussie")
elseif GetPlayerOriginalName(p) == "ImmortaL_GoD" then
return CheerSound(p, "PIMP.mp3")
elseif GetPlayerOriginalName(p) == "heIgan" then
return CheerSound(p, "nyanko.mp3")
elseif GetPlayerOriginalName(p) == "kwakster" then
return CheerSound(p, "odd future.mp3")
elseif GetPlayerOriginalName(p) == "Ruckle" then
return CheerSound(p, "ptg2.mp3")
endif
endif
return 4.00
endfunction
private function sounds takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local player p = GetTriggerPlayer()
if s == "-cheer" or s == "-cheers" then
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"List of Cheers (for the full list, check the Tips menu):|r")
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"none, off, on, america, smokin, zeus, hurray, joffrey, " + /*
*/ "headband, bound 2, bounty, coco, gdfr, single ladies, space jam, yee, dope walk, microphone fiend, ayo gg, " + /*
*/ "cell, snappy, PIMP, stone cold, ram ranch, bump n grind, haruhi, flyers, gee, odd future, shake it off, " + /*
*/ "sk8erboi, triple, wolfpls, aussie.|r")
elseif SubString(s, 0, 6) == "-cheer" then
set s = SubString(s, 7, StringLength(s))
if s == "none" then
set playerSound[GetPlayerId(p)] = "none"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have disabled your cheer.|r")
elseif s == "off" then
set playerSound[GetPlayerId(p)] = "none"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have disabled cheers.|r")
set soundsEnabled[GetPlayerId(p)] = false
elseif s == "on" then
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have enabled cheers.|r")
set soundsEnabled[GetPlayerId(p)] = true
elseif s == "america" then
set playerSound[GetPlayerId(p)] = "america"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to AMERICA FUCK YEAH!|r")
elseif s == "smokin" then
set playerSound[GetPlayerId(p)] = "smokin.wav"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to SMOKIN.|r")
elseif s == "zeus" then
set playerSound[GetPlayerId(p)] = "lightning.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to lightning.|r")
elseif s == "hurray" then
set playerSound[GetPlayerId(p)] = "hurray.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to self-motivation.|r")
elseif s == "joffrey" then
set playerSound[GetPlayerId(p)] = "joffrey.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Joffrey.|r")
elseif s == "headband" then
set playerSound[GetPlayerId(p)] = "HeadBand.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to HeadBand.|r")
elseif s == "bound 2" then
set playerSound[GetPlayerId(p)] = "bound 2.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Bound 2.|r")
elseif s == "bounty" then
set playerSound[GetPlayerId(p)] = "bounty.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to bountykillah.|r")
elseif s == "coco" then
set playerSound[GetPlayerId(p)] = "coco.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to CoCo.|r")
elseif s == "gdfr" then
set playerSound[GetPlayerId(p)] = "down.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to GDFR.|r")
elseif s == "single ladies" then
set playerSound[GetPlayerId(p)] = "single ladies.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Single Ladies.|r")
elseif s == "space jam" then
set playerSound[GetPlayerId(p)] = "space jam.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to the Space Jam.|r")
elseif s == "yee" then
set playerSound[GetPlayerId(p)] = "yee.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Yee.|r")
elseif s == "dope walk" then
set playerSound[GetPlayerId(p)] = "Dope Walk.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Dope Walk.|r")
elseif s == "microphone fiend" then
set playerSound[GetPlayerId(p)] = "Microphone Fiend.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Microphone Fiend.|r")
elseif s == "really" then
set playerSound[GetPlayerId(p)] = "really.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to I Really Like You.|r")
elseif s == "ayo gg" then
set playerSound[GetPlayerId(p)] = "AYO GG.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to AYO GG.|r")
elseif s == "cell" then
set playerSound[GetPlayerId(p)] = "cell.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to cell_destroyer's favorite song.|r")
elseif s == "snappy" then
set playerSound[GetPlayerId(p)] = "snappy.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"WOW!|r")
elseif s == "pimp" then
set playerSound[GetPlayerId(p)] = "PIMP.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to PIMP by 50 Cent.|r")
elseif s == "stone cold" then
set playerSound[GetPlayerId(p)] = "stone cold.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to literally pimp+cell.|r")
elseif s == "ram ranch" then
set playerSound[GetPlayerId(p)] = "ram ranch.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"Ram Ranch really rocks!|r")
elseif s == "bump n grind" then
set playerSound[GetPlayerId(p)] = "bump n grind.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Bump n Grind!|r")
elseif s == "haruhi" then
set playerSound[GetPlayerId(p)] = "dancedance.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Sleek's waifu!|r")
elseif s == "flyers" then
set playerSound[GetPlayerId(p)] = "flyers.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Flyers!|r")
elseif s == "gee" then
set playerSound[GetPlayerId(p)] = "gee.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Gee!|r")
elseif s == "nyanko" then
set playerSound[GetPlayerId(p)] = "nyanko.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You dirty fucking weeb.|r")
elseif s == "odd future" then
set playerSound[GetPlayerId(p)] = "odd future.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Odd Future!|r")
elseif s == "shake it off" then
set playerSound[GetPlayerId(p)] = "shake it off.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to Shake It Off!|r")
elseif s == "sk8erboi" then
set playerSound[GetPlayerId(p)] = "sk8erboi.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have set your cheer to sk8erboi!|r")
elseif s == "tenkz" then
set playerSound[GetPlayerId(p)] = "tenkz.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"two fucking people pickaxing me because you guys are fake friends|r")
elseif s == "triple" then
set playerSound[GetPlayerId(p)] = "triple.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"Oh baby, a triple!|r")
elseif s == "wolfpls" then
set playerSound[GetPlayerId(p)] = "wolfpls.mp3"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+":^)!|r")
elseif s == "aussie" then
set playerSound[GetPlayerId(p)] = "aussie"
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"BONGOBALL!|r")
else
call DisplayTextToPlayer(p, 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
endif
endif
set p = null
return false
endfunction
private function init takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", true)
endif
set playerSound[i] = ""
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function sounds)
set t = null
call InitSound("war3mapImported\\trinnin1 [High quality].mp3")
call InitSound("war3mapImported\\trinnin2 [High quality].mp3")
call InitSound("war3mapImported\\smokin.wav")
call InitSound("war3mapImported\\lightning.mp3")
call InitSound("war3mapImported\\hurray.mp3")
call InitSound("war3mapImported\\joffrey.mp3")
call InitSound("war3mapImported\\HeadBand.mp3")
call InitSound("war3mapImported\\bound 2.mp3")
call InitSound("war3mapImported\\coco.mp3")
call InitSound("war3mapImported\\down.mp3")
call InitSound("war3mapImported\\single ladies.mp3")
call InitSound("war3mapImported\\space jam.mp3")
call InitSound("war3mapImported\\yee.mp3")
call InitSound("war3mapImported\\bounty.mp3")
call InitSound("war3mapImported\\Dope Walk.mp3")
call InitSound("war3mapImported\\Microphone Fiend.mp3")
call InitSound("war3mapImported\\really.mp3")
call InitSound("war3mapImported\\AYO GG.mp3")
call InitSound("war3mapImported\\dawg.mp3")
call InitSound("war3mapImported\\cell.mp3")
call InitSound("war3mapImported\\snappy.mp3")
call InitSound("war3mapImported\\PIMP.mp3")
call InitSound("war3mapImported\\stone cold.mp3")
call InitSound("war3mapImported\\ram ranch.mp3")
call InitSound("war3mapImported\\bump n grind.mp3")
call InitSound("war3mapImported\\dancedance.mp3")
call InitSound("war3mapImported\\flyers.mp3")
call InitSound("war3mapImported\\gee.mp3")
call InitSound("war3mapImported\\nyanko.mp3")
call InitSound("war3mapImported\\odd future.mp3")
call InitSound("war3mapImported\\shake it off.mp3")
call InitSound("war3mapImported\\sk8erboi.mp3")
call InitSound("war3mapImported\\tenkz.mp3")
call InitSound("war3mapImported\\triple.mp3")
call InitSound("war3mapImported\\wolfpls.mp3")
call InitSound("war3mapImported\\aussie0.mp3")
call InitSound("war3mapImported\\aussie1.mp3")
call InitSound("war3mapImported\\aussie2.mp3")
call InitSound("war3mapImported\\aussie3.mp3")
call InitSound("war3mapImported\\aussie4.mp3")
call InitSound("war3mapImported\\aussie5.mp3")
call InitSound("war3mapImported\\aussie6.mp3")
call InitSound("war3mapImported\\aussie7.mp3")
call InitSound("war3mapImported\\ptg2.mp3")
endfunction
endlibrary
scope MiscCommands initializer init
private function commands takes nothing returns boolean
local Ball ball = Ball.balls[0]
local string s = StringCase(GetEventPlayerChatString(), false)
local player p = GetTriggerPlayer()
local player target
local integer n
if s == "-clear" then
if GetLocalPlayer() == p then
call ClearTextMessages()
endif
elseif s == "-fake injury" then
if ( fakeInjuryEnabled[GetPlayerId(p)] ) then
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have disabled faking injuries.|r")
set fakeInjuryEnabled[GetPlayerId(p)] = false
else
call DisplayTextToPlayer(p, 0.00, 0.00, DEFAULT_COLOR_CODE+"You have enabled faking injuries.|r")
set fakeInjuryEnabled[GetPlayerId(p)] = true
endif
elseif SubString(s, 0, 5) == "-lock" then
if s == "-lock" then // Locks onto the ball
if p == GetLocalPlayer() then
call SetCameraTargetController(ball.ball, 0, 0, true)
endif
call SetCamLock(GetPlayerId(p), 13)
elseif s == "-lockme" and not IsPlayerObserving(p) then // Locks onto player
if p == GetLocalPlayer() then
call SetCameraTargetController(GetPlayerUnit(p), 0, 0, true)
endif
call SetCamLock(GetPlayerId(p), GetPlayerId(p) + 1)
elseif StringLength(s) > 6 then // Locks onto targetted player
set n = S2I(SubString(s, 6, StringLength(s)))
if n > 0 and n <= GetPlayerCount() and StringLength(s) <= 8 then
set target = GetPlayerByNumber(n - 1)
else
set target = GetPlayerNamed(SubString(s, 6, StringLength(s)))
endif
if target != null and not IsPlayerObserving(target) then
if p == GetLocalPlayer() then
call SetCameraTargetController(GetPlayerUnit(target), 0, 0, true)
endif
call SetCamLock(GetPlayerId(p), GetPlayerId(target) + 1)
endif
set target = null
else // Throw Error
call DisplayTextToPlayer(GetTriggerPlayer(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
endif
elseif s == "-unlock" then
if p == GetLocalPlayer() then
call SetCamLock(GetPlayerId(GetTriggerPlayer()), 0)
call ResetToGameCamera(0.00)
endif
endif
set p = null
return false
endfunction
private function init takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerChatEvent(t, Player(i), "", true)
endif
set playerSound[i] = ""
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function commands)
set t = null
endfunction
endscope
library Initialization initializer init requires Event, Utilities, Game, Draft, Fields, TimerUtils
globals
private trigger gameSetupTrigger = CreateTrigger()
private trigger optionalSetupTrigger = CreateTrigger()
private boolean wispEnabled = false
private boolean testHeroEnabled = false
private timer msgTimer = CreateTimer()
private timer startTimer = CreateTimer()
Event EVENT_GAME_START
boolean ModeChosen = false
boolean lm = false
endglobals
private function setCompetitionObserve takes integer p returns nothing
local integer i = 0
if GetPlayerSlotState(Player(p)) == PLAYER_SLOT_STATE_PLAYING then
if p >= 6 then // Team 2
set i = 6
endif
call SetPlayerObserve(Player(p), true)
loop
call SetPlayerAllianceStateBJ(Player(p), Player(i), bj_ALLIANCE_UNALLIED)
call SetPlayerAllianceStateBJ(Player(i), Player(p), bj_ALLIANCE_UNALLIED)
set i = i + 1
exitwhen (i == 5) or (i == 11)
endloop
call SetPlayerColor(Player(p), GetPlayerColor(Player(PLAYER_NEUTRAL_PASSIVE)))
endif
endfunction
private module initModule
private static method onInit takes nothing returns nothing
set EVENT_GAME_START = CreateEvent()
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
private function message takes nothing returns nothing
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"10 seconds left.|r")
call DestroyTimer(msgTimer)
set msgTimer = null
endfunction
private function timerStart takes nothing returns nothing
set gameTimer = NewTimer()
if isTournament then
call TimerStart(gameTimer, gameTimeTotal, false, function FirstHalfEnd)
else
call TimerStart(gameTimer, gameTimeTotal, false, function GameEnd)
endif
call PauseTimer(gameTimer)
set timerDisplay = CreateTimerDialog(gameTimer)
if isTournament then
call TimerDialogSetTitle(timerDisplay, "First half:")
else
call TimerDialogSetTitle(timerDisplay, "Time left:")
endif
call TimerDialogDisplay(timerDisplay, true)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function begin takes nothing returns nothing
call NewRound()
call ReleaseTimer(GetExpiredTimer())
endfunction
private function start takes nothing returns nothing
call DisableTrigger(gameSetupTrigger)
call DisableTrigger(optionalSetupTrigger)
call DestroyTimer(startTimer)
set startTimer = null
if isTournament then
call TimerStart(NewTimer(), 3.00, false, function timerStart)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Game mode: Tournament\nFirst half ends after: "+Seconds2Time(gameTimeTotal)+".|r")
elseif gameTimeTotal > 0.00 then
call TimerStart(NewTimer(), 3.00, false, function timerStart)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Game mode: Timed game\nGame ends after: "+Seconds2Time(gameTimeTotal)+".|r")
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Game mode: Win by score\nScore needed to win: "+I2S(gameVictoryScore)+".|r")
endif
call EVENT_GAME_START.fire()
set ModeChosen = true
call TimerStart(NewTimer(), 1.00, false, function begin)
endfunction
private function gameSetup takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local integer i
local real secs
if (isTournament) or (StringLength(s) > 14) or (GetTriggerPlayer() != GetHost()) then
return false
endif
if SubString(s, 0, 6) == "-time " then
set secs = Time2Seconds(SubString(s, 6, StringLength(s)))
if secs > 0 then
set gameTimeTotal = secs
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Game time set to "+Seconds2Time(secs)+".|r")
set gameVictoryScore = 0
set i = 0
loop
call SetPlayerStateBJ(Player(i), PLAYER_STATE_RESOURCE_FOOD_USED, 0)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
else
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
endif
elseif SubString(s, 0, 7) == "-score " then
set i = S2I(SubString(s, 7, StringLength(s)))
if i > 0 and i < 201 then
set gameVictoryScore = i
set i = 0
loop
call SetPlayerStateBJ(Player(i), PLAYER_STATE_RESOURCE_FOOD_USED, gameVictoryScore)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Score needed for victory set to "+I2S(gameVictoryScore)+" points.|r")
set gameTimeTotal = 0.00
else
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
endif
elseif s == "-tournament" then
call Play("Sound\\Interface\\QuestNew.wav")
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Tournament mode!")
set gameTimeTotal = TOURNAMENT_HALF_TIME
set gameVictoryScore = 0
call enableLolzMode.execute(false)
set isTournament = true
elseif s == "-lm" or s == "-league" then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"League mode!")
call lmModePickScreen(function start, startTimer, function message, msgTimer)
set lm = true
call setCompetitionObserve(5)
call setCompetitionObserve(11)
call SetPlayerObserve(Player(4), true)
call SetPlayerObserve(Player(10), true)
call SetPlayerAllianceStateBJ(Player(5), Player(11), bj_ALLIANCE_ALLIED)
call SetPlayerAllianceStateBJ(Player(11), Player(5), bj_ALLIANCE_ALLIED)
call PauseTimer(startTimer)
call StartFranchise(msgTimer, function message)
endif
return false
endfunction
private function optionalSetup takes nothing returns boolean
local string s = StringCase(GetEventPlayerChatString(), false)
local integer i
if GetTriggerPlayer() == GetHost() then
if SubString(s, 0, 6) == "-draft" then
if s == "-draft" or s == "-draft " then
call StartDraft(GetPlayerCount()/2, msgTimer, function message, startTimer, function start)
elseif StringLength(s) == 8 then
set i = S2I(SubString(s, 7, 8))
if (i == 0) or (i > MAX_PLAYERS/2) then
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
else
call StartDraft(i, msgTimer, function message, startTimer, function start)
endif
else
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid input.|r")
endif
elseif s == "-wisp" and not wispEnabled then
set wispEnabled = true
call AddUnitToStock(GetCharacterTavern2(), PARCH_NINE_TIE_RAWCODE, 100, 100)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Wisp enabled!|r")
elseif s == "-test" and not testHeroEnabled and true then
set testHeroEnabled = true
call AddUnitToStock(GetCharacterTavern2(), MR_DOLT_AMIGO_RAWCODE, 100, 100)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Test Hero enabled!|r")
endif
endif
return false
endfunction
private function checkHCL takes nothing returns nothing
local string s = StringCase(GetCommandString(), false)
local integer i
local boolean valid = false
if s == "-lm" or s == "-league" then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Valid HCL Input: " + s)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"League mode!")
call lmModePickScreen(function start, startTimer, function message, msgTimer)
set lm = true
call setCompetitionObserve(5)
call setCompetitionObserve(11)
call SetPlayerObserve(Player(4), true)
call SetPlayerObserve(Player(10), true)
call SetPlayerAllianceStateBJ(Player(5), Player(11), bj_ALLIANCE_ALLIED)
call SetPlayerAllianceStateBJ(Player(11), Player(5), bj_ALLIANCE_ALLIED)
call PauseTimer(startTimer)
call StartFranchise(msgTimer, function message)
elseif SubString(s, 0, 6) == "-draft" then
if s == "-draft" or s == "-draft " then
call StartDraft(GetPlayerCount()/2, msgTimer, function message, startTimer, function start)
set valid = true
elseif StringLength(s) == 8 then
set i = S2I(SubString(s, 7, 8))
if (i == 0) or (i > MAX_PLAYERS/2) then
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid HCL input.|r")
else
call StartDraft(i, msgTimer, function message, startTimer, function start)
set valid = true
endif
endif
if valid then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, DEFAULT_COLOR_CODE+"Valid HCL Input: " + s)
endif
elseif StringLength(s) > 0 then
call DisplayTextToPlayer(GetHost(), 0.00, 0.00, INVALID_COLOR_CODE+"Invalid HCL input.|r")
endif
endfunction
private function setup takes nothing returns nothing
local integer i = 0
local real r = (GetRectMaxY(gg_rct_Goal_1) - GetRectMinY(gg_rct_Goal_1))/12
loop
call CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMaxX(gg_rct_Goal_1) + 73.0, GetRectMaxY(gg_rct_Goal_1) - r*i, 0.00)
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMaxX(gg_rct_Goal_1) + 73.0, GetRectMaxY(gg_rct_Goal_1) - r*i, 0.00), GOAL_HEIGHT, 0.00)
call CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMinX(gg_rct_Goal_2) + 7.00, GetRectMaxY(gg_rct_Goal_2) - r*i, 0.00)
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMinX(gg_rct_Goal_2) + 7.00, GetRectMaxY(gg_rct_Goal_2) - r*i, 0.00), GOAL_HEIGHT, 0.00)
set i = i + 1
exitwhen i == 13
endloop
set i = 1
set r = GOAL_HEIGHT/5
loop
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMaxX(gg_rct_Goal_1) + 73.0, GetRectMaxY(gg_rct_Goal_1), 0.00), GOAL_HEIGHT - r*i, 0.00)
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMaxX(gg_rct_Goal_1) + 73.0, GetRectMinY(gg_rct_Goal_1), 0.00), GOAL_HEIGHT - r*i, 0.00)
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMinX(gg_rct_Goal_2) + 7.00, GetRectMaxY(gg_rct_Goal_2), 0.00), GOAL_HEIGHT - r*i, 0.00)
call SetUnitFlyHeight(CreateUnit(REFEREE_PLAYER, GOAL_LINE_RAWCODE, GetRectMinX(gg_rct_Goal_2) + 7.00, GetRectMinY(gg_rct_Goal_2), 0.00), GOAL_HEIGHT - r*i, 0.00)
set i = i + 1
exitwhen i == 5
endloop
set i = 0
loop
call SetPlayerStateBJ(Player(i), PLAYER_STATE_RESOURCE_FOOD_USED, gameVictoryScore)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call DisplayTimedTextToPlayer(GetHost(), 0.00, 0.00, 21.0, DEFAULT_COLOR_CODE+/*
*/"Game Setup Commands:\n"+/*
*/"-time (Followed by minutes:seconds format; team with more goals after the set time wins)\n"+/*
*/"-score (Followed by required score; whichever team reaches set score wins)\n"+/*
*/"-tournament (Two halves of 10 minutes, side switch inbetween)\n"+/*
*/"Optional:\n"+/*
*/"-draft x (Team captains pick players for their team, x is optional and represents team size)\n"+/*
*/"-wisp (Makes wisp available)|r")
call EnableTrigger(gameSetupTrigger)
call EnableTrigger(optionalSetupTrigger)
call TimerStart(msgTimer, 21.0, false, function message)
static if TEST then
call TimerStart(startTimer, 3.0, false, function start)
else
call TimerStart(startTimer, 31.0, false, function start)
endif
call checkHCL()
endfunction
private function registerChatCommand takes player p returns nothing
call TriggerRegisterPlayerChatEvent(gameSetupTrigger, p, "", false)
call TriggerRegisterPlayerChatEvent(optionalSetupTrigger, p, "", false)
endfunction
private function showUpkeep takes nothing returns nothing
local integer i = 0
loop
call SetPlayerStateBJ(Player(i), PLAYER_STATE_RESOURCE_FOOD_USED, 500)
call SetPlayerStateBJ(Player(i), PLAYER_STATE_RESOURCE_FOOD_USED, 0)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call ReleaseTimer(GetExpiredTimer())
endfunction
//===========================================================================
private function init takes nothing returns nothing
call RegisterEvent(function setup, EVENT_FIELD_CHOOSE)
//! runtextmacro protectionCheck2()
call IteratePlayersPlaying(registerChatCommand)
call TriggerAddCondition(gameSetupTrigger, function gameSetup)
call TriggerAddCondition(optionalSetupTrigger, function optionalSetup)
call DisableTrigger(gameSetupTrigger)
call DisableTrigger(optionalSetupTrigger)
call SetSkyModel("Environment\\Sky\\LordaeronWinterSky\\LordaeronWinterSky.mdl")
//! runtextmacro protectionCheck1()
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, 3.00)
call SetTimeOfDayScale(0.60)
call InitSound("Sound\\Interface\\QuestNew.wav")
call SetMapFlag(MAP_LOCK_RESOURCE_TRADING, true)
call TimerStart(NewTimer(), 0.00, false, function showUpkeep)
//call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SELL, function startLM)
endfunction
endlibrary
library Fields initializer init requires Event, TimerUtils, LinkedList, Host, Players, Pick, Repick
globals
Event EVENT_FIELD_CHOOSE
Field currentField = 0
region playable
region team1Goal
region team2Goal
Field selection = 1
private destructable array frozenWater
private destructable array waterfallWater
private trigger t1 = CreateTrigger()
private trigger t2 = CreateTrigger()
private trigger t3 = CreateTrigger()
private trigger t4 = CreateTrigger()
private constant real BLOCK_SIZE = 128.00
private Field standardField
private boolean fieldChosen = false
endglobals
private struct Camera extends array
static integer count = 0
camerasetup cam
real duration
static method create takes camerasetup c, real d returns thistype
set count = count + 1
set thistype[count].cam = c
set thistype[count].duration = d
return count
endmethod
endstruct
private module EventInit
private static method onInit takes nothing returns nothing
set EVENT_FIELD_CHOOSE = CreateEvent()
endmethod
endmodule
private struct Rectangle extends array
static integer count = 0
static real dWidth
static real dHeight
rect r
real offsetX
real offsetY
real incrementMinX
real incrementMinY
real incrementMaxX
real incrementMaxY
static method create takes rect r, integer offsetX, integer offsetY, integer incrementMinX, integer incrementMinY, integer incrementMaxX, integer incrementMaxY returns thistype
local thistype this
set count = count + 1
set this = thistype[count]
set .r = r
set .offsetX = offsetX*dWidth*BLOCK_SIZE
set .offsetY = offsetY*dHeight*BLOCK_SIZE
set .incrementMinX = incrementMinX*dWidth*BLOCK_SIZE
set .incrementMinY = incrementMinY*dHeight*BLOCK_SIZE
set .incrementMaxX = incrementMaxX*dWidth*BLOCK_SIZE
set .incrementMaxY = incrementMaxY*dHeight*BLOCK_SIZE
return this
endmethod
endstruct
struct Field extends array
static integer count = 0
static Node camCurrentNode = 0
static timer camTimer = CreateTimer()
string name
real centerX
real centerY
integer blockWidth
integer blockHeight
rect zone
List cameras
implement EventInit
static method create takes string n, real x, real y, integer width, integer height, rect zo, integer w returns thistype
local thistype this
set count = count + 1
set this = thistype[count]
set name = n
set centerX = x
set centerY = y
set blockWidth = width
set blockHeight = height
set zone = zo
set cameras = List.create()
if w != 0 then
call EnableWeatherEffect(AddWeatherEffect(zo, w), true)
endif
return count
endmethod
method addCamera takes camerasetup c, real d returns nothing
call cameras.addElement(Camera.create(c, d))
endmethod
endstruct
private function nextCam takes nothing returns nothing
local Camera camera
set Field.camCurrentNode = Field.camCurrentNode.next
if Field.camCurrentNode == selection.cameras.head then
set Field.camCurrentNode = Field.camCurrentNode.next
endif
set camera = Camera(Field.camCurrentNode.data)
call CameraSetupApplyForceDuration(camera.cam, true, camera.duration)
call TimerStart(Field.camTimer, camera.duration, false, function nextCam)
endfunction
private function left takes nothing returns boolean
if GetTriggerPlayer() == GetHost() then
set selection = selection - 1
if integer(selection) < 1 then
set selection = Field.count
endif
endif
return false
endfunction
private function right takes nothing returns boolean
if GetTriggerPlayer() == GetHost() then
set selection = selection + 1
if integer(selection) > Field.count then
set selection = 1
endif
endif
return false
endfunction
private function showSelectionText takes nothing returns nothing
local player host = GetHost()
call DisplayTimedTextToPlayer(host, 0.00, 0.00, 60.0, DEFAULT_COLOR_CODE+"Use "+EMPHASIZE_COLOR_CODE+"left|r"+DEFAULT_COLOR_CODE+" and "+EMPHASIZE_COLOR_CODE+"right arrow|r"+DEFAULT_COLOR_CODE+/*
*/" keys to select the field and "+EMPHASIZE_COLOR_CODE+"up|r"+DEFAULT_COLOR_CODE+" arrow to choose the selected.")
if GetLocalPlayer() != host then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 60.0, GetPlayerColorCode(host)+GetPlayerName(host)+DEFAULT_COLOR_CODE+" is selecting the field.|r")
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 60.0, DEFAULT_COLOR_CODE+"Current Field:|r "+selection.name)
set host = null
endfunction
private function select takes nothing returns boolean
if GetTriggerPlayer() == GetHost() then
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 1.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 90.0, 90.0, 90.0, 0)
set Field.camCurrentNode = selection.cameras.head.next
call CameraSetupApplyForceDuration(Camera(Field.camCurrentNode.data).cam, true, 0.00)
call PauseTimer(Field.camTimer)
call nextCam()
call ClearTextMessages()
call showSelectionText()
endif
return false
endfunction
private function setupRegions takes nothing returns nothing
local integer i
local Rectangle rectangle
if currentField != standardField then
set Rectangle.dWidth = (currentField.blockWidth - standardField.blockWidth)/2.00
set Rectangle.dHeight = (currentField.blockHeight - standardField.blockHeight)/2.00
call Rectangle.create(gg_rct_0_1, -1, 0, 0, 0, 0, 1)
call Rectangle.create(gg_rct_0_2, -1, 0, 0, -1, 0, 0)
call Rectangle.create(gg_rct_0_3, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_135, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_180_1, 1, 0, 0, 0, 0, 1)
call Rectangle.create(gg_rct_180_2, 1, 0, 0, -1, 0, 0)
call Rectangle.create(gg_rct_180_3, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_225, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_270_1, 0, 1, -1, 0, 1, 0)
call Rectangle.create(gg_rct_270_2, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_270_3, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_315, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_45, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_90_1, 0, -1, -1, 0, 1, 0)
call Rectangle.create(gg_rct_90_2, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_90_3, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Field, 0, 0, -1, -1, 1, 1)
call Rectangle.create(gg_rct_Goal_1, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Goal_1_Front, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Goal_2, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Goal_2_Front, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Goal_1_Area, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Goal_2_Area, 1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Start_1, -1, 0, 0, 0, 0, 0)
call Rectangle.create(gg_rct_Start_2, 1, 0, 0, 0, 0, 0)
set i = 1
loop
set rectangle = Rectangle[i]
exitwhen rectangle.r == null
call MoveRectTo(rectangle.r, currentField.centerX + (GetRectCenterX(rectangle.r) - standardField.centerX) + rectangle.offsetX, currentField.centerY + (GetRectCenterY(rectangle.r) - standardField.centerY) + rectangle.offsetY)
call SetRect(rectangle.r, /*
*/GetRectMinX(rectangle.r) + rectangle.incrementMinX, GetRectMinY(rectangle.r) + rectangle.incrementMinY, /*
*/GetRectMaxX(rectangle.r) + rectangle.incrementMaxX, GetRectMaxY(rectangle.r) + rectangle.incrementMaxY)
set i = i + 1
endloop
endif
set playable = CreateRegion()
call RegionAddRect(playable, gg_rct_Field)
call RegionAddRect(playable, gg_rct_Goal_1_Area)
call RegionAddRect(playable, gg_rct_Goal_2_Area)
set team1Goal = CreateRegion()
call RegionAddRect(team1Goal, gg_rct_Goal_1)
set team2Goal = CreateRegion()
call RegionAddRect(team2Goal, gg_rct_Goal_2)
endfunction
private function setCam takes nothing returns nothing
local integer i = 0
call FogEnable(true)
call FogMaskEnable(true)
loop
call FogModifierStart(CreateFogModifierRect(Player(i), FOG_OF_WAR_VISIBLE, Rect(GetRectMinX(currentField.zone) - 1600.0, GetRectMinY(currentField.zone) - 1600.0, GetRectMaxX(currentField.zone) + 1600.0, GetRectMaxY(currentField.zone) + 1600.0), true, false))
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call PauseTimer(Field.camTimer)
call DestroyTimer(Field.camTimer)
call IteratePlayersPlaying(SetPickReady)
call IteratePlayersPlaying(GiveRepick)
call setupRegions()
call ClearTextMessages()
call EVENT_FIELD_CHOOSE.fire()
call ReleaseTimer(GetExpiredTimer())
endfunction
private function fadeIn takes nothing returns nothing
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 1.50, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function choose takes nothing returns boolean
local integer i
if GetTriggerPlayer() == GetHost() then
set fieldChosen = true
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 1.50, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 0.00, 0.00, 0.00, 0)
call DisableTrigger(t1)
call DisableTrigger(t2)
call DisableTrigger(t3)
call DisableTrigger(t4)
set currentField = selection
if selection != 3 and selection != 4 then
set i = 0
loop
exitwhen frozenWater[i] == null
call RemoveDestructable(frozenWater[i])
set i = i + 1
endloop
else
set BALL_FRICTION_GROUND = BALL_FRICTION_ICE
set PLAYER_FRICTION_GROUND = PLAYER_FRICTION_ICE
set i = 0
loop
exitwhen waterfallWater[i] == null
call RemoveDestructable(waterfallWater[i])
set i = i + 1
endloop
endif
call TimerStart(NewTimer(), 1.50, false, function setCam)
call TimerStart(NewTimer(), 2.00, false, function fadeIn)
endif
return false
endfunction
private function startSelection takes nothing returns nothing
call CinematicFadeBJ(bj_CINEFADETYPE_FADEIN, 1.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 90.0, 90.0, 90.0, 0)
set Field.camCurrentNode = selection.cameras.head.next
call CameraSetupApplyForceDuration(Camera(Field.camCurrentNode.data).cam, true, 0.00)
call PauseTimer(Field.camTimer)
call nextCam()
call showSelectionText()
endfunction
private function hostRepick takes nothing returns nothing
if not fieldChosen then
call showSelectionText()
endif
endfunction
private function registerArrowKeys takes player p returns nothing
call TriggerRegisterPlayerEvent(t1, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
call TriggerRegisterPlayerEvent(t2, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
call TriggerRegisterPlayerEvent(t3, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
call TriggerRegisterPlayerEvent(t3, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
call TriggerRegisterPlayerEvent(t4, p, EVENT_PLAYER_ARROW_UP_DOWN)
endfunction
private function hideFranchiseLogos takes nothing returns nothing
local destructable dest = GetEnumDestructable()
local integer id = GetDestructableTypeId(dest)
if id == LOGO_PLACEHOLDER or id == BANNER_PLACEHOLDER_HOME or id == BANNER_PLACEHOLDER_AWAY then
call ShowDestructable(dest, false)
endif
endfunction
private function init takes nothing returns nothing
static if not TEST then
local integer i
local integer n
local integer h
local integer v
local real sx
local real sy
local Field field
local integer array weathers
call IteratePlayersPlaying(registerArrowKeys)
call TriggerAddCondition(t1, function left)
call TriggerAddCondition(t2, function right)
call TriggerAddCondition(t3, function select)
call TriggerAddCondition(t4, function choose)
// Franchise Logos
call EnumDestructablesInRectAll(GetPlayableMapRect(), function hideFranchiseLogos)
set weathers[0] = 'RLlr'
//32:21
set field = Field.create("|c0060FF00Sunny Hills|r"+DEFAULT_COLOR_CODE+" (Normal size, recommended for 4v4)|r", -2048.0, 11520.0, 32, 21, gg_rct_Sunny_Hills, weathers[GetRandomInt(0, 2)])
call field.addCamera(gg_cam_Hills_1, 7.50)
call field.addCamera(gg_cam_Hills_2, 7.50)
call field.addCamera(gg_cam_Hills_3, 7.50)
call field.addCamera(gg_cam_Hills_4, 7.50)
call field.addCamera(gg_cam_Hills_5, 7.50)
set standardField = field
set weathers[0] = 'RLlr'
//37:24
set field = Field.create("|c0060FF00Waterfall|r"+DEFAULT_COLOR_CODE+" (Large size, recommended for 5v5)|r", 10240.0, 11328.0, 37, 24, gg_rct_Waterfall, weathers[GetRandomInt(0, 2)])
call field.addCamera(gg_cam_Waterfall_1, 1.50)
call field.addCamera(gg_cam_Waterfall_2, 2.00)
call field.addCamera(gg_cam_Waterfall_3, 4.00)
call field.addCamera(gg_cam_Waterfall_4, 4.00)
call field.addCamera(gg_cam_Waterfall_5, 8.00)
call field.addCamera(gg_cam_Waterfall_6, 4.00)
call field.addCamera(gg_cam_Waterfall_7, 5.00)
set weathers[0] = 'SNls'
set weathers[1] = 'SNhs'
set weathers[2] = 'SNbs'
//32:21
set field = Field.create("|c0097DDFFFrozen|r"+DEFAULT_COLOR_CODE+" (Normal size, recommended for 4v4)|r", -1408.0, 22016.0, 32, 21, gg_rct_Frozen, weathers[GetRandomInt(0, 2)])
call field.addCamera(gg_cam_Frozen_1, 7.00)
call field.addCamera(gg_cam_Frozen_2, 7.00)
call field.addCamera(gg_cam_Frozen_3, 7.00)
call field.addCamera(gg_cam_Frozen_4, 7.00)
call field.addCamera(gg_cam_Frozen_5, 7.00)
set weathers[0] = 'SNls'
set weathers[1] = 'SNhs'
set weathers[2] = 'SNbs'
//37:24
set field = Field.create("|c0097DDFFFrozen Coast|r"+DEFAULT_COLOR_CODE+" (Large size, recommended for 5v5)|r", 9536.0, 22272.0, 37, 24, gg_rct_Frozen_Coast, weathers[GetRandomInt(0, 2)])
call field.addCamera(gg_cam_Frozen_Coast_1, 8.00)
call field.addCamera(gg_cam_Frozen_Coast_2, 8.00)
call field.addCamera(gg_cam_Frozen_Coast_3, 8.00)
call field.addCamera(gg_cam_Frozen_Coast_4, 12.00)
call field.addCamera(gg_cam_Frozen_Coast_5, 12.00)
set sx = GetRectMinX(gg_rct_Frozen) - 1024.0
set sy = GetRectMinY(gg_rct_Frozen)
set h = R2I((GetRectMaxX(gg_rct_Frozen) - sx)/512.0 + 0.600) + 11
set v = R2I((GetRectMaxY(gg_rct_Frozen) - sy)/512.0 + 0.600) + 2
set i = 0
loop
set n = 0
loop
set frozenWater[i*v + n] = CreateDestructableZ(WATER_RAWCODE, sx + i*512.0, sy + n*512.0, 900.0, 90.0, 1.00, 0)
set n = n + 1
exitwhen n == v
endloop
set i = i + 1
exitwhen i == h
endloop
set frozenWater[i*v ] = CreateDestructableZ('B001' + GetRandomInt(0, 4), 5500. + GetRandomReal(-400., 400.), 22460. + GetRandomReal(-400., 400.), 900., GetRandomReal(0.00, 360.), GetRandomReal(0.90, 1.20), 0)
set frozenWater[i*v + 1] = CreateDestructableZ('B001' + GetRandomInt(0, 4), 2150. + GetRandomReal(-400., 400.), 19050. + GetRandomReal(-400., 400.), 900., GetRandomReal(0.00, 360.), GetRandomReal(0.90, 1.20), 0)
set frozenWater[i*v + 2] = CreateDestructableZ('B001' + GetRandomInt(0, 4), -430. + GetRandomReal(-400., 400.), 25300. + GetRandomReal(-400., 400.), 900., GetRandomReal(0.00, 360.), GetRandomReal(0.90, 1.20), 0)
set frozenWater[i*v + 3] = CreateDestructableZ('B001' + GetRandomInt(0, 4), 4500. + GetRandomReal(-400., 400.), 23500. + GetRandomReal(-400., 400.), 900., GetRandomReal(0.00, 360.), GetRandomReal(0.90, 1.20), 0)
set frozenWater[i*v + 4] = CreateDestructableZ('B001' + GetRandomInt(0, 4), 5100. + GetRandomReal(-400., 400.), 18600. + GetRandomReal(-400., 400.), 900., GetRandomReal(0.00, 360.), GetRandomReal(0.90, 1.20), 0)
set sx = GetRectMinX(gg_rct_Waterfall) - 768.0
set sy = GetRectMinY(gg_rct_Waterfall)
set h = R2I((GetRectMaxX(gg_rct_Waterfall) - sx)/512.0 + 0.600) + 3
set v = R2I((GetRectMaxY(gg_rct_Waterfall) - sy)/512.0 + 0.600) - 1
set i = 0
loop
set n = 0
loop
set waterfallWater[i*v + n] = CreateDestructableZ(WATER_RAWCODE, sx + i*512.0, sy + n*512.0, 1016.0, 90.0, 1.00, 0)
set n = n + 1
exitwhen n == v
endloop
set i = i + 1
exitwhen i == h
endloop
call FogEnable(false)
call FogMaskEnable(false)
call CinematicFadeBJ(bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\White_mask.blp", 90.0, 90.0, 90.0, 0)
call TimerStart(NewTimer(), 0.00, false, function startSelection)
call RegisterEvent(function hostRepick, EVENT_HOST_REPICK)
endif
endfunction
endlibrary
library Pick initializer init requires Taverns, Players, Observe, AutoIndex, Camera, Utilities
/*
*
* function SetPickReady takes player p returns nothing
* function HasPlayerPicked takes player p returns boolean
*
*/
globals
private integer array picks
private string array hats
private timer startTimer
private code startFunction
private timer msgTimer
private code msgFunction
endglobals
function lmModePickScreen takes code start, timer sTimer, code msg, timer mTimer returns nothing
set startTimer = sTimer
set startFunction = start
set msgTimer = mTimer
set msgFunction = msg
call PauseTimer(startTimer)
if msgTimer != null then
call PauseTimer(msgTimer)
endif
endfunction
private function removePickers takes nothing returns boolean
if GetUnitTypeId(GetFilterUnit()) == PICKER_RAWCODE then
call RemoveUnit(GetFilterUnit())
endif
return false
endfunction
function SetPickReady takes player p returns nothing
local real minX
local real minY
local real maxX
local real maxY
set picks[GetPlayerId(p)] = 0
if GetLocalPlayer() == p then
set camAdjustment = false
set minX = GetRectMinX(gg_rct_Taverns)
set minY = GetRectMinY(gg_rct_Taverns)
set maxX = GetRectMaxX(gg_rct_Taverns)
set maxY = GetRectMaxY(gg_rct_Taverns)
call SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY)
call ResetToGameCamera(0.00)
call PanCameraToTimed(GetStartLocationX(GetPlayerStartLocation(Player(0))), GetStartLocationY(GetPlayerStartLocation(Player(0))) + 64.0, 0.00)
endif
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function removePickers))
call CreateUnit(p, PICKER_RAWCODE, GetUnitX(GetCharacterTavern1()) + 150.0, GetStartLocationY(0), 0.00)
call CreateUnit(p, PICKER_RAWCODE, GetUnitX(GetHatTavern1()) - 150.0, GetStartLocationY(0), 0.00)
endfunction
function HasPlayerPicked takes player p returns boolean
return (picks[GetPlayerId(p)] == 2)
endfunction
function HaveAllPicked takes nothing returns boolean
return ( (picks[0] + picks[1] + picks[2] + picks[3]) + (picks[6] + picks[7] + picks[8] + picks[9]) == 16 )
endfunction
public function EveryonePickedLM takes nothing returns nothing
call TimerStart(startTimer, TimerGetRemaining(startTimer), false, startFunction)
if msgTimer != null then
call TimerStart(msgTimer, TimerGetRemaining(msgTimer), false, msgFunction)
endif
endfunction
private function acquireLolz takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call TextTag(EMOTE_COLOR_CODE+"Lolz acquired", 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 2.00)
call UnitAddAbility(u, SHOUT_RAWCODE)
call UnitAddAbility(u, TAUNT_RAWCODE)
call UnitAddAbility(u, SADFACE_RAWCODE)
set u = null
call ReleaseTimer(GetExpiredTimer())
endfunction
function SetFilter takes integer red, integer green, integer blue, real trans returns nothing
call SetCineFilterTexture("ReplaceableTextures\\CameraMasks\\White_mask.blp")
call SetCineFilterStartColor(red, green, blue, PercentTo255(100-trans))
call SetCineFilterEndColor(red, green, blue, PercentTo255(100-trans))
call SetCineFilterDuration(0.00)
call DisplayCineFilter(true)
endfunction
private function pick takes nothing returns nothing
local real minX
local real minY
local real maxX
local real maxY
local player p = GetOwningPlayer(GetBuyingUnit())
local unit u = GetSoldUnit()
local location loc
set picks[GetPlayerId(p)] = picks[GetPlayerId(p)] + 1
if GetSellingUnit() == GetCharacterTavern1() or GetSellingUnit() == GetCharacterTavern2() then
call SetPlayerUnit(p, GetSoldUnit())
call SetUnitX(u, GetPlayerStartX(p))
call SetUnitY(u, GetPlayerStartY(p))
call ShowUnit(u, false)
call SetUnitFacing(u, GetPlayerFacing(p))
elseif GetSellingUnit() == GetHatTavern1() or GetSellingUnit() == GetHatTavern2() or GetSellingUnit() == GetHatTavern3() then
call SetPlayerHatPath(p, hats[GetUnitPointValue(u)])
call RemoveUnit(u)
endif
if picks[GetPlayerId(p)] == 2 then
set u = GetPlayerUnit(p)
call SetPlayerHat(p, AddSpecialEffectTarget(GetPlayerHatPath(p), u, "head"))
call SetUnitColor(u, GetPlayerColor(p))
if GetLocalPlayer() == p then
set minX = GetRectMinX(currentField.zone) + 1000.0
set minY = GetRectMinY(currentField.zone) + 1000.0
set maxX = GetRectMaxX(currentField.zone) - 1000.0
set maxY = GetRectMaxY(currentField.zone) - 1000.0
call SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, CAMERA_DEFAULT_DISTANCE, 0.00)
call PanCameraToTimed(GetPlayerStartX(p), GetPlayerStartY(p), 0.00)
if (selection == 3 or selection == 4) then
call SetFilter(0, 0, 0, 70.00)
endif
set camAdjustment = true
call camAdjust()
endif
call TimerStart(NewTimerEx(GetUnitId(u)), 40.0, false, function acquireLolz)
if IsPlayerObserving(p) then
call SetUnitObserve(u, true)
call SetPlayerObservePoint(p, GetPlayerStartX(p), GetPlayerStartY(p))
else
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.00, GetPlayerColorCode(p)+GetPlayerName(p)+/*
*/"|r"+DEFAULT_COLOR_CODE+" has picked|r "+GetUnitName(u)+DEFAULT_COLOR_CODE+".|r")
call ShowUnit(u, true)
if not playing then
call DisableUnit(u, true)
endif
if GetLocalPlayer() == p then
call ClearSelection()
call SelectUnit(u, true)
endif
endif
if lm then
if HaveAllPicked() then
call EveryonePickedLM()
endif
endif
endif
set unitActive[GetPlayerId(p)] = true
set p = null
set u = null
call RemoveUnit(GetBuyingUnit())
endfunction
private function addAbilities takes unit u returns nothing
if IsUnitType(u, UNIT_TYPE_PLAYER) then
call UnitAddAbility(u, KICK_RAWCODE)
call UnitAddAbility(u, PASS_ME_RAWCODE)
endif
endfunction
private function init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SELL, function pick)
call OnUnitIndexed(addAbilities)
set hats[0] = "war3mapImported\\ChefsHat.mdx"
set hats[1] = "war3mapImported\\Mage Hat.mdx"
set hats[2] = "war3mapImported\\Hat_Military.mdx"
set hats[3] = "war3mapImported\\PirateHat.MDX"
set hats[4] = "war3mapImported\\SantaHat.mdx"
set hats[5] = "war3mapImported\\WitchHunterHat.MDX"
set hats[6] = "war3mapImported\\CrusaderHelm.mdx"
set hats[7] = "war3mapImported\\PumpkinHeadFinish.mdx"
set hats[8] = "war3mapImported\\SamuraiHelmet.mdx"
set hats[9] = "war3mapImported\\Spartan Helmet.mdx"
set hats[10] = "war3mapImported\\VoodooMask.mdx"
set hats[11] = "war3mapImported\\Wolf Cap by Sunchips.mdx"
set hats[12] = ""
set hats[13] = "units\\critters\\Penguin\\Penguin.mdl"
set hats[14] = "units\\critters\\EasterChicken\\EasterChicken.mdl"
set hats[15] = "units\\critters\\Sheep\\Sheep.mdl"
set hats[16] = "units\\critters\\Frog\\Frog.mdl"
set hats[17] = "units\\critters\\EasterRabbit\\EasterRabbit.mdl"
set hats[18] = "units\\critters\\Pig\\Pig.mdl"
set hats[19] = "units\\critters\\Raccoon\\Raccoon.mdl"
set hats[20] = "units\\critters\\BlackStagMale\\BlackStagMale.mdl"
set hats[21] = "units\\critters\\SnowOwl\\SnowOwl.mdl"
set hats[22] = "units\\critters\\BrownWolf\\BrownWolf.mdl"
set hats[23] = "units\\critters\\SpiderCrab\\SpiderCrab.mdl"
set hats[24] = "units\\critters\\Seal\\Seal.mdl"
set hats[25] = ""
set hats[26] = "war3mapImported\\Cowboy Hat.mdx"
set hats[27] = "war3mapImported\\RoyalCrown.mdx"
set hats[28] = "war3mapImported\\Earthbender.mdx"
set hats[29] = "war3mapImported\\Traffic Cone.mdx"// "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl"
set hats[30] = "war3mapImported\\Hat.mdx"
set hats[31] = "war3mapImported\\halo.mdx"
set hats[32] = "war3mapImported\\MickeyMouseEars.mdx"
set hats[33] = "Objects\\RandomObject\\RandomObject.mdl"
set hats[34] = "war3mapImported\\Straw Hat.mdx"
set hats[35] = "war3mapImported\\Musketeer Hat.mdx"
set hats[36] = "war3mapImported\\Turban.mdx"
set hats[37] = "war3mapImported\\Team Colored Mage Hat.mdx"
endfunction
endlibrary
library Leaving initializer init requires TimerUtils, Event, Players, PlayerUtilities
/*
*
* function KickPlayer takes player p returns boolean
* function GetLeavingPlayer takes nothing returns player
*
*/
globals
Event EVENT_LEAVE
private player leaver = null
endglobals
private module initModule
private static method onInit takes nothing returns nothing
set EVENT_LEAVE = CreateEvent()
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
function GetLeavingPlayer takes nothing returns player
return leaver
endfunction
private function fireEvent takes nothing returns nothing
call ArrangePlayers()
call EVENT_LEAVE.fire()
call ReleaseTimer(GetExpiredTimer())
endfunction
private function quit takes nothing returns nothing
call EndGame(true)
endfunction
private function kickDialog takes player p returns nothing
local trigger t = CreateTrigger()
local dialog d = DialogCreate()
call DialogSetMessage(d, "You have been kicked :(")
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, "Quit", 0))
call TriggerAddAction(t, function quit)
if (GetLocalPlayer() == p) then
call EnableUserControl(true)
call EnableUserUI(false)
endif
call DialogDisplay(p, d, true)
set t = null
set d = null
endfunction
function KickPlayer takes player p returns boolean
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
set leaver = p
call RemovePlayer(p, PLAYER_GAME_RESULT_DEFEAT)
call kickDialog(p)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, GetPlayerColorCode(p)+GetPlayerName(p)+"|r"+DEFAULT_COLOR_CODE+" has been kicked.|r")
call RemovePlayerUnits(p, false)
call TimerStart(NewTimer(), 0.00, false, function fireEvent)
return true
endif
return false
endfunction
private function leave takes nothing returns boolean
set leaver = GetTriggerPlayer()
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, GetPlayerColorCode(leaver)+GetPlayerName(leaver)+"|r"+DEFAULT_COLOR_CODE+" has left the game.|r")
set unitActive[GetPlayerId(leaver)] = false
call RemovePlayerUnits(leaver, false)
call TimerStart(NewTimer(), 0.00, false, function fireEvent)
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_LEAVE)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function leave)
endfunction
endlibrary
library GoalBlock initializer init requires Table, Utilities, Event, Fields
globals
region array goalRegion
private trigger enterTrigger
private trigger leaveTrigger
private TableArray goalData
private real leftX
private real rightX
private real topY
private real botY
private Vector array V
endglobals
private function enter takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer h = GetHandleId(GetTriggeringRegion())
local real x
local real y
local real d
local real r
local Vector v
local location loc
local boolean swapBool = false
local Swap swap
if (GetUnitTypeId(u) == SWAP_PROJECTILE_RAWCODE) then
set swapBool = Swap.getSwapFrontGoal(u)
endif
if IsUnitType(u, UNIT_TYPE_PLAYER) or (GetUnitTypeId(u) == SWAP_PROJECTILE_RAWCODE and swapBool) or (GetUnitTypeId(u) == HOOK_PROJECTILE_RAWCODE) or (GetUnitTypeId(u) == RIFT_PROJECTILE_RAWCODE) then
if ((goalData[2][h] > 0 and IsUnitType(u, UNIT_TYPE_PLAYER)) or GetPlayerTeam(GetOwningPlayer(u)) != goalData[0][h]) then
set x = GetUnitX(u)
set y = GetUnitY(u)
if x < leftX or x > rightX then
set x = goalData[3].real[h]
call SetUnitX(u, x)
endif
set r = topY - y
set d = y - botY
if r < d then
set d = topY
set v = V[90]
else
set r = d
set d = botY
set v = V[270]
endif
if r < RAbsBJ(GetUnitX(u) - goalData[1].real[h]) then
call SetUnitY(u, d)
else
call SetUnitX(u, goalData[1].real[h])
if (x - leftX) < (rightX - x) then
set v = V[0]
else
set v = V[180]
endif
endif
set r = Atan2(GetUnitY(u) - y, GetUnitX(u) - x)*bj_RADTODEG
set x = GetUnitX(u) + sgn(x - GetUnitX(u))*50.0
set y = GetUnitY(u) + sgn(y - GetUnitY(u))*50.0
if GetUnitTypeId(u) != RIFT_PROJECTILE_RAWCODE then
call Sfx(GOAL_BLOCK_SFX_PATH, x, y, GetUnitZ(u) + 80.0, r, 0.00, 0.90)
endif
if Vector.dotProduct(Object[u].velocity, v) < 0.00 then
set v = Vector.projectionVector(Object[u].velocity, v)
call v.scale(-1.00)
call Object[u].applyVector(v)
if IsUnitType(u, UNIT_TYPE_PLAYER) then
call v.setLength(v.getLength()*GOAL_BLOCK_FACTOR)
endif
call Object[u].applyVector(v)
call v.destroy()
endif
if not IsUnitType(u, UNIT_TYPE_PLAYER) then
set loc = Location(GetUnitX(u) + Object[u].getVector().x, GetUnitY(u) + Object[u].getVector().y)
call SetUnitFacingToFaceLocTimed(u, loc, 0.00)
call RemoveLocation(loc)
endif
endif
if IsUnitType(u, UNIT_TYPE_PLAYER) then
set goalData[2][h] = goalData[2][h] + 1
endif
elseif (GetUnitTypeId(u) == SWAP_PROJECTILE_RAWCODE) then
set swap = Swap.getSwap(u)
set swap.inGoal = true
endif
if (GetUnitTypeId(u) == HOOK_PROJECTILE_RAWCODE) then
call Hook.staticDrop(u)
endif
//if
//endif
set u = null
return false
endfunction
private function leave takes nothing returns boolean
local integer h
local Swap swap
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_PLAYER) then
set h = GetHandleId(GetTriggeringRegion())
set goalData[2][h] = goalData[2][h] - 1
elseif GetUnitTypeId(GetTriggerUnit()) == SWAP_PROJECTILE_RAWCODE then
set swap = Swap.getSwap(GetTriggerUnit())
set swap.inGoal = false
endif
return false
endfunction
function InitGoalBlock takes nothing returns boolean
if goalRegion[0] != null then
call RemoveRegion(goalRegion[0])
endif
if goalRegion[1] != null then
call RemoveRegion(goalRegion[1])
endif
set goalRegion[0] = CreateRegion()
call RegionAddRect(goalRegion[0], gg_rct_Goal_1_Front)
call RegionAddRect(goalRegion[0], gg_rct_Goal_1_Area)
set goalRegion[1] = CreateRegion()
call RegionAddRect(goalRegion[1], gg_rct_Goal_2_Front)
call RegionAddRect(goalRegion[1], gg_rct_Goal_2_Area)
call TriggerRegisterEnterRegion(enterTrigger, goalRegion[0], null)
call TriggerRegisterEnterRegion(enterTrigger, goalRegion[1], null)
call TriggerRegisterLeaveRegion(leaveTrigger, goalRegion[0], null)
call TriggerRegisterLeaveRegion(leaveTrigger, goalRegion[1], null)
set goalData[0][GetHandleId(goalRegion[0])] = 0
set goalData[1].real[GetHandleId(goalRegion[0])] = GetRectMaxX(gg_rct_Goal_1_Front) + 40.0
set goalData[2][GetHandleId(goalRegion[0])] = 0
set goalData[3].real[GetHandleId(goalRegion[0])] = GetRectMaxX(gg_rct_Goal_1_Area)
set goalData[0][GetHandleId(goalRegion[1])] = 1
set goalData[1].real[GetHandleId(goalRegion[1])] = GetRectMinX(gg_rct_Goal_2_Front) - 10.0
set goalData[2][GetHandleId(goalRegion[1])] = 0
set goalData[3].real[GetHandleId(goalRegion[1])] = GetRectMinX(gg_rct_Goal_2_Area)
set leftX = GetRectMaxX(gg_rct_Goal_1_Area)
set rightX = GetRectMinX(gg_rct_Goal_2_Area)
set topY = GetRectMaxY(gg_rct_Goal_1_Front) + 40.0
set botY = GetRectMinY(gg_rct_Goal_1_Front) - 10.0
return false
endfunction
private function init takes nothing returns nothing
set goalData = TableArray[5]
set V[0] = Vector.create(1.00, 0.00, 0.00)
set V[90] = Vector.create(0.00, 1.00, 0.00)
set V[180] = Vector.create(-1.00, 0.00, 0.00)
set V[270] = Vector.create(0.00, -1.00, 0.00)
set enterTrigger = CreateTrigger()
call TriggerAddCondition(enterTrigger, function enter)
set leaveTrigger = CreateTrigger()
call TriggerAddCondition(leaveTrigger, function leave)
set goalRegion[0] = null
set goalRegion[1] = null
call EVENT_FIELD_CHOOSE.register(function InitGoalBlock)
endfunction
endlibrary
library Game initializer init requires TimerUtils, UnitStatus, Utilities, Event, GoalBlock, Teams, Fields, Players, PlayerUtilities, Pick, Repick, Cheer
globals
integer team1Points = 0
integer team2Points = 0
boolean playing = false
boolean gameEnded = false
timer gameTimer = null
real gameTimeTotal = 0.0
integer gameVictoryScore = 10
Event EVENT_GAME_SCORE
Event EVENT_FIELD_CLEARING
boolean goalEnabled = true
private integer count = 3
timerdialog timerDisplay
integer half = 1
boolean isTournament = false
code firstHalfFunction
trigger goalTrigger
Event EVENT_GAME_END
private boolean array win
endglobals
function IsPlayerVictor takes player p returns boolean
return win[GetPlayerId(p)]
endfunction
//! runtextmacro protectionFunction1()
private function victory takes nothing returns nothing
local integer i = 0
call ReleaseTimer(GetExpiredTimer())
loop
call RemovePlayer(Player(i), PLAYER_GAME_RESULT_VICTORY)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call EndGame(true)
endfunction
private function setVictorPlayer takes player p returns nothing
if GetPlayerTeam(p) == tempInteger then
set win[GetPlayerId(p)] = true
endif
endfunction
function GameEnd takes nothing returns nothing
if gameTimeTotal > 0.00 then
call TimerStart(gameTimer, 0.00, false, null)
call PauseTimer(gameTimer)
endif
if team1Points == team2Points then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 20.0, DEFAULT_COLOR_CODE+"Draw! Game extended by "+Seconds2Time(EXTENSION_TIME)+".|r")
call TimerStart(gameTimer, EXTENSION_TIME, false, function GameEnd)
else
call IteratePlayers(DisablePlayerUnit)
if team1Points > team2Points then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 20.0, GetTeamColorCode(0)+GetTeamName(0)+"|r "+DEFAULT_COLOR_CODE+"has won the game!|r")
set tempInteger = 0
else
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 20.0, GetTeamColorCode(1)+GetTeamName(1)+"|r "+DEFAULT_COLOR_CODE+"has won the game!|r")
set tempInteger = 1
endif
call IteratePlayers(setVictorPlayer)
set gameEnded = true
set playing = false
set goalEnabled = false
call EVENT_GAME_END.fire()
call TimerStart(NewTimer(), 20.0, false, function victory)
endif
endfunction
private function start takes nothing returns nothing
local Ball ball = Ball.balls[0]
local Vector v
local real a
local real m
if count > 0 then
if gameEnded then
call PauseTimer(GetExpiredTimer())
call ReleaseTimer(GetExpiredTimer())
else
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+I2S(count)+"|r")
set count = count - 1
endif
else
call PauseTimer(GetExpiredTimer())
call ReleaseTimer(GetExpiredTimer())
if not gameEnded then
set count = 3
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, DEFAULT_COLOR_CODE+"Play!|r")
set playing = true
call IteratePlayers(EnablePlayerUnit)
set ball.owner = null
set a = GetRandomReal(0.00, 2 * bj_PI)
set m = GetRandomReal(15.0, 20.0)
set v = Vector.create(m * Cos(a), m * Sin(a), 0.00)
call ball.applyVector(v)
call v.destroy()
if gameTimeTotal > 0.00 then
if isTournament and half == 1 then
call TimerStart(gameTimer, TimerGetRemaining(gameTimer), false, firstHalfFunction)
else
call TimerStart(gameTimer, TimerGetRemaining(gameTimer), false, function GameEnd)
endif
endif
endif
endif
endfunction
function NewRound takes nothing returns nothing
call start()
call TimerStart(NewTimer(), 1.00, true, function start)
endfunction
private function resetPlayerUnit takes player p returns nothing
local unit u = GetPlayerUnit(p)
if GetUnitTypeId(u) != 0 then
if IsPlayerObserving(p) then
if GetPlayerTeam(p) == 0 then
call SetPlayerObservePoint(p, GetRectCenterX(gg_rct_Start_1), GetRectCenterY(gg_rct_Start_1))
else
call SetPlayerObservePoint(p, GetRectCenterX(gg_rct_Start_2), GetRectCenterY(gg_rct_Start_2))
endif
else
call Object[u].velocity.setLength(0.00)
call SetUnitX(u, GetPlayerStartX(p))
call SetUnitY(u, GetPlayerStartY(p))
call SetUnitFlyHeight(u, 0.00, 0.00)
call SetUnitFacing(u, GetPlayerFacing(p))
call SetUnitState(u, UNIT_STATE_MANA, 100.0)
if GetLocalPlayer() == p then
call SelectUnit(u, true)
endif
endif
endif
set u = null
endfunction
private function delay takes nothing returns nothing
local Ball ball = Ball.balls[0]
local integer i = 0
if not gameEnded then
call EVENT_FIELD_CLEARING.fire()
call ClearSelection()
call IteratePlayersAll(resetPlayerUnit)
if ball.hold then
call ball.drop()
endif
loop
if GetLocalPlayer() == Player(i) and IsCamUnlocked(i) then
call PanCameraTo(currentField.centerX, currentField.centerY)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call SetUnitX(ball.ball, currentField.centerX)
call SetUnitY(ball.ball, currentField.centerY)
call ball.vel.setLength(0.00)
call SetUnitFlyHeight(ball.ball, 0.00, 0.00)
set ball.protectionCounter = 0
set goalEnabled = true
call NewRound()
endif
call ReleaseTimer(GetExpiredTimer())
endfunction
private function secondHalfTimer takes nothing returns nothing
call EVENT_GAME_START.fire()
call TimerStart(gameTimer, gameTimeTotal, false, function GameEnd)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function selectPlayerUnit takes player p returns nothing
if GetUnitTypeId(GetPlayerUnit(p)) != 0 and GetLocalPlayer() == p then
call SelectUnit(GetPlayerUnit(p), true)
call PanCameraToTimed(currentField.centerX, currentField.centerY, 0.00)
endif
endfunction
private function startSecondHalf takes nothing returns nothing
call ClearSelection()
call IteratePlayers(selectPlayerUnit)
set goalEnabled = true
call NewRound()
call TimerStart(GetExpiredTimer(), 3.00, false, function secondHalfTimer)
endfunction
private function secondHalf takes nothing returns nothing
local Ball ball = Ball.balls[0]
local real minX
call EVENT_FIELD_CLEARING.fire()
call IteratePlayersAll(RemovePlayerUnit)
call IteratePlayersPlaying(SetPickReady)
call IteratePlayersPlaying(GiveRepick)
set minX = GetRectCenterX(gg_rct_Goal_1)
call MoveRectTo(gg_rct_Goal_1, GetRectCenterX(gg_rct_Goal_2), GetRectCenterY(gg_rct_Goal_2))
call MoveRectTo(gg_rct_Goal_2, minX, GetRectCenterY(gg_rct_Goal_1))
set minX = GetRectCenterX(gg_rct_Goal_1_Front)
call MoveRectTo(gg_rct_Goal_1_Front, GetRectCenterX(gg_rct_Goal_2_Front), GetRectCenterY(gg_rct_Goal_2_Front))
call MoveRectTo(gg_rct_Goal_2_Front, minX, GetRectCenterY(gg_rct_Goal_1_Front))
set minX = GetRectCenterX(gg_rct_Start_1)
call MoveRectTo(gg_rct_Start_1, GetRectCenterX(gg_rct_Start_2), GetRectCenterY(gg_rct_Start_2))
call MoveRectTo(gg_rct_Start_2, minX, GetRectCenterY(gg_rct_Start_1))
call RemoveRegion(team1Goal)
set team1Goal = CreateRegion()
call RegionAddRect(team1Goal, gg_rct_Goal_1)
call RemoveRegion(team2Goal)
set team2Goal = CreateRegion()
call RegionAddRect(team2Goal, gg_rct_Goal_2)
call TriggerRegisterEnterRegion(goalTrigger, team1Goal, null)
call TriggerRegisterEnterRegion(goalTrigger, team2Goal, null)
call InitGoalBlock()
call ArrangeStartPositions()
if ball.hold then
call ball.drop()
endif
call SetUnitX(ball.ball, currentField.centerX)
call SetUnitY(ball.ball, currentField.centerY)
call ball.vel.setLength(0.00)
set ball.protectionCounter = 0
call TimerDialogSetTitle(timerDisplay, "Second half:")
call TimerStart(NewTimer(), HALF_DELAY - 3.00, false, function startSecondHalf)
endfunction
function FirstHalfEnd takes nothing returns nothing
call IteratePlayers(DisablePlayerUnit)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 20.0, DEFAULT_COLOR_CODE+"First half is over! The sides are switched and you have "+I2S(R2I(HALF_DELAY))+" seconds to pick new character.|r")
set playing = false
set goalEnabled = false
set half = 2
call TimerStart(gameTimer, 0.00, false, null)
call PauseTimer(gameTimer)
call TimerStart(GetExpiredTimer(), 3.00, false, function secondHalf)
endfunction
private function countAssistants takes nothing returns nothing
local Ball ball = Ball.balls[0]
if GetOwningPlayer(ball.owner) == GetOwningPlayer(GetEnumUnit()) or IsUnitEnemy(ball.owner, GetOwningPlayer(GetEnumUnit())) then
call GroupRemoveUnit(ball.assistants, GetEnumUnit())
else
set bj_groupCountUnits = bj_groupCountUnits + 1
endif
endfunction
function score takes region goal returns boolean
local Ball ball = Ball.balls[0]
local integer i
local string t
local string assists = ""
local boolean autogoal = false
local player p
local real pauseTime
if goalEnabled and not gameEnded and not noGoalMode then
set i = 0
if goal == team2Goal then
set team1Points = team1Points + 1
loop
call AdjustPlayerStateBJ(1, Player(i), PLAYER_STATE_RESOURCE_GOLD)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
set t = GetTeamColorCode(0)+GetTeamName(0)+"|r"
if GetPlayerTeam(GetOwningPlayer(ball.owner)) == 1 then
set autogoal = true
endif
elseif goal == team1Goal then
set team2Points = team2Points + 1
loop
call AdjustPlayerStateBJ(1, Player(i), PLAYER_STATE_RESOURCE_LUMBER)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
set t = GetTeamColorCode(1)+GetTeamName(1)+"|r"
if GetPlayerTeam(GetOwningPlayer(ball.owner)) == 0 then
set autogoal = true
endif
else
call BJDebugMsg("Scoring Error: Ball isn't in goal.")
return false
endif
set goalEnabled = false
if gameTimeTotal > 0.00 then
call PauseTimer(gameTimer)
endif
if not autogoal then
set p = GetOwningPlayer(ball.owner)
call SetPlayerScores(p, GetPlayerScores(p) + 1)
call UpdatePlayer(p)
set bj_groupCountUnits = 0
call ForGroup(ball.assistants, function countAssistants)
set i = bj_groupCountUnits
if i > 0 then
set assists = DEFAULT_COLOR_CODE+" Assists:|r "
loop
set p = GetOwningPlayer(FirstOfGroup(ball.assistants))
call SetPlayerAssists(p, GetPlayerAssists(p) + 1)
if p != REFEREE_PLAYER then
call UpdatePlayer(p)
endif
set assists = assists + GetPlayerColorCode(p)+GetPlayerName(p)
call GroupRemoveUnit(ball.assistants, FirstOfGroup(ball.assistants))
set i = i - 1
if i == 0 then
set assists = assists+DEFAULT_COLOR_CODE+".|r"
exitwhen true
else
set assists = assists+DEFAULT_COLOR_CODE+", |r"
endif
endloop
endif
endif
set p = GetOwningPlayer(ball.owner)
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r "+DEFAULT_COLOR_CODE+"has scored for|r "+t+DEFAULT_COLOR_CODE+"!|r"+assists)
set pauseTime = Cheer(p, autogoal)
set p = null
set playing = false
if gameVictoryScore > 0 and (team1Points == gameVictoryScore or team2Points == gameVictoryScore) then
call GameEnd()
else
call IteratePlayers(DisablePlayerUnit)
call TimerStart(NewTimer(), pauseTime, false, function delay)
endif
call EVENT_GAME_SCORE.fire()
return true
endif
return false
endfunction
private function goal takes nothing returns boolean
local Ball ball = Ball.balls[0]
if GetTriggerUnit() == ball.ball and not ball.hold and GetUnitFlyHeight(ball.ball) < GOAL_HEIGHT then
call score(GetTriggeringRegion())
endif
return false
endfunction
private function registerGoals takes nothing returns boolean
set goalTrigger = CreateTrigger()
call TriggerRegisterEnterRegion(goalTrigger, team1Goal, null)
call TriggerRegisterEnterRegion(goalTrigger, team2Goal, null)
call TriggerAddCondition(goalTrigger, function goal)
return false
endfunction
private module initModule
private static method onInit takes nothing returns nothing
set EVENT_GAME_SCORE = CreateEvent()
set EVENT_FIELD_CLEARING = CreateEvent()
set EVENT_GAME_END = CreateEvent()
endmethod
endmodule
private struct initStruct
implement initModule
endstruct
private function clearPlayers takes nothing returns nothing
call IteratePlayers(ClearPlayer)
endfunction
private function init takes nothing returns nothing
call RegisterEvent(function registerGoals, EVENT_FIELD_CHOOSE)
call RegisterEvent(function clearPlayers, EVENT_FIELD_CLEARING)
set firstHalfFunction = function FirstHalfEnd
endfunction
endlibrary
library Referee requires TimerUtils, Players
struct Referee
readonly static unit referee
readonly unit instance
readonly real x
readonly real y
private static method remove takes nothing returns nothing
local thistype this = thistype(GetTimerData(GetExpiredTimer()))
call RemoveUnit(instance)
call destroy()
call ReleaseTimer(GetExpiredTimer())
endmethod
private static method kick takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = thistype(GetTimerData(GetExpiredTimer()))
set ball.protectionCounter = 0
set ball.warned = false
call ball.kick(x, y, KICK_SPEED, KICK_Z)
set ball.intercept = 8
call ball.assist(referee)
call stop32()
call ReleaseTimer(GetExpiredTimer())
endmethod
private method iterate32 takes nothing returns nothing
local Ball mainBall = Ball.balls[0]
local unit ball = mainBall.ball
local real a = Atan2(GetUnitY(ball) - y, GetUnitX(ball) - x)
call SetUnitX(instance, GetUnitX(ball) + 110.0*Cos(a))
call SetUnitY(instance, GetUnitY(ball) + 110.0*Sin(a))
call SetUnitZ(instance, GetUnitZ(ball))
set ball = null
endmethod
implement II32
private static method animation takes nothing returns nothing
call SetUnitAnimation(thistype(GetTimerData(GetExpiredTimer())).instance, "attack")
call ReleaseTimer(GetExpiredTimer())
endmethod
static method kickBall takes real tx, real ty returns nothing
local Ball mainBall = Ball.balls[0]
local unit ball = mainBall.ball
local thistype this = thistype.create()
local real a = Atan2(GetUnitY(ball) - ty, GetUnitX(ball) - tx)
set x = tx
set y = ty
set instance = CreateUnit(REFEREE_PLAYER, REFEREE_RAWCODE, GetUnitX(ball) + 110.0*Cos(a), GetUnitY(ball) + 110.0*Sin(a), bj_RADTODEG*a + 180.0)
call SetUnitColor(instance, ConvertPlayerColor(9))
call Alpha.create(instance, 0, 14, true)
call TimerStart(NewTimerEx(this), 0.00, false, function thistype.animation)
call TimerStart(NewTimerEx(this), 0.57, false, function thistype.kick)
call TimerStart(NewTimerEx(this), 1.50, false, function thistype.remove)
call start32()
set ball = null
endmethod
static method allyReferee takes player p returns nothing
call SetPlayerAllianceStateBJ(p, REFEREE_PLAYER, bj_ALLIANCE_ALLIED_VISION)
endmethod
private static method onInit takes nothing returns nothing
set referee = CreateUnit(REFEREE_PLAYER, REFEREE_RAWCODE, GetStartLocationX(0), GetStartLocationY(0) + 340.0, 270.0)
call SetUnitColor(referee, ConvertPlayerColor(9))
call SetPlayerColorCode(REFEREE_PLAYER, REFEREE_COLOR_CODE)
call SetPlayerName(REFEREE_PLAYER, "Referee")
call IteratePlayersAll(allyReferee)
endmethod
endstruct
endlibrary
library Test initializer init requires Initialization, Fields, Observe, Players
static if TEST then
globals
private integer testInteger = 0
endglobals
private function cast takes nothing returns boolean
call UnitResetCooldown(GetTriggerUnit())
return false
endfunction
private function cond takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_PLAYER)
endfunction
private function lolz takes nothing returns boolean
local unit u = GetFilterUnit()
if IsUnitType(u, UNIT_TYPE_PLAYER) then
call TextTag(EMOTE_COLOR_CODE+"Lolz acquired", 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 2.00)
call UnitAddAbility(u, SHOUT_RAWCODE)
call UnitAddAbility(u, TAUNT_RAWCODE)
call UnitAddAbility(u, SADFACE_RAWCODE)
set u = null
endif
return false
endfunction
private function esc takes nothing returns boolean
local group g = CreateGroup()
local unit u
local Vector v
call GroupEnumUnitsSelected(g, Player(0), Condition(function cond))
set u = GroupPickRandomUnit(g)
if u == null then
//set v = Vector.create(GetRandomReal(0.00, 00.0), GetRandomReal(0.00, 00.0), GetRandomReal(30.0, 40.0))
//call Ball.applyVector(v)
//call v.destroy()
else
call SetUnitX(Ball.ball, GetUnitX(u))
call SetUnitY(Ball.ball, GetUnitY(u))
call SetUnitZ(Ball.ball, GetUnitZ(u))
call UnitResetCooldown(u)
call SetUnitState(u, UNIT_STATE_MANA, 100.00)
endif
call DestroyGroup(g)
set testInteger = testInteger + 1
set g = null
set u = null
return false
endfunction
private function chat takes nothing returns boolean
return false
endfunction
private function fieldChosen takes nothing returns nothing
call EVENT_FIELD_CHOOSE.fire()
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_FINISH)
call TriggerAddCondition(t, function cast)
set t = CreateTrigger()
call TriggerRegisterPlayerEvent(t, Player(0), EVENT_PLAYER_END_CINEMATIC)
call TriggerAddCondition(t, function esc)
set t = CreateTrigger()
call TriggerRegisterPlayerChatEvent(t, Player(0), "", false)
call TriggerAddCondition(t, function chat)
set t = null
call TimerStart(NewTimer(), 0.20, false, function fieldChosen)
//call SetCameraFieldForPlayer(Player(0), CAMERA_FIELD_TARGET_DISTANCE, 2500.0, 0.00)
call SetPlayerAllianceStateBJ(Player(1), Player(0), bj_ALLIANCE_ALLIED_ADVUNITS)
call SetPlayerAllianceStateBJ(Player(2), Player(0), bj_ALLIANCE_ALLIED_ADVUNITS)
set currentField = Field.create("|c0060FF00Sunny Hills|r"+DEFAULT_COLOR_CODE+" (Medium size, recommended for 4v4)", -2048.0, 11520.0, 30, 21, gg_rct_Sunny_Hills, 0)
set playable = CreateRegion()
call RegionAddRect(playable, gg_rct_Field)
call RegionAddRect(playable, gg_rct_Goal_1_Area)
call RegionAddRect(playable, gg_rct_Goal_2_Area)
set team1Goal = CreateRegion()
call RegionAddRect(team1Goal, gg_rct_Goal_1)
set team2Goal = CreateRegion()
call RegionAddRect(team2Goal, gg_rct_Goal_2)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, CAMERA_DEFAULT_DISTANCE, 0.00)
call PanCameraToTimed(currentField.centerX, currentField.centerY, 0.00)
call CreateFogModifierRectBJ(true, Player(0), FOG_OF_WAR_VISIBLE, GetPlayableMapRect())
call GroupEnumUnitsInRange(CreateGroup(), currentField.centerX, currentField.centerY, 6000.0, Filter(function lolz))
call BJDebugMsg("Test mode enabled.")
call CreateUnit(Player(0), PICKER_RAWCODE, GetUnitX(GetCharacterTavern()) + 150.0, GetUnitY(GetCharacterTavern()), 0.00)
call CreateUnit(Player(0), PICKER_RAWCODE, GetUnitX(GetHatTavern1()) - 150.0, GetUnitY(GetCharacterTavern()), 0.00)
//call BJDebugMsg(I2S(StringHash("|c00468BFFBanjoball v1.18|r")))
//call BJDebugMsg(I2S(StringHash("|c00468BFFBanjoball v1.18|r TEST")))
endfunction
endif
endlibrary
library ballEvent
globals
Event EVENT_BALL_TAKE
Event EVENT_BALL_ENCOUNTER
endglobals
module takeEvent
private static method onInit takes nothing returns nothing
set EVENT_BALL_TAKE = CreateEvent()
set EVENT_BALL_ENCOUNTER = CreateEvent()
endmethod
endmodule
function getBall takes unit u returns Ball
local integer i = 0
local Ball ball
if (u == null) then
return Ball.balls[0]
endif
loop
set ball = Ball.balls[i]
if ball != 0 then
if u == ball.ball or (u == ball.owner and ball.hold) then
return Ball.balls[i]
endif
endif
set i = i + 1
exitwhen i == MAX_BALLS
endloop
return Ball.balls[0]
endfunction
function getBallTime takes timer t returns Ball
local integer i = 0
local Ball ball
if (t == null) then
return Ball.balls[0]
endif
loop
set ball = Ball.balls[i]
if ball != 0 then
if t == ball.death then
return Ball.balls[i]
endif
endif
set i = i + 1
exitwhen i == MAX_BALLS
endloop
return Ball.balls[0]
endfunction
endlibrary
struct Ball
// Derpy static shit
static thistype array balls
// Main Ball
static group assistants = CreateGroup()
static integer protectionCounter = 0
static boolean warned = false
static Table tab
// Every Ball
private integer ballNumb
unit ball
timer t = CreateTimer()
Vector vel
unit owner = null
boolean hold = false
integer intercept = 3
boolean intercepted = false
boolean keep = true
unit encounterer
integer nosteal = 0
trigger trig = null
real lastX
real lastY
real lastZ
// Trickster Shit
boolean fake = false
timer death = CreateTimer()
unit trickster = null
static method explode takes nothing returns boolean
local timer time = GetExpiredTimer()
local Ball ball = getBallTime(time)
if ball != balls[0] then
call ball.destroy()
endif
return false
endmethod
method onDestroy takes nothing returns nothing
local integer i = .ballNumb
local thistype ball
set balls[.ballNumb] = 0
call KillUnit(CreateUnit(GetOwningPlayer(.owner), TRICKSTER_FAKE_BALL_SFX_RAWCODE, GetUnitX(.ball), GetUnitY(.ball), 0.00))
if .hold then
call .drop()
endif
call vel.destroy()
call RemoveUnit(.ball)
call PauseTimer(.t)
call PauseTimer(.death)
call DestroyTimer(.t)
call DestroyTimer(.death)
call DestroyTrigger(.trig)
set .encounterer = null
set .owner = null
set .trickster = null
set .ball = null
set .trig = null
endmethod
static method addBall takes nothing returns boolean
call create(null, false)
return false
endmethod
static method addFake takes unit owner returns thistype
return create(owner, true)
endmethod
static method create takes unit owner, boolean fake returns thistype
local thistype this
local integer i = 0
local player p
if owner == null then // Main Ball
set this = thistype.allocate()
set .owner = owner
set .fake = fake
set .ball = CreateUnit(Player(0), BALL_RAWCODE, currentField.centerX, currentField.centerY, 0.00)
call TimerStart(CreateTimer(), 0.05, true, function thistype.keepProtection)
set .ballNumb = 0
set balls[.ballNumb] = this
set trig = CreateTrigger()
call TriggerRegisterUnitInRange(trig, .ball, BALL_CATCH_RANGE, null)
call TriggerAddCondition(trig, function thistype.take0 )
set .vel = Vector.create(0.00, 0.00, 0.00)
else // All other Balls
set p = GetOwningPlayer(owner)
if balls[GetPlayerId(p)+1] == 0 then
set this = thistype.allocate()
set .owner = owner
set .fake = fake
set .ball = CreateUnit(Player(0), BALL_RAWCODE, GetUnitX(balls[0].ball), GetUnitY(balls[0].ball), 0.00)
call ShowUnit(.ball, false)
set .trickster = owner
if fake then
loop
if GetPlayerTeam(p) == GetPlayerTeam(Player(i)) then
if Player(i) == GetLocalPlayer() then
call SetUnitVertexColor(.ball, 100, 100, 255, 255)
endif
else
if Player(i) == GetLocalPlayer() then
call SetUnitVertexColor(.ball, 255, 255, 255, 255)
endif
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endif
call TimerStart(.death, TRICKSTER_FAKE_BALL_DEATH, true, function thistype.explode)
call ShowUnit(.ball, true)
set .ballNumb = GetPlayerId(p) + 1
set balls[.ballNumb] = this
set trig = CreateTrigger()
call TriggerRegisterUnitInRange(trig, .ball, BALL_CATCH_RANGE, null)
/*
FUCK YOUUUUUU JAAAAASSSSSSSSSSSSS
*/
if .ballNumb == 1 then
call TriggerAddCondition(trig, function thistype.take1 )
elseif .ballNumb == 2 then
call TriggerAddCondition(trig, function thistype.take2 )
elseif .ballNumb == 3 then
call TriggerAddCondition(trig, function thistype.take3 )
elseif .ballNumb == 4 then
call TriggerAddCondition(trig, function thistype.take4 )
elseif .ballNumb == 5 then
call TriggerAddCondition(trig, function thistype.take5 )
elseif .ballNumb == 6 then
call TriggerAddCondition(trig, function thistype.take6 )
elseif .ballNumb == 7 then
call TriggerAddCondition(trig, function thistype.take7 )
elseif .ballNumb == 8 then
call TriggerAddCondition(trig, function thistype.take8 )
elseif .ballNumb == 9 then
call TriggerAddCondition(trig, function thistype.take9 )
elseif .ballNumb == 10 then
call TriggerAddCondition(trig, function thistype.take10)
elseif .ballNumb == 11 then
call TriggerAddCondition(trig, function thistype.take11)
elseif .ballNumb == 12 then
call TriggerAddCondition(trig, function thistype.take12)
endif
/*
I hate everything I just wrote
*/
set .vel = Vector.create(0.00, 0.00, 0.00)
else
set this = balls[GetPlayerId(p)+1]
endif
endif
return this
endmethod
/*
JASS YOU'RE LITERALLY SATAN
*/
static method take0 takes nothing returns boolean
return take(.balls[0])
endmethod
static method take1 takes nothing returns boolean
return take(.balls[1])
endmethod
static method take2 takes nothing returns boolean
return take(.balls[2])
endmethod
static method take3 takes nothing returns boolean
return take(.balls[3])
endmethod
static method take4 takes nothing returns boolean
return take(.balls[4])
endmethod
static method take5 takes nothing returns boolean
return take(.balls[5])
endmethod
static method take6 takes nothing returns boolean
return take(.balls[6])
endmethod
static method take7 takes nothing returns boolean
return take(.balls[7])
endmethod
static method take8 takes nothing returns boolean
return take(.balls[8])
endmethod
static method take9 takes nothing returns boolean
return take(.balls[9])
endmethod
static method take10 takes nothing returns boolean
return take(.balls[10])
endmethod
static method take11 takes nothing returns boolean
return take(.balls[11])
endmethod
static method take12 takes nothing returns boolean
return take(.balls[12])
endmethod
/*
FOOOOOOK YOOOOOU JAAAAASSSSSSSSSS
*/
static method take takes thistype ball returns boolean
local unit u = GetTriggerUnit()
local real h
local Ball temp = getBall(u)
if ball.nosteal == 0 and IsUnitType(u, UNIT_TYPE_PLAYER) and not (ball.hold and ball.owner == u) then
if not (temp.hold and temp.owner == u) then
set h = GetUnitZ(ball.ball) - GetUnitZ(u)
if h >= -BALL_CATCH_RANGE and h <= GetUnitHeight(u) then
call ball.takeOwnership(u)
endif
endif
endif
set u = null
return false
endmethod
method drop takes nothing returns nothing
call UnitRemoveAbility(.owner, BALL_SLOW_BUFF_RAWCODE)
set .hold = false
set .nosteal = 0
endmethod
method takeOwnership takes unit u returns nothing
set .encounterer = u
call EVENT_BALL_ENCOUNTER.fire()
if .keep then
if .vel.getLength() == 0.00 and not .hold then
call TimerStart(.t, 0.03125, true, function thistype.movement)
elseif .hold then
call UnitRemoveAbility(.owner, BALL_SLOW_BUFF_RAWCODE)
endif
if IsUnitEnemy(.owner, GetOwningPlayer(u)) and this == balls[0] then
call ForGroup(.assistants, function thistype.removeAssistants)
endif
set .hold = true
set .owner = u
call dummyCast(u, BALL_SLOW_RAWCODE, "slow")
call EVENT_BALL_TAKE.fire()
call .vel.setLength(0.00)
call SetUnitX(.ball, GetUnitX(u) + 100.0 * Cos(GetUnitFacing(u) * bj_DEGTORAD))
call SetUnitY(.ball, GetUnitY(u) + 100.0 * Sin(GetUnitFacing(u) * bj_DEGTORAD))
call SetUnitZ(.ball, GetUnitZ(u))
else
set .keep = true
endif
endmethod
implement takeEvent
static method catch takes nothing returns boolean
local unit f = GetFilterUnit()
local thistype this = getBall(f)
local real h
if IsUnitType(f, UNIT_TYPE_PLAYER) then
set h = GetUnitZ(.ball) - GetUnitZ(f)
if h >= -BALL_CATCH_RANGE and h <= GetUnitHeight(f) then
if .intercept == 0 then
call takeOwnership(f)
set .intercepted = true
elseif GetFilterUnit() != .owner then
call takeOwnership(f)
set .intercepted = true
endif
endif
endif
set f = null
return false
endmethod
static method movement takes nothing returns nothing
local thistype this
local integer i = 0
local real z
loop
set this = balls[i]
if this != 0 then
if .hold then
if .nosteal > 0 then
set .nosteal = .nosteal - 1
if .nosteal == 0 then
call SetUnitX(.ball, DUMMY_X)
call SetUnitY(.ball, DUMMY_Y)
endif
endif
call SetUnitX(.ball, GetUnitX(.owner) + BALL_KEEP_RANGE*Cos(GetUnitFacing(.owner)*bj_DEGTORAD))
call SetUnitY(.ball, GetUnitY(.owner) + BALL_KEEP_RANGE*Sin(GetUnitFacing(.owner)*bj_DEGTORAD))
call SetUnitZ(.ball, GetUnitZ(.owner))
else
call GroupEnumUnitsInRange(enumGroup, GetUnitX(.ball) + .vel.x, GetUnitY(.ball) + .vel.y, BALL_CATCH_RANGE, Filter(function thistype.catch))
if not .intercepted then
if .intercept > 0 then
set .intercept = .intercept - 1
endif
if GetUnitFlyHeight(.ball) < 1.00 then
if .vel.getLength() > BALL_FRICTION_GROUND then
call .vel.setLength(.vel.getLength() - BALL_FRICTION_GROUND)
else
call SetUnitFlyHeight(.ball, 0.00, 0.00)
call .vel.setLength(0.00)
call PauseTimer(.t)
endif
else
set .vel.z = .vel.z - GRAVITY_ACCELERATION
if .vel.getLength() > BALL_FRICTION_AIR then
call .vel.setLength(.vel.getLength() - BALL_FRICTION_AIR)
else
call .vel.setLength(0.00)
endif
endif
call SetUnitX(.ball, GetUnitX(.ball) + .vel.x)
call SetUnitY(.ball, GetUnitY(.ball) + .vel.y)
set z = GetUnitZ(.ball) + .vel.z
if z < GetTerrainZ(GetUnitX(.ball), GetUnitY(.ball)) and .vel.z < 0.00 then
call SetUnitFlyHeight(.ball, 0.00, 0.00)
set .vel.z = -.vel.z
set .vel.z = .vel.z - BALL_BUMP_SPEED_LOSS - GRAVITY_ACCELERATION/2
if .vel.z < 0.00 then
set .vel.z = 0.00
endif
else
call SetUnitZ(.ball, GetUnitZ(.ball) + .vel.z)
endif
else
set .intercepted = false
set .intercept = 0
endif
endif
set .lastX = GetUnitX(.ball)
set .lastY = GetUnitY(.ball)
set .lastZ = GetUnitZ(.ball)
endif
set i = i + 1
exitwhen i == MAX_BALLS
endloop
endmethod
method applyVector takes Vector v returns nothing
if .vel.getLength() == 0.00 and not .hold then
call TimerStart(.t, 0.03125, true, function thistype.movement)
elseif .hold then
call .drop()
endif
call .vel.add(v)
set .nosteal = 0
call BoundaryCheck(.ball, .vel, BALL_BUMP_SPEED_LOSS)
endmethod
method zero takes nothing returns nothing
local Vector v = Vector.create(-vel.x, -vel.y, -vel.z)
call applyVector(v)
call v.destroy()
endmethod
method kick takes real x, real y, real f, real p returns nothing
local Vector v = Vector.create(x - GetUnitX(.ball), y - GetUnitY(.ball), 0.00)
call v.setLength(f)
set v.z = p
call applyVector(v)
call v.destroy()
set .hold = false
call UnitRemoveAbility(.owner, BALL_SLOW_BUFF_RAWCODE)
if this == balls[0] then
call assist(.owner)
endif
set .intercept = 5
endmethod
static method castUtil takes unit u, real x, real y returns nothing
local thistype this = getBall(u)
if u == this.owner and this.hold and not pShotCharging then
call this.kick(x, y, KICK_SPEED, KICK_Z)
endif
endmethod
static method quickcast takes nothing returns nothing
call castUtil(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY())
endmethod
static method cast takes nothing returns nothing
call castUtil(GetTriggerUnit(), GetSpellTargetX(), GetSpellTargetY())
endmethod
// Shit for the main ball
static method removeAssistants takes nothing returns nothing
local timer t = balls[0].tab.timer[GetHandleId(GetEnumUnit())]
call PauseTimer(t)
call ReleaseTimer(t)
call GroupRemoveUnit(balls[0].assistants, GetEnumUnit())
set t = null
endmethod
static method nullAssistant takes nothing returns nothing
call GroupRemoveUnit(balls[0].assistants, GetUnitById(GetTimerData(GetExpiredTimer())))
call ReleaseTimer(GetExpiredTimer())
endmethod
static method assist takes unit a returns nothing
local timer t
local thistype this = balls[0]
if not IsUnitEnemy(.owner, GetOwningPlayer(a)) then
if IsUnitInGroup(a, .assistants) then
set t = tab.timer[GetHandleId(a)]
call PauseTimer(t)
if .ballNumb == 0 then
call TimerStart(t, ASSIST_TIME, false, function thistype.nullAssistant)
endif
else
call GroupAddUnit(.assistants, a)
set t = NewTimerEx(GetUnitId(a))
set tab.timer[GetHandleId(a)] = t
if .ballNumb == 0 then
call TimerStart(t, ASSIST_TIME, false, function thistype.nullAssistant)
endif
endif
set t = null
endif
endmethod
static method keepProtection takes nothing returns nothing
local thistype this = balls[0]
if playing then
if GetBoundaryRegion(GetUnitX(.ball), GetUnitY(.ball)) != null and .hold then
if IsTerrainWalkable(GetUnitX(.ball), GetUnitY(.ball)) then
set .protectionCounter = .protectionCounter + 1
else
set .protectionCounter = .protectionCounter + 5
endif
elseif IsUnitInRegion(goalRegion[0], .ball) or IsUnitInRegion(goalRegion[1], .ball) then
if .hold then
set .protectionCounter = .protectionCounter + 2
else
set .protectionCounter = .protectionCounter + 1
endif
elseif .protectionCounter != 0 then
if .protectionCounter <= 4 then
set .protectionCounter = 0
set .warned = false
else
set .protectionCounter = .protectionCounter - 4
endif
endif
if .protectionCounter >= 210 and not .warned then
call TextTag("|cffffcc00!|r", 0.0235, GetUnitX(.ball) + 6.0, GetUnitY(.ball), GetUnitZ(.ball) + 100.0, 1.50)
set .warned = true
elseif .protectionCounter >= 300 and not noGoalMode then
if IsUnitInRegion(team1Goal, .ball) or IsUnitInRegion(team2Goal, .ball) then
call DisplayTextToPlayer(GetLocalPlayer(), 0.00, 0.00, GetPlayerColorCode(GetOwningPlayer(.owner)) + GetPlayerName(GetOwningPlayer(.owner)) + "|r " + DEFAULT_COLOR_CODE+"has held the ball in goal for too long!|r")
if IsUnitInRegion(team1Goal, .ball) then
call score(team1Goal)
else
call score(team2Goal)
endif
else
if (not .hold and .vel.getLength() > 3.00) or (GetUnitFlyHeight(.ball) > 60.0) then
set .protectionCounter = 290
else
call Referee.kickBall(currentField.centerX, currentField.centerY)
set .protectionCounter = -100
endif
endif
endif
endif
endmethod
static method onObserve takes nothing returns boolean
local unit u = GetPlayerUnit(GetObservingPlayer())
local thistype this = getBall(u)
if .hold and .owner == GetObservingPlayer() then
call drop()
endif
set u = null
return false
endmethod
static method onInit takes nothing returns nothing
set Ball.tab = Table.create()
call EVENT_FIELD_CHOOSE.register(function thistype.addBall)
call EVENT_OBSERVE.register(function thistype.onObserve)
call RegisterSpellEffectEvent(KICK_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(KICK_QC_RAWCODE, function thistype.quickcast)
endmethod
endstruct
library Silence initializer init
globals
private unit array silencedDummy
private integer array silencedCounter
endglobals
struct Silence
static method silencePlayer takes player p returns nothing
local integer i = GetPlayerId(p)
if silencedCounter[i] == 0 then
call RemoveUnit(silencedDummy[i])
set silencedDummy[i] = null
endif
set silencedCounter[i] = silencedCounter[i] + 1
endmethod
static method unsilencePlayer takes player p returns nothing
local integer i = GetPlayerId(p)
if silencedCounter[i] > 0 then
set silencedCounter[i] = silencedCounter[i] - 1
if silencedCounter[i] == 0 then
set silencedDummy[i] = CreateUnit(p, SILENCED_DUMMY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
endif
endmethod
endstruct
private function init takes nothing returns nothing
local integer i = 0
local player p
loop
set p = Player(i)
if GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
set silencedDummy[i] = CreateUnit(Player(i), SILENCED_DUMMY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set silencedCounter[i] = 0
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
set p = null
endfunction
endlibrary
scope OuterSpace initializer init
globals
private boolean array gone
endglobals
private function heightCheck takes player p returns nothing
local unit u = GetPlayerUnit(p)
if not gone[GetPlayerId(p)] and u != null and GetUnitFlyHeight(u) > ATMOSPHERE_HEIGHT then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.00, GetPlayerColorCode(p)+GetPlayerName(p)+"|r"+DEFAULT_COLOR_CODE+" has gone to outer space.|r")
set u = null
set gone[GetPlayerId(p)] = true
endif
endfunction
private function check takes nothing returns nothing
call IteratePlayers(heightCheck)
endfunction
private function init takes nothing returns nothing
call TimerStart(NewTimer(), 1.00, true, function check)
endfunction
endscope
scope AntiCell initializer init
globals
private dialog d = DialogCreate()
private boolean done = false
endglobals
private function back takes nothing returns nothing
call DialogDestroy(d)
endfunction
private function continue takes nothing returns nothing
local trigger t = CreateTrigger()
call DialogDestroy(d)
set d = DialogCreate()
call DialogSetMessage(d, "jk")
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, "back to gaem", GetLocalizedHotkey("GAMEOVER_RESTART")))
call TriggerAddAction(t, function back)
call DialogDisplay(GetTriggerPlayer(), d, true)
set t = null
endfunction
private function removeCell takes player p returns nothing
local trigger t = CreateTrigger()
set done = true
call DialogSetMessage(d, "Anti-cell trigger in action")
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_RESTART"), GetLocalizedHotkey("GAMEOVER_RESTART")))
call TriggerAddAction(t, function continue)
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_REDUCE_DIFFICULTY"), GetLocalizedHotkey("GAMEOVER_REDUCE_DIFFICULTY")))
call TriggerAddAction(t, function continue)
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_LOAD"), GetLocalizedHotkey("GAMEOVER_LOAD")))
call TriggerAddAction(t, function continue)
call TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_QUIT_MISSION"), GetLocalizedHotkey("GAMEOVER_QUIT_MISSION")))
call TriggerAddAction(t, function continue)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 10.0, GetPlayerColorCode(p)+GetPlayerName(p)+"|r"+DEFAULT_COLOR_CODE+" has left the game.|r")
call DialogDisplay(p, d, true)
call VolumeGroupSetVolumeForPlayerBJ(p, SOUND_VOLUMEGROUP_UI, 1.0)
call StartSoundForPlayerBJ(p, bj_defeatDialogSound)
set t = null
set d = null
endfunction
private function findCell takes nothing returns boolean
local integer i
if StringHash(GetEventPlayerChatString()) == -523113500 and IsPlayerCool(GetTriggerPlayer()) and not done then //-remove cell
set i = 0
loop
if StringHash(GetPlayerOriginalName(Player(i))) == -2118640893 then //cell_destroyer
call removeCell(Player(i))
exitwhen true
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endif
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "", false)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function findCell)
set t = null
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope BizTree initializer init
private function disappear takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real z = GetUnitZ(u)
local integer id
if GetUnitTypeId(u) == BIZ_TREE_SUMMER_RAWCODE then
set id = SUMMER_TREE_RAWCODE
else
set id = SNOWY_TREE_RAWCODE
endif
call RemoveUnit(u)
set u = null
call TextTag("Hue", 0.0220, x - 40.0, y, z + 200.0, 1.50)
call CreateDestructable(id, x, y, 270.0, 2.30, 6)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function select takes nothing returns boolean
call TimerStart(NewTimerEx(GetUnitId(GetTriggerUnit())), 0.50, false, function disappear)
return false
endfunction
private function init takes nothing returns nothing
local integer i = 0
local destructable d
local trigger t
local unit tree
loop
loop
set d = RandomDestructableInRectBJ(bj_mapInitialPlayableArea, null)
exitwhen (GetDestructableTypeId(d) != 0) and ((GetDestructableTypeId(d) == SUMMER_TREE_RAWCODE) or (GetDestructableTypeId(d) == SNOWY_TREE_RAWCODE))
endloop
set i = i + 1
exitwhen i == 3
endloop
if (GetDestructableTypeId(d) == SUMMER_TREE_RAWCODE) then
set tree = CreateUnit(REFEREE_PLAYER, BIZ_TREE_SUMMER_RAWCODE, GetDestructableX(d), GetDestructableY(d), 270.0)
else
set tree = CreateUnit(REFEREE_PLAYER, BIZ_TREE_SNOW_RAWCODE, GetDestructableX(d), GetDestructableY(d), 270.0)
endif
call RemoveDestructable(d)
set t = CreateTrigger()
call TriggerRegisterUnitEvent(t, tree, EVENT_UNIT_SELECTED)
call TriggerAddCondition(t, Condition(function select))
set t = null
set tree = null
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
library EpicChickens initializer init requires Fields
private function placeChickens takes nothing returns nothing
local integer i = 0
local integer j
loop
set j = 0
loop
call CreateUnit(REFEREE_PLAYER, EPIC_CHICKEN_RAWCODE, currentField.centerX - 1400.0 + j*400.0, currentField.centerY + 1000.0 - i*400.0,0.00)
set j = j + 1
exitwhen j == 8
endloop
set i = i + 1
exitwhen i == 6
endloop
endfunction
private function init takes nothing returns nothing
call RegisterEvent(function placeChickens, EVENT_FIELD_CHOOSE)
endfunction
endlibrary
scope Protection
//! textmacro protectionFunction1
//! endtextmacro
//! textmacro protectionCheck1
//! endtextmacro
//! textmacro protectionCheck2
//! endtextmacro
endscope
scope AngelicKick initializer init
globals
private integer angelicSFX
endglobals
private function cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
if GetTriggerUnit() == ball.owner and ball.hold then
call ball.kick(GetSpellTargetX(), GetSpellTargetY(), ANGELIC_KICK_SPEED, KICK_Z)
call Sfx(ANGELIC_KICK_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), 0.00, 0.50, 0.75)
set angelicSFX = 4
endif
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(ANGELIC_KICK_RAWCODE, function cast)
endfunction
endscope
scope Backflip
struct Backflip
static TableArray tab
timer flipTimer = null
unit b = null
implement ObjectList
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, BACKFLIP_RAWCODE) > 0 or GetUnitAbilityLevel(u, METAMORPH_RAWCODE) > 0
endmethod
method end takes nothing returns nothing
local Ball ball
call stop32()
call listRemove()
if (GetUnitTypeId(.me) == MANFUL_LOAF_RAWCODE) then // MANFUL LOAF SHIT
set Metamorph.Reptillians[GetUnitId(.me)].delay = Metamorph.Reptillians[GetUnitId(.me)].time
else
call DestroyEffect(tab[2].effect[GetHandleId(.b)])
if GetUnitAbilityLevel(.b, STEALTH_SPRINT_INVIS_RAWCODE) > 0 then
call DestroyEffect(tab[0].effect[GetHandleId(.b)])
call DestroyEffect(tab[1].effect[GetHandleId(.b)])
endif
call RemoveUnit(.b)
set .b = null
call SetUnitScale(.me, OAK_KING_ZIT_SCALE, OAK_KING_ZIT_SCALE, OAK_KING_ZIT_SCALE)
endif
call SetUnitPropWindow(.me, GetUnitDefaultPropWindow(.me))
call SetUnitPathing(.me, true)
if GetUnitFlyHeight(.me) < 20.00 then
if Object[.me].velocity.getLength() <= 14.00 then
call Object[.me].velocity.setLength(0.00)
else
call Object[.me].velocity.setLength(Object[.me].velocity.getLength() - 14.00)
endif
endif
set ball = getBall(.me)
if ball.hold and .me == ball.owner then
set ball.nosteal = 0
endif
if practiceMode then
call UnitRemoveAbility(.me, BACKFLIP_RAWCODE)
call UnitAddAbility(.me, BACKFLIP_RAWCODE)
endif
endmethod
static method expire takes nothing returns nothing
call thistype(GetTimerData(GetExpiredTimer())).end()
call ReleaseTimer(GetExpiredTimer())
endmethod
method iterate32 takes nothing returns nothing
if (GetUnitTypeId(.me) == OAK_KING_ZIT_RAWCODE) then
call SetUnitX(.b, GetUnitX(.me))
call SetUnitY(.b, GetUnitY(.me))
call SetUnitZ(.b, GetUnitZ(.me))
if GetUnitAbilityLevel(.b, STEALTH_SPRINT_INVIS_RAWCODE) > 0 and GetUnitAbilityLevel(.me, STEALTH_SPRINT_INVIS_RAWCODE) == 0 then
call DestroyEffect(tab[0].effect[GetHandleId(.b)])
call DestroyEffect(tab[1].effect[GetHandleId(.b)])
call UnitRemoveAbility(.b, STEALTH_SPRINT_INVIS_RAWCODE)
endif
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method animationSlow takes nothing returns nothing
call SetUnitTimeScale(GetUnitById(GetTimerData(GetExpiredTimer())), 0.41)
call ReleaseTimer(GetExpiredTimer())
endmethod
static method animationStart takes nothing returns nothing
call SetUnitAnimationByIndex(GetUnitById(GetTimerData(GetExpiredTimer())), 2)
call ReleaseTimer(GetExpiredTimer())
endmethod
static method cast takes nothing returns nothing
local Ball ball
local thistype this = thistype[GetTriggerUnit()]
local timer t
local Vector v
local real h
if GetUnitFlyHeight(.me) < 20.00 then
call SetUnitPathing(.me, false)
set flipTimer = NewTimer()
call SetTimerData(flipTimer, this)
call SetUnitPropWindow(.me, 0.00)
if (GetUnitTypeId(.me) == OAK_KING_ZIT_RAWCODE) then // NOT MANFUL LOAF SHIT
set .b = CreateUnit(GetOwningPlayer(.me), BACKFLIP_DUMMY_RAWCODE, GetUnitX(.me), GetUnitY(.me), GetUnitFacing(.me))
call SetUnitScale(.me, 0.1, 0.1, 0.1)
call SetUnitX(.b, GetUnitX(.me))
call SetUnitY(.b, GetUnitY(.me))
call SetUnitZ(.b, GetUnitZ(.me))
set tab[2].effect[GetHandleId(.b)] = AddSpecialEffectTarget(GetPlayerHatPath(GetOwningPlayer(.me)), .b,"head")
call SetUnitColor(.b, GetPlayerColor(GetOwningPlayer(.b)))
if GetUnitAbilityLevel(.me, STEALTH_SPRINT_INVIS_RAWCODE) > 0 then
set tab[0].effect[GetHandleId(.b)] = AddSpecialEffectTarget(STEALTH_SPRINT_SFX_PATH, .b, "foot, left")
set tab[1].effect[GetHandleId(.b)] = AddSpecialEffectTarget(STEALTH_SPRINT_SFX_PATH, .b, "foot, right")
call UnitAddAbility(.b, STEALTH_SPRINT_INVIS_RAWCODE)
endif
call SetUnitTimeScale(.b, 4.00)
set t = NewTimer()
call SetTimerData(t, GetUnitId(b))
call TimerStart(t, 0.00, false, function thistype.animationStart)
set t = NewTimer()
call SetTimerData(t, GetUnitId(b))
call TimerStart(t, 0.100000, false, function thistype.animationSlow)
set t = null
set tab[0].unit[GetHandleId(flipTimer)] = .me
set tab[1].unit[GetHandleId(flipTimer)] = .b
endif
call TimerStart(flipTimer, BACKFLIP_TIME, false, function thistype.expire)
set h = BACKFLIP_RANGE/BACKFLIP_TIME/32.0 + PLAYER_FRICTION_AIR*BACKFLIP_TIME*16.0
set v = Vector.create(h*Cos(GetUnitFacing(.me)*bj_DEGTORAD), h*Sin(GetUnitFacing(.me)*bj_DEGTORAD), BACKFLIP_TIME*GRAVITY_ACCELERATION*16.0)
call Object[.me].applyVector(v)
call v.destroy()
set ball = getBall(.me)
if ball.hold and .me == ball.owner then
set ball.nosteal = 10
endif
call listAdd()
call start32()
else
call UnitRemoveAbility(.me, BACKFLIP_RAWCODE)
call UnitAddAbility(.me, BACKFLIP_RAWCODE)
endif
endmethod
static method interrupt takes nothing returns nothing
local thistype this
local unit u = GetTriggerUnit()
if GetUnitAbilityLevel(u, BACKFLIP_RAWCODE) > 0 and GetUnitTypeId(u) == OAK_KING_ZIT_RAWCODE then
set this = thistype[GetTriggerUnit()]
if .b != null and GetUnitAbilityLevel(u, STEALTH_SPRINT_INVIS_RAWCODE) > 0 then
call UnitRemoveAbility(u, STEALTH_SPRINT_INVIS_RAWCODE)
call UnitAddAbility(u, STEALTH_SPRINT_INVIS_RAWCODE)
endif
endif
endmethod
static method stealthSprint takes unit u, boolean o returns nothing
local thistype this = thistype[u]
if .b != null then
if o then
set tab[0].effect[GetHandleId(.b)] = AddSpecialEffectTarget(STEALTH_SPRINT_SFX_PATH, .b, "foot, left")
set tab[1].effect[GetHandleId(.b)] = AddSpecialEffectTarget(STEALTH_SPRINT_SFX_PATH, .b, "foot, right")
call UnitAddAbility(.b, STEALTH_SPRINT_INVIS_RAWCODE)
else
call DestroyEffect(tab[0].effect[GetHandleId(.b)])
call DestroyEffect(tab[1].effect[GetHandleId(.b)])
call UnitRemoveAbility(.b, STEALTH_SPRINT_INVIS_RAWCODE)
endif
endif
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).me) == p then
call thistype(node.data).end()
call PauseTimer(thistype(node.data).flipTimer)
call ReleaseTimer(thistype(node.data).flipTimer)
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
set tab = TableArray[3]
call RegisterSpellEffectEvent(BACKFLIP_RAWCODE, function thistype.cast)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_EFFECT, function thistype.interrupt)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope BlackHole
globals
private real growSpeed = (BLACK_HOLE_SIZE - BLACK_HOLE_INITIAL_SIZE)/BLACK_HOLE_GROW_TIME/32.0
private real pullPowerIncrement = (BLACK_HOLE_FORCE - BLACK_HOLE_INITIAL_FORCE)/BLACK_HOLE_GROW_TIME/32.0
endglobals
private struct BlackHoleCast
lightning l
unit u1
unit u2
real t
method iterate32 takes nothing returns nothing
call MoveLightningEx(l, true, GetUnitX(u2), GetUnitY(u2), GetTerrainZ(GetUnitX(u2), GetUnitY(u2)) + BLACK_HOLE_HEIGHT, GetUnitX(u1), GetUnitY(u1), GetUnitZ(u1) + 60.0)
set t = t - II32period
if t <= 0.00 then
call DestroyLightning(l)
call stop32()
call destroy()
endif
endmethod
static method create takes unit t1, unit t2 returns thistype
local thistype this = thistype.allocate()
set l = AddLightningEx(BLACK_HOLE_LIGHTNING_CODE, true, GetUnitX(t2), GetUnitY(t2), GetTerrainZ(GetUnitX(t2), GetUnitY(t2)) + BLACK_HOLE_HEIGHT, GetUnitX(t1), GetUnitY(t1), GetUnitZ(t1) + 80.0)
set u1 = t1
set u2 = t2
set t = BLACK_HOLE_GROW_TIME
call start32()
return this
endmethod
implement II32
endstruct
struct BlackHole
static thistype dis
unit owner
unit bh
real size
real pullPower
real x
real y
real z
real count
boolean ballCaught = false
real ballAngle = 0.00
implement ObjectList
method destroy takes nothing returns nothing
call stop32()
call KillUnit(bh)
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.owner, BLACK_HOLE_RAWCODE)
call UnitAddAbility(.owner, BLACK_HOLE_RAWCODE)
endif
endmethod
static method pullObjects takes nothing returns boolean
local thistype this = .dis
local unit f = GetFilterUnit()
local real dx
local real dy
local real dz
local real d
local Vector v
if IsUnitInRangeXY(f, x, y, BLACK_HOLE_AOE) and IsUnitType(f, UNIT_TYPE_OBJECT) and f != .owner then
set dx = x - GetUnitX(f)
set dy = y - GetUnitY(f)
set dz = z - GetUnitZ(f)
set d = SquareRoot(dx*dx + dy*dy + dz*dz)
if d <= BLACK_HOLE_AOE then
set v = Vector.create(dx, dy, dz)
call v.setLength(pullPower/d/d)
call Object[f].applyVector(v)
if Object[f].velocity.getLength() > BLACK_HOLE_LIMIT then
call Object[f].velocity.setLength(BLACK_HOLE_LIMIT)
endif
call v.destroy()
endif
endif
set f = null
return false
endmethod
static method pullPlayerObjects takes player p returns nothing
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function thistype.pullObjects))
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
local Vector v
local real dx = x - GetUnitX(ball.ball)
local real dy = y - GetUnitY(ball.ball)
local real dz = z - GetUnitZ(ball.ball)
local real d = SquareRoot(dx*dx + dy*dy + dz*dz)
if d <= BLACK_HOLE_AOE then
if ball.hold then
if .ballCaught then
set .ballCaught = false
endif
else
if ball.vel.getLength() == 0.00 or ball.owner == null then
set ball.owner = owner
endif
call ball.assist(.owner)
if not ballCaught then
set ballCaught = true
set ballAngle = Atan2(ball.vel.y, ball.vel.x)
endif
if SquareRoot(d) != 0.00 then
set v = Vector.create(dx, dy, dz)
call v.setLength(pullPower/d/d)
call ball.applyVector(v)
if ball.vel.getLength() > BLACK_HOLE_LIMIT then
call ball.vel.setLength(BLACK_HOLE_LIMIT)
endif
call v.destroy()
endif
endif
elseif ballCaught then
set ballCaught = false
if not ball.hold and Acos(Cos(Atan2(ball.vel.y, ball.vel.x) - .ballAngle)) > 80.0*bj_DEGTORAD then
call ball.assist(ball.owner)
set ball.owner = owner
endif
endif
set dis = this
call IteratePlayersAll(pullPlayerObjects)
set count = count - II32period
if count > (BLACK_HOLE_DURATION - BLACK_HOLE_GROW_TIME) then
set size = size + growSpeed
call SetUnitScale(bh, size, size, size)
set pullPower = pullPower + pullPowerIncrement
endif
if count <= 0.00 then
call destroy()
endif
endmethod
implement II32
static method cast takes nothing returns nothing
local thistype this = thistype.create()
set owner = GetTriggerUnit()
set size = BLACK_HOLE_INITIAL_SIZE
set pullPower = BLACK_HOLE_INITIAL_FORCE
set x = GetSpellTargetX()
set y = GetSpellTargetY()
set z = GetTerrainZ(x, y) + BLACK_HOLE_HEIGHT
set bh = CreateUnit(GetOwningPlayer(owner), BLACK_HOLE_DUMMY_RAWCODE, x, y, GetRandomReal(0.00, 360.0))
call SetUnitScale(bh, size, size, size)
set count = BLACK_HOLE_DURATION
call listAdd()
call start32()
call BlackHoleCast.create(owner, bh)
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).bh) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(BLACK_HOLE_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
//! runtextmacro protectionCheck2()
endmethod
endstruct
endscope
scope Curveshot initializer init
globals
private Vector centripetal
private real INITIAL_SPEED
private real INITIAL_ANGLE
private real C_ANGLE
private real C_FORCE
private real C_ANGLE_DELTA
private real C_FORCE_DELTA
private real cForce
private real cAngle
private real cForceDelta
private real cAngleDelta
private effect sfx
private boolean activated = false
private timer forceTimer = CreateTimer()
private timer curveshotTimer = CreateTimer()
private unit lastcaster
private unit array leftCooldowns
private unit array rightCooldowns
endglobals
private function end takes nothing returns nothing
local Ball ball = Ball.balls[0]
if activated then
call PauseTimer(forceTimer)
call PauseTimer(curveshotTimer)
call DestroyEffect(sfx)
set activated = false
if (ball.hold and IsUnitAlly(lastcaster, GetOwningPlayer(ball.owner))) then
call SetUnitState(ball.owner, UNIT_STATE_MANA, GetUnitState(ball.owner, UNIT_STATE_MANA) + CURVESHOT_MANA_INCREASE)
endif
endif
if (GetUnitTypeId(lastcaster) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(lastcaster)].delay = Metamorph.Reptillians[GetUnitId(lastcaster)].time
endif
endfunction
private function castBegin takes nothing returns nothing
local Ball ball = Ball.balls[0]
if ((GetSpellAbilityId() == CURVESHOT_LEFT_RAWCODE) or (GetSpellAbilityId() == CURVESHOT_RIGHT_RAWCODE)) /*
*/and ((GetTriggerUnit() != ball.owner) or (not ball.hold)) then
call IssueImmediateOrder(GetTriggerUnit(), "stop")
endif
endfunction
private function overtimeForce takes nothing returns nothing
local Ball ball = Ball.balls[0]
local real a = Atan2(ball.vel.y, ball.vel.x) + cAngle
set centripetal.x = cForce*Cos(a)
set centripetal.y = cForce*Sin(a)
call ball.applyVector(centripetal)
set cForce = cForce + cForceDelta/2.
set cAngle = cAngle + cAngleDelta/2.
endfunction
private function refresh takes nothing returns nothing
local integer i = GetTimerData(GetExpiredTimer())
if leftCooldowns[i] == null then
set leftCooldowns[i] = CreateUnit(Player(i), CURVESHOT_COOLDOWN_LEFT_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
if rightCooldowns[i] == null then
set rightCooldowns[i] = CreateUnit(Player(i), CURVESHOT_COOLDOWN_RIGHT_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes unit u returns nothing
local Ball ball = Ball.balls[0]
set sfx = AddSpecialEffectTarget(CURVESHOT_SFX_PATH, ball.ball, "chest")
call ball.assist(ball.owner)
set ball.intercept = 5
set activated = true
call TimerStart(forceTimer, II32period, true, function overtimeForce)
call TimerStart(curveshotTimer, CURVESHOT_DURATION, false, function end)
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(u))), CURVESHOT_COOLDOWN, false, function refresh)
endfunction
private function castRight takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
local real a = Atan2(GetSpellTargetY() - GetUnitY(u), GetSpellTargetX() - GetUnitX(u)) + INITIAL_ANGLE
set centripetal.x = INITIAL_SPEED*Cos(a)
set centripetal.y = INITIAL_SPEED*Sin(a)
call ball.applyVector(centripetal)
set cForce = C_FORCE
set cAngle = C_ANGLE
set cForceDelta = C_FORCE_DELTA
set cAngleDelta = C_ANGLE_DELTA
call SetUnitAnimationByIndex(u, 4)
call RemoveUnit(leftCooldowns[GetPlayerId(GetOwningPlayer(u))])
set leftCooldowns[GetPlayerId(GetOwningPlayer(u))] = null
set lastcaster = u
call cast(u)
set u = null
endfunction
private function castLeft takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
local real a = Atan2(GetSpellTargetY() - GetUnitY(u), GetSpellTargetX() - GetUnitX(u)) - INITIAL_ANGLE
set centripetal.x = INITIAL_SPEED*Cos(a)
set centripetal.y = INITIAL_SPEED*Sin(a)
call ball.applyVector(centripetal)
set cForce = C_FORCE
set cAngle = -C_ANGLE
set cForceDelta = C_FORCE_DELTA
set cAngleDelta = -C_ANGLE_DELTA
call SetUnitAnimationByIndex(u, 5)
call RemoveUnit(rightCooldowns[GetPlayerId(GetOwningPlayer(u))])
set rightCooldowns[GetPlayerId(GetOwningPlayer(u))] = null
set lastcaster = u
call cast(u)
set u = null
endfunction
public function initValues takes nothing returns nothing
local real ox
local real oy
local real omega
local real fi
local real theta1
local real theta2
local real theta3
local Vector v
local Vector v1
local Vector v2
local Vector v3
set omega = Acos(CURVESHOT_RANGE/2.00/CURVESHOT_RADIUS)
set ox = CURVESHOT_RANGE/2.00
set oy = CURVESHOT_RADIUS*Sin(omega)
set omega = omega + bj_PI
set fi = 2.00*Asin(CURVESHOT_RANGE/2.00/CURVESHOT_RADIUS)
set INITIAL_SPEED = (CURVESHOT_RADIUS*fi/CURVESHOT_DURATION*CURVESHOT_SPEED_FACTOR + BALL_FRICTION_GROUND/II32period*CURVESHOT_DURATION/2.00)*II32period
set theta1 = INITIAL_SPEED/CURVESHOT_RADIUS
set theta2 = (INITIAL_SPEED - BALL_FRICTION_GROUND)/CURVESHOT_RADIUS
set theta3 = (INITIAL_SPEED - 2.00*BALL_FRICTION_GROUND)/CURVESHOT_RADIUS
set v1 = Vector.create(ox + CURVESHOT_RADIUS*Cos(omega + theta1), oy + CURVESHOT_RADIUS*Sin(omega + theta1), 0.00)
set v2 = Vector.create(ox + CURVESHOT_RADIUS*Cos(omega + theta1 + theta2) - v1.x, oy + CURVESHOT_RADIUS*Sin(omega + theta1 + theta2) - v1.y, 0.00)
set v3 = Vector.create(ox + CURVESHOT_RADIUS*Cos(omega + theta1 + theta2 + theta3) - (v1.x + v2.x), oy + CURVESHOT_RADIUS*Sin(omega + theta1 + theta2 + theta3) - (v1.y + v2.y), 0.00)
call v1.setLength(v1.getLength() + BALL_FRICTION_GROUND)
call v2.setLength(v2.getLength() + BALL_FRICTION_GROUND)
call v3.setLength(v3.getLength() + BALL_FRICTION_GROUND)
set INITIAL_SPEED = INITIAL_SPEED + BALL_FRICTION_GROUND
set INITIAL_ANGLE = Atan2(v1.y, v1.x)
call v1.setLength(v1.getLength() - BALL_FRICTION_GROUND)
set v = Vector.create(v2.x - v1.x, v2.y - v1.y, 0.00)
set C_FORCE = v.getLength()
set C_ANGLE = Acos((v1.x*v.x + v1.y*v.y)/(v1.getLength()*v.getLength()))
call v2.setLength(v2.getLength() - BALL_FRICTION_GROUND)
set v.x = v3.x - v2.x
set v.y = v3.y - v2.y
set C_FORCE_DELTA = v.getLength() - C_FORCE
set C_ANGLE_DELTA = Acos((v2.x*v.x + v2.y*v.y)/(v2.getLength()*v.getLength())) - C_ANGLE
call v.destroy()
call v1.destroy()
call v2.destroy()
call v3.destroy()
endfunction
private function init takes nothing returns nothing
local integer i = 0
loop
exitwhen i == MAX_PLAYERS
set leftCooldowns[i] = CreateUnit(Player(i), CURVESHOT_COOLDOWN_LEFT_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set rightCooldowns[i] = CreateUnit(Player(i), CURVESHOT_COOLDOWN_RIGHT_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set i = i + 1
endloop
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CHANNEL, function castBegin)
call RegisterSpellEffectEvent(CURVESHOT_LEFT_RAWCODE, function castLeft)
call RegisterSpellEffectEvent(CURVESHOT_RIGHT_RAWCODE, function castRight)
call RegisterEvent(function end, EVENT_BALL_TAKE)
call RegisterEvent(function end, EVENT_FIELD_CLEARING)
set centripetal = Vector.create(0.00, 0.00, 0.00)
call initValues.execute()
endfunction
endscope
scope EarthPillar
struct EarthPillar
static thistype array taurens
static boolean array knockedUp
static boolean array deflected
static thistype dis
boolean ballKnockedUp
unit owner
unit pillar
real count
effect hat
real x
real y
real z
implement ObjectList
method destroy takes nothing returns nothing
if pillar != null then
call stop32()
call KillUnit(pillar)
call DestroyEffect(hat)
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.owner, EARTH_PILLAR_RAWCODE)
call UnitAddAbility(.owner, EARTH_PILLAR_RAWCODE)
endif
endif
endmethod
private static method allowDeflect takes nothing returns nothing
set deflected[GetTimerData(GetExpiredTimer())] = false
endmethod
static method deflectObject takes nothing returns boolean
local Ball ball = Ball.balls[0]
local thistype this = dis
local unit f = GetFilterUnit()
local real dx
local real dy
local real dz
local real d
local real ux
local real uy
local real offx
local real offy
local real vel
local Vector n
local Vector v
local boolean ballCheck = f == ball.ball and not ball.hold
if not deflected[GetUnitId(f)] and (IsUnitType(f, UNIT_TYPE_OBJECT) or ballCheck) then
if IsUnitInRangeXY(f, x, y, EARTH_PILLAR_RADIUS + PLAYER_COLLISION_SIZE) then
if (not ballCheck and not knockedUp[GetUnitId(f)]) or /*
*/ (ballCheck and not ballKnockedUp) then
if (not ballCheck and Object[f].getVector().getLength() > 0.05) or /*
*/ (ballCheck and ball.vel.getLength() > 0.05) then
set dx = GetUnitX(f) - x
set dy = GetUnitY(f) - y
set dz = RAbsBJ(z - GetUnitZ(f))
set d = SquareRoot(dx*dx + dy*dy)
if dz < EARTH_PILLAR_HEIGHT then
set ux = dx / d
set uy = dy / d
set n = Vector.create(ux, uy, 0)
set offx = ux*(EARTH_PILLAR_RADIUS)
set offy = uy*(EARTH_PILLAR_RADIUS)
call SetUnitPosition(f, x+offx, y+offy)
if ballCheck then
set v = Vector.create(ball.vel.x, ball.vel.y, ball.vel.z)
else
set v = Object[f].getVector()
set v = Vector.create(v.x, v.y, v.z)
endif
set vel = v.getLength()
call n.scale(-2 * Vector.dotProduct(v, n))
call v.add(n)
call v.setLength(vel * EARTH_PILLAR_DEFLECT_DAMPEN)
if ballCheck then
call ball.zero()
call ball.applyVector(v)
else
call Object[f].setVector(v)
endif
set deflected[GetUnitId(f)] = true
call TimerStart(NewTimerEx(GetUnitId(f)), 0.10, false, function thistype.allowDeflect)
call v.destroy()
call n.destroy()
endif
endif
endif
else
if ballCheck then
set ballKnockedUp = false
else
set knockedUp[GetUnitId(f)] = false
endif
endif
endif
set f = null
return false
endmethod
static method deflectPlayerObjects takes player p returns nothing
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function thistype.deflectObject))
endmethod
// Cast knockup
private static method knockPlayerObjects takes player p returns nothing
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function thistype.knockbackFilter))
endmethod
private static method knockbackFilter takes nothing returns boolean
local thistype this = dis
local unit f = GetFilterUnit()
call knockback(f)
set f = null
return false
endmethod
private method knockback takes unit u returns nothing
local Ball ball = Ball.balls[0]
local Vector v
local real px = GetUnitX(pillar)
local real py = GetUnitY(pillar)
local real pz = GetUnitZ(pillar)
local real xy
local boolean ballCheck = u == ball.ball and not ball.hold
if IsUnitInRange(u, pillar, EARTH_PILLAR_RADIUS + 5) and (IsUnitType(u, UNIT_TYPE_OBJECT) or ballCheck) then
if ballCheck then
set ballKnockedUp = true
else
set knockedUp[GetUnitId(u)] = true
endif
set v = Vector.create(GetUnitX(u) - px, GetUnitY(u) - py, 0)
if v.getLength() <= 0.05 then
set v.x = currentField.centerX - GetUnitX(u)
set v.y = currentField.centerY - GetUnitY(u)
set xy = (EARTH_PILLAR_RADIUS + 5) * EARTH_PILLAR_DISTANCE_FACTOR
else
set xy = ((EARTH_PILLAR_RADIUS + 5) - v.getLength() / 3) * EARTH_PILLAR_DISTANCE_FACTOR
endif
call v.setLength(xy)
set v.z = EARTH_PILLAR_KNOCKUP_FORCE - (GetUnitZ(pillar) - pz)*EARTH_PILLAR_DISTANCE_FACTOR
if u == ball.ball then
set v.z = v.z / 2
call ball.applyVector(v)
else
call Object[u].applyVector(v)
if u == ball.owner then
call ball.assist(owner)
endif
endif
call v.destroy()
endif
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
local Vector v
set dis = this
call IteratePlayersAll(deflectPlayerObjects)
set count = count - II32period
if count <= 0.00 then
call destroy()
endif
endmethod
implement II32
private static method createPillar takes nothing returns nothing
local thistype this = taurens[GetTimerData(GetExpiredTimer())]
local Ball ball = Ball.balls[0]
set dis = this
// Create and animate pillar
set pillar = CreateUnit(GetOwningPlayer(owner), EARTH_PILLAR_DUMMY_RAWCODE, x, y, GetRandomReal(0.00, 360.0))
call DisableUnitCollision(pillar)
call SetUnitPosition(pillar, x, y)
call EnableUnitCollision(pillar)
set hat = AddSpecialEffectTarget(GetPlayerHatPath(GetOwningPlayer(owner)), pillar, "overhead")
set count = EARTH_PILLAR_DURATION
call SetUnitAnimationByIndex(pillar, PILLAR_BIRTH_ANIMATION_INDEX)
// Call pillar knockback
call IteratePlayersAll(thistype.knockPlayerObjects)
if not ball.hold then
call knockback(ball.ball)
endif
call listAdd()
call start32()
call ReleaseTimer(GetExpiredTimer())
endmethod
private static method animation takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call SetUnitAnimation(u, EARTH_PILLAR_ANIMATION_INDEX)
call ReleaseTimer(GetExpiredTimer())
set u = null
endmethod
private static method endAnimation takes nothing returns nothing
local thistype this = taurens[GetTimerData(GetExpiredTimer())]
local real dx = x - GetUnitX(owner)
local real dy = y - GetUnitY(owner)
local integer i = 1
local real tx
local real ty
local real randSize
local real randOffset
call DisableUnit(owner, false)
call SetUnitTimeScale(owner, 1.00)
// Create sexy particles
loop
exitwhen i == 8
set randSize = GetRandomReal(0.05, 0.15)
set randOffset = GetRandomReal(-0.1, 0.1)
set tx = i * (dx / 8) - (dy * randOffset)
set ty = i * (dy / 8) + (dx * randOffset)
call Sfx(EARTH_PILLAR_SFX_PATH, GetUnitX(owner) + tx, GetUnitY(owner) + ty, z, 0.00, 0.00, randSize)
set i = i + 1
endloop
call Sfx(EARTH_PILLAR_END_SFX_PATH, x, y, z, 0.00, 0.00, 1.00)
call ReleaseTimer(GetExpiredTimer())
endmethod
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local thistype this = thistype.create()
local real dirX = GetSpellTargetX() - GetUnitX(u)
local real dirY = GetSpellTargetY() - GetUnitY(u)
local real lenDir = RAbsBJ(dirX) + RAbsBJ(dirY)
if lenDir < EARTH_PILLAR_RANGE then
set x = GetSpellTargetX()
set y = GetSpellTargetY()
else
set x = GetUnitX(u) + (dirX / lenDir) * EARTH_PILLAR_RANGE
set y = GetUnitY(u) + (dirY / lenDir) * EARTH_PILLAR_RANGE
endif
set z = GetTerrainZ(x, y)
set owner = u
set taurens[GetUnitId(u)] = this
call DisableUnit(u, true)
call SetUnitTimeScale(u, 4.00)
call TimerStart(NewTimerEx(GetUnitId(u)), 0.00, false, function thistype.animation)
call TimerStart(NewTimerEx(GetUnitId(u)), EARTH_PILLAR_ANIMATION_TIME, false, function thistype.endAnimation)
call TimerStart(NewTimerEx(GetUnitId(u)), EARTH_PILLAR_DELAY, false, function thistype.createPillar)
set u = null
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).pillar) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(EARTH_PILLAR_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope HookSpell
struct Hook
static thistype array hooks
static thistype dis
static unit array enemyCooldowns
static unit array allyCooldowns
unit caster
unit hookedPlayer
unit projectile
real time
boolean hooked
boolean returning
boolean friendly
boolean ballHooked
lightning link
implement ObjectList
static method getHookByPlayer takes unit u returns thistype
local integer i = 0
loop
if (hooks[i] != 0) then
if (u == hooks[i].hookedPlayer) then
return Hook.hooks[i]
endif
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
return 0
endmethod
static method getHook takes unit u returns thistype
local integer i = 0
loop
if (hooks[i] != 0) then
if (u == hooks[i].projectile) or (u == hooks[i].caster) then
return Hook.hooks[i]
endif
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
return 0
endmethod
static method staticDrop takes unit u returns nothing
local thistype this = getHook(u)
if not .ballHooked then
call .drop()
endif
endmethod
static method removeSilenceFromHooked takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call Silence.unsilencePlayer(GetOwningPlayer(u))
call UnitRemoveAbility(u, HOOK_SILENCE_VISUAL_RAWCODE)
call ReleaseTimer(GetExpiredTimer())
set u = null
endmethod
method destroy takes nothing returns nothing
local Ball ball = Ball.balls[0]
if .hooked then
if .ballHooked then
call SetUnitX(ball.ball, GetUnitX(.caster))
call SetUnitY(ball.ball, GetUnitY(.caster))
call SetUnitZ(ball.ball, GetUnitZ(.caster))
set ball.owner = .caster
else
call EnableUnitCollision(.hookedPlayer)
if not .friendly then
call TimerStart(NewTimerEx(GetUnitId(.hookedPlayer)), 0.50, false, /*
*/ function thistype.removeSilenceFromHooked)
endif
endif
endif
set .hookedPlayer = null
set .hooked = false
call RemoveUnit(.projectile)
call DestroyLightning(.link)
call stop32()
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.caster, HOOK_ENEMY_RAWCODE)
call UnitAddAbility(.caster, HOOK_ENEMY_RAWCODE)
call UnitRemoveAbility(.caster, HOOK_ALLY_RAWCODE)
call UnitAddAbility(.caster, HOOK_ALLY_RAWCODE)
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(.caster))), 0.01, false, function thistype.refresh)
endif
if (GetUnitTypeId(.caster) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(.caster)].delay = Metamorph.Reptillians[GetUnitId(.caster)].time
else
call UnitAddAbility(.caster, HOOK_ANCHOR_RAWCODE)
endif
call UnitRemoveAbility(.caster, HOOK_DROP_ENEMY_RAWCODE)
call UnitRemoveAbility(.caster, HOOK_DROP_ALLY_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ENEMY_RAWCODE, true)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ALLY_RAWCODE, true)
set hooks[GetPlayerId(GetOwningPlayer(.caster))] = 0
set .caster = null
endmethod
static method hook takes nothing returns boolean
local unit f = GetFilterUnit()
local thistype this = dis
local real h
if IsUnitType(f, UNIT_TYPE_PLAYER) and f != caster and not hooked then
if (not IsUnitEnemy(.caster, GetOwningPlayer(f)) and .friendly) or (IsUnitEnemy(.caster, GetOwningPlayer(f)) and not .friendly) then
set h = GetUnitZ(projectile) - GetUnitZ(f)
if h >= -HOOK_PROJECTILE_AOE/2.00 and h <= GetUnitHeight(f) + HOOK_PROJECTILE_AOE/2.00 then
if (getHookByPlayer(f) != 0) then
call getHookByPlayer(f).drop()
endif
call Sfx(HOOK_SFX_PATH, GetUnitX(f), GetUnitY(f), GetUnitZ(f), 0.00, 0.00, 0.01)
set .hooked = true
set .hookedPlayer = f
set .returning = true
call .returnToOrigin()
call DisableUnitCollision(hookedPlayer)
if not .friendly then
call dummyCast(hookedPlayer, HOOK_SILENCE_RAWCODE, "silence")
if (IsUnitInRegion(goalRegion[0], .projectile) or IsUnitInRegion(goalRegion[1], .projectile)) then
call Object[.hookedPlayer].setX(GetUnitX(.projectile))
call Object[.hookedPlayer].setY(GetUnitY(.projectile))
call .drop()
else
call Silence.silencePlayer(GetOwningPlayer(hookedPlayer))
call UnitAddAbility(hookedPlayer, HOOK_SILENCE_VISUAL_RAWCODE)
endif
endif
endif
endif
endif
set f = null
return false
endmethod
method ballhook takes nothing returns boolean
local Ball ball = Ball.balls[0]
local real h
if not (ball.owner == .caster and ball.hold) and (HOOK_BALL_HOOK_ENABLED) then
if (not ball.hold) or (not IsUnitEnemy(.caster, GetOwningPlayer(ball.owner)) and .friendly) or (IsUnitEnemy(.caster, GetOwningPlayer(ball.owner)) and not .friendly) then
set h = GetUnitZ(projectile) - GetUnitZ(ball.ball)
if h >= -HOOK_PROJECTILE_AOE/2.00 and h <= GetUnitHeight(ball.ball) + HOOK_PROJECTILE_AOE/2.00 then
if (getHookByPlayer(ball.ball) != 0) then
call getHookByPlayer(ball.ball).drop()
endif
call Sfx(HOOK_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), 0.00, 0.00, 0.01)
call UnitRemoveAbility(ball.owner, BALL_SLOW_BUFF_RAWCODE)
set .hooked = true
set .hookedPlayer = ball.ball
set .ballHooked = true
set .returning = true
call .returnToOrigin()
endif
endif
endif
return false
endmethod
method returnToOrigin takes nothing returns nothing
local Vector v
set v = Vector.create(GetUnitX(.caster) - GetUnitX(.projectile), GetUnitY(.caster) - GetUnitY(.projectile), GetUnitZ(.caster) - GetUnitZ(.projectile))
if .hooked and not .ballHooked then
call v.setLength(HOOK_PROJECTILE_RETURN_SPEED)
else
call v.setLength(HOOK_PROJECTILE_SPEED)
endif
call Object[projectile].setVector(v)
call v.destroy()
//call UnitAddAbility(u, PULL_DISABLE_RAWCODE)
if (.friendly) then
call UnitRemoveAbility(.caster, HOOK_WITHDRAW_ALLY_RAWCODE)
if (.hookedPlayer == null) then
call UnitRemoveAbility(.caster, HOOK_DROP_ALLY_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ALLY_RAWCODE, true)
else
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ALLY_RAWCODE, false)
call UnitAddAbility(.caster, HOOK_DROP_ALLY_RAWCODE)
endif
else
call UnitRemoveAbility(.caster, HOOK_WITHDRAW_ENEMY_RAWCODE)
if (.hookedPlayer == null) then
call UnitRemoveAbility(.caster, HOOK_DROP_ENEMY_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ENEMY_RAWCODE, true)
else
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ENEMY_RAWCODE, false)
call UnitAddAbility(.caster, HOOK_DROP_ENEMY_RAWCODE)
endif
endif
endmethod
method drop takes nothing returns nothing
if .hookedPlayer != null then
if not .ballHooked then
call EnableUnitCollision(.hookedPlayer)
if not .friendly then
call TimerStart(NewTimerEx(GetUnitId(.hookedPlayer)), 0.50, false, /*
*/ function thistype.removeSilenceFromHooked)
endif
endif
set .hookedPlayer = null
endif
endmethod
static method castDrop takes nothing returns nothing
local thistype this = getHook(GetTriggerUnit())
call .drop()
endmethod
static method withdraw takes nothing returns nothing
local thistype this = getHook(GetTriggerUnit())
set .returning = true
call .returnToOrigin()
endmethod
method iterate32 takes nothing returns nothing
local real x = GetUnitX(.projectile) - GetUnitX(.caster)
local real y = GetUnitY(.projectile) - GetUnitY(.caster)
local real distance = SquareRoot(Pow(x, 2) + Pow(y, 2))
local location loc
local Ball ball = Ball.balls[0]
set dis = this
if .returning and distance <= HOOK_RETURN_AOE then
call .destroy()
else
if .hooked then
if (.hookedPlayer != null) then
if (not .ballHooked) then
call Object[.hookedPlayer].setX(GetUnitX(.projectile))
call Object[.hookedPlayer].setY(GetUnitY(.projectile))
else // FUCKIN BALL HOOK, YO
call SetUnitX(ball.ball, GetUnitX(.projectile))
call SetUnitY(ball.ball, GetUnitY(.projectile))
call SetUnitZ(ball.ball, GetUnitZ(.projectile))
call ball.assist(.caster)
// set ball.owner = .caster
if ball.hold then
call UnitRemoveAbility(ball.owner, BALL_SLOW_BUFF_RAWCODE)
endif
set ball.hold = false
set ball.vel.x = 0
set ball.vel.y = 0
set ball.vel.z = 0
endif
endif
else
if SquareRoot(Pow(GetUnitX(ball.ball) - GetUnitX(.projectile), 2) + Pow(GetUnitY(ball.ball) - GetUnitY(.projectile), 2)) <= HOOK_PROJECTILE_AOE then
call .ballhook()
else
call GroupEnumUnitsInRange(enumGroup, GetUnitX(projectile), GetUnitY(projectile), HOOK_PROJECTILE_AOE, Filter(function thistype.hook))
endif
endif
set time = time + II32period
if time >= HOOK_PROJECTILE_DURATION * 10 then
call .destroy()
elseif time >= HOOK_PROJECTILE_DURATION or returning then
set .returning = true
call returnToOrigin()
call MoveLightningEx(link, false, GetUnitX(.caster), GetUnitY(.caster), GetUnitZ(.caster) + 75.0, GetUnitX(projectile), GetUnitY(projectile), GetUnitZ(projectile) + 75)
else
call MoveLightningEx(link, false, GetUnitX(.caster), GetUnitY(.caster), GetUnitZ(.caster) + 75.0, GetUnitX(projectile), GetUnitY(projectile), GetUnitZ(projectile) + 75)
endif
if .returning then
set loc = Location(GetUnitX(.projectile) - Object[.projectile].getVector().x, GetUnitY(.projectile) - Object[.projectile].getVector().y)
else
set loc = Location(GetUnitX(.projectile) + Object[.projectile].getVector().x, GetUnitY(.projectile) + Object[.projectile].getVector().y)
endif
call SetUnitFacingToFaceLocTimed(.projectile, loc, 0.00)
call RemoveLocation(loc)
endif
endmethod
implement II32
private static method resetAnimation takes nothing returns nothing
call SetUnitTimeScale(GetUnitById(GetTimerData(GetExpiredTimer())), 1.00)
call ReleaseTimer(GetExpiredTimer())
endmethod
static method castBegin takes nothing returns nothing
if (GetSpellAbilityId() == HOOK_ENEMY_RAWCODE) or (GetSpellAbilityId() == HOOK_ALLY_RAWCODE) and (GetUnitTypeId(GetTriggerUnit()) != MANFUL_LOAF_RAWCODE) then
call SetUnitTimeScale(GetTriggerUnit(), 2.00)
call TimerStart(NewTimerEx(GetUnitId(GetTriggerUnit())), 0.20, false, function thistype.resetAnimation)
endif
endmethod
private static method refresh takes nothing returns nothing
local integer i = GetTimerData(GetExpiredTimer())
if enemyCooldowns[i] == null then
set enemyCooldowns[i] = CreateUnit(Player(i), HOOK_COOLDOWN_ENEMY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
if allyCooldowns[i] == null then
set allyCooldowns[i] = CreateUnit(Player(i), HOOK_COOLDOWN_ALLY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
call ReleaseTimer(GetExpiredTimer())
endmethod
static method castEnemy takes nothing returns nothing
local thistype this = thistype.create()
set .caster = GetTriggerUnit()
set .friendly = false
call RemoveUnit(allyCooldowns[GetPlayerId(GetOwningPlayer(.caster))])
set allyCooldowns[GetPlayerId(GetOwningPlayer(.caster))] = null
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(.caster))), HOOK_ENEMY_COOLDOWN, false, function thistype.refresh)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ENEMY_RAWCODE, false)
call UnitAddAbility(.caster, HOOK_WITHDRAW_ENEMY_RAWCODE)
call .cast(GetSpellTargetX(), GetSpellTargetY())
endmethod
static method castAlly takes nothing returns nothing
local thistype this = thistype.create()
set .caster = GetTriggerUnit()
set .friendly = true
call RemoveUnit(enemyCooldowns[GetPlayerId(GetOwningPlayer(.caster))])
set enemyCooldowns[GetPlayerId(GetOwningPlayer(.caster))] = null
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(.caster))), HOOK_ALLY_COOLDOWN, false, function thistype.refresh)
call SetPlayerAbilityAvailable(GetOwningPlayer(.caster), HOOK_ALLY_RAWCODE, false)
call UnitAddAbility(.caster, HOOK_WITHDRAW_ALLY_RAWCODE)
call .cast(GetSpellTargetX(), GetSpellTargetY())
endmethod
method cast takes real x, real y returns nothing
local real a
local Vector v
set .caster = GetTriggerUnit()
set hooks[GetPlayerId(GetOwningPlayer(.caster))] = this
if (GetUnitTypeId(.caster) != MANFUL_LOAF_RAWCODE) then
call UnitRemoveAbility(.caster, HOOK_ANCHOR_RAWCODE)
endif
set v = Vector.create(x - GetUnitX(caster), y - GetUnitY(caster), GetTerrainZ(x, y) - GetUnitZ(caster))
set a = Atan2(v.y, v.x)
set x = GetUnitX(caster) + 20.0*Cos(a)
set y = GetUnitY(caster) + 20.0*Sin(a)
set projectile = CreateUnit(GetOwningPlayer(caster), HOOK_PROJECTILE_RAWCODE, x, y, bj_RADTODEG*a)
if .friendly then
call SetUnitVertexColor(projectile, 100, 255, 100, 255)
else
call SetUnitVertexColor(projectile, 255, 100, 100, 255)
endif
call SetUnitZ(projectile, GetUnitZ(caster) /*+ 100.0*/)
call DisableUnitCollision(projectile)
call v.setLength(HOOK_PROJECTILE_SPEED)
call Object[projectile].applyVector(v)
call v.destroy()
set time = 0.00
set hooked = false
set returning = false
set ballHooked = false
set link = AddLightningEx(HOOK_LIGHTNING_CODE, false, GetUnitX(.caster), GetUnitY(.caster), GetUnitZ(.caster) + 100.0, x, y, GetUnitZ(projectile) + 100)
call listAdd()
call start32()
//call SetUnitVertexColor(caster, 255, 255, 255, 0)
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).caster) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
local integer i = 0
loop
set hooks[i] = 0
set enemyCooldowns[i] = CreateUnit(Player(i), HOOK_COOLDOWN_ENEMY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set allyCooldowns[i] = CreateUnit(Player(i), HOOK_COOLDOWN_ALLY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CHANNEL, function thistype.castBegin)
call RegisterSpellEffectEvent(HOOK_ENEMY_RAWCODE, function thistype.castEnemy)
call RegisterSpellEffectEvent(HOOK_ALLY_RAWCODE, function thistype.castAlly)
call RegisterSpellEffectEvent(HOOK_WITHDRAW_ENEMY_RAWCODE, function thistype.withdraw)
call RegisterSpellEffectEvent(HOOK_WITHDRAW_ALLY_RAWCODE, function thistype.withdraw)
call RegisterSpellEffectEvent(HOOK_DROP_ENEMY_RAWCODE, function thistype.castDrop)
call RegisterSpellEffectEvent(HOOK_DROP_ALLY_RAWCODE, function thistype.castDrop)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope Metamorph initializer init
globals
private MetamorphSpellLayout array spells
private integer array castsRemaining
private integer array lastHero
private timer array mTimers
private real array counter
private unit array icon
endglobals
function getMetamorphSpell takes integer i returns MetamorphSpellLayout
return spells[i]
endfunction
private function metamorph takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
local unit u = GetUnitById(id)
if (counter[id] == 0) then
call RemoveUnit(icon[id])
set icon[id] = CreateUnit(GetOwningPlayer(u), METAMORPH_REMOVE_ABILITY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
call UnitRemoveAbility(u, METAMORPH_RAWCODE)
set castsRemaining[id] = 3
call DisableUnit(u, false)
call SetUnitAnimation(u, "stand")
call spells[id].addSkills(u)
call ReleaseTimer(GetExpiredTimer())
elseif (counter[id] == 0.50) then
set spells[id] = MetamorphSpellLayout.GetRandomHero(lastHero[id])
call RemoveUnit(icon[id])
set lastHero[id] = spells[id].getHero()
set icon[id] = CreateUnit(GetOwningPlayer(u), spells[id].getHero(), DUMMY_X, DUMMY_Y, 0.00)
set counter[id] = 0
call ReleaseTimer(GetExpiredTimer())
set mTimers[id] = NewTimerEx(id)
call TimerStart(mTimers[id], 0.50, false, function metamorph)
else
set spells[id] = MetamorphSpellLayout.GetRandomHero(lastHero[id])
if (icon[id] != null) then
call RemoveUnit(icon[id])
endif
set icon[id] = CreateUnit(GetOwningPlayer(u), spells[id].getHero(), DUMMY_X, DUMMY_Y, 0.00)
set counter[id] = counter[id] - METAMORPH_ROLL_TIME
call ReleaseTimer(GetExpiredTimer())
set mTimers[id] = NewTimerEx(id)
call TimerStart(mTimers[id], METAMORPH_ROLL_TIME, false, function metamorph)
endif
set u = null
endfunction
private function animation takes nothing returns nothing
call SetUnitAnimationByIndex(GetUnitById(GetTimerData(GetExpiredTimer())), METAMORPH_ANIMATION_INDEX)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetUnitId(u)
call DisableUnit(u, true)
call TimerStart(NewTimerEx(id), 0.00, false, function animation)
set counter[id] = METAMORPH_CAST_TIME
set mTimers[id] = NewTimerEx(id)
call TimerStart(mTimers[id], METAMORPH_ROLL_TIME, false, function metamorph)
set u = null
endfunction
private function resetCooldown takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call UnitRemoveAbility(u, METAMORPH_COOLDOWN_RAWCODE)
call UnitAddAbility(u, METAMORPH_RAWCODE)
set u = null
call ReleaseTimer(GetExpiredTimer())
endfunction
private function select takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id = GetUnitId(GetPlayerUnit(GetOwningPlayer(u)))
if (GetUnitTypeId(u) == METAMORPH_REMOVE_ABILITY_RAWCODE) then
if (GetOwningPlayer(u) == GetLocalPlayer()) then
call ClearSelection()
call SelectUnit(GetUnitById(id), true)
endif
call RemoveUnit(u)
set u = GetUnitById(id)
call spells[id].removeSkills(u)
if practiceMode then
call UnitAddAbility(u, METAMORPH_RAWCODE)
else
call UnitAddAbility(u, METAMORPH_COOLDOWN_RAWCODE)
call IssueImmediateOrder(u, "soulburn")
set mTimers[id] = NewTimerEx(id)
call TimerStart(mTimers[id], METAMORPH_COOLDOWN, false, function resetCooldown)
endif
set spells[id] = 0
endif
set u = null
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING then
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SELECTED, null)
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call TriggerAddCondition(t, function select)
set t = null
call RegisterSpellEffectEvent(METAMORPH_RAWCODE, function cast)
endfunction
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
// Metamorph Animations // // Metamorph Animations // // Metamorph Animations // // Metamorph Animations //
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
// Metamorph Animations // // Metamorph Animations // // Metamorph Animations // // Metamorph Animations //
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
struct Metamorph
static thistype array Reptillians
unit caster
unit ghostAnimation
real time
real delay
boolean specialAnimation
effect hat
boolean moving
real movementX
real movementY
implement ObjectList
method destroy takes nothing returns nothing
local integer id = GetUnitId(caster)
call stop32()
call listRemove()
set Reptillians[id] = 0
if (castsRemaining[id] <= 0) then
call spells[id].removeSkills(caster)
if practiceMode then
call UnitAddAbility(caster, METAMORPH_RAWCODE)
else
call UnitAddAbility(caster, METAMORPH_COOLDOWN_RAWCODE)
call IssueImmediateOrder(caster, "soulburn")
set mTimers[id] = NewTimerEx(id)
call TimerStart(mTimers[id], METAMORPH_COOLDOWN, false, function resetCooldown)
endif
set spells[id] = 0
else
set icon[id] = CreateUnit(GetOwningPlayer(caster), METAMORPH_REMOVE_ABILITY_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
call SetUnitVertexColor(caster, 255, 255, 255, 255)
call RemoveUnit(ghostAnimation)
call DestroyEffect(hat)
call deallocate()
endmethod
method iterate32 takes nothing returns nothing
set time = time + II32period
call SetUnitFacing(ghostAnimation, GetUnitFacing(caster))
call SetUnitX(ghostAnimation, GetUnitX(caster))
call SetUnitY(ghostAnimation, GetUnitY(caster))
call SetUnitZ(ghostAnimation, GetUnitZ(caster))
if (moving) then
call GroupEnumUnitsInRange(enumGroup, .movementX, .movementY, POSITION_RADIUS, Filter(function thistype.checkEnd))
endif
if time > delay + 2.00 then
call destroy()
elseif time > delay then
if (specialAnimation) then
set specialAnimation = false
call SetUnitTimeScale(ghostAnimation, 1.00)
if moving then
call IssuePointOrder(ghostAnimation, "smart", movementX, movementY)
else
call IssueImmediateOrder(ghostAnimation, "stop")
endif
endif
call SetUnitVertexColor(ghostAnimation, 255, 255, 255, R2I((2.55 - (time - delay)) * 100))
if (time > delay + 0.75) then
call SetUnitVertexColor(caster, 255, 255, 255, R2I(255 - ((2.55 - (time - delay)) * 100)))
endif
endif
endmethod
implement II32
private static method checkEnd takes nothing returns boolean
local unit f = GetFilterUnit()
local real x = GetUnitX(f)
local real y = GetUnitY(f)
local thistype this
if (GetUnitTypeId(f) == MANFUL_LOAF_RAWCODE) then
set this = Reptillians[GetUnitId(f)]
if this != 0 then
set x = Pow(movementX - x, 2)
set y = Pow(movementY - y, 2)
if (SquareRoot(x + y) <= POSITION_RADIUS) then
set moving = false
if not specialAnimation then
call IssueImmediateOrder(ghostAnimation, "stop")
endif
endif
endif
endif
set f = null
return false
endmethod
static method isMoving takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s = OrderId2String(GetIssuedOrderId())
local thistype this
if GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE and unitActive[GetPlayerId(GetOwningPlayer(u))] then
set this = Reptillians[GetUnitId(u)]
if s == "smart" then
set moving = true
set movementX = GetOrderPointX()
set movementY = GetOrderPointY()
if not specialAnimation then
call IssuePointOrder(ghostAnimation, "smart", movementX, movementY)
endif
else
set moving = false
if not specialAnimation then
call IssueImmediateOrder(ghostAnimation, "stop")
endif
endif
endif
set u = null
endmethod
static method ninjaAnimationSlow takes nothing returns nothing
call SetUnitTimeScale(GetUnitById(GetTimerData(GetExpiredTimer())), 0.41)
call ReleaseTimer(GetExpiredTimer())
endmethod
private static method resetHookAnimation takes nothing returns nothing
call SetUnitTimeScale(GetUnitById(GetTimerData(GetExpiredTimer())), 1.00)
call UnitRemoveAbility(GetUnitById(GetTimerData(GetExpiredTimer())), HOOK_ANCHOR_RAWCODE)
call ReleaseTimer(GetExpiredTimer())
endmethod
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local thistype this
local MetamorphSpellLayout spell = spells[GetUnitId(u)]
local timer t
if GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE then
if (Reptillians[GetUnitId(u)] == 0) then
set this = thistype.create()
set caster = u
set Reptillians[GetUnitId(caster)] = this
set time = 0
call RemoveUnit(icon[GetUnitId(u)])
set icon[GetUnitId(u)] = null
set castsRemaining[GetUnitId(u)] = castsRemaining[GetUnitId(u)] - 1
set ghostAnimation = CreateUnit(GetOwningPlayer(caster), spell.getHero(), GetUnitX(caster), GetUnitY(caster), GetUnitFacing(caster))
set hat = AddSpecialEffectTarget(GetPlayerHatPath(GetOwningPlayer(caster)), ghostAnimation,"head")
call SetUnitColor(ghostAnimation, GetPlayerColor(GetOwningPlayer(caster)))
set moving = Object[caster].moving
set movementX = Object[caster].movementX
set movementY = Object[caster].movementY
set specialAnimation = false
call SetUnitVertexColor(caster, 255, 255, 255, 50)
call SetUnitVertexColor(ghostAnimation, 255, 255, 255, 255)
call Sfx(METAMORPH_SFX_PATH, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster), 0.00, 0.00, 2.00)
if (GetSpellAbilityId() == SLAM_RAWCODE) then
set delay = SLAM_DELAY
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, SLAM_ANIMATION_INDEX)
elseif (GetSpellAbilityId() == BLACK_HOLE_RAWCODE) then
set delay = BLACK_HOLE_DURATION
elseif (GetSpellAbilityId() == TACKLE_RAWCODE) then
set delay = 1.50
elseif (GetSpellAbilityId() == BACKFLIP_RAWCODE) then
set delay = BACKFLIP_TIME
set specialAnimation = true
call SetUnitTimeScale(ghostAnimation, 4.00)
call SetUnitAnimationByIndex(ghostAnimation, 2)
set t = NewTimer()
call SetTimerData(t, GetUnitId(ghostAnimation))
call TimerStart(t, 0.10, false, function thistype.ninjaAnimationSlow)
set t = null
elseif (GetSpellAbilityId() == POWERSHOT_RAWCODE) then
set delay = POWERSHOT_CHARGE_TIME
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, POWERSHOT_ANIMATION_INDEX)
elseif (GetSpellAbilityId() == PULL_RAWCODE) then
set delay = PULL_DURATION
call SetUnitAnimation(ghostAnimation, "spell channel")
elseif (GetSpellAbilityId() == SWAP_RAWCODE) then
set delay = SWAP_PROJECTILE_DURATION
call SetUnitAnimation(ghostAnimation, "attack")
elseif (GetSpellAbilityId() == CURVESHOT_LEFT_RAWCODE or GetSpellAbilityId() == CURVESHOT_RIGHT_RAWCODE) then
set delay = CURVESHOT_DURATION
call SetUnitAnimation(ghostAnimation, "attack")
elseif (GetSpellAbilityId() == SHADOW_RAWCODE) then
set delay = 4.00
elseif (GetSpellAbilityId() == HOOK_ENEMY_RAWCODE or GetSpellAbilityId() == HOOK_ALLY_RAWCODE) then
set delay = 15.00
call SetUnitAnimation(ghostAnimation, "stand channel")
call SetUnitTimeScale(ghostAnimation, 2.00)
set t = NewTimer()
call SetTimerData(t, GetUnitId(ghostAnimation))
call TimerStart(t, 0.20, false, function thistype.resetHookAnimation)
set t = null
elseif (GetSpellAbilityId() == SMASH_OGRE_TIME_RAWCODE) then
set delay = SMASH_OGRE_TIME + SMASH_DELAY
call SetUnitVertexColor(ghostAnimation, 255, 155, 155, 255)
elseif (GetSpellAbilityId() == SMASH_RAWCODE) then
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, SMASH_ANIMATION_INDEX)
call SetUnitTimeScale(ghostAnimation, 2.00)
set delay = SMASH_DELAY
else
set delay = 0.00
endif
call listAdd()
call start32()
else
set this = Reptillians[GetUnitId(u)]
set time = 0
call SetUnitVertexColor(caster, 255, 255, 255, 50)
call SetUnitVertexColor(ghostAnimation, 255, 255, 255, 255)
set castsRemaining[GetUnitId(u)] = castsRemaining[GetUnitId(u)] - 1
if (GetSpellAbilityId() == SLAM_RAWCODE) then
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, SLAM_ANIMATION_INDEX)
elseif (GetSpellAbilityId() == BACKFLIP_RAWCODE) then
set specialAnimation = true
call SetUnitTimeScale(ghostAnimation, 4.00)
call SetUnitAnimationByIndex(ghostAnimation, 2)
set t = NewTimer()
call SetTimerData(t, GetUnitId(ghostAnimation))
call TimerStart(t, 0.10, false, function thistype.ninjaAnimationSlow)
set t = null
elseif (GetSpellAbilityId() == POWERSHOT_RAWCODE) then
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, POWERSHOT_ANIMATION_INDEX)
elseif (GetSpellAbilityId() == PULL_RAWCODE) then
call SetUnitAnimation(ghostAnimation, "spell channel")
elseif (GetSpellAbilityId() == SWAP_RAWCODE) then
call SetUnitAnimation(ghostAnimation, "attack")
elseif (GetSpellAbilityId() == CURVESHOT_LEFT_RAWCODE or GetSpellAbilityId() == CURVESHOT_RIGHT_RAWCODE) then
call SetUnitAnimation(ghostAnimation, "attack")
elseif (GetSpellAbilityId() == SHADOW_RAWCODE) then
elseif (GetSpellAbilityId() == HOOK_ENEMY_RAWCODE or GetSpellAbilityId() == HOOK_ALLY_RAWCODE) then
call SetUnitAnimation(ghostAnimation, "stand channel")
call SetUnitTimeScale(ghostAnimation, 2.00)
set t = NewTimer()
call SetTimerData(t, GetUnitId(ghostAnimation))
call TimerStart(t, 0.20, false, function thistype.resetHookAnimation)
set t = null
elseif (GetSpellAbilityId() == SMASH_OGRE_TIME_RAWCODE) then
call SetUnitVertexColor(ghostAnimation, 255, 155, 155, 255)
elseif (GetSpellAbilityId() == SMASH_RAWCODE) then
set specialAnimation = true
call SetUnitAnimationByIndex(ghostAnimation, SMASH_ANIMATION_INDEX)
call SetUnitTimeScale(ghostAnimation, 2.00)
elseif (GetSpellAbilityId() == EARTH_PILLAR_RAWCODE) then
set specialAnimation = true
call SetUnitAnimation(ghostAnimation, EARTH_PILLAR_ANIMATION_INDEX)
call SetUnitTimeScale(ghostAnimation, 4.00)
endif
endif
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(SLAM_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(BLACK_HOLE_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(TACKLE_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(BACKFLIP_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(POWERSHOT_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(PULL_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(SWAP_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(CURVESHOT_LEFT_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(CURVESHOT_RIGHT_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(SHADOW_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(HOOK_ENEMY_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(HOOK_ALLY_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(SMASH_RAWCODE, function thistype.cast)
call RegisterSpellEffectEvent(EARTH_PILLAR_RAWCODE, function thistype.cast)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.isMoving)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function thistype.isMoving)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function thistype.isMoving)
endmethod
endstruct
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
// Metamorph Spell Layout // // Metamorph Spell Layout // // Metamorph Spell Layout // // Metamorph Spell Layout //
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
// Metamorph Spell Layout // // Metamorph Spell Layout // // Metamorph Spell Layout // // Metamorph Spell Layout //
//////////////////////////// //////////////////////////// //////////////////////////// ////////////////////////////
struct MetamorphSpellLayout
static thistype array iNeedAHero
static integer abilities
private integer hero
private integer qSkill
private integer rSkill
private integer dCD
method addSkills takes unit u returns nothing
call UnitAddAbility(u, qSkill)
if (rSkill != 0) then
call UnitAddAbility(u, rSkill)
endif
endmethod
method removeSkills takes unit u returns nothing
call UnitRemoveAbility(u, qSkill)
if (rSkill != 0) then
call UnitRemoveAbility(u, rSkill)
endif
if (dCD != 0) then
call UnitRemoveAbility(u, dCD)
endif
endmethod
method getHero takes nothing returns integer
return hero
endmethod
static method GetRandomHero takes integer hero returns thistype
local integer temp = GetRandomInt(0, abilities-1)
local boolean exit = (hero == 0)
if (not exit) then
loop
set exit = true
if (iNeedAHero[temp].hero == hero) then
set temp = GetRandomInt(0, abilities-1)
set exit = false
endif
exitwhen exit
endloop
endif
//set temp = 10
return iNeedAHero[temp]
endmethod
static method construct takes integer h, integer q, integer r, integer d returns nothing
local thistype this = thistype.create()
set hero = h
set qSkill = q
set rSkill = r
set dCD = d
set iNeedAHero[abilities] = this
set abilities = abilities + 1
endmethod
static method onInit takes nothing returns nothing
set abilities = 0
call construct(METAMORPH_SLAM_RAWCODE, SLAM_RAWCODE, 0, 0) // 0 - Slam
call construct(METAMORPH_BLACKHOLE_RAWCODE, BLACK_HOLE_RAWCODE, 0, 0) // 1 - Black Hole
call construct(METAMORPH_TACKLE_RAWCODE, TACKLE_RAWCODE, 0, 0) // 2 - Tackle
call construct(METAMORPH_POWERSHOT_RAWCODE, POWERSHOT_RAWCODE, 0, 0) // 3 - Powershot
call construct(METAMORPH_PULL_RAWCODE, PULL_RAWCODE, 0, PULL_DISABLE_RAWCODE) // 4 - Pull
call construct(METAMORPH_SWAP_RAWCODE, SWAP_RAWCODE, 0, 0) // 5 - Swap
call construct(METAMORPH_CURVESHOT_RAWCODE, CURVESHOT_LEFT_RAWCODE, CURVESHOT_RIGHT_RAWCODE, 0) // 6 - Curveshot
call construct(METAMORPH_SHADOW_RAWCODE, SHADOW_RAWCODE, 0, SHADOW_RECALL_RAWCODE) // 7 - Shadow
call construct(METAMORPH_HOOK_RAWCODE, HOOK_ENEMY_RAWCODE, HOOK_ALLY_RAWCODE, 0) // 8 - Hook
call construct(METAMORPH_SMASH_RAWCODE, SMASH_RAWCODE, 0, 0) // 9 - Smash
call construct(METAMORPH_BACKFLIP_RAWCODE, BACKFLIP_RAWCODE, 0, 0) // 10 - Backflip
call construct(METAMORPH_EARTH_PILLAR_RAWCODE, EARTH_PILLAR_RAWCODE, 0, 0) // 11 - Earth Pillar
endmethod
endstruct
endscope
scope Pull
struct Pull
static thistype array pulls
unit u
real duration
lightning l
integer level
implement ObjectList
method destroy takes nothing returns nothing
local real cd = 30.00
call stop32()
call DestroyLightning(l)
set pulls[GetUnitId(u)] = 0
call listRemove()
call deallocate()
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(.u)].delay = Metamorph.Reptillians[GetUnitId(.u)].time
endif
if practiceMode then
call SetPlayerAbilityAvailable(GetOwningPlayer(.u), PULL_RAWCODE, true)
call UnitRemoveAbility(.u, PULL_DISABLE_RAWCODE)
call UnitRemoveAbility(.u, PULL_RAWCODE)
call UnitAddAbility(.u, PULL_RAWCODE)
else
/**if (level == 1) then
elseif (level == 2) then
elseif (level == 3) then
elseif (level == 4) then
elseif (level == 5) then
endif*/
set cd = 5.0 + level * 5
call TimerStart(NewTimerEx(GetUnitId(.u)), cd, false, function thistype.cooldown)
endif
endmethod
private static method cooldown takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
if (SZURA_COH_RAWCODE == GetUnitTypeId(u) or (MANFUL_LOAF_RAWCODE == GetUnitTypeId(u) and (getMetamorphSpell(GetUnitId(u)).getHero()) == METAMORPH_PULL_RAWCODE)) then // Manful Loaf strikes again!
call UnitRemoveAbility(u, PULL_DISABLE_RAWCODE)
call UnitRemoveAbility(u, PULL_RAWCODE)
call UnitAddAbility(u, PULL_RAWCODE)
endif
call SetPlayerAbilityAvailable(GetOwningPlayer(u), PULL_RAWCODE, true)
set playerOnDynamicCD[GetPlayerId(GetOwningPlayer(u))] = false
set u = null
call ReleaseTimer(GetExpiredTimer())
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
local Vector v = Vector.create(GetUnitX(ball.ball) - GetUnitX(u), GetUnitY(ball.ball) - GetUnitY(u), GetUnitZ(ball.ball) - GetUnitZ(.u))
call v.setLength(PULL_FORCE)
call Object[u].applyVector(v)
call v.destroy()
call MoveLightningEx(.l, false, GetUnitX(u), GetUnitY(u), GetUnitZ(u) + 60.0, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball))
set duration = .duration - II32period
if duration <= -1.00 then
call .destroy()
elseif duration <= 0.00 then
call IssueImmediateOrder(.u, "incineratearrowoff")
elseif duration <= 1.00 then
set level = 5
elseif duration <= 2.00 then
set level = 4
elseif duration <= 3.00 then
set level = 3
elseif duration <= 4.00 then
set level = 2
else
set level = 1
endif
call SetUnitAbilityLevel(u, PULL_DISABLE_RAWCODE, level)
endmethod
implement II32
static method cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = thistype.create()
local integer level = 1
set u = GetTriggerUnit()
set duration = PULL_DURATION
set l = AddLightningEx(PULL_LIGHTNING_CODE, false, GetUnitX(u), GetUnitY(u), GetUnitZ(u) + 60.0, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball))
set pulls[GetUnitId(u)] = this
call SetPlayerAbilityAvailable(GetTriggerPlayer(), PULL_RAWCODE, false)
call UnitAddAbility(u, PULL_DISABLE_RAWCODE)
call SetUnitAbilityLevel(u, PULL_DISABLE_RAWCODE, level)
call listAdd()
call start32()
set playerOnDynamicCD[GetPlayerId(GetOwningPlayer(u))] = true
endmethod
static method ballTaken takes nothing returns boolean
local Ball ball = Ball.balls[0]
if pulls[GetUnitId(ball.owner)] != 0 then
call IssueImmediateOrder(ball.owner, "incineratearrowoff")
endif
return false
endmethod
static method castBegin takes nothing returns nothing
local Ball ball = Ball.balls[0]
if GetSpellAbilityId() == PULL_RAWCODE and GetTriggerUnit() == ball.owner and ball.hold then
call UnitRemoveAbility(GetTriggerUnit(), PULL_RAWCODE)
call UnitAddAbility(GetTriggerUnit(), PULL_RAWCODE)
endif
endmethod
static method disable takes nothing returns nothing
if pulls[GetUnitId(GetTriggerUnit())] != 0 then
call pulls[GetUnitId(GetTriggerUnit())].destroy()
endif
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).u) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(PULL_RAWCODE, function thistype.cast)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CAST, function thistype.castBegin)
call RegisterSpellEffectEvent(PULL_DISABLE_RAWCODE, function thistype.disable)
call EVENT_BALL_TAKE.register(function thistype.ballTaken)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope RiftSpell
struct Rift
static thistype array rifts
static boolean array traveled
static thistype dis
unit caster
unit projectile
unit riftA
unit riftB
real time
real messageTime = 0
integer castCount = 0
integer start
lightning link
implement ObjectList
private static method removeRift takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call RemoveUnit(u)
call ReleaseTimer(GetExpiredTimer())
set u = null
endmethod
private static method resetCooldown takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call UnitRemoveAbility(u, RIFT_REFUND_RAWCODE)
call UnitAddAbility(u, RIFT_RAWCODE)
set u = null
call ReleaseTimer(GetExpiredTimer())
endmethod
method destroy takes nothing returns nothing
set rifts[GetPlayerId(GetOwningPlayer(.caster))] = 0
set .castCount = 0
if .riftA != null then
call KillUnit(.riftA)
call SetUnitTimeScale(.riftA, 2.50)
call TimerStart(NewTimerEx(GetUnitId(.riftA)), 2.00, false, function thistype.removeRift)
set .riftA = null
if .riftB != null then
call KillUnit(.riftB)
call SetUnitTimeScale(.riftB, 2.50)
call TimerStart(NewTimerEx(GetUnitId(.riftB)), 2.00, false, function thistype.removeRift)
set .riftB = null
elseif not practiceMode then
// Failed cast
call UnitRemoveAbility(.caster, RIFT_RAWCODE)
call UnitAddAbility(.caster, RIFT_REFUND_RAWCODE)
call IssueImmediateOrder(.caster, "soulburn")
call TimerStart(NewTimerEx(GetUnitId(.caster)), RIFT_REFUND_COOLDOWN, false, function thistype.resetCooldown)
endif
endif
call DestroyLightning(.link)
if practiceMode then
call UnitRemoveAbility(.caster, RIFT_RAWCODE)
call UnitAddAbility(.caster, RIFT_RAWCODE)
endif
call stop32()
call listRemove()
call deallocate()
set .caster = null
set .link = null
/*
if (GetUnitTypeId(.caster) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(.caster)].delay = Metamorph.Reptillians[GetUnitId(.caster)].time
endif
*/
endmethod
method teleport takes unit u, real x0, real y0, real x1, real y1, boolean ballTP returns nothing
local integer id = GetPlayerId(GetOwningPlayer(u))
local real a = GetUnitFacing(u) * bj_DEGTORAD
local Vector v
if ballTP then
set traveled[.start] = true
if Ball.balls[0].vel.getLength() > 0.05 then
set v = Vector.create(Ball.balls[0].vel.x, Ball.balls[0].vel.y, 0)
call v.setLength(RIFT_BUMP_FORCE / 4)
else
set a = GetRandomReal(0, 360) * bj_DEGTORAD
set v = Vector.create(Cos(a), Sin(a), 0)
call v.setLength(RIFT_BUMP_FORCE)
endif
call Ball.balls[0].applyVector(v)
else
set traveled[.start + id + 1] = true
if Object[u].getVector().getLength() > 0.05 then
set v = Vector.create(Object[u].getVector().x, Object[u].getVector().y, 0)
else
set v = Vector.create(Cos(a), Sin(a), 0)
endif
call v.setLength(RIFT_BUMP_FORCE)
call Object[u].applyVector(v)
endif
call SetUnitPosition(u, x1, y1)
call v.destroy()
endmethod
// A -> B
static method filterA takes nothing returns boolean
local thistype this = dis
local unit f = GetFilterUnit()
local integer id = GetPlayerId(GetOwningPlayer(f))
if IsUnitType(f, UNIT_TYPE_PLAYER) and not traveled[.start + id + 1] and GetUnitZ(f) <= GetTerrainZ(GetUnitX(f), GetUnitY(f)) + RIFT_GROUND_THRESHOLD then
call .teleport(f, GetUnitX(.riftA), GetUnitY(.riftA), GetUnitX(.riftB), GetUnitY(.riftB), false)
endif
set f = null
return false
endmethod
// B -> A
static method filterB takes nothing returns boolean
local thistype this = dis
local unit f = GetFilterUnit()
local integer id = GetPlayerId(GetOwningPlayer(f))
if IsUnitType(f, UNIT_TYPE_PLAYER) and not traveled[.start + id + 1] and GetUnitZ(f) <= GetTerrainZ(GetUnitX(f), GetUnitY(f)) + RIFT_GROUND_THRESHOLD then
call .teleport(f, GetUnitX(.riftB), GetUnitY(.riftB), GetUnitX(.riftA), GetUnitY(.riftA), false)
endif
set f = null
return false
endmethod
private static method removeProjectile takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call RemoveUnit(u)
call ReleaseTimer(GetExpiredTimer())
set u = null
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
local Vector v
local real x
local real y
local real z
local real a
local real d
local real t = RMinBJ(.time, 0.50) * 1.5
if .projectile != null then
set x = GetUnitX(.projectile)
set y = GetUnitY(.projectile)
set z = GetUnitZ(.projectile)
set a = GetUnitFacing(.projectile)
if z <= GetTerrainZ(x, y) + 5 then
set v = Vector.create(0,0,0)
call Object[.projectile].setVector(v)
call v.destroy()
call SetUnitZ(.projectile, z + 15)
call KillUnit(.projectile)
call TimerStart(NewTimerEx(GetUnitId(.projectile)), 0.25, false, function thistype.removeProjectile)
set .projectile = null
set .time = 0.00
set .messageTime = 0.00
// Do cast stuff
if .riftA == null then
set .riftA = CreateUnit(GetOwningPlayer(.caster), RIFT_DUMMY_RAWCODE, x, y, a)
else
set .riftB = CreateUnit(GetOwningPlayer(.caster), RIFT_DUMMY_RAWCODE, x, y, a)
call SetUnitScale(.riftA, 0.75, 0.75, 0.75)
set x = GetUnitX(.riftB) - GetUnitX(.riftA)
set y = GetUnitY(.riftB) - GetUnitY(.riftA)
set z = SquareRoot(Pow(x, 2) + Pow(y, 2))
set x = (x / z) * RIFT_RADIUS
set y = (y / z) * RIFT_RADIUS
set .link = AddLightningEx(RIFT_LIGHTNING_RAWCODE, false, GetUnitX(.riftA) + x, GetUnitY(.riftA) + y, GetUnitZ(.riftA), /*
*/ GetUnitX(.riftB) - x, GetUnitY(.riftB) - y, GetUnitZ(.riftB))
endif
else
set v = Vector.create(0, 0, -RIFT_PROJECTILE_GRAVITY_FORCE)
call Object[.projectile].applyVector(v)
call v.destroy()
endif
endif
if .riftB != null then
call SetUnitScale(.riftB, t, t, t)
if .time < RIFT_DURATION then
// Check for Ball collision
set x = GetUnitX(ball.ball)
set y = GetUnitY(ball.ball)
set z = GetUnitZ(ball.ball)
if not ball.hold and not traveled[.start] and z <= GetTerrainZ(x, y) + RIFT_GROUND_THRESHOLD then
if SquareRoot(Pow(GetUnitX(.riftA) - x, 2) + Pow(GetUnitY(.riftA) - y, 2)) <= RIFT_RADIUS + 25.0 then
call .teleport(ball.ball, GetUnitX(.riftA), GetUnitY(.riftA), GetUnitX(.riftB), GetUnitY(.riftB), true)
elseif SquareRoot(Pow(GetUnitX(.riftB) - x, 2) + Pow(GetUnitY(.riftB) - y, 2)) <= RIFT_RADIUS + 25.0 then
call .teleport(ball.ball, GetUnitX(.riftB), GetUnitY(.riftB), GetUnitX(.riftA), GetUnitY(.riftA), true)
endif
endif
set dis = this
call GroupEnumUnitsInRange(enumGroup, GetUnitX(.riftA), GetUnitY(.riftA), RIFT_RADIUS + POSITION_RADIUS / 2, Filter(function thistype.filterA))
call GroupEnumUnitsInRange(enumGroup, GetUnitX(.riftB), GetUnitY(.riftB), RIFT_RADIUS + POSITION_RADIUS / 2, Filter(function thistype.filterB))
if .time >= .messageTime then
if GetPlayerTeam(GetOwningPlayer(.caster)) == GetPlayerTeam(GetLocalPlayer()) then
call TextTag(EMOTE_COLOR_CODE+SubString(R2S(RIFT_DURATION - .messageTime), 0, 3)+"!", 0.0220, GetUnitX(.riftA) - 35.0, GetUnitY(.riftA), GetUnitZ(.riftA) + EMOTE_Z_OFFSET, 0.75)
call TextTag(EMOTE_COLOR_CODE+SubString(R2S(RIFT_DURATION - .messageTime), 0, 3)+"!", 0.0220, GetUnitX(.riftB) - 35.0, GetUnitY(.riftB), GetUnitZ(.riftB) + EMOTE_Z_OFFSET, 0.75)
endif
set .messageTime = .messageTime + 0.50
endif
else
call .destroy()
endif
set .time = .time + II32period
elseif .riftA != null then
call SetUnitScale(.riftA, t, t, t)
if .time < RIFT_TIMEOUT_DURATION then
if .time >= .messageTime then
if GetOwningPlayer(.caster) == GetLocalPlayer() then
call TextTag(EMOTE_COLOR_CODE+SubString(R2S(RIFT_TIMEOUT_DURATION - .messageTime), 0, 3)+"!", 0.0220, GetUnitX(.riftA) - 35.0, GetUnitY(.riftA), GetUnitZ(.riftA) + EMOTE_Z_OFFSET, 0.75)
endif
set .messageTime = .messageTime + 0.50
endif
elseif .projectile == null then
call .destroy()
endif
set .time = .time + II32period
endif
endmethod
implement II32
private static method resetAnimation takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
call SetUnitTimeScale(u, 1.00)
call SetUnitAnimation(u, "stand")
call ReleaseTimer(GetExpiredTimer())
set u = null
endmethod
static method cast takes nothing returns nothing
local thistype this
local unit u = GetTriggerUnit()
local integer id = GetPlayerId(GetOwningPlayer(u))
local boolean firstCast = rifts[id].castCount == 0
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real z = GetUnitZ(u)
local real tx = GetSpellTargetX()
local real ty = GetSpellTargetY()
local Vector v = Vector.create(tx - x, ty - y, 0)
local real travelTime = 0
local real a = Atan2(v.y, v.x)
local integer i = 0
if firstCast then
set rifts[id] = thistype.create()
call BlzSetUnitAbilityCooldown(u, RIFT_RAWCODE, 1, 1.50)
set this = rifts[id]
else
call BlzSetUnitAbilityCooldown(u, RIFT_RAWCODE, 1, RIFT_COOLDOWN)
set this = rifts[id]
set .start = id * (MAX_PLAYERS + 1)
loop
set traveled[.start + i] = false
set i = i + 1
exitwhen i == MAX_PLAYERS + 1
endloop
endif
if .projectile == null then
set .castCount = .castCount + 1
if GetUnitTypeId(u) != MANFUL_LOAF_RAWCODE then
call SetUnitTimeScale(u, 3.00)
call SetUnitAnimation(u, "attack 2")
call TimerStart(NewTimerEx(GetUnitId(u)), 0.35, false, function thistype.resetAnimation)
endif
set .caster = u
if v.getLength() <= 0.05 then
set a = GetUnitFacing(u)
call v.destroy()
set v = Vector.create(Cos(a*bj_DEGTORAD), Sin(a*bj_DEGTORAD), 0)
endif
set .projectile = CreateUnit(GetOwningPlayer(.caster), RIFT_PROJECTILE_RAWCODE, x, y, bj_RADTODEG*a)
set z = z + RIFT_PROJECTILE_START_HEIGHT
call SetUnitZ(.projectile, z)
set z = z - GetTerrainZ(GetUnitX(.projectile), GetUnitY(.projectile))
call DisableUnitCollision(.projectile)
set travelTime = RMinBJ(v.getLength(), RIFT_MAX_RANGE) / (RIFT_PROJECTILE_SPEED * 32)
call v.setLength(RIFT_PROJECTILE_SPEED)
//set v.z = ((z / travelTime) + (0.5 * RIFT_PROJECTILE_GRAVITY_FORCE * travelTime))
// Fuck math i'm just hard coding this
if travelTime > 0.5 then
set v.z = 32.5 * (travelTime * 2) - 16.25
elseif travelTime > 0.2 then
set v.z = 35 * (travelTime * 2) - 17.5
else
set v.z = (-82.5 * Pow((0.2 - travelTime) * 2, 3)) - 17.5
endif
if not firstCast then
set v.z = v.z + RIFT_PROJECTILE_GRAVITY_FORCE
endif
call Object[.projectile].applyVector(v)
if firstCast then
call listAdd()
call start32()
endif
else
// Cancel cast and refund cooldown
call BlzSetUnitAbilityCooldown(u, RIFT_RAWCODE, 1, 0)
endif
set u = null
call v.destroy()
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).caster) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
local integer i = 0
loop
set rifts[i] = 0
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call RegisterSpellEffectEvent(RIFT_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope Shadow initializer init
globals
private timer array delayTimers
private boolean array shadowing
private unit array shadow
private real array counter
endglobals
private function resetCooldown takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
local unit u = GetUnitById(id)
if (counter[id] == 0) then
if (CLAY_HAND_NIL_RAWCODE == GetUnitTypeId(u) or (MANFUL_LOAF_RAWCODE == GetUnitTypeId(u) and (getMetamorphSpell(GetUnitId(u)).getHero()) == METAMORPH_SHADOW_RAWCODE)) then
call UnitRemoveAbility(u, SHADOW_RECALL_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(u), SHADOW_RAWCODE, true)
call Sfx(SHADOW_SFX_PATH, GetUnitX(shadow[id]), GetUnitY(shadow[id]), GetUnitZ(shadow[id]), 0.00, 0.00, 1.00)
call RemoveUnit(shadow[id])
set shadow[id] = null
if practiceMode then
call UnitRemoveAbility(u, SHADOW_RAWCODE)
call UnitAddAbility(u, SHADOW_RAWCODE)
endif
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(u)].delay = Metamorph.Reptillians[GetUnitId(u)].time
endif
endif
call ReleaseTimer(GetExpiredTimer())
else
if (GetOwningPlayer(u) == GetLocalPlayer()) then
call TextTag(EMOTE_COLOR_CODE+SubString(R2S(counter[id]), 0, 3)+"!", 0.0220, GetUnitX(shadow[id]) - 40.0, GetUnitY(shadow[id]), GetUnitZ(shadow[id]) + EMOTE_Z_OFFSET, 0.75)
endif
set counter[id] = counter[id] - 0.50
call ReleaseTimer(GetExpiredTimer())
set delayTimers[id] = NewTimerEx(id)
call TimerStart(delayTimers[id], 0.50, false, function resetCooldown)
endif
set u = null
endfunction
private function blink takes nothing returns nothing
local integer id = GetTimerData(GetExpiredTimer())
local unit u = GetUnitById(id)
local real f = GetUnitFacing(u)*bj_DEGTORAD
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real fx
local real fy
local real r = 0.00
set shadow[id] = CreateUnit(GetOwningPlayer(u), SHADOW_SHADOW_RAWCODE, GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
call SetUnitVertexColor(shadow[id], 128, 128, 128, 128)
set shadowing[id] = false
call Sfx(SHADOW_SFX_PATH, x, y, GetUnitZ(u), 0.00, 0.00, 1.00)
loop
set fx = x + 40.0*Cos(f)
set fy = y + 40.0*Sin(f)
exitwhen r >= SHADOW_RANGE or not IsTerrainWalkable(fx, fy)
set x = x + 10.0*Cos(f)
set y = y + 10.0*Sin(f)
set r = r + 10.0
endloop
call Object[u].setX(x)
call Object[u].setY(y)
call UnitAddAbility(u, SHADOW_RECALL_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(u), SHADOW_RAWCODE, false)
call ReleaseTimer(GetExpiredTimer())
set delayTimers[id] = NewTimerEx(id)
set counter[id] = R2I(SHADOW_RECALL_DELAY)
call TimerStart(delayTimers[id], 0.50, false, function resetCooldown)
set u = null
endfunction
private function cast takes nothing returns nothing
local integer id = GetUnitId(GetTriggerUnit())
set shadowing[id] = true
set delayTimers[id] = NewTimerEx(id)
call TimerStart(delayTimers[id], SHADOW_DELAY, false, function blink)
endfunction
private function castRecall takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer id = GetUnitId(u)
call Sfx(SHADOW_SFX_PATH, GetUnitX(u), GetUnitY(u), GetUnitZ(u), 0.00, 0.00, 1.00)
call Object[u].setX(GetUnitX(shadow[id]))
call Object[u].setY(GetUnitY(shadow[id]))
call PauseTimer(delayTimers[id])
call ReleaseTimer(delayTimers[id])
if practiceMode then
call UnitRemoveAbility(u, SHADOW_RECALL_RAWCODE)
call SetPlayerAbilityAvailable(GetOwningPlayer(u), SHADOW_RAWCODE, true)
call UnitRemoveAbility(u, SHADOW_RAWCODE)
call UnitAddAbility(u, SHADOW_RAWCODE)
else
set delayTimers[id] = NewTimerEx(id)
call TimerStart(delayTimers[id], SHADOW_RECALL_COOLDOWN, false, function resetCooldown)
endif
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(u)].delay = Metamorph.Reptillians[GetUnitId(u)].time
endif
set counter[id] = 0
call RemoveUnit(shadow[id])
set shadow[id] = null
set u = null
endfunction
private function onPlayerClearing takes nothing returns nothing
local unit u = GetPlayerUnit(GetClearingPlayer())
local integer id
if GetUnitTypeId(u) != 0 then
set id = GetUnitId(u)
if shadowing[id] then
set shadowing[id] = false
call PauseTimer(delayTimers[id])
call ReleaseTimer(delayTimers[id])
endif
endif
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(SHADOW_RAWCODE, function cast)
call RegisterSpellEffectEvent(SHADOW_RECALL_RAWCODE, function castRecall)
call RegisterEvent(function onPlayerClearing, EVENT_PLAYER_CLEARING)
endfunction
endscope
scope Slam initializer init
globals
private unit caster
private real x
private real y
private real z
private real factor = 0.00
boolean sirSlam = false
private timer sirslam = CreateTimer()
endglobals
private function knock takes nothing returns boolean
local Ball ball = Ball.balls[0]
local Vector v
local unit f = GetFilterUnit()
if IsUnitInRange(f, caster, SLAM_AOE) and f != caster and IsUnitType(f, UNIT_TYPE_OBJECT) then
set v = Vector.create(GetUnitX(f) - x, GetUnitY(f) - y, GetUnitZ(f) - z - SLAM_KNOCKBACK_POINT_Z)
if v.getLength() <= SLAM_AOE then
call v.setLength((SLAM_FORCE - v.getLength()*SLAM_DISTANCE_FACTOR)*factor)
call Object[f].applyVector(v)
if f == ball.owner then
call ball.assist(caster)
endif
endif
call v.destroy()
endif
set f = null
return false
endfunction
private function knockPlayerObjects takes player p returns nothing
call GroupEnumUnitsOfPlayer(enumGroup, p, Filter(function knock))
endfunction
private function SirCheck takes nothing returns boolean
set sirSlam = false
return false
endfunction
private function slamEffect takes nothing returns nothing
local Ball ball
local Vector v
local integer i = 0
set caster = GetUnitById(GetTimerData(GetExpiredTimer()))
if GetUnitTypeId(caster) != 0 then
set x = GetUnitX(caster) + BALL_KEEP_RANGE*Cos(bj_DEGTORAD * GetUnitFacing(caster))
set y = GetUnitY(caster) + BALL_KEEP_RANGE*Sin(bj_DEGTORAD * GetUnitFacing(caster))
set z = GetUnitZ(caster)
set factor = 1.00
if GetUnitFlyHeight(caster) > 70.0 then
if GetUnitFlyHeight(caster) > -2.00*SLAM_KNOCKBACK_POINT_Z then
set factor = 0.00
else
set factor = (2.20*SLAM_KNOCKBACK_POINT_Z + GetUnitFlyHeight(caster))/(2.20*SLAM_KNOCKBACK_POINT_Z)
endif
endif
if factor > 0.00 then
call DestroyEffect(AddSpecialEffectZ(SLAM_SFX_PATH, x, y, z))
endif
call SetUnitTimeScale(caster, 1.00)
call DisableUnit(caster, false)
call SetUnitAnimation(caster, "stand")
call IteratePlayersAll(knockPlayerObjects)
loop
set ball = Ball.balls[i]
if ball != 0 then
set v = Vector.create(GetUnitX(ball.ball) - x, GetUnitY(ball.ball) - y, GetUnitZ(ball.ball) - z - SLAM_KNOCKBACK_POINT_Z)
if v.getLength() <= SLAM_AOE and (not ball.hold) then
call v.setLength((SLAM_FORCE + 3.00 - v.getLength()*SLAM_DISTANCE_FACTOR)*factor)
call ball.applyVector(v)
set ball.owner = caster
endif
call v.destroy()
endif
set i = i + 1
exitwhen i == MAX_BALLS
endloop
endif
call ReleaseTimer(GetExpiredTimer())
set ball = Ball.balls[0]
if (GetPlayerOriginalName(GetOwningPlayer(caster)) == "SirSirrrr") and (caster == ball.owner) then /* lightning bolt on slam shots */
call TimerStart(sirslam, 5.00, false, function SirCheck)
set sirSlam = true
endif
if practiceMode then
call UnitRemoveAbility(caster, SLAM_RAWCODE)
call UnitAddAbility(caster, SLAM_RAWCODE)
endif
endfunction
private function animation takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
call SetUnitAnimationByIndex(u, METAMORPH_ANIMATION_INDEX)
else
call SetUnitAnimationByIndex(u, SLAM_ANIMATION_INDEX)
endif
set u = null
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
call DisableUnit(u, true)
call TimerStart(NewTimerEx(GetUnitId(u)), 0.00, false, function animation)
call SetUnitTimeScale(u, 1.20)
call TimerStart(NewTimerEx(GetUnitId(u)), SLAM_DELAY, false, function slamEffect)
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(SLAM_RAWCODE, function cast)
endfunction
endscope
scope Smash
struct Smash
static thistype array ogres
static thistype dis
static unit array smashCooldowns
static unit array speedCooldowns
integer text
boolean smashed
unit u
implement ObjectList
method destroy takes nothing returns nothing
call deallocate()
if practiceMode then
call UnitRemoveAbility(.u, SMASH_RAWCODE)
call UnitAddAbility(.u, SMASH_RAWCODE)
endif
if (not smashed) then
call DisableUnit(u, false)
call SetUnitTimeScale(u, 1.00)
call SetUnitAnimation(u, "stand")
endif
call listRemove()
endmethod
/**
Hitbox
O = Ogre
3===4
\ /
2=O=1
*/
static method isInHitbox takes unit u, boolean ballSmash returns boolean
local Ball ball = Ball.balls[0]
local real a = GetUnitFacing(dis.u)
local integer i = 0
local real array x
local real array y
local real v1x
local real v1y
local real v2x
local real v2y
local real smashWidthInner = SMASH_WIDTH_INNER
local real smashWidthOuter = SMASH_WIDTH_OUTER
local real smashRange = SMASH_RANGE
if ballSmash and ball.owner == dis.u then
set smashRange = smashRange + SMASH_RANGE_BALL
endif
set x[0] = GetUnitX(dis.u)
set y[0] = GetUnitY(dis.u)
set x[1] = x[0] + smashWidthInner*Cos((a-90)*bj_DEGTORAD)
set y[1] = y[0] + smashWidthInner*Sin((a-90)*bj_DEGTORAD)
set x[2] = x[0] + smashWidthInner*Cos((a+90)*bj_DEGTORAD)
set y[2] = y[0] + smashWidthInner*Sin((a+90)*bj_DEGTORAD)
set x[3] = x[0] + smashWidthOuter*Cos((a+90)*bj_DEGTORAD) + smashRange*Cos(a*bj_DEGTORAD)
set y[3] = y[0] + smashWidthOuter*Sin((a+90)*bj_DEGTORAD) + smashRange*Sin(a*bj_DEGTORAD)
set x[4] = x[0] + smashWidthOuter*Cos((a-90)*bj_DEGTORAD) + smashRange*Cos(a*bj_DEGTORAD)
set y[4] = y[0] + smashWidthOuter*Sin((a-90)*bj_DEGTORAD) + smashRange*Sin(a*bj_DEGTORAD)
set x[0] = GetUnitX(u)
set y[0] = GetUnitY(u)
loop
set i = i + 1
set v1x = x[i] - x[0]
set v1y = y[i] - y[0]
if (i < 4) then
set v2x = x[i+1] - x[0]
set v2y = y[i+1] - y[0]
else
set v2x = x[1] - x[0]
set v2y = y[1] - y[0]
endif
if ((v2x*v1y - v1x*v2y) < 0) then
return false
endif
exitwhen i == 4
endloop
return true
endmethod
static method bump takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = ogres[GetTimerData(GetExpiredTimer())]
local real x
local real y
local real a
local Vector v
set smashed = true
set dis = this
set u = GetUnitById(GetTimerData(GetExpiredTimer()))
call TextTag(EMOTE_COLOR_CODE+"OGRE SMASH!", 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 1.00)
call GroupEnumUnitsInRange(enumGroup, GetUnitX(u), GetUnitY(u), SMASH_RANGE, Filter(function thistype.checkUnits))
call DisableUnit(u, false)
call SetUnitTimeScale(u, 1.00)
call SetUnitAnimation(u, "stand")
set a = GetUnitFacing(u) * bj_DEGTORAD
set x = SMASH_RANGE*Cos(a)
set y = SMASH_RANGE*Sin(a)
// Ball smash
if (not ball.hold) then
set dis = this
if (isInHitbox(ball.ball, ball.owner == u)) and (GetUnitZ(ball.ball) < GetUnitZ(u) + 50 and GetUnitZ(ball.ball) > GetUnitZ(u) - 25) then
set v = Vector.create(Cos(a), Sin(a), 0)
call v.setLength(SMASH_PUSH_FORCE)
if (ball.owner == u) then
call ball.zero()
call v.setLength(SMASH_BALL_PUSH_FORCE)
endif
call ball.applyVector(v)
call v.destroy()
set ball.owner = u
endif
endif
// SFX
call Sfx(SMASH_SFX_PATH, GetUnitX(u) + x/4, GetUnitY(u) + y/4, GetUnitZ(u), 0.00, 0.00, 0.01)
call Sfx(SMASH_SFX_PATH, GetUnitX(u) + x/2, GetUnitY(u) + y/2, GetUnitZ(u), 0.00, 0.00, 0.10)
call Sfx(SMASH_SFX_PATH, GetUnitX(u) + 3*x/4, GetUnitY(u) + 3*y/4, GetUnitZ(u), ModuloReal(GetUnitFacing(u) + 180, 360), 0.00, 0.50)
//call Sfx(SMASH_SFX_PATH, GetUnitX(u) + 3*x/4, GetUnitY(u) + 2*y/3, GetUnitZ(u), 0.00, 0.00, 1.00)
call ReleaseTimer(GetExpiredTimer())
call destroy()
endmethod
static method checkUnits takes nothing returns boolean
local Ball ball = Ball.balls[0]
local unit f = GetFilterUnit()
local Vector v
local real a
if f != dis.u and IsUnitType(f, UNIT_TYPE_PLAYER) then
if (isInHitbox(f, false)) and (GetUnitZ(f) < GetUnitZ(dis.u) + 10 and GetUnitZ(f) > GetUnitZ(dis.u) - 10) then
if (IsUnitEnemy(dis.u, GetOwningPlayer(f))) then
call dummyCast(f, SMASH_SLOW_RAWCODE, "cripple")
endif
set a = GetUnitFacing(dis.u) * bj_DEGTORAD
set v = Vector.create(Cos(a), Sin(a), 0)
call v.setLength(SMASH_PUSH_FORCE)
call Object[f].applyVector(v)
call v.destroy()
if f == ball.owner then
call ball.assist(dis.u)
endif
endif
endif
set f = null
return false
endmethod
private static method animation takes nothing returns nothing
call SetUnitAnimationByIndex(GetUnitById(GetTimerData(GetExpiredTimer())), SMASH_ANIMATION_INDEX)
call ReleaseTimer(GetExpiredTimer())
endmethod
private method cast takes nothing returns nothing
call DisableUnit(u, true)
call TimerStart(NewTimerEx(GetUnitId(u)), 0.00, false, function thistype.animation)
call SetUnitTimeScale(u, 2.00)
call TimerStart(NewTimerEx(GetUnitId(u)), SMASH_DELAY, false, function thistype.bump)
endmethod
// Ogre Smash
static method castSmash takes nothing returns nothing
local unit caster = GetTriggerUnit()
local thistype this = thistype.create()
set ogres[GetUnitId(caster)] = this
call listAdd()
set u = caster
set smashed = false
call cast()
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(SMASH_RAWCODE, function thistype.castSmash)
endmethod
endstruct
endscope
scope Swap
globals
private region inFrontOfGoal
endglobals
private struct SwapLightning
unit caster
unit target
lightning light
real duration
method iterate32 takes nothing returns nothing
call MoveLightningEx(light, false, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 100.0, GetUnitX(target), GetUnitY(target), GetUnitZ(target) + 100.0)
set duration = duration - II32period
if duration <= 0.00 then
call DestroyLightning(light)
call stop32()
call destroy()
endif
endmethod
implement II32
static method create takes unit u1, unit u2 returns thistype
local thistype this = thistype.allocate()
set caster = u1
set target = u2
set light = AddLightningEx(SWAP_LIGHTNING_2_CODE, false, GetUnitX(u1), GetUnitY(u1), GetUnitZ(u1) + 100.0, GetUnitX(u2), GetUnitY(u2), GetUnitZ(u2) + 100.0)
set duration = 0.40
call start32()
return this
endmethod
endstruct
struct Swap
static thistype array swapz
static thistype dis
unit caster
unit projectile
real time
boolean swapped
boolean frontGoal
boolean inGoal
lightning link
implement ObjectList
static method getSwap takes unit projectile returns thistype
local integer i = 0
loop
if (swapz[i].projectile == projectile) then
return swapz[i]
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
return 0
endmethod
static method getSwapFrontGoal takes unit projectile returns boolean
local thistype swap = getSwap(projectile)
return swap.frontGoal
endmethod
private static method derpy takes nothing returns boolean
local unit u = GetTriggerUnit()
local thistype swap = 0
if (GetUnitTypeId(u) == SWAP_PROJECTILE_RAWCODE) then
set swap = getSwap(u)
set swap.frontGoal = true
endif
return false
endmethod
private static method removeProjectile takes nothing returns nothing
call RemoveUnit(GetUnitById(GetTimerData(GetExpiredTimer())))
call ReleaseTimer(GetExpiredTimer())
endmethod
method destroy takes nothing returns nothing
if not swapped then
call SetUnitAnimation(projectile, "death")
call TimerStart(NewTimerEx(GetUnitId(projectile)), 0.900, false, function thistype.removeProjectile)
else
call RemoveUnit(projectile)
endif
call DestroyLightning(link)
call stop32()
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.caster, SWAP_RAWCODE)
call UnitAddAbility(.caster, SWAP_RAWCODE)
endif
if (GetUnitTypeId(caster) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(caster)].delay = Metamorph.Reptillians[GetUnitId(caster)].time
endif
endmethod
static method swap takes nothing returns boolean
local unit f = GetFilterUnit()
local thistype this = dis
local Object a
local real xa
local real ya
local real za
local Vector va
local boolean ea
local Object b
local real xb
local real yb
local real zb
local Vector vb
local boolean eb
local real h
local Ball ball
if IsUnitType(f, UNIT_TYPE_PLAYER) and f != caster and not swapped and not inGoal then
set h = GetUnitZ(projectile) - GetUnitZ(f)
if h >= -SWAP_PROJECTILE_AOE/2.00 and h <= GetUnitHeight(f) + SWAP_PROJECTILE_AOE/2.00 then
set swapped = true
set a = Object[caster]
set xa = GetUnitX(caster)
set ya = GetUnitY(caster)
set za = GetUnitZ(caster)
set va = a.velocity
set ea = a.enabled32
call SetUnitX(caster, DUMMY_X)
call SetUnitY(caster, DUMMY_Y)
set b = Object[f]
set xb = GetUnitX(f)
set yb = GetUnitY(f)
set zb = GetUnitZ(f)
set vb = b.velocity
set eb = b.enabled32
call SetUnitX(f, DUMMY_X)
call SetUnitY(f, DUMMY_Y)
call a.setX(xb)
call a.setY(yb)
call a.setZ(zb)
set a.velocity = vb
if eb then
call a.start32()
endif
call b.setX(xa)
call b.setY(ya)
call b.setZ(za)
set b.velocity = va
if ea then
call b.start32()
endif
call AddSpecialEffectTarget(SWAP_CASTER_SFX_PATH, caster, "origin")
call AddSpecialEffectTarget(SWAP_TARGET_SFX_PATH, f, "origin")
set time = SWAP_PROJECTILE_DURATION
call SwapLightning.create(caster, f)
set ball = getBall(caster)
if ball.hold and caster == ball.owner then
call SetUnitX(ball.ball, GetUnitX(ball.owner) + BALL_KEEP_RANGE*Cos(GetUnitFacing(ball.owner)*bj_DEGTORAD))
call SetUnitY(ball.ball, GetUnitY(ball.owner) + BALL_KEEP_RANGE*Sin(GetUnitFacing(ball.owner)*bj_DEGTORAD))
call SetUnitZ(ball.ball, GetUnitZ(ball.owner))
endif
set ball = getBall(f)
if ball.hold and f == ball.owner then
call SetUnitX(ball.ball, GetUnitX(ball.owner) + BALL_KEEP_RANGE*Cos(GetUnitFacing(ball.owner)*bj_DEGTORAD))
call SetUnitY(ball.ball, GetUnitY(ball.owner) + BALL_KEEP_RANGE*Sin(GetUnitFacing(ball.owner)*bj_DEGTORAD))
call SetUnitZ(ball.ball, GetUnitZ(ball.owner))
endif
endif
endif
set f = null
return false
endmethod
method iterate32 takes nothing returns nothing
set dis = this
call GroupEnumUnitsInRange(enumGroup, GetUnitX(projectile), GetUnitY(projectile), SWAP_PROJECTILE_AOE, Filter(function thistype.swap))
set time = time + II32period
if time >= SWAP_PROJECTILE_DURATION then
call destroy()
else
call MoveLightningEx(link, false, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 80.0, GetUnitX(projectile), GetUnitY(projectile), GetUnitZ(projectile))
endif
endmethod
implement II32
static method cast takes nothing returns nothing
local thistype this = thistype.create()
local real a
local real x = GetSpellTargetX()
local real y = GetSpellTargetY()
local Vector v
set caster = GetTriggerUnit()
if IsUnitInRegion(inFrontOfGoal, caster) then
set frontGoal = true
else
set frontGoal = false
endif
set inGoal = false
set swapz[GetPlayerId(GetOwningPlayer(caster))] = this
set v = Vector.create(x - GetUnitX(caster), y - GetUnitY(caster), GetTerrainZ(x, y) - GetUnitZ(caster))
set a = Atan2(v.y, v.x)
set x = GetUnitX(caster) + 20.0*Cos(a)
set y = GetUnitY(caster) + 20.0*Sin(a)
set projectile = CreateUnit(GetOwningPlayer(caster), SWAP_PROJECTILE_RAWCODE, x, y, bj_RADTODEG*a)
call SetUnitZ(projectile, GetUnitZ(caster) + 100.0)
call DisableUnitCollision(projectile)
call v.setLength(SWAP_PROJECTILE_SPEED)
call Object[projectile].applyVector(v)
call v.destroy()
set time = 0.00
set swapped = false
set link = AddLightningEx(SWAP_LIGHTNING_1_CODE, false, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 100.0, x, y, GetUnitZ(projectile))
call listAdd()
call start32()
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).caster) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
local trigger trig = CreateTrigger()
call RegisterSpellEffectEvent(SWAP_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
call TriggerAddCondition(trig, function thistype.derpy)
set inFrontOfGoal = CreateRegion()
call RegionAddRect(inFrontOfGoal, gg_rct_Goal_1_Front_Face)
call RegionAddRect(inFrontOfGoal, gg_rct_Goal_2_Front_Face)
call TriggerRegisterEnterRegion(trig, inFrontOfGoal, null)
set trig = null
endmethod
endstruct
endscope
scope Trickster initializer init
globals
private unit array keepCooldowns
private unit array kickCooldowns
endglobals
private function end takes nothing returns nothing
local integer i = 0
local Ball ball
loop
set ball = Ball.balls[i+1]
if ball != null then
call ball.destroy()
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endfunction
private function castBegin takes nothing returns nothing
local Ball ball = Ball.balls[0]
if ((GetSpellAbilityId() == TRICKSTER_KEEP_RAWCODE) or (GetSpellAbilityId() == TRICKSTER_KICK_RAWCODE)) /*
*/ and ((GetTriggerUnit() != ball.owner) or (not ball.hold)) then
call IssueImmediateOrder(GetTriggerUnit(), "stop")
endif
endfunction
private function refresh takes nothing returns nothing
local integer i = GetTimerData(GetExpiredTimer())
if keepCooldowns[i] == null then
set keepCooldowns[i] = CreateUnit(Player(i), TRICKSTER_COOLDOWN_KEEP_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
if kickCooldowns[i] == null then
set kickCooldowns[i] = CreateUnit(Player(i), TRICKSTER_COOLDOWN_KICK_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
endif
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes unit u, boolean keep, real targetX, real targetY returns nothing
local Ball ball = getBall(u)
local Ball fake = Ball.addFake(u)
set ball.nosteal = 10
if keep then
call ball.drop()
call fake.takeOwnership(u)
call fake.kick(targetX, targetY, KICK_SPEED, KICK_Z)
call ball.takeOwnership(u)
else
call ball.kick(targetX, targetY, KICK_SPEED, KICK_Z)
call fake.takeOwnership(u)
endif
set ball.nosteal = 0
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(u))), TRICKSTER_COOLDOWN, false, function refresh)
endfunction
private function castKeep takes nothing returns nothing
local unit u = GetTriggerUnit()
call RemoveUnit(kickCooldowns[GetPlayerId(GetOwningPlayer(u))])
set kickCooldowns[GetPlayerId(GetOwningPlayer(u))] = null
call cast(u, true, GetSpellTargetX(), GetSpellTargetY())
set u = null
endfunction
private function castKick takes nothing returns nothing
local unit u = GetTriggerUnit()
call RemoveUnit(keepCooldowns[GetPlayerId(GetOwningPlayer(u))])
set keepCooldowns[GetPlayerId(GetOwningPlayer(u))] = null
call cast(u, false, GetSpellTargetX(), GetSpellTargetY())
set u = null
endfunction
private function init takes nothing returns nothing
local integer i = 0
loop
exitwhen i == MAX_PLAYERS
set keepCooldowns[i] = CreateUnit(Player(i), TRICKSTER_COOLDOWN_KEEP_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set kickCooldowns[i] = CreateUnit(Player(i), TRICKSTER_COOLDOWN_KICK_RAWCODE, DUMMY_X, DUMMY_Y, 0.00)
set i = i + 1
endloop
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_SPELL_CHANNEL, function castBegin)
call RegisterSpellEffectEvent(TRICKSTER_KEEP_RAWCODE, function castKeep)
call RegisterSpellEffectEvent(TRICKSTER_KICK_RAWCODE, function castKick)
call RegisterEvent(function end, EVENT_FIELD_CLEARING)
endfunction
endscope
scope Tackle
struct Tackle
static thistype dis
unit u
real d = 0
implement ObjectList
method destroy takes nothing returns nothing
call EnableUnitCollision(u)
call SetUnitPropWindow(u, GetUnitDefaultPropWindow(u))
call stop32()
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.u, TACKLE_RAWCODE)
call UnitAddAbility(.u, TACKLE_RAWCODE)
endif
endmethod
static method tackle takes nothing returns boolean
local unit f = GetFilterUnit()
local Vector v
local real a
if f != dis.u and IsUnitType(f, UNIT_TYPE_PLAYER) then
set v = Vector.create(GetUnitX(f) - GetUnitX(dis.u), GetUnitY(f) - GetUnitY(dis.u), GetUnitZ(f) - GetUnitZ(dis.u))
if v.getLength() <= TACKLE_AOE then
if GetUnitAbilityLevel(f, TACKLE_SLOW_BUFF_RAWCODE) == 0 and IsUnitEnemy(dis.u, GetOwningPlayer(f)) then
call dummyCast(f, TACKLE_SLOW_RAWCODE, "cripple")
endif
set a = GetUnitFacing(dis.u)*bj_DEGTORAD
if (Acos(Cos(a - Atan2(v.y, v.x)))*bj_RADTODEG <= 32.0) and (v.getLength() <= 140.0) then
set tempBoolean = true
call v.setLength(TACKLE_PUSH_FORCE)
call Object[f].applyVector(v)
set v.x = TACKLE_PUSH_FORCE/2.00*Cos(a)
set v.y = TACKLE_PUSH_FORCE/2.00*Sin(a)
set v.z = 0.00
call Object[dis.u].applyVector(v)
endif
endif
call v.destroy()
endif
set f = null
return false
endmethod
static method removeShadow takes nothing returns nothing
call RemoveUnit(GetUnitById(GetTimerData(GetExpiredTimer())))
call ReleaseTimer(GetExpiredTimer())
endmethod
static method slowShadow takes nothing returns nothing
call SetUnitTimeScale(GetUnitById(GetTimerData(GetExpiredTimer())), 0.30)
call ReleaseTimer(GetExpiredTimer())
endmethod
method iterate32 takes nothing returns nothing
local real a = GetUnitFacing(u)
local unit s = CreateUnit(GetOwningPlayer(u), TACKLE_SHADOW_RAWCODE, GetUnitX(u), GetUnitY(u), a)
local real x = GetUnitX(u) + TACKLE_SPEED*Cos(a*bj_DEGTORAD)
local real y = GetUnitY(u) + TACKLE_SPEED*Sin(a*bj_DEGTORAD)
call SetUnitZ(s, GetUnitZ(u))
call SetUnitTimeScale(s, 4.00)
call SetUnitAnimation(s, "attack")
call Alpha.create(s, 127, -3, false).setColor(155, 155, 255)
call TimerStart(NewTimerEx(GetUnitId(s)), 1.40, false, function thistype.removeShadow)
call TimerStart(NewTimerEx(GetUnitId(s)), 0.10, false, function thistype.slowShadow)
if IsPointInRegion(playable, x, y) and IsTerrainWalkable(x, y) then
call Object[u].setX(x)
call Object[u].setY(y)
else
set x = GetUnitX(u)
set y = GetUnitY(u)
if not IsPointInRegion(playable, x, y) or not IsTerrainWalkable(x, y) then
call SetUnitPosition(u, x, y)
endif
endif
set tempBoolean = false
set dis = this
call GroupEnumUnitsInRange(enumGroup, GetUnitX(u), GetUnitY(u), TACKLE_AOE, Filter(function thistype.tackle))
set d = d + TACKLE_SPEED
if d >= TACKLE_RANGE or tempBoolean then
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
set Metamorph.Reptillians[GetUnitId(u)].delay = Metamorph.Reptillians[GetUnitId(u)].time
endif
call destroy()
endif
endmethod
implement II32
static method cast takes nothing returns nothing
local thistype this = thistype.create()
set u = GetTriggerUnit()
call DisableUnitCollision(u)
call SetUnitPropWindow(u, 0.00)
call listAdd()
call start32()
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).u) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent(TACKLE_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
scope Possess initializer init
globals
private unit controller = null
private real targetX
private real targetY
private boolean jumpDue = false
private unit flag = null
private timer groundTimer = null
private timer selectTimer = null
private timer endTimer = null
private boolean array ejecting
private boolean array jumpOnCooldown
endglobals
private function endEjection takes nothing returns nothing
set ejecting[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function eject takes nothing returns nothing
local Ball ball = Ball.balls[0]
local real a
local real minZ
local real maxZ
local Vector v
if controller != null then
call DestroyEffect(AddSpecialEffectZ(POSSESS_EJECT_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball)))
call SetUnitPropWindow(controller, GetUnitDefaultPropWindow(controller))
call Object[controller].setX(GetUnitX(ball.ball))
call Object[controller].setY(GetUnitY(ball.ball))
call Object[controller].setZ(GetUnitZ(ball.ball))
set a = GetRandomReal(0.00, 2*bj_PI)
set minZ = Tan(bj_DEGTORAD*30.0)
set maxZ = Tan(bj_DEGTORAD*60.0) - minZ
set v = Vector.create(Cos(a), Sin(a), GetRandomReal(minZ, maxZ))
call v.setLength(POSSESS_EJECT_MAGNITUDE)
call Object[controller].applyVector(v)
call v.destroy()
set ejecting[GetUnitId(controller)] = true
call TimerStart(NewTimerEx(GetUnitId(controller)), 1.00, false, function endEjection)
if jumpDue then
set jumpDue = false
call PauseTimer(groundTimer)
call SetUnitX(flag, DUMMY_X)
call SetUnitY(flag, DUMMY_Y)
endif
call PauseTimer(selectTimer)
call PauseTimer(endTimer)
set controller = null
endif
endfunction
private function end takes nothing returns nothing
if controller != null then
call eject()
endif
endfunction
private function selectWisp takes nothing returns nothing
if (controller != null) and (GetLocalPlayer() == GetOwningPlayer(controller)) and (not IsUnitSelected(controller, GetLocalPlayer())) then
call ClearSelection()
call SelectUnit(controller, true)
endif
endfunction
private function stopSprint takes nothing returns nothing
call IssueImmediateOrder(GetUnitById(GetTimerData(GetExpiredTimer())), "unimmolation")
call ReleaseTimer(GetExpiredTimer())
endfunction
function takeControl takes unit wisp returns nothing
local Ball ball = Ball.balls[0]
call Object[wisp].setX(DUMMY_X)
call Object[wisp].setY(DUMMY_Y)
call SetUnitFlyHeight(wisp, 0.00, 0.00)
call Object[wisp].velocity.setLength(0.00)
call SetUnitPropWindow(wisp, 0.00)
call SetUnitColor(flag, GetPlayerColor(GetOwningPlayer(wisp)))
if GetLocalPlayer() == GetOwningPlayer(wisp) then
call SetUnitVertexColor(flag, 255, 255, 255, 255)
else
call SetUnitVertexColor(flag, 255, 255, 255, 0)
endif
if controller != null then
call eject()
endif
set controller = wisp
if not ball.hold then
set ball.owner = wisp
endif
call TimerStart(NewTimerEx(GetUnitId(wisp)), 0.10, false, function stopSprint)
call TimerStart(selectTimer, 0.10, true, function selectWisp)
call TimerStart(endTimer, POSSESS_DURATION, false, function end)
endfunction
private function resetCooldown takes nothing returns nothing
set jumpOnCooldown[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function jump takes nothing returns nothing
local Ball ball = Ball.balls[0]
local real s = POSSESS_JUMP_SPEED*Cos(POSSESS_JUMP_ANGLE)
local real a = Atan2(targetY - GetUnitY(ball.ball), targetX - GetUnitX(ball.ball))
local Vector v
if ball.vel.getLength() <= POSSESS_JUMP_VELOCITY_REDUCTION then
call ball.vel.setLength(0.00)
else
call ball.vel.setLength(ball.vel.getLength() - POSSESS_JUMP_VELOCITY_REDUCTION)
endif
set ball.owner = controller
set v = Vector.create(s*Cos(a), s*Sin(a), POSSESS_JUMP_SPEED*Sin(POSSESS_JUMP_ANGLE))
call ball.applyVector(v)
call v.destroy()
set jumpOnCooldown[GetUnitId(controller)] = true
call TimerStart(NewTimerEx(GetUnitId(controller)), 0.20, false, function resetCooldown)
if jumpDue then
set jumpDue = false
call PauseTimer(groundTimer)
call SetUnitX(flag, DUMMY_X)
call SetUnitY(flag, DUMMY_Y)
endif
endfunction
private function jumpCheck takes nothing returns boolean
local Ball ball = Ball.balls[0]
local real flyHeight = GetUnitFlyHeight(ball.ball)
local boolean ballHold = ball.hold
return (not jumpOnCooldown[GetUnitId(controller)]) and (flyHeight <= 1.00) and (not ballHold)
endfunction
private function groundCheck takes nothing returns nothing
if jumpCheck() then
call jump()
endif
endfunction
private function order takes nothing returns nothing
local unit u = GetTriggerUnit()
if (u == controller) and /*
*/ ((GetIssuedOrderId() == OrderId("smart")) or (GetIssuedOrderId() == OrderId("move"))) then
if GetOrderTarget() == null then
set targetX = GetOrderPointX()
set targetY = GetOrderPointY()
else
set targetX = GetWidgetX(GetOrderTarget())
set targetY = GetWidgetY(GetOrderTarget())
endif
if jumpCheck() then
call jump()
else
if not jumpDue then
set jumpDue = true
call TimerStart(groundTimer, 0.031250, true, function groundCheck)
endif
call SetUnitX(flag, targetX)
call SetUnitY(flag, targetY)
endif
endif
set u = null
endfunction
private function onPlayerClearing takes nothing returns nothing
if (controller != null) and (GetOwningPlayer(controller) == GetClearingPlayer()) then
call eject()
endif
endfunction
private function onEncounter takes nothing returns nothing
local Ball ball = Ball.balls[0]
if ejecting[GetUnitId(ball.encounterer)] then
set ball.keep = false
endif
endfunction
struct Flight
static thistype array flights
unit wisp
integer iterations
Vector direction
real scale
method destroy takes nothing returns nothing
call stop32()
call direction.destroy()
call deallocate()
endmethod
method end takes nothing returns nothing
call SetUnitScale(wisp, PARCH_NINE_TIE_SCALE, PARCH_NINE_TIE_SCALE, PARCH_NINE_TIE_SCALE)
call SetUnitPropWindow(wisp, GetUnitDefaultPropWindow(wisp))
call EnableUnitCollision(wisp)
set flights[GetUnitId(wisp)] = 0
call destroy()
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
set direction.x = GetUnitX(ball.ball) - GetUnitX(wisp)
set direction.y = GetUnitY(ball.ball) - GetUnitY(wisp)
set direction.z = GetUnitZ(ball.ball) - GetUnitZ(wisp)
call direction.setLength(direction.getLength()/iterations)
call Object[wisp].setX(GetUnitX(wisp) + direction.x)
call Object[wisp].setY(GetUnitY(wisp) + direction.y)
call Object[wisp].setZ(GetUnitZ(wisp) + direction.z)
set scale = scale - (scale - 0.50)/iterations
call SetUnitScale(wisp, scale, scale, scale)
set iterations = iterations - 1
if iterations == 0 then
call end()
call DestroyEffect(AddSpecialEffectZ(POSSESS_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball)))
call takeControl(wisp)
endif
endmethod
implement II32
static method create takes unit u, integer iter returns thistype
local thistype this
if GetUnitTypeId(u) == PARCH_NINE_TIE_RAWCODE then
set this = thistype.allocate()
set wisp = u
set iterations = iter
if iterations == 0 then
set iterations = 1
endif
set direction = Vector.create(0.00, 0.00, 0.00)
set scale = PARCH_NINE_TIE_SCALE
call SetUnitPropWindow(wisp, 0.00)
call DisableUnitCollision(wisp)
set flights[GetUnitId(wisp)] = this
call start32()
call iterate32()
endif
return 0
endmethod
static method onPlayerClearing takes nothing returns nothing
local thistype this = flights[GetUnitId(GetPlayerUnit(GetClearingPlayer()))]
if this != 0 then
call end()
endif
endmethod
static method onEncounter takes nothing returns nothing
local Ball ball = Ball.balls[0]
if flights[GetUnitId(ball.encounterer)] != 0 then
set ball.keep = false
endif
endmethod
static method onInit takes nothing returns nothing
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
call RegisterEvent(function thistype.onEncounter, EVENT_BALL_ENCOUNTER)
endmethod
endstruct
private function cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
if (ball.hold) and (ball.owner == u) and (not IsUnitDisabled(u)) then
call Flight.create(u, R2I(BALL_KEEP_RANGE/POSSESS_SPEED + 0.900))
call ball.drop()
else
call UnitRemoveAbility(u, POSSESS_RAWCODE)
call UnitAddAbility(u, POSSESS_RAWCODE)
endif
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(POSSESS_RAWCODE, function cast)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function order)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, function order)
call RegisterEvent(function onPlayerClearing, EVENT_PLAYER_CLEARING)
call RegisterEvent(function onEncounter, EVENT_BALL_ENCOUNTER)
set flag = CreateUnit(Player(0), POSSESS_FLAG_RAWCODE, DUMMY_X, DUMMY_Y, 270.0)
set groundTimer = CreateTimer()
set selectTimer = CreateTimer()
set endTimer = CreateTimer()
endfunction
endscope
scope Powerdash
struct Powerdash
static thistype dis
unit u
real d = 0
Vector v
implement ObjectList
method destroy takes nothing returns nothing
call stop32()
call listRemove()
call deallocate()
if practiceMode then
call UnitRemoveAbility(.u, POWERDASH_RAWCODE)
call UnitAddAbility(.u, POWERDASH_RAWCODE)
endif
endmethod
method iterate32 takes nothing returns nothing
local real a = GetUnitFacing(u)
local real x = GetUnitX(u) + v.x
local real y = GetUnitY(u) + v.y
call Sfx(POWERDASH_SFX_PATH, GetUnitX(u), GetUnitY(u), GetUnitZ(u), 0.00, 90.0, 0.67)
if IsPointInRegion(playable, x, y) and IsTerrainWalkable(x, y) then
call Object[u].setX(x)
call Object[u].setY(y)
else
set x = GetUnitX(u)
set y = GetUnitY(u)
if not IsPointInRegion(playable, x, y) or not IsTerrainWalkable(x, y) then
call SetUnitPosition(u, x, y)
endif
endif
set tempBoolean = false
set dis = this
set d = d + POWERDASH_SPEED
if d >= POWERDASH_RANGE or tempBoolean then
call destroy()
endif
endmethod
implement II32
static method cast takes nothing returns nothing
local thistype this = thistype.create()
set u = GetTriggerUnit()
set v = Vector.create(GetSpellTargetX() - GetUnitX(u), GetSpellTargetY() - GetUnitY(u), 0)
call v.setLength(POWERDASH_SPEED)
call DisableUnitCollision(u)
call listAdd()
call start32()
endmethod
static method onPlayerClearing takes nothing returns nothing
local player p = GetClearingPlayer()
local Node head = list.head
local Node node = head.next
loop
exitwhen node == head
if GetOwningPlayer(thistype(node.data).u) == p then
call thistype(node.data).destroy()
endif
set node = node.next
endloop
set p = null
endmethod
static method onInit takes nothing returns nothing
//call RegisterSpellEffectEvent(POWERDASH_RAWCODE, function thistype.cast)
//call RegisterSpellEffectEvent('A01F', function thistype.cast)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
endmethod
endstruct
endscope
//TESH.scrollpos=119
//TESH.alwaysfold=0
scope Powershot initializer init
globals
boolean pShotCharging = false
private timer PT = CreateTimer()
private boolean powershotON = false
private constant real c1 = BALL_FRICTION_GROUND
private constant real c2 = BALL_FRICTION_AIR
private constant real c3 = BALL_BUMP_SPEED_LOSS
private constant real c4 = BALL_FRICTION_ICE
private unit caster = null
private TextBar bar
private effect chargeSfx
private real targetX
private real targetY
private boolean derpstop
endglobals
private function endCharge takes nothing returns nothing
if pShotCharging then
call bar.destroy()
call DestroyEffect(chargeSfx)
call UnitRemoveAbility(caster, POWERSHOT_SLOW_BUFF_RAWCODE)
call SetUnitTurnSpeed(caster, 0.60)
call SetUnitPropWindow(caster, GetUnitDefaultPropWindow(caster))
//call DisableUnit(caster, false)
set pShotCharging = false
endif
endfunction
private function cancelCharge takes nothing returns nothing
if pShotCharging then
call endCharge()
call PauseTimer(PT)
endif
endfunction
private function ballTaken takes nothing returns boolean
local Ball ball = Ball.balls[0]
local Vector v
if powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
if ball.hold then
set v = Vector.create(ball.vel.x, ball.vel.y, ball.vel.z)
call v.setLength(v.getLength()*POWERSHOT_BLAST_FACTOR)
call Object[ball.owner].applyVector(v)
call v.destroy()
call Sfx(POWERSHOT_BLAST_SFX_PATH, GetUnitX(ball.owner), GetUnitY(ball.owner), GetUnitZ(ball.owner), 0.00, 90.0, 0.70)
endif
elseif pShotCharging and ball.owner != caster then
call cancelCharge()
endif
return false
endfunction
private function visual takes nothing returns nothing
local Ball ball = Ball.balls[0]
if ball.vel.getLength() > 5.00 and not ball.hold then
call Sfx(POWERSHOT_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), 0.00, 90.0, 0.67)
elseif powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
endif
endfunction
private function finish takes nothing returns nothing
local Ball ball = Ball.balls[0]
if caster == ball.owner and ball.hold then
call ball.kick(targetX, targetY, POWERSHOT_SPEED, 0.00)
set BALL_FRICTION_GROUND = 0.02
set BALL_FRICTION_AIR = 0.02
set BALL_BUMP_SPEED_LOSS = 0.00
call TimerStart(PT, 0.03125, true, function visual)
set powershotON = true
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
call endCharge()
if practiceMode then
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
set caster = null
endfunction
private function animation takes nothing returns nothing
call SetUnitAnimationByIndex(GetUnitById(GetTimerData(GetExpiredTimer())), POWERSHOT_ANIMATION_INDEX)
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
if GetTriggerUnit() == ball.owner and ball.hold then
call cancelCharge()
set caster = GetTriggerUnit()
set targetX = GetSpellTargetX()
set targetY = GetSpellTargetY()
call TimerStart(NewTimerEx(GetUnitId(caster)), 0.00, false, function animation)
set bar = TextBar.create(POWERSHOT_CHARGE_TIME, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 150.0, "|c00FF0000")
set chargeSfx = AddSpecialEffectTarget(POWERSHOT_CHARGE_SFX_PATH, caster, "overhead")
call dummyCast(caster, POWERSHOT_DISABLE_RAWCODE, POWERSHOT_SLOW_ORDER)
call SetUnitTurnSpeed(caster, 0.00)
call SetUnitPropWindow(caster, 0.00)
set pShotCharging = true
call TimerStart(PT, POWERSHOT_CHARGE_TIME, false, function finish)
//call DisableUnit(caster, true)
else
call UnitRemoveAbility(GetTriggerUnit(), POWERSHOT_RAWCODE)
call UnitAddAbility(GetTriggerUnit(), POWERSHOT_RAWCODE)
endif
endfunction
private function onFieldClearing takes nothing returns nothing
if powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
endif
endfunction
private function onPlayerClearing takes nothing returns nothing
local Ball ball = Ball.balls[0]
if pShotCharging and ball.hold and ball.owner == GetPlayerUnit(GetClearingPlayer()) then
call cancelCharge()
endif
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(POWERSHOT_RAWCODE, function cast)
call RegisterEvent(function ballTaken, EVENT_BALL_TAKE)
call RegisterEvent(function onFieldClearing, EVENT_FIELD_CLEARING)
call RegisterEvent(function onPlayerClearing, EVENT_PLAYER_CLEARING)
endfunction
endscope
scope Powershot initializer init
globals
private timer PT = CreateTimer()
boolean pShotCharging = false
private boolean powershotON = false
private constant real c1 = BALL_FRICTION_GROUND
private constant real c2 = BALL_FRICTION_AIR
private constant real c3 = BALL_BUMP_SPEED_LOSS
private constant real c4 = BALL_FRICTION_ICE
private unit caster = null
private TextBar bar
private effect chargeSfx
private real targetX
private real targetY
private boolean array canSlow
private boolean derpstop
endglobals
private function endCharge takes nothing returns nothing
if pShotCharging then
call bar.destroy()
call DestroyEffect(chargeSfx)
call UnitRemoveAbility(caster, POWERSHOT_SLOW_BUFF_RAWCODE)
call SetUnitTurnSpeed(caster, 0.60)
//call DisableUnit(caster, false)
set pShotCharging = false
endif
endfunction
private function cancelCharge takes nothing returns nothing
if pShotCharging then
call endCharge()
call PauseTimer(PT)
endif
endfunction
private function ballTaken takes nothing returns boolean
local Ball ball = Ball.balls[0]
local Vector v
if powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
if ball.hold then
set v = Vector.create(ball.vel.x, ball.vel.y, ball.vel.z)
call v.setLength(v.getLength()*POWERSHOT_BLAST_FACTOR)
call Object[ball.owner].applyVector(v)
call v.destroy()
call Sfx(POWERSHOT_BLAST_SFX_PATH, GetUnitX(ball.owner), GetUnitY(ball.owner), GetUnitZ(ball.owner), 0.00, 90.0, 0.70)
endif
elseif pShotCharging and ball.owner != caster then
call cancelCharge()
endif
return false
endfunction
private function visual takes nothing returns nothing
local Ball ball = Ball.balls[0]
if ball.vel.getLength() > 5.00 and not ball.hold then
call Sfx(POWERSHOT_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), 0.00, 90.0, 0.67)
elseif powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
endif
endfunction
private function finish takes nothing returns nothing
local Ball ball = Ball.balls[0]
if caster == ball.owner and ball.hold then
call ball.kick(targetX, targetY, POWERSHOT_SPEED, 0.00)
set BALL_FRICTION_GROUND = 0.02
set BALL_FRICTION_AIR = 0.02
set BALL_BUMP_SPEED_LOSS = 0.00
call TimerStart(PT, 0.03125, true, function visual)
set powershotON = true
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
call endCharge()
if practiceMode then
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
set caster = null
endfunction
private function resetSlow takes nothing returns nothing
set canSlow[GetTimerData(GetExpiredTimer())] = true
call ReleaseTimer(GetExpiredTimer())
endfunction
private function slow takes nothing returns boolean
local unit f = GetFilterUnit()
if f != tempUnit and IsUnitType(f, UNIT_TYPE_PLAYER) then
call dummyCast(f, POWERSHOT_SLOW_RAWCODE, POWERSHOT_SLOW_ORDER)
endif
set f = null
return false
endfunction
private function animation takes nothing returns nothing
local unit u = GetUnitById(GetTimerData(GetExpiredTimer()))
if (GetUnitTypeId(u) == MANFUL_LOAF_RAWCODE) then
call SetUnitAnimationByIndex(u, METAMORPH_ANIMATION_INDEX)
else
call SetUnitAnimationByIndex(u, POWERSHOT_ANIMATION_INDEX)
endif
set u = null
call ReleaseTimer(GetExpiredTimer())
endfunction
private function stopCommandPowershot takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
local Vector v
if unitActive[GetPlayerId(GetOwningPlayer(u))] then
if pShotCharging and (ball.hold and ball.owner == u) then
if GetIssuedOrderId() == OrderId("stop") then
if not derpstop then
call cancelCharge()
endif
set derpstop = false
elseif GetIssuedOrderId() == OrderId("smart") then
set derpstop = true
call IssueImmediateOrder(caster, "stop")
endif
endif
endif
set u = null
endfunction
private function cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
if GetTriggerUnit() == ball.owner and ball.hold then
call cancelCharge()
set caster = GetTriggerUnit()
set targetX = GetSpellTargetX()
set targetY = GetSpellTargetY()
call TimerStart(NewTimerEx(GetUnitId(caster)), 0.00, false, function animation)
set bar = TextBar.create(POWERSHOT_CHARGE_TIME, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 150.0, "|c00FF0000")
set chargeSfx = AddSpecialEffectTarget(POWERSHOT_CHARGE_SFX_PATH, caster, "overhead")
set tempUnit = caster
call dummyCast(caster, POWERSHOT_DISABLE_RAWCODE, POWERSHOT_SLOW_ORDER)
call SetUnitTurnSpeed(caster, 0.00)
if canSlow[GetPlayerId(GetOwningPlayer(caster))] then
set canSlow[GetPlayerId(GetOwningPlayer(caster))] = false
call GroupEnumUnitsInRange(enumGroup, GetUnitX(caster), GetUnitY(caster), POWERSHOT_SLOW_AOE, Filter(function slow))
call TimerStart(NewTimerEx(GetPlayerId(GetOwningPlayer(caster))), POWERSHOT_SLOW_COOLDOWN, false, function resetSlow)
endif
set pShotCharging = true
call TimerStart(PT, POWERSHOT_CHARGE_TIME, false, function finish)
//call DisableUnit(caster, true)
else
call UnitRemoveAbility(GetTriggerUnit(), POWERSHOT_RAWCODE)
call UnitAddAbility(GetTriggerUnit(), POWERSHOT_RAWCODE)
endif
endfunction
private function onFieldClearing takes nothing returns nothing
if powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
endif
endfunction
private function onPlayerClearing takes nothing returns nothing
local Ball ball = Ball.balls[0]
if pShotCharging and ball.hold and ball.owner == GetPlayerUnit(GetClearingPlayer()) then
call cancelCharge()
endif
endfunction
private function init takes nothing returns nothing
local integer i = 0
loop
set canSlow[i] = true
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
call RegisterSpellEffectEvent(POWERSHOT_RAWCODE, function cast)
call RegisterEvent(function ballTaken, EVENT_BALL_TAKE)
call RegisterEvent(function onFieldClearing, EVENT_FIELD_CLEARING)
call RegisterEvent(function onPlayerClearing, EVENT_PLAYER_CLEARING)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function stopCommandPowershot)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function stopCommandPowershot)
endfunction
endscope
//TESH.scrollpos=170
//TESH.alwaysfold=0
scope Powershot
globals
private boolean powershotON = false
private constant real c1 = BALL_FRICTION_GROUND
private constant real c2 = BALL_FRICTION_AIR
private constant real c3 = BALL_BUMP_SPEED_LOSS
private constant real c4 = BALL_FRICTION_ICE
endglobals
private struct Powershot
static thistype array pshots
static integer active
private boolean charging
private unit caster
private TextBar bar
private effect chargeSfx
private real targetX
private real targetY
private boolean oneTimer
private boolean derpstop
private timer PT
private static method visual takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = getPowershotByTimer(GetExpiredTimer())
if ball.vel.getLength() > 5.00 and not ball.hold then
call Sfx(POWERSHOT_SFX_PATH, GetUnitX(ball.ball), GetUnitY(ball.ball), GetUnitZ(ball.ball), 0.00, 90.0, 0.67)
elseif powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
call ReleaseTimer(PT)
set powershotON = false
endif
endmethod
private method cancelCharge takes nothing returns nothing
if charging then
call endCharge()
call PauseTimer(PT)
endif
endmethod
private method endCharge takes nothing returns nothing
if charging then
call bar.destroy()
call DestroyEffect(chargeSfx)
call UnitRemoveAbility(caster, POWERSHOT_SLOW_BUFF_RAWCODE)
call SetUnitTurnSpeed(caster, 0.60)
//call DisableUnit(caster, false)
set charging = false
endif
call destroy()
endmethod
private static method animation takes nothing returns nothing
call SetUnitAnimationByIndex(GetUnitById(GetTimerData(GetExpiredTimer())), POWERSHOT_ANIMATION_INDEX)
call ReleaseTimer(GetExpiredTimer())
endmethod
private static method finish takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = pshots[active]
if caster == ball.owner and ball.hold then
call ball.kick(targetX, targetY, POWERSHOT_SPEED, 0.00)
set BALL_FRICTION_GROUND = 0.02
set BALL_FRICTION_AIR = 0.02
set BALL_BUMP_SPEED_LOSS = 0.00
call TimerStart(PT, 0.03125, true, function thistype.visual)
set powershotON = true
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
call endCharge()
if practiceMode then
call UnitRemoveAbility(caster, POWERSHOT_RAWCODE)
call UnitAddAbility(caster, POWERSHOT_RAWCODE)
endif
set caster = null
endmethod
private static method oneTimerCast takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = pshots[GetTimerData(GetExpiredTimer())]
if caster == ball.owner and ball.hold then
set active = GetTimerData(GetExpiredTimer())
call finish()
endif
set caster = null
endmethod
static method cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this = thistype.create()
set caster = GetTriggerUnit()
set targetX = GetSpellTargetX()
set targetY = GetSpellTargetY()
set pshots[GetPlayerId(GetOwningPlayer(caster))] = this
set PT = CreateTimer()
call cancelCharge()
call TimerStart(NewTimerEx(GetUnitId(caster)), 0.00, false, function thistype.animation)
set bar = TextBar.create(POWERSHOT_CHARGE_TIME, GetUnitX(caster), GetUnitY(caster), GetUnitZ(caster) + 150.0, "|c00FF0000")
set chargeSfx = AddSpecialEffectTarget(POWERSHOT_CHARGE_SFX_PATH, caster, "overhead")
call dummyCast(caster, POWERSHOT_DISABLE_RAWCODE, POWERSHOT_SLOW_ORDER)
call SetUnitTurnSpeed(caster, 0.00)
set charging = true
//call DisableUnit(caster, true)
if caster == ball.owner and ball.hold then
set oneTimer = false
call TimerStart(PT, POWERSHOT_CHARGE_TIME, false, function thistype.finish)
set active = GetPlayerId(GetOwningPlayer(caster))
else
set oneTimer = true
call TimerStart(PT, POWERSHOT_CHARGE_TIME, false, function thistype.oneTimerCast)
endif
endmethod
static method getPowershot takes unit u returns thistype
local integer i = 0
loop
if (pshots[i] != 0) then
if (u == pshots[i].caster) then
return Powershot.pshots[i]
endif
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
return 0
endmethod
static method getPowershotByTimer takes timer t returns thistype
local integer i = 0
loop
if (pshots[i] != 0) then
if (t == pshots[i].PT) then
return Powershot.pshots[i]
endif
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
return 0
endmethod
private static method ballTaken takes nothing returns boolean
local Ball ball = Ball.balls[0]
local thistype this
local Vector v
if powershotON then
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
if ball.hold then
set v = Vector.create(ball.vel.x, ball.vel.y, ball.vel.z)
call v.setLength(v.getLength()*POWERSHOT_BLAST_FACTOR)
call Object[ball.owner].applyVector(v)
call v.destroy()
call Sfx(POWERSHOT_BLAST_SFX_PATH, GetUnitX(ball.owner), GetUnitY(ball.owner), GetUnitZ(ball.owner), 0.00, 90.0, 0.70)
endif
else
set this = getPowershot(ball.owner)
if this != 0 then
if charging then
call cancelCharge()
endif
endif
endif
return false
endmethod
private static method onFieldClearing takes nothing returns nothing
local thistype this
if powershotON then
set this = pshots[active]
if (selection != 3 and selection != 4) then
set BALL_FRICTION_GROUND = c1
else
set BALL_FRICTION_GROUND = c4
endif
set BALL_FRICTION_AIR = c2
set BALL_BUMP_SPEED_LOSS = c3
call PauseTimer(PT)
set powershotON = false
endif
endmethod
private static method stopCommandPowershot takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
local thistype this = getPowershot(u)
local Vector v
if this != 0 then
if unitActive[GetPlayerId(GetOwningPlayer(u))] then
if charging and oneTimer and (ball.hold and ball.owner == u) then
if GetIssuedOrderId() == OrderId("stop") then
if not derpstop then
call cancelCharge()
endif
set derpstop = false
elseif GetIssuedOrderId() == OrderId("smart") then
set derpstop = true
call IssueImmediateOrder(caster, "stop")
endif
endif
endif
endif
set u = null
endmethod
private static method onPlayerClearing takes nothing returns nothing
local Ball ball = Ball.balls[0]
local thistype this
local integer i = 0
loop
set this = pshots[i]
if charging then
call cancelCharge()
endif
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endmethod
static method onInit takes nothing returns nothing
call RegisterEvent(function thistype.ballTaken, EVENT_BALL_TAKE)
call RegisterSpellEffectEvent(POWERSHOT_RAWCODE, function thistype.cast)
//call RegisterSpellEffectEvent(POWERSHOT_ONE_TIMER_RAWCODE, function thistype.cast)
call RegisterEvent(function thistype.onFieldClearing, EVENT_FIELD_CLEARING)
call RegisterEvent(function thistype.onPlayerClearing, EVENT_PLAYER_CLEARING)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.stopCommandPowershot)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, function thistype.stopCommandPowershot)
endmethod
endstruct
endscope
scope DivineEndurance
struct DivineEndurance
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, DIVINE_ENDURANCE_RAWCODE) > 0
endmethod
method onDestroy takes nothing returns nothing
local Ball ball = Ball.balls[0]
if (ball.hold and ball.owner == .me) then
call dummyCast(.me, BALL_SLOW_RAWCODE, "slow")
endif
call .stop32()
endmethod
method iterate32 takes nothing returns nothing
local Ball ball = Ball.balls[0]
call UnitRemoveAbility(.me, BALL_SLOW_BUFF_RAWCODE)
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
if (ball.hold and ball.owner == .me) then
call dummyCast(.me, BALL_SLOW_RAWCODE, "slow")
endif
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, DIVINE_ENDURANCE_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
call UnitRemoveAbility(u, BALL_SLOW_BUFF_RAWCODE)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, DIVINE_ENDURANCE_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
if (ball.hold and ball.owner == u) then
call dummyCast(u, BALL_SLOW_RAWCODE, "slow")
endif
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope Sprint
struct Sprint
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, SPRINT_RAWCODE) > 0
endmethod
method onDestroy takes nothing returns nothing
call .stop32()
endmethod
method iterate32 takes nothing returns nothing
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitMoveSpeed(.me, GetUnitDefaultMoveSpeed(.me))
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, SPRINT_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
call SetUnitMoveSpeed(u, SPRINT_NEW_SPEED)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, SPRINT_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u))
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope SuperSprint
struct SuperSprint
unit s
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, SUPER_SPRINT_RAWCODE) > 0
endmethod
method refreshCD takes unit u returns nothing
if practiceMode then
call UnitRemoveAbility(u, SUPER_SPRINT_RAWCODE)
call UnitAddAbility(u, SUPER_SPRINT_RAWCODE)
endif
endmethod
method onDestroy takes nothing returns nothing
call .stop32()
if GetUnitTypeId(.s) != 0 then
call RemoveUnit(.s)
endif
endmethod
method iterate32 takes nothing returns nothing
local Vector v = Vector.create(SUPER_SPRINT_ACCELERATION * Cos(GetUnitFacing(.me) * bj_DEGTORAD), SUPER_SPRINT_ACCELERATION * Sin(GetUnitFacing(.me) * bj_DEGTORAD), 0.00)
call Object[.me].applyVector(v)
call v.destroy()
if Object[.me].velocity.getLength()*128.00 >= 3.00*GetUnitDefaultMoveSpeed(.me) then
call SetUnitX(.s, GetUnitX(.me))
call SetUnitY(.s, GetUnitY(.me))
call SetUnitZ(.s, GetUnitZ(.me))
call SetUnitFacing(.s, GetUnitFacing(.me))
else
call IssueImmediateOrder(.me, "unimmolation")
call refreshCD(.me)
endif
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitMoveSpeed(.me, GetUnitDefaultMoveSpeed(.me))
call SetUnitPathing(.me, true)
call RemoveUnit(.s)
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
call refreshCD(.me)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local thistype this
local Vector v
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, SUPER_SPRINT_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
set this = thistype[u]
call SetUnitMoveSpeed(u, 20.0)
call SetUnitPathing(u, false)
set v = Vector.create(SUPER_SPRINT_PROPULSION * Cos(GetUnitFacing(u) * bj_DEGTORAD), SUPER_SPRINT_PROPULSION * Sin(GetUnitFacing(u) * bj_DEGTORAD), 0.00)
call Object[u].applyVector(v)
call v.destroy()
set .s = CreateUnit(GetOwningPlayer(u), SUPER_SPRINT_SHADOW_RAWCODE, GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
call SetUnitX(.s, GetUnitX(u))
call SetUnitY(.s, GetUnitY(u))
call SetUnitZ(.s, GetUnitZ(u))
call SetUnitVertexColor(.s, 255, 255, 255, 127)
call SetUnitTimeScale(.s, 4.00)
call SetUnitAnimationByIndex(.s, 8)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, SUPER_SPRINT_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
set this = thistype[u]
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u))
call SetUnitPathing(u, true)
call RemoveUnit(.s)
call refreshCD(u)
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope OgreTime
struct OgreTime
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, SMASH_OGRE_TIME_RAWCODE) > 0
endmethod
method refreshCD takes unit u returns nothing
if practiceMode then
call UnitRemoveAbility(u, SMASH_OGRE_TIME_RAWCODE)
call UnitAddAbility(u, SMASH_OGRE_TIME_RAWCODE)
endif
endmethod
method onDestroy takes nothing returns nothing
call .stop32()
endmethod
method iterate32 takes nothing returns nothing
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
call UnitRemoveAbility(.me, SMASH_OGRE_SPEED_BUFF_RAWCODE)
call SetUnitVertexColor(.me, 255, 255, 255, 255)
call refreshCD(.me)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local thistype this
local Vector v
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, SMASH_OGRE_TIME_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
set this = thistype[u]
call dummyCast(u, SMASH_OGRE_SPEED_RAWCODE, "bloodlust")
call SetUnitVertexColor(u, 255, 155, 155, 255)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, SMASH_OGRE_TIME_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
set this = thistype[u]
call UnitRemoveAbility(u, SMASH_OGRE_SPEED_BUFF_RAWCODE)
call SetUnitVertexColor(u, 255, 255, 255, 255)
call refreshCD(u)
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope StealthSprint
struct StealthSprint
real t
boolean stealth
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, STEALTH_SPRINT_RAWCODE) > 0
endmethod
method onDestroy takes nothing returns nothing
call .stop32()
endmethod
method iterate32 takes nothing returns nothing
set .t = .t - II32period
if .t <= -1.00 then
elseif .t <= 0.00 then
set .t = -1.00
call UnitAddAbility(.me, STEALTH_SPRINT_INVIS_RAWCODE)
endif
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitMoveSpeed(.me, GetUnitDefaultMoveSpeed(.me))
call UnitRemoveAbility(.me, STEALTH_SPRINT_INVIS_RAWCODE)
call Backflip.stealthSprint(.me, false)
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, STEALTH_SPRINT_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
set thistype[u].t = 1.00
call SetUnitMoveSpeed(u, STEALTH_SPRINT_NEW_SPEED)
call Backflip.stealthSprint(u, true)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, STEALTH_SPRINT_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u))
call UnitRemoveAbility(u, STEALTH_SPRINT_INVIS_RAWCODE)
call Backflip.stealthSprint(u, false)
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope WispSprint
struct WispSprint
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, WISP_SPRINT_RAWCODE) > 0
endmethod
method onDestroy takes nothing returns nothing
call .stop32()
endmethod
method iterate32 takes nothing returns nothing
if GetUnitState(.me, UNIT_STATE_MANA) < 1.00 and .stop32() then
call SetUnitMoveSpeed(.me, GetUnitDefaultMoveSpeed(.me))
call SetUnitState(.me, UNIT_STATE_MANA, 0.00)
endif
endmethod
implement AutoCreate
implement AutoDestroy
implement II32
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, WISP_SPRINT_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and thistype[u].start32() then
call SetUnitMoveSpeed(u, SPRINT_NEW_SPEED)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, WISP_SPRINT_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].stop32() then
call SetUnitMoveSpeed(u, GetUnitDefaultMoveSpeed(u))
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
endmethod
endstruct
endscope
scope FakeInjury initializer init
globals
private boolean array multipress
private timer array repeat
private timer array endAnimation
endglobals
private function resetMultipress takes nothing returns nothing
set multipress[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function resetAnimation takes nothing returns nothing
if (not multipress[GetTimerData(GetExpiredTimer())]) then
call SetUnitAnimation(GetUnitById(GetTimerData(GetExpiredTimer())), "stand")
endif
call ReleaseTimer(GetExpiredTimer())
endfunction
private function fakeInjury takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local Ball ball = Ball.balls[0]
if GetIssuedOrderId() == OrderId("stop") and IsUnitType(u, UNIT_TYPE_PLAYER) then
if multipress[GetUnitId(u)] and not(ball.hold and ball.owner == u) and fakeInjuryEnabled[GetPlayerId(p)] then
call SetUnitAnimation(u, "death")
if (GetUnitTypeId(u) == KARMA_GREEN_INN_RAWCODE) then
call TimerStart(NewTimerEx(GetUnitId(u)), 2.00, false, function resetAnimation)
elseif (GetUnitTypeId(u) == KARMIC_LIVID_LION_RAWCODE) then
call TimerStart(NewTimerEx(GetUnitId(u)), 1.00, false, function resetAnimation)
elseif (GetUnitTypeId(u) == PARCH_NINE_TIE_RAWCODE) then
call TimerStart(NewTimerEx(GetUnitId(u)), 1.00, false, function resetAnimation)
endif
endif
set multipress[GetUnitId(u)] = true
call TimerStart(NewTimerEx(GetUnitId(u)), 0.25, false, function resetMultipress)
endif
set u = null
set p = null
endfunction
private function init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function fakeInjury)
endfunction
endscope
scope Jump initializer init
globals
private boolean array onCooldown
private constant real intensityXY = Cos(JUMP_ANGLE)*JUMP_INTENSITY
private constant real intensityZ = JUMP_INTENSITY*Sin(JUMP_ANGLE)
private effect array sfx
private region array goalArea
private unit closestUnit
private real distance
private real X
private real Y
endglobals
private function checkUnits takes nothing returns boolean
local unit f = GetFilterUnit()
local real x = GetUnitX(f) - X
local real y = GetUnitY(f) - Y
local real d = SquareRoot(x*x + y*y)
if d < distance then
set closestUnit = f
set distance = d
endif
set f = null
return false
endfunction
private function isUnitGoalkeeper takes unit u returns boolean
local rect r1
local rect r2
local integer team = GetPlayerTeam(GetOwningPlayer(u))
if IsUnitInRegion(goalRegion[team], u) then
set closestUnit = null
set distance = 99999.0
if team == 0 then
set r1 = gg_rct_Goal_1_Area
set r2 = gg_rct_Goal_1_Front
else
set r1 = gg_rct_Goal_2_Area
set r2 = gg_rct_Goal_2_Front
endif
set X = (GetRectCenterX(r1) + GetRectCenterX(r2))/2.00
set Y = (GetRectCenterY(r1) + GetRectCenterY(r2))/2.00
call GroupEnumUnitsInRect(enumGroup, r1, Filter(function checkUnits))
call GroupEnumUnitsInRect(enumGroup, r2, Filter(function checkUnits))
set r1 = null
set r2 = null
if u == closestUnit then
return true
endif
endif
return false
endfunction
private function cooldownFinish takes nothing returns nothing
local timer t = GetExpiredTimer()
call SetUnitAnimation(GetUnitById(GetTimerData(t)), "stand")
call DestroyEffect(sfx[GetTimerData(t)])
set onCooldown[GetTimerData(t)] = false
call ReleaseTimer(t)
set t = null
endfunction
private function jump takes nothing returns nothing
local Ball ball = Ball.balls[0]
local unit u = GetTriggerUnit()
local real f
local Vector v
if GetIssuedOrderId() == OrderId("holdposition") and isUnitGoalkeeper(u) and (not (ball.hold and ball.owner == u)) and (not onCooldown[GetUnitId(u)]) then
set f = GetUnitFacing(u)*bj_DEGTORAD
set v = Vector.create(intensityXY*Cos(f), intensityXY*Sin(f), intensityZ)
call Object[u].applyVector(v)
call v.destroy()
if GetUnitTypeId(u) == MARZIPAN_USA_BRO_RAWCODE then
call SetUnitAnimation(u, "attack")
else
call SetUnitAnimation(u, "attack slam")
endif
set sfx[GetUnitId(u)] = AddSpecialEffect(JUMP_SFX_PATH, GetUnitX(u), GetUnitY(u))
set onCooldown[GetUnitId(u)] = true
call TimerStart(NewTimerEx(GetUnitId(u)), JUMP_COOLDOWN, false, function cooldownFinish)
endif
set u = null
endfunction
private function onFieldClearing takes nothing returns nothing
local integer i = 0
loop
set onCooldown[i] = false
set i = i + 1
exitwhen i == MAX_PLAYERS
endloop
endfunction
private function init takes nothing returns nothing
call RegisterEvent(function onFieldClearing, EVENT_GAME_SCORE)
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function jump)
endfunction
endscope
//TESH.scrollpos=24
//TESH.alwaysfold=0
scope Shout initializer init
globals
private integer array length
private string array letter
private timer array timers
private string array shouts
private integer array count
endglobals
private function expiration takes nothing returns nothing
set count[GetTimerData(GetExpiredTimer())] = 0
endfunction
private function together takes nothing returns nothing
call Play("war3mapImported\\death4 [High quality].mp3")
call ReleaseTimer(GetExpiredTimer())
endfunction
private function rage takes player p returns nothing
call dummyCast(GetPlayerUnit(p), SHOUT_ADRENALINE_RAWCODE, SHOUT_ADRENALINE_ORDER)
endfunction
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s = ""
local integer i
local integer n = 0
loop
set i = GetRandomInt(length[n], length[n+5])
loop
set s = s + letter[n]
set i = i - 1
exitwhen i == 0
endloop
set n = n + 1
exitwhen n == 5
endloop
set s = s + "!"
call TextTag(EMOTE_COLOR_CODE+s, 0.0220, GetUnitX(u) - 180.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 3.00)
if (GetUnitPointValueByType(GetUnitTypeId(u)) == 0) then // Female
call Play(shouts[3])
elseif (GetUnitPointValueByType(GetUnitTypeId(u)) == 1) then // Male
call Play(shouts[GetRandomInt(0,2)])
else // Neutral
call Play(shouts[GetRandomInt(0,3)])
endif
set i = GetPlayerTeam(GetOwningPlayer(u))
call PauseTimer(timers[i])
set count[i] = count[i] + 1
if count[i] == GetTeamPlayerCount(i) then
call TimerStart(NewTimer(), 2.00, false, function together)
set count[i] = 0
call IteratePlayersByTeam(rage, i)
else
call TimerStart(timers[i], 4.50, false, function expiration)
endif
set u = null
endfunction
private function init takes nothing returns nothing
set letter[0] = "D"
set length[0] = 2
set length[5] = 4
set letter[1] = "E"
set length[1] = 6
set length[6] = 10
set letter[2] = "A"
set length[2] = 6
set length[7] = 10
set letter[3] = "T"
set length[3] = 2
set length[8] = 4
set letter[4] = "H"
set length[4] = 2
set length[9] = 4
set shouts[0] = "war3mapImported\\death1 [High quality].mp3"
set shouts[1] = "war3mapImported\\death2 [High quality].mp3"
set shouts[2] = "war3mapImported\\death3 [High quality].mp3"
set shouts[3] = "war3mapImported\\death5 [High quality].mp3"
call InitSound("war3mapImported\\death1 [High quality].mp3")
call InitSound("war3mapImported\\death2 [High quality].mp3")
call InitSound("war3mapImported\\death3 [High quality].mp3")
call InitSound("war3mapImported\\death4 [High quality].mp3")
call InitSound("war3mapImported\\death5 [High quality].mp3")
set timers[0] = NewTimerEx(0)
set timers[1] = NewTimerEx(1)
call RegisterSpellEffectEvent(SHOUT_RAWCODE, function cast)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope PassMe initializer init
globals
private boolean array onCooldown
endglobals
private function cooldownFinish takes nothing returns nothing
set onCooldown[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local string s
if GetIssuedOrderId() == OrderId(PASS_ME_ORDER_STRING) and GetUnitAbilityLevel(u, PASS_ME_RAWCODE) > 0 and not onCooldown[GetUnitId(u)] then
if IsUnitAlly(u, GetLocalPlayer()) then
call TextTag(EMOTE_COLOR_CODE+"Pass me!", 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 3.00)
call PingMinimapEx(GetUnitX(u), GetUnitY(u), 1.00, 100, 100, 100, false)
set s = "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl"
else
set s = ""
endif
call DestroyEffect(AddSpecialEffectTarget(s, u, "overhead"))
set onCooldown[GetUnitId(u)] = true
call TimerStart(NewTimerEx(GetUnitId(u)), PASS_ME_COOLDOWN, false, function cooldownFinish)
endif
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function cast)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope Emotes initializer init
globals
private string array taunts
private boolean array tauntOnCooldown
private string array sadfaces
private boolean array sadfaceOnCooldown
endglobals
private function tauntCooldownFinish takes nothing returns nothing
set tauntOnCooldown[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function sadfaceCooldownFinish takes nothing returns nothing
set sadfaceOnCooldown[GetTimerData(GetExpiredTimer())] = false
call ReleaseTimer(GetExpiredTimer())
endfunction
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
if GetIssuedOrderId() == OrderId(TAUNT_ORDER) and GetUnitAbilityLevel(u, TAUNT_RAWCODE) > 0 and not tauntOnCooldown[GetUnitId(u)] then
call TextTag(EMOTE_COLOR_CODE+taunts[GetRandomInt(0, 10)], 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 3.00)
set tauntOnCooldown[GetUnitId(u)] = true
call TimerStart(NewTimerEx(GetUnitId(u)), TAUNT_COOLDOWN, false, function tauntCooldownFinish)
elseif (GetIssuedOrderId() == OrderId(SADFACE_ORDER_1) or GetIssuedOrderId() == OrderId(SADFACE_ORDER_2)) and GetUnitAbilityLevel(u, SADFACE_RAWCODE) > 0 and not sadfaceOnCooldown[GetUnitId(u)] then
call TextTag(EMOTE_COLOR_CODE+sadfaces[GetRandomInt(0, 10)], 0.0220, GetUnitX(u) - 40.0, GetUnitY(u), GetUnitZ(u) + EMOTE_Z_OFFSET, 3.00)
set sadfaceOnCooldown[GetUnitId(u)] = true
call TimerStart(NewTimerEx(GetUnitId(u)), SADFACE_COOLDOWN, false, function sadfaceCooldownFinish)
endif
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function cast)
set taunts[0] = "lololo"
set taunts[1] = "u wot m8"
set taunts[2] = ">:D"
set taunts[3] = "\\o/"
set taunts[4] = "deal with it"
set taunts[5] = "mad?"
set taunts[6] = "mwahahaha"
set taunts[7] = ":]"
set taunts[8] = ":DDD"
set taunts[9] = ":J"
set taunts[10] = ":3"
set sadfaces[0] = "QQ"
set sadfaces[1] = ":("
set sadfaces[2] = ":C"
set sadfaces[3] = "fffuuu"
set sadfaces[4] = ":<"
set sadfaces[5] = ":["
set sadfaces[6] = ":/"
set sadfaces[7] = ":\\"
set sadfaces[8] = ":S"
set sadfaces[9] = ":L"
set sadfaces[10] = "._."
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope RideHorse initializer init
private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local Vector v = Vector.create(currentField.centerX - GetUnitX(u), currentField.centerY - GetUnitY(u), 0.00)
call v.setLength(60.0)
set v.z = 36.00
call Object[u].applyVector(v)
call v.destroy()
set u = null
endfunction
private function init takes nothing returns nothing
call RegisterSpellEffectEvent(RIDE_HORSE_RAWCODE, function cast)
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope HorseDance
private struct Dance extends array
static integer count = 0
integer animIndex
real period
static method create takes integer ai, real p returns thistype
set count = count + 1
set thistype[count].animIndex = ai
set thistype[count].period = p
return count
endmethod
endstruct
struct HorseDance
boolean enabled = false
integer animIndex
timer rythm
static method createFilter takes unit u returns boolean
return GetUnitAbilityLevel(u, HORSE_DANCE_RAWCODE) > 0
endmethod
method onCreate takes nothing returns nothing
set rythm = NewTimerEx(this)
endmethod
method onDestroy takes nothing returns nothing
call PauseTimer(rythm)
call DestroyTimer(rythm)
endmethod
static method dance takes nothing returns nothing
local thistype this = GetTimerData(GetExpiredTimer())
call SetUnitAnimationByIndex(me, animIndex)
endmethod
implement AutoCreate
implement AutoDestroy
static method cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i
local thistype this
if GetIssuedOrderId() == OrderId("immolation") and GetUnitAbilityLevel(u, HORSE_DANCE_RAWCODE) > 0 and not IsUnitDisabled(u) and IsUnitIndexed(u) and not thistype[u].enabled then
set this = thistype[u]
set enabled = true
set i = GetRandomInt(1, Dance.count)
set animIndex = Dance[i].animIndex
call SetUnitAnimationByIndex(u, animIndex)
call TimerStart(rythm, Dance[i].period, true, function thistype.dance)
elseif GetIssuedOrderId() == OrderId("unimmolation") and GetUnitAbilityLevel(u, HORSE_DANCE_RAWCODE) > 0 and IsUnitIndexed(u) and thistype[u].enabled then
set this = thistype[u]
set enabled = false
call SetUnitAnimation(u, "stand")
call PauseTimer(rythm)
endif
set u = null
endmethod
static method onInit takes nothing returns nothing
call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_ISSUED_ORDER, function thistype.cast)
call Dance.create(5, 0.450)
call Dance.create(6, 0.500)
call Dance.create(11, 0.450)
call Dance.create(12, 1.850)
endmethod
endstruct
endscope