if CTHTDGameMode == nil then
	CTHTDGameMode = class({})
end

require( "util")
require( "common")
-- require( "component/timers")
require( "system/service")
require( "system/spawner")
require( "system/items")
require( "system/tower")
require( "system/damage")
require( "system/custom_event")
require( "system/combo")
require( "system/ai")
require( "trigger/PassCorner")
-- require( "cosmetic_abilities")

function Precache( context )

	PrecacheEveryThingFromKV( context )

	PrecacheResource( "particle", "particles/econ/events/ti6/hero_levelup_ti6_godray.vpcf",context )
	PrecacheResource( "particle", "particles/thtd/msg/thtd_msg_level.vpcf",context )
	PrecacheResource( "particle", "particles/thtd/msg/thtd_msg_star.vpcf",context )
	PrecacheResource( "particle", "particles/thtd/msg/thtd_msg_food.vpcf",context )
	PrecacheResource( "particle", "particles/common/thtd_food_msg.vpcf",context )

	PrecacheResource( "particle_folder", "particles/portraits", context )

	PrecacheResource( "particle", "particles/heroes/lily/ability_lily_01_a.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lily/ability_lily_02.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_cirno/ability_cirno_02.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/letty/ability_letty_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/kogasa/ability_kogasa_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/kogasa/ability_kogasa_01_debuff.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lyrica/ability_lyrica_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lunasa/ability_lunasa_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lunasa/ability_lunasa_buff.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/merlin/ability_merlin_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/merlin/ability_merlin_buff.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/rumia/ability_rumia_02_projectile.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/satori/ability_satori_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/iku/ability_iku_lightning.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/iku/ability_iku_01_explosion.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_marisa/ability_marisa_02.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_marisa/ability_marisa_02_pink.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_marisa/ability_marisa_02_blue.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_marisa/ability_marisa_02_normal.vpcf",context )
	PrecacheResource( "particle", "particles/econ/items/earthshaker/egteam_set/hero_earthshaker_egset/earthshaker_echoslam_start_fallback_low_egset.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/tenshi/ability_tenshi_03.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_patchouli/ability_patchouli_01_agni_shine.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_patchouli/ability_patchouli_01_bury_in_lake.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_patchouli/ability_patchouli_01_mercury_poison.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_reisen/ability_reisen_03.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_yuyuko/ability_yuyuko_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_yuyuko/ability_yuyuko_04.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/thtd_youmu/ability_youmu_01_laser.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/youmu/youmu_02_effect_explosion.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/heroes/youmu/youmu_01_blink_effect.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/youmu/youmu_04_circle.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/heroes/youmu/youmu_04_sword_effect.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/rin/ability_rin_02_body_c.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/rin/ability_rin_01_projectile.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/rin/ability_rin_01.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/moluo/abiilty_moluo_014.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/heroes/utsuho/ability_utsuho03_effect.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lyrica/ability_lyrica_music_buff.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/lunasa/ability_lunasa_music_buff.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/merlin/ability_merlin_music_buff.vpcf",context )

	PrecacheResource( "particle", "particles/heroes/byakuren/ability_byakuren_02.vpcf",context )
	PrecacheResource( "particle", "particles/econ/items/lina/lina_ti6/lina_ti6_laguna_blade.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/items/item_yatagarasu.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/daiyousei/ability_daiyousei_02.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/cirno/ability_cirno_02.vpcf",context )	

	PrecacheResource( "particle", "particles/heroes/yumemi/ability_yumemi_04_exolosion.vpcf",context )	
	PrecacheResource( "particle", "particles/thd2/items/item_donation_box.vpcf",context )	
	PrecacheResource( "particle", "particles/thtd_item/ability_item_2022.vpcf",context )	

	PrecacheResource( "particle", "particles/thtd/emoji/thtd_msg_hongliange.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/environment/death/act_hero_die.vpcf",context )	

	-- bosses
	PrecacheResource( "particle", "particles/heroes/minoriko/ability_minoriko_04.vpcf",context )
	PrecacheResource( "particle", "particles/bosses/thtd_keine/ability_bosses_keine.vpcf",context )
	PrecacheResource( "particle", "particles/thd2/heroes/rumia/ability_rumia01_effect.vpcf",context )
	PrecacheResource( "particle", "particles/heroes/marisa/marisa_01_rocket_a.vpcf",context )

	-- 装饰技能
	PrecacheResource( "particle", "particles/econ/events/new_bloom/pig_cast.vpcf",context )
	PrecacheResource( "particle", "particles/econ/events/new_bloom/lion_dance_eyes_group.vpcf",context )
	PrecacheResource( "particle", "particles/econ/events/ti9/ti9_drums_musicnotes.vpcf",context )
	PrecacheResource( "particle", "particles/econ/events/snowball/snowball_projectile.vpcf",context )
	PrecacheResource( "particle", "particles/econ/events/snowman/snowman_projectile_explosion_c.vpcf",context )

	PrecacheResource( "particle", "particles/imagine_assets/courier_fx/courier_fx_2.vpcf",context )
	PrecacheResource( "particle", "particles/particles/imagine_assets/courier_fx/rainbow_tail.vpcf",context )

	PrecacheResource( "particle", "particles/econ/items/monkey_king/mk_ti9_immortal/mk_ti9_immortal_army_ring.vpcf",context )
	PrecacheResource( "particle", "particles/units/heroes/hero_omniknight/omniknight_purification.vpcf",context )

	PrecacheResource( "particle", "particles/econ/events/ti10/attack_modifier_ti10.vpcf",context )

	PrecacheResource( "particle", "particles/units/heroes/hero_monkey_king/monkey_king_quad_tap_stack.vpcf",context )

	-- sounds
	PrecacheResource( "soundfile",  "soundevents/game_sounds_custom.vsndevts", context)
	PrecacheResource( "soundfile", "soundevents/custom_game/ui.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/custom_game/store.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/game_sounds/thdots_tower_attack_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/game_sounds/thdots_tower_sound_voice.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/game_sounds/thdots_tower_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_alice_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_aya_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_cirno_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_flandre_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_iku_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_kaguya_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_kanako_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_koishi_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_marisa_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_minamitsu_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_momiji_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_nue_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_ran_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_reimu_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_reisen_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_remilia_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_sakuya_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_shikieiki_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_tenshi_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_utsuho_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_youmu_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_yukari_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_yumemi_sounds.vsndevts", context )
	PrecacheResource( "soundfile", "soundevents/thdots_hero_sounds/thdots_yuyuko_sounds.vsndevts", context )

	-- 信使
	local mxx={
		--以前的模型和特效
		"particles/units/heroes/hero_templar_assassin/templar_assassin_base_attack.vpcf",
		"particles/dev/library/base_dust_hit_smoke.vpcf",
		"particles/econ/events/fall_major_2016/teleport_start_fm06_lvl3.vpcf",
		"soundevents/soundevents_dota_ui.vsndevts",
		"particles/econ/events/snowball/snowball_projectile.vpcf",
		"particles/units/heroes/hero_venomancer/venomancer_base_attack.vpcf",
		"particles/neutral_fx/gnoll_poison_debuff.vpcf",
		"particles/units/heroes/hero_crystalmaiden/maiden_frostbite_buff.vpcf",
		"models/items/courier/teron/teron_flying.vmdl",
		"soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_zuus.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
		"particles/econ/items/zeus/arcana_chariot/zeus_arcana_thundergods_wrath_start.vpcf",
		"particles/econ/items/omniknight/hammer_ti6_immortal/omniknight_pu_ti6_heal_hammers.vpcf",
		"particles/econ/items/lina/lina_ti6/lina_ti6_laguna_blade.vpcf",
		"particles/units/heroes/hero_disruptor/disruptor_thunder_strike_bolt.vpcf",
		"particles/units/heroes/hero_keeper_of_the_light/keeper_chakra_magic.vpcf",
		"particles/units/heroes/hero_oracle/oracle_fatesedict.vpcf",
		"particles/econ/events/winter_major_2017/blink_dagger_end_wm07.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_antimage.vsndevts",
		"particles/units/heroes/hero_lina/lina_spell_light_strike_array.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",	
		"particles/units/heroes/hero_dazzle/dazzle_shallow_grave.vpcf",
		"particles/econ/items/axe/axe_cinder/axe_cinder_battle_hunger.vpcf",
		"particles/units/heroes/hero_rubick/rubick_spell_steal.vpcf",
		"models/items/courier/duskie/duskie.vmdl",
		"particles/units/heroes/hero_lone_druid/lone_druid_bear_entangle_body.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_lone_druid.vsndevts",
		"particles/items2_fx/tranquil_boots_healing.vpcf",
		"particles/units/heroes/hero_beastmaster/beastmaster_primal_roar.vpcf",
		"particles/units/heroes/hero_spirit_breaker/spirit_breaker_nether_strike_end.vpcf",
		"particles/units/heroes/hero_batrider/batrider_base_attack.vpcf",
		"particles/items_fx/healing_flask_c.vpcf",
		"particles/units/heroes/hero_skeletonking/wraith_king_spirits.vpcf",
		"particles/units/heroes/hero_phoenix/phoenix_supernova_scepter_f.vpcf",
		"particles/radiant_fx/good_barracks_ranged001_lvl3_disintegrate.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_vengefulspirit.vsndevts",
		"particles/units/heroes/hero_tinker/tinker_missile.vpcf",
		
		"soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",	
		"particles/units/heroes/hero_visage/visage_grave_chill_skel.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_invoker.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_rattletrap.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_sniper.vsndevts",
		"particles/econ/items/rubick/rubick_puppet_master/rubick_back_puppet_ambient_edge_c.vpcf",
		"particles/newplayer_fx/npx_sleeping.vpcf",
		"particles/generic_gameplay/generic_stunned_old.vpcf",
		"particles/econ/items/enchantress/enchantress_virgas/ench_impetus_virgas.vpcf",
		"particles/econ/items/alchemist/alchemist_smooth_criminal/alchemist_smooth_criminal_unstable_concoction_projectile_explosion_fire.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_phoenix.vsndevts",
		"particles/econ/items/shadow_fiend/sf_fire_arcana/sf_fire_arcana_shadowraze_char.vpcf",
		"particles/units/heroes/hero_tiny/tiny_loadout.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_tiny.vsndevts",
		"models/props_structures/tower_good.vmdl",
		"models/props_structures/tower_bad.vmdl",
		"particles/econ/items/sniper/sniper_immortal_cape/sniper_immortal_cape_headshot_slow_model.vpcf",
		"particles/customgames/capturepoints/cp_allied_wind.vpcf",
		"particles/customgames/capturepoints/cp_wood.vpcf",
		"models/items/courier/hermit_crab/hermit_crab.vmdl",
		"particles/econ/events/ti7/teleport_end_ti7_team1836806.vpcf",
		"particles/econ/items/sniper/sniper_immortal_cape/sniper_immortal_cape_headshot_slow_ring.vpcf",
		"particles/econ/items/clinkz/clinkz_maraxiform/clinkz_maraxiform_searing_arrow.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_dazzle.vsndevts",
		"particles/addons_gameplay/tower_good_tintable_lamp_end.vpcf",
		"particles/econ/events/ti7/teleport_end_ti7_model.vpcf",
		"particles/units/heroes/hero_shredder/shredder_whirling_death_spin_blades.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
		"particles/units/heroes/hero_lina/lina_base_attack.vpcf",
		"particles/units/heroes/hero_razor/razor_static_link_projectile_a.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
		"particles/econ/items/crystal_maiden/ti7_immortal_shoulder/cm_ti7_immortal_frostbite.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_earthshaker.vsndevts",
		"particles/econ/items/earthshaker/earthshaker_totem_ti6/earthshaker_totem_ti6_leap_impact.vpcf",
		"particles/units/heroes/hero_stormspirit/stormspirit_overload_discharge.vpcf",
		"particles/units/heroes/hero_sven/sven_spell_gods_strength_small.vpcf",
		"particles/units/heroes/hero_sven/sven_spell_gods_strength.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_bloodseeker.vsndevts",
		"particles/econ/items/bloodseeker/bloodseeker_eztzhok_weapon/bloodseeker_bloodbath_eztzhok_ribbon.vpcf",
		"particles/econ/items/slardar/slardar_takoyaki_gold/slardar_crush_tako_ground_dust_pyro_gold.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_death_prophet.vsndevts",
		"particles/dac/explode/land_mine_explode.vpcf",
		"particles/units/heroes/hero_dragon_knight/dragon_knight_transform_blue_smoke04.vpcf",
		"particles/econ/items/antimage/antimage_weapon_basher_ti5_gold/antimage_manavoid_explode_b_b_ti_5_gold.vpcf",
		"particles/dac/zhayaotong/zhayaotong.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_silencer.vsndevts",
		"particles/econ/items/bounty_hunter/bounty_hunter_hunters_hoard/bounty_hunter_hoard_shield_mark.vpcf",
		"particles/dac/ansha/loadout.vpcf",
		"particles/dac/jingzhixianjingplant_ground_disturb.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_techies.vsndevts",
		"particles/generic_gameplay/generic_stunned.vpcf",
		"particles/units/heroes/hero_techies/techies_stasis_trap_explode.vpcf",


		"particles/econ/items/ancient_apparition/aa_blast_ti_5/ancient_apparition_ice_blast_sphere_final_explosion_smoke_ti5.vpcf",
		"models/items/wards/eye_of_avernus_ward/eye_of_avernus_ward.vmdl",
		"models/props_structures/dire_ancient_base001_destruction.vmdl",
		"models/props_structures/radiant_ancient001_rock_destruction.vmdl",
		"models/creeps/lane_creeps/creep_radiant_melee/radiant_melee.vmdl",
		"models/creeps/lane_creeps/creep_bad_melee/creep_bad_melee.vmdl",
		"models/props_structures/radiant_ranged_barracks001.vmdl",
		"models/props_structures/dire_barracks_ranged001.vmdl",
		"models/props_structures/radiant_ancient001.vmdl",
		"models/props_structures/dire_ancient_base001.vmdl",
		"models/props_structures/dire_barracks_ranged001_destruction.vmdl",
		"models/props_structures/radiant_ranged_barracks001_destruction.vmdl",
		"effects/damage.vpcf",
		"effects/damage2.vpcf",
		"effects/damage3.vpcf",
		"particles/ui/ui_game_start_hero_spawn.vpcf",
		"particles/base_attacks/ranged_tower_bad_trail.vpcf",
		"particles/units/heroes/hero_warlock/warlock_fatal_bonds_base.vpcf",
		"particles/units/heroes/hero_tinker/tinker_laser.vpcf",
		"particles/units/heroes/hero_ursa/ursa_fury_swipes_debuff.vpcf",
		"soundevents/voscripts/game_sounds_vo_wisp.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_wisp.vsndevts",

		"soundevents/voscripts/game_sounds_vo_lina.vsndevts",
		"particles/econ/items/puck/puck_alliance_set/puck_dreamcoil_waves_aproset.vpcf",
		"particles/econ/items/drow/drow_ti6/drow_ti6_silence_wave_ground_smoke.vpcf",
		"materials/pumpkin.vmdl",
		"models/props_gameplay/boots_of_speed.vmdl",
		"models/props_gameplay/quelling_blade.vmdl",
		"models/props_gameplay/stout_shield.vmdl",
		"models/props_gameplay/tango.vmdl",
		"models/props_gameplay/smoke.vmdl",
		"models/props_gameplay/halloween_candy.vmdl",
		"models/props_gameplay/salve_red.vmdl",
		"models/props_gameplay/mango.vmdl",
		"models/props_gameplay/branch.vmdl",
		"particles/gem/sniper_crosshair.vpcf",
		"particles/radiant_fx/tower_good3_dest_beam.vpcf",
		"particles/units/heroes/hero_witchdoctor/witchdoctor_maledict_dot.vpcf",
		"soundevents/voscripts/game_sounds_vo_shredder.vsndevts",
		"soundevents/voscripts/game_sounds_vo_rattletrap.vsndevts",
		"soundevents/voscripts/game_sounds_vo_dragon_knight.vsndevts",
		"soundevents/voscripts/game_sounds_vo_death_prophet.vsndevts",
		"soundevents/voscripts/game_sounds_vo_tinker.vsndevts",
		"soundevents/voscripts/game_sounds_vo_lycan.vsndevts",
		"soundevents/voscripts/game_sounds_vo_ursa.vsndevts",
		"soundevents/voscripts/game_sounds_vo_enchantress.vsndevts",
		"soundevents/voscripts/game_sounds_vo_techies.vsndevts",
		"soundevents/voscripts/game_sounds_vo_tiny.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_shadowshaman.vsndevts",
		"soundevents/game_sounds.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lion.vsndevts",
		"soundevents/voscripts/game_sounds_vo_stormspirit.vsndevts",
		"soundevents/game_sounds_roshan_halloween.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lone_druid.vsndevts",
		"soundevents/voscripts/game_sounds_vo_doom_bringer.vsndevts",
		"soundevents/voscripts/game_sounds_vo_nyx_assassin.vsndevts",
		"particles/dev/library/base_dust_hit.vpcf",
		"particles/econ/events/fall_major_2016/radiant_fountain_regen_fm06_lvl3_ring.vpcf",

		--新的模型和特效
		"soundevents/game_sounds_heroes/game_sounds_lion.vsndevts",
		"particles/units/heroes/hero_shadowshaman/shadowshaman_voodoo.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_axe.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tusk.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_enchantress.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_juggernaut.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lycan.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_drowranger.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_razor.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_windrunner.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_kunkka.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_doombringer.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_troll_warlord.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_venomancer.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_gyrocopter.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_jakiro.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lich.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_queenofpain.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",
		"particles/units/heroes/hero_lycan/lycan_weapon_blur_b.vpcf",
		"particles/econ/items/necrolyte/necrophos_sullen/necro_sullen_pulse_enemy.vpcf",
		"particles/units/unit_greevil/loot_greevil_death.vpcf",	
		"soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_sandking.vsndevts",
		"particles/units/heroes/hero_omniknight/omniknight_purification.vpcf",
		"particles/dire_fx/bad_ancient002_destroy_fire.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_witchdoctor.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tusk.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_axe.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_enchantress.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_antimage.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_rattletrap.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_shadowshaman.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_bounty_hunter.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_witchdoctor.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_juggernaut.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lycan.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_phantom_assassin.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_puck.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_slardar.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_chaos_knight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_drowranger.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_razor.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_windrunner.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_sandking.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_abaddon.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_slark.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_sniper.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_kunkka.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_doombringer.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_troll_warlord.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_venomancer.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_necrolyte.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_templar_assassin.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_gyrocopter.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_lich.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_queenofpain.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_enigma.vsndevts",
		"models/props_gameplay/donkey.vmdl",
		"models/items/courier/bearzky/bearzky.vmdl",
		"models/items/courier/bajie_pig/bajie_pig.vmdl",
		"models/courier/mech_donkey/mech_donkey.vmdl",
		"models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl",
		"models/items/courier/baekho/baekho.vmdl",
		"models/items/courier/green_jade_dragon/green_jade_dragon.vmdl",
		"models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl",
		"models/items/courier/pw_zombie/pw_zombie.vmdl",
		"models/courier/drodo/drodo.vmdl",
		"models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl",
		"particles/generic_gameplay/rune_bounty_prespawn.vpcf",
		"particles/prime/hero_spawn_hero_level_2_base_ring.vpcf",
		"particles/econ/items/treant_protector/ti7_shoulder/treant_ti7_livingarmor_seedlings_parent.vpcf",
		"particles/econ/items/bloodseeker/bloodseeker_eztzhok_weapon/bloodseeker_bloodrage_ground_eztzhok_arc.vpcf",
		"particles/econ/items/treant_protector/ti7_shoulder/treant_ti7_crimson_livingarmor.vpcf",
		"particles/units/heroes/hero_puck/puck_base_attack_warmup.vpcf",
		"particles/units/heroes/hero_phantom_assassin/phantom_assassin_attack_blur_crit.vpcf",
		"particles/units/heroes/hero_lycan/lycan_weapon_blur_both.vpcf",
		"particles/units/heroes/hero_juggernaut/jugg_attack_blur.vpcf",
		"particles/econ/items/juggernaut/jugg_ti8_sword/juggernaut_ti8_sword_attack_b.vpcf",
		"particles/econ/items/juggernaut/jugg_ti8_sword/juggernaut_ti8_sword_attack_a.vpcf",
		"particles/units/heroes/hero_windrunner/wr_taunt_kiss.vpcf",
		"effect/big.vpcf",
		"effect/arrow/1.vpcf",
		"effect/arrow/2.vpcf",
		"effect/arrow/3.vpcf",
		"effect/arrow/4.vpcf",
		"effect/arrow/5.vpcf",
		"effect/arrow/star1.vpcf",
		"effect/arrow/star2.vpcf",
		"effect/arrow/star3.vpcf",
		"particles/error/error.vpcf",
		"particles/units/heroes/hero_chaos_knight/chaos_knight_weapon_blur.vpcf",
		"particles/units/heroes/hero_lycan/lycan_claw_blur.vpcf",
		"soundevents/voscripts/game_sounds_vo_tusk.vsndevts",
		"soundevents/voscripts/game_sounds_vo_crystalmaiden.vsndevts",
		'models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl',


		"particles/econ/items/templar_assassin/templar_assassin_focal/templar_assassin_meld_focal_attack_shockwave.vpcf",

		"models/props_gameplay/donkey.vmdl",
		"models/courier/skippy_parrot/skippy_parrot.vmdl",
		"models/courier/smeevil_mammoth/smeevil_mammoth.vmdl",
		"models/items/courier/arneyb_rabbit/arneyb_rabbit.vmdl",
		"models/items/courier/axolotl/axolotl.vmdl",
		"models/items/courier/coco_the_courageous/coco_the_courageous.vmdl",
		"models/items/courier/coral_furryfish/coral_furryfish.vmdl",
		"models/items/courier/corsair_ship/corsair_ship.vmdl",
		"models/items/courier/duskie/duskie.vmdl",
		"models/items/courier/itsy/itsy.vmdl",
		"models/items/courier/jumo/jumo.vmdl",
		"models/items/courier/mighty_chicken/mighty_chicken.vmdl",
		"models/items/courier/nexon_turtle_05_green/nexon_turtle_05_green.vmdl",
		"models/items/courier/pumpkin_courier/pumpkin_courier.vmdl",
		"models/items/courier/pw_ostrich/pw_ostrich.vmdl",
		"models/items/courier/scuttling_scotty_penguin/scuttling_scotty_penguin.vmdl",
		"models/items/courier/shagbark/shagbark.vmdl",
		"models/items/courier/snaggletooth_red_panda/snaggletooth_red_panda.vmdl",
		"models/items/courier/snail/courier_snail.vmdl",
		"models/items/courier/teron/teron.vmdl",
		"models/items/courier/xianhe_stork/xianhe_stork.vmdl",
		"models/items/courier/starladder_grillhound/starladder_grillhound.vmdl",
		"models/items/courier/pw_zombie/pw_zombie.vmdl",
		"models/items/courier/raiq/raiq.vmdl",
		"models/courier/frog/frog.vmdl",
		"models/courier/godhorse/godhorse.vmdl",
		"models/courier/imp/imp.vmdl",
		"models/courier/mighty_boar/mighty_boar.vmdl",
		"models/items/courier/onibi_lvl_03/onibi_lvl_03.vmdl",
		"models/items/courier/echo_wisp/echo_wisp.vmdl",  --蠕行水母
		"models/courier/sw_donkey/sw_donkey.vmdl", --驴法师new
		"models/items/courier/gnomepig/gnomepig.vmdl", --丰臀公主new
		"models/items/furion/treant/ravenous_woodfang/ravenous_woodfang.vmdl",--焚牙树精new
		"models/courier/mechjaw/mechjaw.vmdl",--机械咬人箱new
		"models/items/courier/mole_messenger/mole_messenger.vmdl",--1级矿车老鼠
		"models/courier/doom_demihero_courier/doom_demihero_courier.vmdl",
		"models/courier/huntling/huntling.vmdl",
		"models/courier/minipudge/minipudge.vmdl",
		"models/courier/seekling/seekling.vmdl",
		"models/items/courier/baekho/baekho.vmdl",
		"models/items/courier/basim/basim.vmdl",
		"models/items/courier/devourling/devourling.vmdl",
		"models/items/courier/faceless_rex/faceless_rex.vmdl",
		"models/items/courier/tinkbot/tinkbot.vmdl",
		"models/items/courier/lilnova/lilnova.vmdl",
		 "models/items/courier/amphibian_kid/amphibian_kid.vmdl",
		"models/courier/venoling/venoling.vmdl",
		"models/courier/juggernaut_dog/juggernaut_dog.vmdl",
		"models/courier/otter_dragon/otter_dragon.vmdl",
		"models/items/courier/boooofus_courier/boooofus_courier.vmdl",
		"models/courier/baby_winter_wyvern/baby_winter_wyvern.vmdl",
		"models/courier/yak/yak.vmdl",
		"models/items/furion/treant/eternalseasons_treant/eternalseasons_treant.vmdl",
		"models/items/courier/blue_lightning_horse/blue_lightning_horse.vmdl",
		"models/items/courier/waldi_the_faithful/waldi_the_faithful.vmdl",
		"models/items/courier/bajie_pig/bajie_pig.vmdl",
		"models/items/courier/courier_faun/courier_faun.vmdl",
		"models/items/courier/livery_llama_courier/livery_llama_courier.vmdl",
		"models/items/courier/onibi_lvl_10/onibi_lvl_10.vmdl",
		"models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl", --胆小南瓜人
		"models/items/courier/hermit_crab/hermit_crab.vmdl", --螃蟹1
		"models/items/courier/hermit_crab/hermit_crab_boot.vmdl", --螃蟹2
		"models/items/courier/hermit_crab/hermit_crab_shield.vmdl", --螃蟹3
		"models/courier/donkey_unicorn/donkey_unicorn.vmdl", --竭智法师new
		"models/items/courier/white_the_crystal_courier/white_the_crystal_courier.vmdl", --蓝心白隼new
		"models/items/furion/treant/furion_treant_nelum_red/furion_treant_nelum_red.vmdl",--莲花人new
		"models/courier/beetlejaws/mesh/beetlejaws.vmdl",--甲虫咬人箱new
		"models/courier/smeevil_bird/smeevil_bird.vmdl",
		"models/items/courier/mole_messenger/mole_messenger_lvl4.vmdl",--蜡烛头矿车老鼠
		"models/items/courier/bookwyrm/bookwyrm.vmdl",
		"models/items/courier/captain_bamboo/captain_bamboo.vmdl",
		"models/items/courier/kanyu_shark/kanyu_shark.vmdl",
		"models/items/courier/tory_the_sky_guardian/tory_the_sky_guardian.vmdl",
		"models/items/courier/shroomy/shroomy.vmdl",
		"models/items/courier/courier_janjou/courier_janjou.vmdl",
		"models/items/courier/green_jade_dragon/green_jade_dragon.vmdl",
		"models/courier/drodo/drodo.vmdl",
		"models/courier/mech_donkey/mech_donkey.vmdl",
		"models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl",
		"models/courier/octopus/octopus.vmdl",
		"models/items/courier/scribbinsthescarab/scribbinsthescarab.vmdl",
		"models/courier/defense3_sheep/defense3_sheep.vmdl",
		"models/items/courier/snapjaw/snapjaw.vmdl",
		"models/items/courier/g1_courier/g1_courier.vmdl",
		"models/courier/donkey_trio/mesh/donkey_trio.vmdl",
		"models/items/courier/boris_baumhauer/boris_baumhauer.vmdl",
		"models/courier/baby_rosh/babyroshan.vmdl",
		"models/items/courier/bearzky/bearzky.vmdl",
		"models/items/courier/defense4_radiant/defense4_radiant.vmdl",
		"models/items/courier/defense4_dire/defense4_dire.vmdl",
		"models/items/courier/onibi_lvl_20/onibi_lvl_20.vmdl",
		"models/items/juggernaut/ward/fortunes_tout/fortunes_tout.vmdl", --招财猫
		"models/items/courier/hermit_crab/hermit_crab_necro.vmdl", --螃蟹4
		"models/items/courier/hermit_crab/hermit_crab_travelboot.vmdl", --螃蟹5
		"models/items/courier/hermit_crab/hermit_crab_lotus.vmdl", --螃蟹6
		"models/courier/donkey_ti7/donkey_ti7.vmdl",
		"models/items/courier/shibe_dog_cat/shibe_dog_cat.vmdl", --天猫地狗new
		"models/items/furion/treant/hallowed_horde/hallowed_horde.vmdl",--万圣树群new
		"models/courier/flopjaw/flopjaw.vmdl",--大嘴咬人箱new
		"models/courier/lockjaw/lockjaw.vmdl",--咬人箱洛克new
		"models/items/courier/butch_pudge_dog/butch_pudge_dog.vmdl",--布狗new
		"models/courier/turtle_rider/turtle_rider.vmdl",
		"models/courier/smeevil_crab/smeevil_crab.vmdl",
		"models/items/courier/mole_messenger/mole_messenger_lvl6.vmdl",--绿钻头矿车老鼠
		"models/courier/navi_courier/navi_courier.vmdl",
		"models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl",
		"models/items/courier/ig_dragon/ig_dragon.vmdl",
		"models/items/courier/lgd_golden_skipper/lgd_golden_skipper.vmdl",
		"models/items/courier/vigilante_fox_red/vigilante_fox_red.vmdl",
		"models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl",
		"models/items/courier/throe/throe.vmdl",
		"models/items/courier/vaal_the_animated_constructradiant/vaal_the_animated_constructradiant.vmdl",
		"models/items/courier/vaal_the_animated_constructdire/vaal_the_animated_constructdire.vmdl",
		"models/items/courier/carty/carty.vmdl",
		"models/items/courier/carty_dire/carty_dire.vmdl",
		"models/items/courier/dc_angel/dc_angel.vmdl",
		"models/items/courier/dc_demon/dc_demon.vmdl",
		"models/items/courier/vigilante_fox_green/vigilante_fox_green.vmdl",
		"models/items/courier/bts_chirpy/bts_chirpy.vmdl",
		"models/items/courier/krobeling/krobeling.vmdl",
		"models/items/courier/jin_yin_black_fox/jin_yin_black_fox.vmdl",
		"models/items/courier/jin_yin_white_fox/jin_yin_white_fox.vmdl",
		"models/items/courier/fei_lian_blue/fei_lian_blue.vmdl",
		"models/items/courier/gama_brothers/gama_brothers.vmdl",
		"models/items/courier/onibi_lvl_21/onibi_lvl_21.vmdl",
		"models/items/courier/wabbit_the_mighty_courier_of_heroes/wabbit_the_mighty_courier_of_heroes.vmdl", --小飞侠
		"models/items/courier/hermit_crab/hermit_crab_octarine.vmdl", --螃蟹7
		"models/items/courier/hermit_crab/hermit_crab_skady.vmdl", --螃蟹8
		"models/items/courier/hermit_crab/hermit_crab_aegis.vmdl", --螃蟹9
		"models/items/furion/treant_flower_1.vmdl",--绽放树精new
		"models/courier/smeevil_magic_carpet/smeevil_magic_carpet.vmdl",
		"models/items/courier/mole_messenger/mole_messenger_lvl7.vmdl",--绿钻头金矿车老鼠
		"models/items/courier/krobeling_gold/krobeling_gold_flying.vmdl",--金dp
		"models/props_gameplay/donkey.vmdl", 
		"particles/items2_fx/refresher.vpcf",
		"soundevents/game_sounds_items.vsndevts",
		"particles/speechbubbles/speech_voice.vpcf",

		"soundevents/game_sounds_heroes/game_sounds_nevermore.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_batrider.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_luna.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_treant.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_dragon_knight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_viper.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_medusa.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_disruptor.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_alchemist.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_techies.vsndevts",
		"particles/econ/events/ti5/dagon_ti5.vpcf",
		"particles/units/heroes/hero_monkey_king/monkey_king_fur_army_positions_ring_dragon.vpcf",
		"particles/econ/items/legion/legion_overwhelming_odds_ti7/legion_commander_odds_ti7_proj_hit_streaks.vpcf",
		"particles/units/heroes/hero_queenofpain/queen_sonic_wave.vpcf",
		"models/props_gameplay/donkey_dire.vmdl",
		"models/props_gameplay/donkey_dire_wings.vmdl",
		"models/courier/baby_rosh/babyroshan_winter18.vmdl",
		"effect/dizuo/1.vpcf",
		"soundevents/voscripts/game_sounds_vo_lone_druid.vsndevts",
		"soundevents/voscripts/game_sounds_vo_furion.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_morphling.vsndevts",
		"soundevents/voscripts/game_sounds_vo_terrorblade.vsndevts",
		"particles/units/heroes/hero_chaos_knight/chaos_knight_phantasm.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_chaos_knight.vsndevts",
		"models/items/kunkka/kunkka_immortal/kunkka_shark_immortal.vmdl",
		"models/courier/frull/frull_courier.vmdl",
		"models/items/courier/amaterasu/amaterasu.vmdl",
		"models/items/courier/chocobo/chocobo.vmdl",
		"models/items/courier/flightless_dod/flightless_dod.vmdl",
		"models/items/courier/frostivus2018_courier_serac_the_seal/frostivus2018_courier_serac_the_seal.vmdl",
		"models/items/courier/jumo_dire/jumo_dire.vmdl",
		"models/items/courier/pangolier_squire/pangolier_squire.vmdl",
		"models/items/courier/sltv_10_courier/sltv_10_courier.vmdl",
		"models/items/courier/nian_courier/nian_courier.vmdl",
		"models/items/courier/nilbog/nilbog.vmdl",
		"particles/items_fx/blink_dagger_end.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_terrorblade.vsndevts",
		"particles/units/heroes/hero_mirana/mirana_spell_arrow.vpcf",
		"particles/econ/items/mirana/mirana_starstorm_bow/mirana_starstorm_starfall_attack.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_mirana.vsndevts",
		"particles/units/heroes/hero_slark/slark_pounce_start.vpcf",
		"particles/econ/items/slark/slark_ti6_blade/slark_ti6_pounce_start.vpcf",
		"particles/econ/items/slark/slark_ti6_blade/slark_ti6_pounce_start_gold.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_zuus.vsndevts",
		"particles/econ/items/zeus/arcana_chariot/zeus_arcana_thundergods_wrath_start_bolt_parent.vpcf",
		"models/items/lycan/wolves/blood_moon_hunter_wolves/blood_moon_hunter_wolves.vmdl",
		"models/items/lycan/ultimate/blood_moon_hunter_shapeshift_form/blood_moon_hunter_shapeshift_form.vmdl",
		"models/items/courier/krobeling_gold/krobeling_gold.vmdl",
		"models/items/courier/krobeling_gold/krobeling_gold_flying.vmdl",
		"effect/jin_dp/courier_krobeling_gold_ambient.vpcf",
		"effect/nianshou/courier_nian_ambient.vpcf",
		"soundevents/game_sounds.vsndevts",
		"soundevents/voscripts/game_sounds_vo_announcer_killing_spree.vsndevts",
		"effect/3sha/vr_killbanner_triplekill.vpcf",
		"effect/5sha/vr_killbanner_rampage.vpcf",
		"effect/zeus/victory/victory.vpcf",
		"effect/god/1.vpcf",
		"soundevents/voscripts/game_sounds_vo_zuus.vsndevts",
		"soundevents/voscripts/game_sounds_vo_mars.vsndevts",
		"effect/mars/2/e.vpcf",
		"effect/mars/1/e.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_dazzle.vsndevts",
		"soundevents/game_sounds_heroes/game_sounds_dark_seer.vsndevts",
		"soundevents/music/game_sounds_stingers_diretide.vsndevts",
		"particles/gem/brewmaster_drunken_haze_debuff_bubbles_2.vpcf",
		"models/qie/qie.vmdl",
		"models/courier/f2p_courier/f2p_courier.vmdl",
		"models/items/courier/azuremircourierfinal/azuremircourierfinal.vmdl",
		"effect/roshan_ti9/1.vpcf",
		"models/items/axe/ti9_jungle_axe/axe_bare.vmdl",	
		"models/shudaixiong/model/shudaixiong/shudaixiong.vmdl",
		"models/shudaixiong/model/shudaixiong_flying/shudaixiong_flying.vmdl",
		"models/courier/baby_rosh/babyroshan_elemental.vmdl",
		"particles/units/heroes/hero_grimstroke/grimstroke_soulchain_debuff.vpcf",
		"soundevents/game_sounds_heroes/game_sounds_rubick.vsndevts",

		"models/pets/armadillo/armadillo.vmdl",	
		"models/courier/baby_rosh/babyroshan_ti9.vmdl",
		"models/heroes/invoker_kid/invoker_kid_trainer_dragon.vmdl",

		"particles/econ/items/juggernaut/jugg_arcana/juggernaut_arcana_v2_idle_rare.vpcf",

		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant.vmdl",

		-- TI10晴儿
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl1_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl2/courier_ti10_radiant_lvl2.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl2_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl3/courier_ti10_radiant_lvl3.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl3_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl4/courier_ti10_radiant_lvl4.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl4_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl5/courier_ti10_radiant_lvl5.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl5_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl6/courier_ti10_radiant_lvl6.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl6_ambient.vpcf",
		"models/items/courier/courier_ti10_radiant/courier_ti10_radiant_lvl7/courier_ti10_radiant_lvl7.vmdl",
		"particles/econ/courier/courier_ti10/courier_ti10_lvl7_ambient.vpcf",
	} 
    print("Precache mxx ...")
	local t=table.maxn(mxx)
	for i=1,t do
		if string.find(mxx[i], ".vpcf") then
			PrecacheResource( "particle",  mxx[i], context)
		end
		if string.find(mxx[i], ".vmdl") then 	
			PrecacheResource( "model",  mxx[i], context)
		end
		if string.find(mxx[i], ".vsndevts") then
			PrecacheResource( "soundfile",  mxx[i], context)
		end
    end
end

function Activate()
	GameRules.THTDGameMode = CTHTDGameMode()
	GameRules.THTDGameMode:InitGameMode()
end


function CTHTDGameMode:InitGameMode()
	GameRules:GetGameModeEntity():SetCameraDistanceOverride(1734.0)
	GameRules:GetGameModeEntity():SetFogOfWarDisabled(true)
	GameRules:GetGameModeEntity():SetUseCustomHeroLevels(true)
	GameRules:GetGameModeEntity():SetCustomXPRequiredToReachNextLevel(self:SettingExp())
	GameRules:GetGameModeEntity():SetCustomHeroMaxLevel(THTD_MAX_LEVEL)
	GameRules:SetStartingGold(4500)
	GameRules:SetGoldPerTick(0)
	GameRules:GetGameModeEntity():SetLoseGoldOnDeath(false)
	GameRules:SetSameHeroSelectionEnabled(true)
	GameRules:SetHeroSelectionTime(10)	
 	GameRules:SetPreGameTime(30)
 	GameRules:SetStrategyTime(0)
	GameRules:SetShowcaseTime(0)
 	GameRules:SetUseUniversalShopMode(true)
	GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_GOODGUYS, 4 )
	GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_BADGUYS, 0 )
	GameRules:SetCustomGameAllowBattleMusic( false )
	GameRules:SetCustomGameAllowMusicAtGameStart( false )	

	-- GameRules:GetGameModeEntity():SetGoldSoundDisabled(true)
	GameRules:GetGameModeEntity():SetNeutralStashEnabled(false)
	GameRules:GetGameModeEntity():SetSendToStashEnabled(false)
	GameRules:GetGameModeEntity():SetStashPurchasingDisabled(true)

	GameRules:GetGameModeEntity():SetAlwaysShowPlayerNames(true)
	GameRules:GetGameModeEntity():SetMaximumAttackSpeed(700) --显示会突破
	GameRules:GetGameModeEntity():SetMinimumAttackSpeed(20)
	GameRules:GetGameModeEntity():SetCustomBackpackSwapCooldown(0)
	-- GameRules:GetGameModeEntity():SetAnnouncerDisabled(true)
	GameRules:GetGameModeEntity():SetKillingSpreeAnnouncerDisabled(true)	
	-- GameRules:SetCustomGameAllowHeroPickMusic( false )
	GameRules:GetGameModeEntity():SetCanSellAnywhere(true)


	ListenToGameEvent('entity_killed', Dynamic_Wrap(CTHTDGameMode, 'OnEntityKilled'), self)    	
  	ListenToGameEvent('player_chat', Dynamic_Wrap(CTHTDGameMode, 'OnPlayerSay'), self)
	ListenToGameEvent('game_rules_state_change', Dynamic_Wrap(CTHTDGameMode, 'OnGameRulesStateChange'), self)
	ListenToGameEvent('player_connect_full', Dynamic_Wrap( CTHTDGameMode, 'OnPlayerConnected' ), self )	

	GameRules:GetGameModeEntity():SetExecuteOrderFilter(Dynamic_Wrap(CTHTDGameMode, 'ExecuteOrder'), self)
  	GameRules:GetGameModeEntity():SetItemAddedToInventoryFilter(Dynamic_Wrap(CTHTDGameMode, 'ItemAddedToInventory'), self)
	GameRules:GetGameModeEntity():SetDamageFilter(Dynamic_Wrap(CTHTDGameMode, 'DamageFilter'), self)
	GameRules:GetGameModeEntity():SetModifierGainedFilter(Dynamic_Wrap(CTHTDGameMode, 'ModifierFilter'), self)		
	GameRules:GetGameModeEntity():SetModifyGoldFilter(Dynamic_Wrap(CTHTDGameMode, 'OnModifyGoldFilter'), self)
	GameRules:GetGameModeEntity():SetTPScrollSlotItemOverride("item_3121")

	LinkLuaModifier("modifier_magical_armor", "modifiers/modifier_magical_armor", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_move_speed", "modifiers/modifier_move_speed", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_move_max_speed", "modifiers/modifier_move_max_speed", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_attack_speed", "modifiers/modifier_attack_speed", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_attack_time", "modifiers/modifier_attack_time", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_cooldown_reduce", "modifiers/modifier_cooldown_reduce", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2005_attack_aura", "modifiers/modifier_item_2005_attack_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2005_attack_aura_effect", "modifiers/modifier_item_2005_attack_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2006_mana_regen_aura", "modifiers/modifier_item_2006_mana_regen_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2006_mana_regen_aura_effect", "modifiers/modifier_item_2006_mana_regen_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2008_slow_aura", "modifiers/modifier_item_2008_slow_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2008_slow_aura_effect", "modifiers/modifier_item_2008_slow_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2009_damage", "modifiers/modifier_item_2009_damage", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2010_damage", "modifiers/modifier_item_2010_damage", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2011_attack_stun", "modifiers/modifier_item_2011_attack_stun", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2012_magical_damage_aura", "modifiers/modifier_item_2012_magical_damage_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2012_magical_damage_aura_effect", "modifiers/modifier_item_2012_magical_damage_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2013_physical_damage_aura", "modifiers/modifier_item_2013_physical_damage_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2013_physical_damage_aura_effect", "modifiers/modifier_item_2013_physical_damage_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2014_damage_aura", "modifiers/modifier_item_2014_damage_aura", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2014_damage_aura_effect", "modifiers/modifier_item_2014_damage_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_item_2018_bonus_attack_range", "modifiers/modifier_item_2018_bonus_attack_range", LUA_MODIFIER_MOTION_NONE)	
	
	LinkLuaModifier("modifier_touhoutd_pause", "modifiers/modifier_touhoutd_pause", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_root", "modifiers/modifier_touhoutd_root", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_release_hidden", "modifiers/modifier_touhoutd_release_hidden", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_building", "modifiers/modifier_touhoutd_building", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_hidden_bar", "modifiers/modifier_hidden_bar", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_root_hidden_info", "modifiers/modifier_root_hidden_info", LUA_MODIFIER_MOTION_NONE)
	
	LinkLuaModifier("modifier_touhoutd_luck", "modifiers/modifier_touhoutd_luck", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_touhoutd_poison", "modifiers/modifier_touhoutd_poison", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_outgoing_pure", "modifiers/modifier_touhoutd_damage_outgoing_pure", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_outgoing_physical", "modifiers/modifier_touhoutd_damage_outgoing_physical", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_outgoing_magical", "modifiers/modifier_touhoutd_damage_outgoing_magical", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_incoming_pure", "modifiers/modifier_touhoutd_damage_incoming_pure", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_incoming_physical", "modifiers/modifier_touhoutd_damage_incoming_physical", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_touhoutd_damage_incoming_magical", "modifiers/modifier_touhoutd_damage_incoming_magical", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_touhoutd_crit_chance", "modifiers/modifier_touhoutd_crit_chance", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_touhoutd_crit_damage", "modifiers/modifier_touhoutd_crit_damage", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_touhoutd_unlimited_resist", "modifiers/modifier_touhoutd_unlimited_resist", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_base_attack_bonus_percent", "modifiers/modifier_base_attack_bonus_percent", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_manacost_reduce_percent", "modifiers/modifier_manacost_reduce_percent", LUA_MODIFIER_MOTION_NONE)

	LinkLuaModifier("modifier_ability_power_common", "modifiers/power/modifier_ability_power_common", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_minoriko", "modifiers/power/modifier_ability_power_minoriko", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_sizuha", "modifiers/power/modifier_ability_power_sizuha", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_lily", "modifiers/power/modifier_ability_power_lily", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_shinki", "modifiers/power/modifier_ability_power_shinki", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_nazrin", "modifiers/power/modifier_ability_power_nazrin", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_byakuren", "modifiers/power/modifier_ability_power_byakuren", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_shikieiki", "modifiers/power/modifier_ability_power_shikieiki", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_reimu", "modifiers/power/modifier_ability_power_reimu", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_flandre", "modifiers/power/modifier_ability_power_flandre", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_ability_power_koishi", "modifiers/power/modifier_ability_power_koishi", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_hecatia", "modifiers/power/modifier_ability_power_hecatia", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_yuuka", "modifiers/power/modifier_ability_power_yuuka", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_daiyousei", "modifiers/power/modifier_ability_power_daiyousei", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_kanako", "modifiers/power/modifier_ability_power_kanako", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_yukari", "modifiers/power/modifier_ability_power_yukari", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_miko", "modifiers/power/modifier_ability_power_miko", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_eirin", "modifiers/power/modifier_ability_power_eirin", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_komachi", "modifiers/power/modifier_ability_power_komachi", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_remilia", "modifiers/power/modifier_ability_power_remilia", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_ability_power_junko", "modifiers/power/modifier_ability_power_junko", LUA_MODIFIER_MOTION_NONE)
	
	LinkLuaModifier("modifier_bb_buff_3011", "modifiers/battle_buff/modifier_bb_buff_3011", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3011_effect", "modifiers/battle_buff/modifier_bb_buff_3011_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3012", "modifiers/battle_buff/modifier_bb_buff_3012", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3013", "modifiers/battle_buff/modifier_bb_buff_3013", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3014", "modifiers/battle_buff/modifier_bb_buff_3014", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3015", "modifiers/battle_buff/modifier_bb_buff_3015", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3015_effect", "modifiers/battle_buff/modifier_bb_buff_3015_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3016", "modifiers/battle_buff/modifier_bb_buff_3016", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3016_effect", "modifiers/battle_buff/modifier_bb_buff_3016_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3017", "modifiers/battle_buff/modifier_bb_buff_3017", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3018", "modifiers/battle_buff/modifier_bb_buff_3018", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3019", "modifiers/battle_buff/modifier_bb_buff_3019", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3020", "modifiers/battle_buff/modifier_bb_buff_3020", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3021", "modifiers/battle_buff/modifier_bb_buff_3021", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3023", "modifiers/battle_buff/modifier_bb_buff_3023", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3024", "modifiers/battle_buff/modifier_bb_buff_3024", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3025", "modifiers/battle_buff/modifier_bb_buff_3025", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3026", "modifiers/battle_buff/modifier_bb_buff_3026", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3027", "modifiers/battle_buff/modifier_bb_buff_3027", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3028", "modifiers/battle_buff/modifier_bb_buff_3028", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3029", "modifiers/battle_buff/modifier_bb_buff_3029", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3030", "modifiers/battle_buff/modifier_bb_buff_3030", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bb_buff_3031", "modifiers/battle_buff/modifier_bb_buff_3031", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_fairy_count", "modifiers/battle_buff/modifier_fairy_count", LUA_MODIFIER_MOTION_NONE)	
	
	LinkLuaModifier("modifier_bosses_alice", "modifiers/bosses/modifier_bosses_alice", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_aya", "modifiers/bosses/modifier_bosses_aya", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_hina", "modifiers/bosses/modifier_bosses_hina", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_hina_aura_effect", "modifiers/bosses/modifier_bosses_hina_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_kaguya", "modifiers/bosses/modifier_bosses_kaguya", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_keine", "modifiers/bosses/modifier_bosses_keine", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_kisume", "modifiers/bosses/modifier_bosses_kisume", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_marisa", "modifiers/bosses/modifier_bosses_marisa", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_minoriko", "modifiers/bosses/modifier_bosses_minoriko", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_mokou", "modifiers/bosses/modifier_bosses_mokou", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_mokou_aura_effect", "modifiers/bosses/modifier_bosses_mokou_aura_effect", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_rumia", "modifiers/bosses/modifier_bosses_rumia", LUA_MODIFIER_MOTION_NONE)
	LinkLuaModifier("modifier_bosses_yuugi", "modifiers/bosses/modifier_bosses_yuugi", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_resist_aura", "modifiers/bosses/modifier_bosses_random_resist_aura", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_resist_effect", "modifiers/bosses/modifier_bosses_random_resist_effect", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_attack_speed_aura", "modifiers/bosses/modifier_bosses_random_attack_speed_aura", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_attack_speed_effect", "modifiers/bosses/modifier_bosses_random_attack_speed_effect", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_move_aura", "modifiers/bosses/modifier_bosses_random_move_aura", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_move_effect", "modifiers/bosses/modifier_bosses_random_move_effect", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_health_aura", "modifiers/bosses/modifier_bosses_random_health_aura", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_health_effect", "modifiers/bosses/modifier_bosses_random_health_effect", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_dead_heal", "modifiers/bosses/modifier_bosses_random_dead_heal", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_aura_dark", "modifiers/bosses/modifier_bosses_random_aura_dark", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_bosses_random_aura_dark_effect", "modifiers/bosses/modifier_bosses_random_aura_dark_effect", LUA_MODIFIER_MOTION_NONE)	

	LinkLuaModifier("modifier_courier_fx", "modifiers/effects/modifier_courier_fx", LUA_MODIFIER_MOTION_NONE)	
	LinkLuaModifier("modifier_rainbow_tail", "modifiers/effects/modifier_rainbow_tail", LUA_MODIFIER_MOTION_NONE)	



	CustomNetTables:SetTableValue("CustomGameInfo", "thtd_tower_list", towerNameList)	
	print("\n---------- InitGameMode Finished ----------")

	GameRules:GetGameModeEntity():SetContextThink(DoUniqueString("collectgarbage"), 
		function()
			local m = collectgarbage('count')
			print(string.format("[Lua Memory]  %.3f KB  %.3f MB", m, m/1024))
			return 60
		end, 
	60)
end

function CTHTDGameMode:SettingExp()
	-- 总和5400
	-- 经验分配规则 保底 1X每只30点 2X每只20点，3X每只10点，4X每只6点，5X每只3点
	-- 单吃一个兵经验 300点 200点 100点 60点 30点
	-- 经验获取率1X 100% 2X 2/3 3X 1/3 4X 1/5 5X 1/10 
	-- 素材培养 （1000+素材卡牌经验/5）* 星级

	local HERO_EXP_TABLE = {0}
	local exp = {200,300,400,500,600,700,800,900,1000}
	local xp = 0

	for i = 2, THTD_MAX_LEVEL-1 do
		HERO_EXP_TABLE[i]=HERO_EXP_TABLE[i-1]+exp[i-1]
	end

	return HERO_EXP_TABLE
end


function CTHTDGameMode:OnDotaItemPickedUp(keys)		
	local item = EntIndexToHScript(keys.ItemEntityIndex)
	if item == nil then return end
	if item.locked_by_player_id == nil or item.locked_by_player_id == keys.PlayerID or item.card_poor_player_id == keys.PlayerID then return end
	-- local heroes = Entities:FindAllByClassname("npc_dota_hero_lina")	
	for _,hero in pairs(GameRules.HeroList) do	
		if hero.thtd_player_id == item.locked_by_player_id and hero.is_game_over == true then return end
	end

	local picker = nil
	if keys.HeroEntityIndex ~= nil then 
		picker = EntIndexToHScript(keys.HeroEntityIndex)
	elseif keys.UnitEntityIndex ~= nil then 
		picker = EntIndexToHScript(keys.UnitEntityIndex) 	
	end		
	if picker == nil then return end	
	CustomGameEventManager:Send_ServerToPlayer(picker:GetPlayerOwner() , "display_custom_error", {msg="item_is_locked"})
	picker:DropItemAtPositionImmediate(item, picker:GetOrigin())
end


function CTHTDGameMode:OnGameRulesStateChange(keys)
	local newState = GameRules:State_Get()
	local stateText = {
		[0] = "DOTA_GAMERULES_STATE_INIT",
		[1] = "DOTA_GAMERULES_STATE_WAIT_FOR_PLAYERS_TO_LOAD",
		[2] = "DOTA_GAMERULES_STATE_CUSTOM_GAME_SETUP",
		[3] = "DOTA_GAMERULES_STATE_HERO_SELECTION",
		[4] = "DOTA_GAMERULES_STATE_STRATEGY_TIME",
		[5] = "DOTA_GAMERULES_STATE_TEAM_SHOWCASE",
		[6] = "DOTA_GAMERULES_STATE_PRE_GAME",
		[7] = "DOTA_GAMERULES_STATE_GAME_IN_PROGRESS",
		[8] = "DOTA_GAMERULES_STATE_POST_GAME",
		[9] = "DOTA_GAMERULES_STATE_DISCONNECT",		
	}
	print("-------- Now State: ", stateText[newState])
	if newState ==  DOTA_GAMERULES_STATE_CUSTOM_GAME_SETUP then			
		self:GameStateCustomGameSetup()		
		Service:LoadGameData()

	elseif newState == DOTA_GAMERULES_STATE_STRATEGY_TIME then	
		ListenToGameEvent('npc_spawned', Dynamic_Wrap( CTHTDGameMode, 'OnNpcSpawned' ), self )			
		ListenToGameEvent('dota_item_picked_up', Dynamic_Wrap(CTHTDGameMode, 'OnDotaItemPickedUp'), self)
		ListenToGameEvent('dota_non_player_used_ability', Dynamic_Wrap(CTHTDGameMode, 'OnDotaNonPlayerUsedAbility'), self)		

  		-------- 设置游戏难度 --------
  		local level = {[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0}
		for k,v in pairs(PlayersSelectedDifficulty) do
			level[v] = (level[v] or 0) + 1
		end
		local difficulty = 0
		for k,v in pairs(level) do
			if k ~= difficulty and level[k] > level[difficulty] then
				difficulty = k
			end
		end		
		difficulty = difficulty + 1	
		GameRules:SetCustomGameDifficulty(difficulty)

		-- 初始化金钱
		for i=0, PlayerResource:GetPlayerCount()-1 do	
			if PlayerResource:IsValidPlayerID(i) then	
				-- PlayerResource:ModifyGold(i, 4500 - 600 , true, DOTA_ModifyGold_Unspecified)	
				PlayerResource:SetLastBuybackTime(i, 0) 
			end		
		end				

  	elseif newState == DOTA_GAMERULES_STATE_PRE_GAME then 			
		Service:GetRank()
		SpawnSystem:PreSpawn()
		-- 解除地图购买上限
		SendToServerConsole("dota_max_physical_items_purchase_limit 59999")		

	elseif newState == DOTA_GAMERULES_STATE_GAME_IN_PROGRESS then 
		SpawnSystem:InitSpawn()
		for i=0, PlayerResource:GetPlayerCount()-1 do			
			if PlayerResource:GetTeam(i) == DOTA_TEAM_GOODGUYS then 
				if GameRules.PlayerData[i].ban == 1 then
					CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(i), "display_chat_msg", {msg="game_ban_tip", params={player_name=PlayerResource:GetPlayerName(i),reason=GameRules.PlayerData[i].reason}})						
					for _,hero in pairs(GameRules.HeroList) do	
						if hero.thtd_player_id == i then 
							SpawnSystem:GameOver(hero)
							break
						end
					end		
				elseif GameRules.PlayerData[i].vip == 1 then
					CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(i), "show_message", {msg="game_start_vip_tip", duration=60, params={name=PlayerResource:GetPlayerName(i),endtime=GameRules.PlayerData[i].end_time}, color="#ff0"})					
				end
				GameRules.HeroList[i]:RemoveModifierByName("modifier_rainbow_tail")
			end			
		end	

		if GameRules.GameData.luck_card == "all" then
			CustomGameEventManager:Send_ServerToAllClients("thtd_server_msg", {code = "0000", msg = "无限潜力活动开启，开局可选潜能Lv999的凤凰之灵！", duration = 15, pos = -150})	
			EmitAnnouncerSound("Quest.Completed")
		end
	end	  
end

-- 全局变量定义
function CTHTDGameMode:GameStateCustomGameSetup()	
	-- 预设，数据载入完成最终设置一次
	local heroNames = {
		"npc_dota_hero_lina",
		"npc_dota_hero_juggernaut",
	}
	for i=0, PlayerResource:GetPlayerCount()-1 do
		PlayerResource:SetCustomTeamAssignment(i, DOTA_TEAM_GOODGUYS)
		local player = PlayerResource:GetPlayer(i)
		if player then
			CreateHeroForPlayer(heroNames[RandomInt(1, #heroNames)], player):RemoveSelf()			
		end
	end

	-- 玩家信息定义，按playerid的steamid、dota2帐户、玩家名称、英雄index信息、黑白名单及宠物信息
	GameRules.PlayerData = { }

	-- 英雄列表定义，按playerid，出生时初始化
	GameRules.HeroList = {}	
	
	-- 战利品buff定义
	GameRules.player_bb_buff = {}

	-- 按玩家id初始化
	for i=0, PlayerResource:GetPlayerCount()-1 do
		-- 玩家信息
		GameRules.PlayerData[i] = {
			["code"] = "",		
			["msg"] = "",	

			["steamid"] = tostring(PlayerResource:GetSteamID(i)),
			["userid"] = tostring(PlayerResource:GetSteamAccountID(i)),
			["name"] = PlayerResource:GetPlayerName(i),
			["hero_index"] = 0,	

			["max_wave"] = 0,	
			["max_team_wave"] = 0,	
			
			["point"] = 0,
			["level_list"] = {},

			["vip"] = 0,
			["ban"] = 0,       
			["pet_level"] = 1,				              
			["end_time"] = "",
			["reason"] = "",								
			["pet_model"] = "h000",	
			["pet_effect"] = "e000",

			["is_first_win"] = 0,
			["key_total"] = 0,
			["key_use_count"] = 0,
			["power_max_total"] = 0,

			["cardgroup1"] = {},
			["cardgroup2"] = {},
			["cardgroup3"] = {},
			["cardgroup4"] = {},
			["cardgroup5"] = {},

			["update_time"] = ""							
		}

		-- 英雄列表
		GameRules.HeroList[i] = nil
		
		-- 战利品buff
		GameRules.player_bb_buff[i] = {
			["item_3011"] = 0,          -- 地灵殿单位物理伤害提升量
			["item_3011_effect"] = 0,   -- 实际加成
			["item_3012"] = 0,          -- 抽卡额外获得的一张卡牌的概率
			["item_3013"] = 1,          -- 无敌意识的负面效果比例
			["item_3014"] = 0,          -- 主角组无尽后每击杀100个单位增加的能量点数（灵梦、魔理沙、东方谷早苗、爱丽丝）
			["item_3015"] = 0,          -- 月之民纯粹伤害提升数值
			["item_3015_effect"] = 0,   -- 实际加成
			["item_3016"] = 0,          -- 所有召唤物+150攻击力和+30%%攻速的倍数
			["item_3017"] = 0,          -- 每有一个外圈漏怪，则全体单位伤害提升量
			["item_3018"] = 1,          -- 抽卡价格优惠度，乘法叠加
			["item_3019"] = 0,          -- 每波最后3秒如果漏怪数量达到30则造成的伤害提高量
			["item_3019_enable"] = false,  -- 是否正在触发
			["item_3020"] = 0,          -- 同名卡上场最大数量增加量
			["item_3021"] = 0,          -- 秒杀伤害上限提高量
			["item_3023"] = 0,          -- 神灵庙单位的相机4件套效果加成和神子附加伤害加成效果提高量
			["item_3024"] = 0,          -- 守矢神社的信仰收集上限提高量
			["item_3025"] = 0,          -- 红魔馆单位的触发类技能的概率增加量
			["item_3026"] = 0,          -- 怪物移动速度降低量     
			["item_3027"] = 0,          -- 星莲船单位装备提供的属性效果提高量
			["item_3028"] = 0,          -- 鬼族单位效果层数
			["item_3028_effect"] = 0,   -- 实际加成
			["item_3029"] = 0,          -- 四季馈赠量
			["item_3030"] = 0,          -- 分身加成效果提高量
		}
	end	
end


function CTHTDGameMode:OnPlayerConnected(keys)
	print("----player_connect_full")
	CustomGameEventManager:Send_ServerToAllClients("debug_msg", {msg = PlayerResource:GetPlayerName(keys.PlayerID).." 连接完成！"})
end


function CTHTDGameMode:OnNpcSpawned(keys)
	local hero = EntIndexToHScript(keys.entindex)
	if hero:IsRealHero() and hero.isFirstSpawn ~= false then			
		hero.isFirstSpawn = false
		hero.thtd_hero_tower_list = {}
		hero.thtd_hero_damage_list ={}
		hero.thtd_combo_voice_array = {}
		hero.thtd_emoji_effect = nil		

		hero.thtd_game_info = {}		
		hero.thtd_game_info["creep_count"] = 0
		hero.thtd_game_info["creep_count_max"] = 0
		hero.thtd_game_info["food_count"] = 0		
		hero.thtd_game_info["creature_kill_count"] = 0
		hero.thtd_game_info["max_wave_damage"] = 0
		hero.thtd_game_info["max_wave"] = 0
		hero.thtd_game_info["is_player_connected"] = 0
	
		hero.thtd_chance_count = {}		
		hero.is_game_over = false	
		hero.thtd_wave_total_health = 0		

		hero:SetTeam(DOTA_TEAM_GOODGUYS)

		-- 判定是否上巅峰榜
		if PlayerResource:GetPlayerCountForTeam(DOTA_TEAM_GOODGUYS) > 1 and GameRules:GetCustomGameDifficulty() ~= PVE_MODE then 
			hero.is_team_mode = true
		else
			hero.is_team_mode = false
		end
		
		local playerId = hero:GetPlayerOwnerID()
		hero.thtd_player_id = playerId	
		hero.spawn_position = SpawnSystem.SpawnOrigin[playerId+1]
		hero:SetAbsOrigin(hero.spawn_position)
		hero:SetContextThink(DoUniqueString("SetSpawn") ,
			function()
				if GameRules:IsGamePaused() then return 0.1 end				
				if GetDistanceBetweenTwoVec2D(hero:GetOrigin(), hero.spawn_position) > 1000 then				
					hero:SetAbsOrigin(hero.spawn_position)
					PlayerResource:SetCameraTarget(hero:GetPlayerID(), hero)										
					return 0.5			
				else		
					PlayerResource:SetCameraTarget(hero:GetPlayerID(), nil)								
				end
				return nil
			end,
		0.5)		

		UnitNoPathingfix( hero,hero,-1)

		hero:AddNewModifier(hero, nil, "modifier_phased", nil)
		hero:AddNewModifier(hero, nil, "modifier_hidden_bar", nil)	
		hero:AddNewModifier(hero, nil, "modifier_rainbow_tail", nil)	

		if GameRules.PlayerData[playerId].power_max_total > 0 then
			for i=1,GameRules.PlayerData[playerId].power_max_total do
				local item = CreateItem("item_3149", nil, nil) 					
				if item ~= nil then	
					item.owner_player_id = playerId							
					item:SetPurchaser(hero)						
					hero:AddItem(item)									
				end
				if i == 4 then 
					break
				end
			end
		end

		GameRules.PlayerData[playerId]["hero_index"] = keys.entindex
		GameRules.HeroList[playerId] = hero	
		
		for i=0,7 do
			local ability=hero:GetAbilityByIndex(i)
			if ability ~= nil then
				ability:SetLevel(1)
			end
		end		
		
		hero:SetContextThink(DoUniqueString("delete_tp"), 
			function()
				if GameRules:IsGamePaused() then return 0.03 end
				for i=0,THTD_MAX_ITEM_SLOT-1 do
					local hTP = hero:GetItemInSlot(i)
					if hTP ~= nil and hTP:GetAbilityName() == "item_tpscroll" then				
						UTIL_Remove( hTP )
					end
				end
				return nil				
			end,
		2.0)		

		local shop = CreateUnitByName(
			"minoriko_shop", 
			SpawnSystem.ShopOrigin[hero:GetPlayerOwnerID()+1], 
			false, 
			hero, 
			hero, 
			hero:GetTeam() 
		)
		shop:SetControllableByPlayer(hero:GetPlayerOwnerID(), true) 
		shop:SetHasInventory(true)
		shop:AddNewModifier(shop, nil, "modifier_root_hidden_info", nil)
		shop.hero = hero
		hero.shop = shop			
		shop:SetContextThink(DoUniqueString("set_shop_forward"), 
			function()
				if GameRules:IsGamePaused() then return 0.1 end
				shop:MoveToPosition(shop:GetOrigin()+SpawnSystem.ShopForward[hero:GetPlayerOwnerID()+1])
				return nil				
			end,
		1.0)		

		if GameRules:GetCustomGameDifficulty() >= FUNNY_MODE then 
			hero:SetContextThink(DoUniqueString("set_gold_bonus") ,
				function()
					if GameRules:IsGamePaused() then return 0.1 end	
					if SpawnSystem.IsUnLimited then return nil end			
					THTD_ModifyGoldEx(playerId, math.min(SpawnSystem.CurWave * 25, 500) , true, DOTA_ModifyGold_Unspecified)	
					return 1
				end,
			10)
		end	

		-- local tree = CreateUnitByName(
		-- 	"christmas_tree", 
		-- 	hero.spawn_position, 
		-- 	false, 
		-- 	hero, 
		-- 	hero, 
		-- 	hero:GetTeam() 
		-- )
		
		local unit = CreateUnitByName(
			"reimu_pet"
			,hero:GetOrigin() + hero:GetForwardVector() * 500
			,false
			,hero
			,hero
			,hero:GetTeam()
		)	
		if unit ~= nil then 
			FindClearSpaceForUnit(unit, unit:GetOrigin(), false)	
			unit:SetControllableByPlayer(hero:GetPlayerOwnerID(), false)
			unit:SetOwner(hero)
			unit:SetHasInventory(true)
			unit:FindAbilityByName("reimu_pet_01"):CastAbility()
			
			local items = {"item_3003", "item_3004", "item_3007"}
			for _,itemName in pairs(items) do 
				local item = CreateItem(itemName, nil, nil)	
				if item ~= nil then
					item.owner_player_id = hero.thtd_player_id				
					unit:AddItem(item)
				end	
			end				

			local reimu_pet_sound = 
			{
				"UI.Aowu",
				"Icewrack_Pup.Ult.Howl",
				"Icewrack_Pup.Flee",
				"Icewrack_Pup.idle_alt_bark",
				"Icewrack_Pup.Alert",
				"Icewrack_Pup.Happy",
				"Icewrack_Pup.Breath",
			}

			unit:SetContextThink(DoUniqueString("reimu_pet_think"), 
				function()	
					if unit:IsStunned() then return nil end
					THTD_ModifyGoldEx(playerId)	
					
					local point = unit.pet_point
					if point == nil then
						point = hero:GetAbsOrigin()
					end
					local d = GetDistanceBetweenTwoVec2D(point, unit:GetOrigin())
					if d > 1800 then
						if unit:IsStunned() then return nil end
						FindClearSpaceForUnit(unit, point + hero:GetForwardVector() * 500, false)
						unit:EmitSound("Sound_THTD.ability_touhoutd_blink.End")
						return 1.0
					elseif d > 1200 then						
						local forward = (unit:GetAbsOrigin() - point):Normalized() 						
						unit:MoveToPosition(point + forward * 500)						
						return 1.0
					else
						if RollPercentage(85) then return 1.0 end						
						local rad = RandomInt(1, 360)
						local distance = RandomInt(500, 1180)
						local moveToPoint = point + 
							Vector(
								math.cos(rad * math.pi/180) * distance,
								math.sin(rad * math.pi/180) * distance,
								0)
						unit:MoveToPosition(moveToPoint)	
						if RollPercentage(10) then 
							unit:EmitSound(reimu_pet_sound[RandomInt(1, #reimu_pet_sound)])
						end		
					end		
					return 1.0
				end,
			1.0)
			hero.reimu_pet = unit
		end

		return
	end		
end


function CTHTDGameMode:OnEntityKilled(keys)
	if keys.entindex_killed == nil or keys.entindex_attacker == nil then return end
	
	-- 储存被击杀的单位
	local killedUnit = EntIndexToHScript( keys.entindex_killed )
	-- 储存杀手单位
	local killerEntity = EntIndexToHScript( keys.entindex_attacker )

	local id = killedUnit.thtd_player_index

	local findNum =  string.find(killedUnit:GetUnitName(), 'creature')
	if findNum ~= nil then
		if not SpawnSystem.IsUnLimited then
			local expRange = 1500
			local targets = THTD_FindFriendlyUnitsInRadius(killerEntity,killedUnit:GetOrigin(),expRange)			
			local expUnits = {}
			for k,v in pairs(targets) do
				if v ~= nil and v:IsNull()==false and v:THTD_IsTower() and v:THTD_GetLevel() < THTD_MAX_LEVEL then 
					table.insert(expUnits,v)
				end
			end
			targets = {}

			local factor = 1
			if GameRules:GetCustomGameDifficulty() >= FUNNY_MODE then 
				factor = 1.5
			end
			local totalNum = #expUnits
			if totalNum > 0 then
				for k,v in pairs(expUnits) do
					v:THTD_AddExp(math.floor(factor * killedUnit:GetDeathXP() / totalNum + 0.5))
				end
			end
		end

		-- 物品掉落
		-- local vHitLoc = killedUnit:GetAttachmentOrigin(killedUnit:ScriptLookupAttachment("attach_hitloc"))
		-- local drop = CreateItemOnPositionSync(vHitLoc, item)
		-- drop:SetModelScale(drop:GetModelScale() * (item:THTD_GetCardQuality() or 2) * 0.5)								
		-- item:LaunchLootInitialHeight(false, vHitLoc.z, vHitLoc.z+300, 2.0, killedUnit:GetAbsOrigin() + RandomVector(300))	

		if killedUnit.thtd_is_outer == true then 
			for k,v in pairs(THTD_EntitiesRectOuter) do
				if v == killedUnit then
					table.remove(THTD_EntitiesRectOuter, k) 
					break
				end
			end
		elseif id ~= nil then
			for k,v in pairs(THTD_EntitiesRectInner[id]) do
				if v == killedUnit then 
					table.remove(THTD_EntitiesRectInner[id], k)
					break
				end
			end
		end

		killedUnit:AddNoDraw()

		local effectIndex = ParticleManager:CreateParticle("particles/thd2/environment/death/act_hero_die.vpcf", PATTACH_CUSTOMORIGIN, nil)
	    ParticleManager:SetParticleControl(effectIndex, 0, killedUnit:GetOrigin())
	    ParticleManager:SetParticleControl(effectIndex, 1, killedUnit:GetOrigin())
	    ParticleManager:DestroyParticleSystem(effectIndex,false)

		local hero = GameRules.HeroList[killerEntity:GetPlayerOwnerID()]
		if hero == nil then return end
		hero.thtd_game_info["creature_kill_count"] = hero.thtd_game_info["creature_kill_count"] + 1
	end
end

function CTHTDGameMode:OnPlayerSay(keys)	
	-- if tostring(PlayerResource:GetSteamID(keys.playerid)) ~= GameRules.GameData.admin then return end	

	local text = keys.text
	if string.sub(text,1,1) ~= "-" then 
		return
	end

	if text == "-6" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		ParticleManager:DestroyParticleSystem(hero.thtd_emoji_effect,true)
		hero.thtd_emoji_effect = ParticleManager:CreateParticle("particles/thtd/emoji/thtd_msg_hongliange.vpcf", PATTACH_OVERHEAD_FOLLOW, hero) 
		ParticleManager:SetParticleControlEnt(hero.thtd_emoji_effect , 0, hero, PATTACH_OVERHEAD_FOLLOW, "attach_hitloc", Vector(0,0,0), true)  --灵梦用 attach_emoji
		ParticleManager:SetParticleControl(hero.thtd_emoji_effect, 3, Vector(1,0,0))
		ParticleManager:DestroyParticleSystemTime(hero.thtd_emoji_effect,5.0)
		return
	end
	if text == "-7" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		ParticleManager:DestroyParticleSystem(hero.thtd_emoji_effect,true)
		hero.thtd_emoji_effect = ParticleManager:CreateParticle("particles/thtd/emoji/thtd_msg_hongliange.vpcf", PATTACH_OVERHEAD_FOLLOW, hero) 
		ParticleManager:SetParticleControlEnt(hero.thtd_emoji_effect , 0, hero, PATTACH_OVERHEAD_FOLLOW, "attach_hitloc", Vector(0,0,0), true)
		ParticleManager:SetParticleControl(hero.thtd_emoji_effect, 3, Vector(2,0,0))
		ParticleManager:DestroyParticleSystemTime(hero.thtd_emoji_effect,5.0)
		return
	end
	if text == "-8" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		ParticleManager:DestroyParticleSystem(hero.thtd_emoji_effect,true)
		hero.thtd_emoji_effect = ParticleManager:CreateParticle("particles/thtd/emoji/thtd_msg_hongliange.vpcf", PATTACH_OVERHEAD_FOLLOW, hero) 
		ParticleManager:SetParticleControlEnt(hero.thtd_emoji_effect , 0, hero, PATTACH_OVERHEAD_FOLLOW, "attach_hitloc", Vector(0,0,0), true)
		ParticleManager:SetParticleControl(hero.thtd_emoji_effect, 3, Vector(3,0,0))
		ParticleManager:DestroyParticleSystemTime(hero.thtd_emoji_effect,5.0)
		return
	end
	if text == "-9" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		ParticleManager:DestroyParticleSystem(hero.thtd_emoji_effect,true)
		hero.thtd_emoji_effect = ParticleManager:CreateParticle("particles/thtd/emoji/thtd_msg_hongliange.vpcf", PATTACH_OVERHEAD_FOLLOW, hero) 
		ParticleManager:SetParticleControlEnt(hero.thtd_emoji_effect , 0, hero, PATTACH_OVERHEAD_FOLLOW, "attach_hitloc", Vector(0,0,0), true)
		ParticleManager:SetParticleControl(hero.thtd_emoji_effect, 3, Vector(4,0,0))
		ParticleManager:DestroyParticleSystemTime(hero.thtd_emoji_effect,5.0)
		return
	end
	if text == "-0" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		ParticleManager:DestroyParticleSystem(hero.thtd_emoji_effect,true)
		hero.thtd_emoji_effect = ParticleManager:CreateParticle("particles/thtd/emoji/thtd_msg_hongliange.vpcf", PATTACH_OVERHEAD_FOLLOW, hero) 
		ParticleManager:SetParticleControlEnt(hero.thtd_emoji_effect , 0, hero, PATTACH_OVERHEAD_FOLLOW, "follow_origin", Vector(0,0,0), true)
		ParticleManager:SetParticleControl(hero.thtd_emoji_effect, 3, Vector(5,0,0))
		ParticleManager:DestroyParticleSystemTime(hero.thtd_emoji_effect,5.0)
		return
	end	

	if string.sub(text,1,6) == "-color" then
		local colorValue = string.sub(text, 8, 11)	
		CustomGameEventManager:Send_ServerToAllClients("show_message", {msg="item_locked_tip", duration=10, params={}, color=colorValue})
		return
	end	

	if string.sub(text,1,3) == "-id" then
		GameRules:SendCustomMessage("<font color='yellow'>id:"..tostring(PlayerResource:GetSteamAccountID(keys.playerid))..", steamid:"..tostring(PlayerResource:GetSteamID(keys.playerid)).."</font>", DOTA_TEAM_GOODGUYS, 0)	
		return
	end	

	if string.sub(text,1,5) == "-date" then	
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid), "display_chat_msg", {msg="open_day_tip", params={server_time=GetRealDateTime(),start_time=GameRules.GameData.server_time,open_day_list=GameRules.GameData.open_day_list}})
		return
	end

	if string.sub(text,1,4) == "-pos" then
		local player = PlayerResource:GetPlayer(keys.playerid)
		local hero = player:GetAssignedHero()
		local pos = hero:GetAbsOrigin()
		print("------- Current Position (x, y, z):")
		print(math.floor(pos.x + 0.5))
		print(math.floor(pos.y + 0.5))
		print(math.floor(pos.z + 0.5))
		GameRules:SendCustomMessage("X: "..tostring(math.floor(pos.x + 0.5)).."，Y："..tostring(math.floor(pos.y + 0.5)).."，Z："..tostring(math.floor(pos.z + 0.5)), DOTA_TEAM_GOODGUYS, 0)
		return
	end

	if string.sub(text,1,5) == "-wave" then
		local num = tonumber(string.sub(text, 7))
		if num ~= nil and num > -49 then 
			CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="wave", param=num})					
		end		
		return	
	end

	if string.sub(text,1,5) == "-boss" then
		local num = string.sub(text, 7, 20)		
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="boss", param=num})	
		return
	end

	if string.sub(text,1,4) == "-add" then
		local num = string.sub(text, 6, 9)
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="add", param=num})
		return
	end

	if string.sub(text,1,3) == "-tp" then
		local num = string.sub(text, 5, 20)
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="tp", param=num})
		return
	end		

	if string.sub(text,1,10) == "-clearrank" then		
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="clearrank", param={}})
		return
	end	

	if string.sub(text,1,8) == "-lv" then		
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="lv", param={}})
		return
	end	

	if string.sub(text,1,5) == "-test" then	
		if tostring(PlayerResource:GetSteamID(keys.playerid)) ~= GameRules.GameData.admin then return end

		local select_cards = {}
		for i = 3011,3031 do
			select_cards["item_"..tostring(i)] = "item_"..tostring(i)		
		end
		for i = 2011,2022 do
			select_cards["item_"..tostring(i)] = "item_"..tostring(i)		
		end
		
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid) , "show_select_bonus_card_panel", {cards=select_cards})	
		return
	end	

	if string.sub(text,1,5) == "-skey" then		
		CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.playerid),"thtd_command", {cmd="skey", param=SERVER_KEY})
		return
	end	
end


function CTHTDGameMode:ExecuteOrder( keys )	
	if table.hasvalue(SpawnSystem.GameOverPlayerId, keys.issuer_player_id_const) then return false end	
	
	local orderUnit = EntIndexToHScript(keys.units["0"])
	if orderUnit == nil then return true end

	-- PrintTable(keys)
	local order_type  = keys.order_type	

	if order_type == DOTA_UNIT_ORDER_ATTACK_TARGET or 
	   order_type == DOTA_UNIT_ORDER_CAST_POSITION or 
	   order_type == DOTA_UNIT_ORDER_CAST_TARGET or 
	   order_type == DOTA_UNIT_ORDER_CAST_NO_TARGET or 
	   order_type == DOTA_UNIT_ORDER_CAST_TARGET_TREE 
	then 
		orderUnit:THTD_SetAggressiveLock()
	end

	if order_type == 32 then
		local ability = EntIndexToHScript(keys.entindex_ability)
		if ability ~= nil and ability:IsItem() then		
			if keys.entindex_target == 1 then
				ability.locked_by_player_id = keys.issuer_player_id_const
			else
				local tower = ability:THTD_GetTower()
				if tower ~= nil then
					for i=0,8 do
						local targetItem = tower:GetItemInSlot(i)
						if targetItem~=nil and targetItem:IsNull()==false then
							CustomGameEventManager:Send_ServerToPlayer(orderUnit:GetPlayerOwner(), "display_custom_error", {msg="card_cannot_unlock_when_having_equipment"})		
							return false
						end
					end
				end
				ability.locked_by_player_id = nil
			end
			return true
		end
		return false
	end
	
	-- if order_type == DOTA_UNIT_ORDER_MOVE_ITEM then
		-- 移动储存处
		-- if keys.entindex_target >= THTD_MAX_ITEM_SLOT then
			
		-- end
		-- return true	
	-- end		

	if order_type == DOTA_UNIT_ORDER_SELL_ITEM then		
		local ability = EntIndexToHScript(keys.entindex_ability)
		if ability ~= nil and ability:IsItem() then	
			if ability:GetAbilityName() == "item_3121" then 
				return false
		    end
			if ability.disable_sell == true then 
				local player = PlayerResource:GetPlayer(keys.issuer_player_id_const)
				if player then 
					CustomGameEventManager:Send_ServerToPlayer(player , "display_custom_error", {msg="item_disable_sell"} )
				end
				return false
			end
			if ability.is_bonus_item == true then 
				CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(keys.issuer_player_id_const), "display_custom_error", {msg="start_card_cannot_be_sell"})	
				return false
			end			
			if ability.locked_by_player_id ~= nil then
				local player = PlayerResource:GetPlayer(keys.issuer_player_id_const)
				if player then 
					CustomGameEventManager:Send_ServerToPlayer(player , "display_custom_error", {msg="item_is_locked"} )
				end
				return false
			end	
			OnItemDestroyed(EntIndexToHScript(keys.units["0"]), ability, true)
		end	
		local gold = ability:GetCost()
		if gold ~= nil and gold > 0 then
			gold = math.floor(gold/2)
			local current_gold = PlayerResource:GetGold(keys.issuer_player_id_const)
			if gold + current_gold > 99999 then
				thtd_extra_gold[keys.issuer_player_id_const] = thtd_extra_gold[keys.issuer_player_id_const] + (gold - (99999-current_gold))
				THTD_RefreshExtraGold(keys.issuer_player_id_const)
			elseif thtd_extra_gold[keys.issuer_player_id_const] > 0 then
				local add_gold = math.min(thtd_extra_gold[keys.issuer_player_id_const], 99999-(gold+current_gold))		
				thtd_extra_gold[keys.issuer_player_id_const] = thtd_extra_gold[keys.issuer_player_id_const] - add_gold			
				PlayerResource:ModifyGold(keys.issuer_player_id_const, add_gold, true, DOTA_ModifyGold_Unspecified)
				THTD_RefreshExtraGold(keys.issuer_player_id_const)
			end
		end
		return true
	end

	if order_type == DOTA_UNIT_ORDER_GIVE_ITEM then	
		local item = EntIndexToHScript(keys.entindex_ability)
		local target = 	EntIndexToHScript(keys.entindex_target)	
		local count = 0
		for i=0,THTD_MAX_ITEM_SLOT-1 do
			local targetItem = target:GetItemInSlot(i)
			if targetItem~=nil and targetItem:IsNull()==false then count = count + 1 end
		end
		if count >= THTD_MAX_ITEM_SLOT then 
			local player = PlayerResource:GetPlayer(keys.issuer_player_id_const)
			if player then 
				CustomGameEventManager:Send_ServerToPlayer(player, "display_custom_error", {msg="not_enough_item_slot"})
			end					
			return false
		else 
			return true
		end
	end	

	if order_type == DOTA_UNIT_ORDER_DROP_ITEM then	
		local item = EntIndexToHScript(keys.entindex_ability)
		if THTD_HasItemScale(item) then 
			if item.item_set_scale ~= true then 
				item.item_set_scale = true
				local count = 600
				item:SetContextThink(DoUniqueString("item_set_scale"),
					function() 
						if GameRules:IsGamePaused() then return 0.03 end
						if item:GetContainer() ~= nil then 
							THTD_ItemSetScale(item)
							item.item_set_scale = nil			
							return nil
						end
						if count <= 0 then 
							item.item_set_scale = nil			
							return nil
						end
						count = count - 1
						return 0.1					
					end,
				0.1)
			end		
		end
		return true			
	end
	
	if order_type == DOTA_UNIT_ORDER_PICKUP_ITEM then	
		local itemC = EntIndexToHScript(keys.entindex_target)
		if itemC ~= nil then
			local item = itemC:GetContainedItem()
			if item ~= nil then
				local itemName = item:GetAbilityName()
				if itemName == "item_3101" or itemName == "item_3102" or itemName == "item_3103" then
					local player = PlayerResource:GetPlayer(keys.issuer_player_id_const)
					if orderUnit:IsRealHero() == false then 
						CustomGameEventManager:Send_ServerToPlayer(player, "display_custom_error", {msg="not_key_unit"})
						return false
					end	
					if orderUnit:GetNumItemsInInventory() >= THTD_MAX_ITEM_SLOT then 
						CustomGameEventManager:Send_ServerToPlayer(player, "display_custom_error", {msg="not_enough_item_slot"})	
						return false
					end
					if not orderUnit:HasItemInInventory("item_3121") then 	
						CustomGameEventManager:Send_ServerToPlayer(player, "display_custom_error", {msg="not_has_key_item"})
						return false
					end
				end
			end	
		end
	end

	return true
end


local item_cn_name = {
	["item_2019"] = "「纳税用阴阳玉」",	
	["item_2008"] = "「死神渡河船桨」",	
	["item_2005"] = "「血染的太阳伞」",	
	["item_2009"] = "「割夺真实之刃」",	
	["item_2010"] = "「死神大镰刀」",	
	["item_2011"] = "「月兔粉碎巨刃」",	
	["item_2015"] = "「念缚灵的船勾」",	
	["item_2016"] = "「速融的核融合棒」",	
	["item_2017"] = "「恶魔的乳牙」",	
	["item_2001"] = "「四次元爆蛋」",	
	["item_2012"] = "「迷你八卦炉」",	
	["item_2013"] = "「莱瓦汀」",	
	["item_2014"] = "「神枪冈格尼尔」",	
	["item_2020"] = "「高科技相机」",	
	["item_3150"] = "「布都御魂」",	
	["item_3151"] = "「天丛云剑」",	
	["item_3152"] = "「天羽羽斩」",	
	["item_3149"] = "「凤凰之灵」",	
	["item_2021"] = "「千年佳酿」",	
}
local item_loot = {
	[1] = {"item_2021","item_2019","item_2008","item_2005"}, --R
	[2] = {"item_2009","item_2010","item_2011","item_2015","item_2016","item_2017","item_2001"}, -- SR
	[3] = {"item_2012","item_2013","item_2014","item_2020"}, -- SSR	
	[4] = {}, -- 羁绊,todo
	[5] = {"item_3150", "item_3151", "item_3152"}, -- 神器	
	
}
function CTHTDGameMode:ItemAddedToInventory( keys )	
	local caster = EntIndexToHScript(keys.inventory_parent_entindex_const)
	local hItem = EntIndexToHScript(keys.item_entindex_const)
	local itemName = hItem:GetAbilityName()
	
	if itemName == "item_enchanted_mango" then
		return false
	end

	if GameRules:GetCustomGameDifficulty() == PVE_MODE then 
		CheckItemShare(caster, hItem)
	end
	
	if itemName == "item_3101" or itemName == "item_3102" or itemName == "item_3103" then
		local keyItem = caster:FindItemInInventory("item_3121")		
		if keyItem ~= nil then 
			keyItem:SpendCharge()			
			if keyItem:GetCurrentCharges() == 0 then 
				caster:RemoveItem(keyItem)
			end
	
			local playerid = caster:GetPlayerOwnerID()
			GameRules.PlayerData[playerid]["key_use_count"] = GameRules.PlayerData[playerid]["key_use_count"] + 1
	
			if caster.first_chest_opened ~= true and GameRules.PlayerData[playerid]["is_first_win"] == 1 then
				caster.first_chest_opened = true
				Service:GiveDayFirstWinBonus(playerid)
			else
				local itemName = ""
				local chance = RandomInt(1, 100)			
				if GameRules.PlayerData[playerid]["key_use_count"] > 100/0.05 then
					chance = 101
				end
	
				if chance <= 35 then
					itemName = item_loot[1][1]
				elseif chance <= 15 + 35 then
					itemName = item_loot[1][RandomInt(1, #item_loot[1])]
				elseif chance <= 25 + 50 then 
					itemName = item_loot[2][RandomInt(1, #item_loot[2])]
				elseif chance <= 12 + 75 then 				
					itemName = item_loot[3][RandomInt(1, #item_loot[3])]
				elseif chance <= 5 + 87 then 				
					itemName = item_loot[1][1]
				elseif chance <= 3 + 92 then 		
					itemName = item_loot[5][RandomInt(1, #item_loot[5])]
				else					
					if chance == 101 or RollPercentage(1) then 
						itemName = "item_3149"						
						GameRules.PlayerData[playerid]["key_use_count"] = 0						
					else
						itemName = item_loot[1][1]
					end
				end			
				local item = CreateItem(itemName, nil, nil)	
				if item ~= nil then
					item.owner_player_id = playerid
					item.disable_sell = true
					item:SetPurchaser(caster)
					item:SetPurchaseTime(1.0)
					caster:AddItem(item)
					CustomGameEventManager:Send_ServerToPlayer(caster:GetPlayerOwner(), "thtd_server_msg", {code = "0000", msg = "获得 "..(item_cn_name[itemName] or itemName)})
					if itemName == "item_3149" then 
						Service:SavePowerMaxCount(playerid, true)
					end
				end			
			end

			Service:SaveKeyCount(playerid)
		end
		
		UTIL_Remove(hItem)
		return false			
	end	

	if not caster:IsRealHero() then
		local hero = caster:GetHero()
		if hero ~= nil then 
			if itemName == "item_3150" or itemName == "item_3151" or itemName == "item_3152" then
				if hero.is_team_mode ~= true then 
					hero.is_team_mode = true 		
					CustomGameEventManager:Send_ServerToPlayer(hero:GetPlayerOwner(), "display_chat_msg", {msg="team_rank_tip", params={player_name=PlayerResource:GetPlayerName(hero:GetPlayerOwnerID()),reason="使用了传说武器"}})					
				end
			end
		end
	end

	return true
end

function CheckItemShare(caster,item)
	if caster == nil or item == nil then return end	
	if item:GetAbilityName() == "item_tpscroll" then return end
	-- local cardName = item:THTD_GetCardName()
	-- if cardName == "BonusEgg" or cardName == "minoriko" or cardName == "sizuha" or cardName == "lily" or cardName == "nazrin" or cardName == "toramaru" or item:THTD_GetCardQuality() == 1 then return end
	
	local playerId = caster:GetPlayerOwnerID()
	if item.owner_player_id ~= playerId then 
		CustomGameEventManager:Send_ServerToPlayer(caster:GetPlayerOwner(), "display_custom_error", {msg="cannot_use_others_item_in_single_mode"})	
		caster:SetContextThink(DoUniqueString("thtd_pertick_gold_think"), 
			function()
				if GameRules:IsGamePaused() then return 0.03 end
				caster:DropItemAtPositionImmediate(item, caster:GetOrigin())
				return nil
			end,
		0.15)
	end	
end


function CTHTDGameMode:ModifierFilter(keys)
	if keys.entindex_parent_const == nil or keys.entindex_caster_const == nil then
		return true
	end

	local caster = EntIndexToHScript(keys.entindex_caster_const)
	local unit = EntIndexToHScript(keys.entindex_parent_const)   

	if unit~=nil and unit:IsNull()==false then
		local modifierName = keys.name_const

		if THTD_IsUniqueSlowBuff(modifierName) == true then
			if unit:THTD_HasUniqueSlowBuff() or unit:HasModifier("modifier_bosses_aya") then
				return false
			else
				return true
			end
		end
		
		if modifierName == "modifier_faceless_void_timelock_freeze" then
			local ability = EntIndexToHScript(keys.entindex_ability_const)
			caster:SetContextThink(DoUniqueString("thtd_bb_3028"), 
				function()					
					local DamageTable = {
						ability = ability,
						victim = unit,
						attacker = caster,
						damage = unit:GetMaxHealth() * ability:GetSpecialValueFor("bonus_damage")/100,
						damage_type = ability:GetAbilityDamageType(),
						damage_flags = DOTA_DAMAGE_FLAG_NONE				
					}
					UnitDamageTarget(DamageTable)					
					return nil 
				end,
			0.3)
		end
	end
	return true
end


function CTHTDGameMode:DamageFilter(keys)	
	-- damage: 24
	-- damagetype_const: 1
	-- entindex_attacker_const: 503
	-- entindex_inflictor_const: 500 技能，普通攻击没有这个
	-- entindex_victim_const: 434	
	if keys.damage <= 0 then return false end
	if keys.entindex_attacker_const == nil or keys.entindex_victim_const == nil then return true end
	
	local target = EntIndexToHScript(keys.entindex_victim_const)	
	local unit = EntIndexToHScript(keys.entindex_attacker_const)
	if unit:IsRealHero() then 
		local health = target:GetHealth()
		-- 辉夜复活
		if target:HasModifier("modifier_bosses_kaguya") and keys.damage > health then	
			target:SetHealth(1)
			target:RemoveModifierByName("modifier_bosses_kaguya")			
			return false
		end
		-- 爱丽丝免死符
		if target:HasModifier("modifier_bosses_alice") and target.left_death_count > 0 and keys.damage >= health then	
			target:SetHealth(1)
			target:RemoveModifierByName("modifier_bosses_alice")			
			return false
		end
		return true 
	end

	local DamageTable = {		
		ability = nil,	
		victim = target,
		attacker = unit,
		damage = keys.damage,
		damage_type = keys.damagetype_const,			
	}
	UnitDamageTarget(DamageTable, false, true)
	return false
end


function CTHTDGameMode:OnModifyGoldFilter(keys)
	-- gold: 15
	-- player_id_const: 0
	-- reason_const: 13
	-- reliable: 0
	
	-- 出售和接口改变金钱不会触发，当前地图只有杀怪奖励金钱

	if keys.gold == 0 then return true end

	if keys.gold > 0 then 	
		if thtd_extra_gold[keys.player_id_const] == nil then
			thtd_extra_gold[keys.player_id_const] = 0
		end
		local current_gold = PlayerResource:GetGold(keys.player_id_const)
		if current_gold + keys.gold > 99999 then
			local add_gold = math.min(keys.gold, 99999-current_gold)
			thtd_extra_gold[keys.player_id_const] = thtd_extra_gold[keys.player_id_const] + (keys.gold - add_gold)
			keys.gold = add_gold		
		elseif thtd_extra_gold[keys.player_id_const] > 0 then
			local add_gold = math.min(thtd_extra_gold[keys.player_id_const], 99999-(keys.gold+current_gold))
			keys.gold = keys.gold + add_gold
			thtd_extra_gold[keys.player_id_const] = thtd_extra_gold[keys.player_id_const] - add_gold
		end
	end

	THTD_RefreshExtraGold(keys.player_id_const)  
	return true
end


function CTHTDGameMode:OnDotaNonPlayerUsedAbility(keys)
	-- 字段
	-- abilityname
	-- caster_entindex
	
	local caster = EntIndexToHScript(keys.caster_entindex)

	local unitName = caster:GetUnitName()
	if unitName == "remilia" or unitName == "flandre" or unitName == "patchouli" or unitName == "sakuya" or unitName == "koakuma" or unitName == "meirin" then
		local playerid = caster:GetPlayerOwnerID()
		if GameRules.player_bb_buff[playerid]["item_3025"] > 0 and RollPercentage(GameRules.player_bb_buff[playerid]["item_3025"]) then
			local ability = caster:FindAbilityByName(keys.abilityname)
			ability:EndCooldown()
			caster:GiveMana(caster:GetRealManaCost(ability))
		end
	end
end