Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 268.22 KB | None | 0 0
  1. --刀塔自走棋
  2. if DAC == nil then
  3. DAC = class({})
  4. end
  5.  
  6. require('Timers')
  7. require('Physics')
  8. require('util')
  9. require('barebones')
  10. require('amhc_library/amhc')
  11. require('pathfinder/core/heuristics')
  12. require('pathfinder/core/node')
  13. require('pathfinder/core/path')
  14. require('pathfinder/grid')
  15. require('pathfinder/pathfinder')
  16. require('pathfinder/core/bheap')
  17. require('pathfinder/search/astar')
  18. require('pathfinder/search/bfs')
  19. require('pathfinder/search/dfs')
  20. require('pathfinder/search/dijkstra')
  21. require('pathfinder/search/jps')
  22. require('jump')
  23. require('status_resistance')
  24. LinkLuaModifier("modifier_jump", "jump.lua", LUA_MODIFIER_MOTION_BOTH)
  25. LinkLuaModifier("modifier_status_resistance", "status_resistance.lua", LUA_MODIFIER_MOTION_NONE)
  26.  
  27. function Precache( context )
  28. local mxx={
  29. --以前的模型和特效
  30. "particles/units/heroes/hero_templar_assassin/templar_assassin_base_attack.vpcf",
  31. "particles/dev/library/base_dust_hit_smoke.vpcf",
  32. "particles/econ/events/fall_major_2016/teleport_start_fm06_lvl3.vpcf",
  33. "soundevents/soundevents_dota_ui.vsndevts",
  34. "particles/econ/events/snowball/snowball_projectile.vpcf",
  35. "particles/units/heroes/hero_venomancer/venomancer_base_attack.vpcf",
  36. "particles/neutral_fx/gnoll_poison_debuff.vpcf",
  37. "particles/units/heroes/hero_crystalmaiden/maiden_frostbite_buff.vpcf",
  38. "models/items/courier/teron/teron_flying.vmdl",
  39. "soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
  40. "soundevents/game_sounds_heroes/game_sounds_zuus.vsndevts",
  41. "soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
  42. "soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
  43. "particles/econ/items/zeus/arcana_chariot/zeus_arcana_thundergods_wrath_start.vpcf",
  44. "particles/econ/items/omniknight/hammer_ti6_immortal/omniknight_pu_ti6_heal_hammers.vpcf",
  45. "particles/econ/items/lina/lina_ti6/lina_ti6_laguna_blade.vpcf",
  46. "particles/units/heroes/hero_disruptor/disruptor_thunder_strike_bolt.vpcf",
  47. "particles/units/heroes/hero_keeper_of_the_light/keeper_chakra_magic.vpcf",
  48. "particles/units/heroes/hero_oracle/oracle_fatesedict.vpcf",
  49. "particles/econ/events/winter_major_2017/blink_dagger_end_wm07.vpcf",
  50. "soundevents/game_sounds_heroes/game_sounds_antimage.vsndevts",
  51. "particles/units/heroes/hero_lina/lina_spell_light_strike_array.vpcf",
  52. "soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",
  53. "particles/radiant_fx/radiant_castle002_destruction_a2.vpcf",
  54. "particles/units/heroes/hero_dazzle/dazzle_shallow_grave.vpcf",
  55. "particles/econ/items/axe/axe_cinder/axe_cinder_battle_hunger.vpcf",
  56. "particles/units/heroes/hero_rubick/rubick_spell_steal.vpcf",
  57. "models/items/courier/duskie/duskie.vmdl",
  58. "particles/units/heroes/hero_lone_druid/lone_druid_bear_entangle_body.vpcf",
  59. "soundevents/game_sounds_heroes/game_sounds_lone_druid.vsndevts",
  60. "particles/items2_fx/tranquil_boots_healing.vpcf",
  61. "particles/units/heroes/hero_beastmaster/beastmaster_primal_roar.vpcf",
  62. "particles/units/heroes/hero_spirit_breaker/spirit_breaker_nether_strike_end.vpcf",
  63. "particles/units/heroes/hero_batrider/batrider_base_attack.vpcf",
  64. "particles/items_fx/healing_flask_c.vpcf",
  65. "particles/units/heroes/hero_skeletonking/wraith_king_spirits.vpcf",
  66. "particles/units/heroes/hero_phoenix/phoenix_supernova_scepter_f.vpcf",
  67. "particles/radiant_fx/good_barracks_ranged001_lvl3_disintegrate.vpcf",
  68. "soundevents/game_sounds_heroes/game_sounds_vengefulspirit.vsndevts",
  69. "particles/units/heroes/hero_tinker/tinker_missile.vpcf",
  70.  
  71. "soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",
  72. "soundevents/game_sounds_ui.vsndevts",
  73. "particles/units/heroes/hero_visage/visage_grave_chill_skel.vpcf",
  74. "soundevents/game_sounds_heroes/game_sounds_invoker.vsndevts",
  75. "soundevents/game_sounds_heroes/game_sounds_rattletrap.vsndevts",
  76. "soundevents/game_sounds_heroes/game_sounds_sniper.vsndevts",
  77. "particles/econ/items/rubick/rubick_puppet_master/rubick_back_puppet_ambient_edge_c.vpcf",
  78. "particles/newplayer_fx/npx_sleeping.vpcf",
  79. "particles/generic_gameplay/generic_stunned_old.vpcf",
  80. "particles/econ/items/enchantress/enchantress_virgas/ench_impetus_virgas.vpcf",
  81. "particles/econ/items/alchemist/alchemist_smooth_criminal/alchemist_smooth_criminal_unstable_concoction_projectile_explosion_fire.vpcf",
  82. "soundevents/game_sounds_heroes/game_sounds_phoenix.vsndevts",
  83. "particles/econ/items/shadow_fiend/sf_fire_arcana/sf_fire_arcana_shadowraze_char.vpcf",
  84. "particles/units/heroes/hero_tiny/tiny_loadout.vpcf",
  85. "soundevents/game_sounds_heroes/game_sounds_tiny.vsndevts",
  86. "models/props_structures/tower_good.vmdl",
  87. "models/props_structures/tower_bad.vmdl",
  88. "particles/econ/items/sniper/sniper_immortal_cape/sniper_immortal_cape_headshot_slow_model.vpcf",
  89. "particles/customgames/capturepoints/cp_allied_wind.vpcf",
  90. "particles/customgames/capturepoints/cp_wood.vpcf",
  91. "models/items/courier/hermit_crab/hermit_crab.vmdl",
  92. "particles/econ/events/ti7/teleport_end_ti7_team1836806.vpcf",
  93. "particles/econ/items/sniper/sniper_immortal_cape/sniper_immortal_cape_headshot_slow_ring.vpcf",
  94. "particles/econ/items/clinkz/clinkz_maraxiform/clinkz_maraxiform_searing_arrow.vpcf",
  95. "soundevents/game_sounds_heroes/game_sounds_dazzle.vsndevts",
  96. "particles/addons_gameplay/tower_good_tintable_lamp_end.vpcf",
  97. "particles/econ/events/ti7/teleport_end_ti7_model.vpcf",
  98. "particles/units/heroes/hero_shredder/shredder_whirling_death_spin_blades.vpcf",
  99. "soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
  100. "particles/units/heroes/hero_lina/lina_base_attack.vpcf",
  101. "particles/units/heroes/hero_razor/razor_static_link_projectile_a.vpcf",
  102. "soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
  103. "particles/econ/items/crystal_maiden/ti7_immortal_shoulder/cm_ti7_immortal_frostbite.vpcf",
  104. "soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
  105. "soundevents/game_sounds_heroes/game_sounds_earthshaker.vsndevts",
  106. "particles/econ/items/earthshaker/earthshaker_totem_ti6/earthshaker_totem_ti6_leap_impact.vpcf",
  107. "particles/units/heroes/hero_stormspirit/stormspirit_overload_discharge.vpcf",
  108. "particles/units/heroes/hero_sven/sven_spell_gods_strength_small.vpcf",
  109. "particles/units/heroes/hero_sven/sven_spell_gods_strength.vpcf",
  110. "soundevents/game_sounds_heroes/game_sounds_bloodseeker.vsndevts",
  111. "particles/econ/items/bloodseeker/bloodseeker_eztzhok_weapon/bloodseeker_bloodbath_eztzhok_ribbon.vpcf",
  112. "particles/econ/items/slardar/slardar_takoyaki_gold/slardar_crush_tako_ground_dust_pyro_gold.vpcf",
  113. "soundevents/game_sounds_heroes/game_sounds_death_prophet.vsndevts",
  114. "particles/dac/explode/land_mine_explode.vpcf",
  115. "particles/units/heroes/hero_dragon_knight/dragon_knight_transform_blue_smoke04.vpcf",
  116. "particles/econ/items/antimage/antimage_weapon_basher_ti5_gold/antimage_manavoid_explode_b_b_ti_5_gold.vpcf",
  117. "particles/dac/zhayaotong/zhayaotong.vpcf",
  118. "soundevents/game_sounds_heroes/game_sounds_silencer.vsndevts",
  119. "particles/econ/items/bounty_hunter/bounty_hunter_hunters_hoard/bounty_hunter_hoard_shield_mark.vpcf",
  120. "particles/dac/ansha/loadout.vpcf",
  121. "particles/dac/jingzhixianjingplant_ground_disturb.vpcf",
  122. "soundevents/game_sounds_heroes/game_sounds_techies.vsndevts",
  123. "particles/generic_gameplay/generic_stunned.vpcf",
  124. "particles/units/heroes/hero_techies/techies_stasis_trap_explode.vpcf",
  125.  
  126.  
  127. "particles/econ/items/ancient_apparition/aa_blast_ti_5/ancient_apparition_ice_blast_sphere_final_explosion_smoke_ti5.vpcf",
  128. "models/items/wards/eye_of_avernus_ward/eye_of_avernus_ward.vmdl",
  129. "models/props_structures/dire_ancient_base001_destruction.vmdl",
  130. "models/props_structures/radiant_ancient001_rock_destruction.vmdl",
  131. "models/creeps/lane_creeps/creep_radiant_melee/radiant_melee.vmdl",
  132. "models/creeps/lane_creeps/creep_bad_melee/creep_bad_melee.vmdl",
  133. "models/props_structures/radiant_ranged_barracks001.vmdl",
  134. "models/props_structures/dire_barracks_ranged001.vmdl",
  135. "models/props_structures/radiant_ancient001.vmdl",
  136. "models/props_structures/dire_ancient_base001.vmdl",
  137. "models/props_structures/dire_barracks_ranged001_destruction.vmdl",
  138. "models/props_structures/radiant_ranged_barracks001_destruction.vmdl",
  139. "effects/damage.vpcf",
  140. "effects/damage2.vpcf",
  141. "effects/damage3.vpcf",
  142. "particles/ui/ui_game_start_hero_spawn.vpcf",
  143. "particles/base_attacks/ranged_tower_bad_trail.vpcf",
  144. "particles/units/heroes/hero_warlock/warlock_fatal_bonds_base.vpcf",
  145. "particles/units/heroes/hero_tinker/tinker_laser.vpcf",
  146. "particles/units/heroes/hero_ursa/ursa_fury_swipes_debuff.vpcf",
  147. "soundevents/voscripts/game_sounds_vo_wisp.vsndevts",
  148. "soundevents/game_sounds_heroes/game_sounds_wisp.vsndevts",
  149.  
  150. "soundevents/voscripts/game_sounds_vo_lina.vsndevts",
  151. "particles/econ/items/puck/puck_alliance_set/puck_dreamcoil_waves_aproset.vpcf",
  152. "particles/econ/items/drow/drow_ti6/drow_ti6_silence_wave_ground_smoke.vpcf",
  153. "materials/pumpkin.vmdl",
  154. "models/props_gameplay/boots_of_speed.vmdl",
  155. "models/props_gameplay/quelling_blade.vmdl",
  156. "models/props_gameplay/stout_shield.vmdl",
  157. "models/props_gameplay/tango.vmdl",
  158. "models/props_gameplay/smoke.vmdl",
  159. "models/props_gameplay/halloween_candy.vmdl",
  160. "models/props_gameplay/salve_red.vmdl",
  161. "models/props_gameplay/mango.vmdl",
  162. "models/props_gameplay/branch.vmdl",
  163. "particles/gem/sniper_crosshair.vpcf",
  164. "particles/radiant_fx/tower_good3_dest_beam.vpcf",
  165. "particles/units/heroes/hero_witchdoctor/witchdoctor_maledict_dot.vpcf",
  166. "soundevents/voscripts/game_sounds_vo_shredder.vsndevts",
  167. "soundevents/voscripts/game_sounds_vo_rattletrap.vsndevts",
  168. "soundevents/voscripts/game_sounds_vo_dragon_knight.vsndevts",
  169. "soundevents/voscripts/game_sounds_vo_death_prophet.vsndevts",
  170. "soundevents/voscripts/game_sounds_vo_tinker.vsndevts",
  171. "soundevents/voscripts/game_sounds_vo_lycan.vsndevts",
  172. "soundevents/voscripts/game_sounds_vo_ursa.vsndevts",
  173. "soundevents/voscripts/game_sounds_vo_enchantress.vsndevts",
  174. "soundevents/voscripts/game_sounds_vo_techies.vsndevts",
  175. "soundevents/voscripts/game_sounds_vo_tiny.vsndevts",
  176. "soundevents/game_sounds_heroes/game_sounds_shadowshaman.vsndevts",
  177. "soundevents/game_sounds.vsndevts",
  178. "soundevents/game_sounds_heroes/game_sounds_lion.vsndevts",
  179. "soundevents/voscripts/game_sounds_vo_stormspirit.vsndevts",
  180. "soundevents/game_sounds_roshan_halloween.vsndevts",
  181. "soundevents/game_sounds_heroes/game_sounds_lone_druid.vsndevts",
  182. "soundevents/voscripts/game_sounds_vo_doom_bringer.vsndevts",
  183. "soundevents/voscripts/game_sounds_vo_nyx_assassin.vsndevts",
  184. "particles/dev/library/base_dust_hit.vpcf",
  185. "particles/econ/events/fall_major_2016/radiant_fountain_regen_fm06_lvl3_ring.vpcf",
  186.  
  187. --新的模型和特效
  188. "soundevents/game_sounds_heroes/game_sounds_lion.vsndevts",
  189. "particles/units/heroes/hero_shadowshaman/shadowshaman_voodoo.vpcf",
  190. "soundevents/game_sounds_heroes/game_sounds_axe.vsndevts",
  191. "soundevents/game_sounds_heroes/game_sounds_tusk.vsndevts",
  192. "soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
  193. "soundevents/game_sounds_heroes/game_sounds_enchantress.vsndevts",
  194. "soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
  195. "soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",
  196. "soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
  197. "soundevents/game_sounds_heroes/game_sounds_juggernaut.vsndevts",
  198. "soundevents/game_sounds_heroes/game_sounds_lycan.vsndevts",
  199. "soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
  200. "soundevents/game_sounds_heroes/game_sounds_drowranger.vsndevts",
  201. "soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
  202. "soundevents/game_sounds_heroes/game_sounds_razor.vsndevts",
  203. "soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
  204. "soundevents/game_sounds_heroes/game_sounds_windrunner.vsndevts",
  205. "soundevents/game_sounds_heroes/game_sounds_kunkka.vsndevts",
  206. "soundevents/game_sounds_heroes/game_sounds_doombringer.vsndevts",
  207. "soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
  208. "soundevents/game_sounds_heroes/game_sounds_troll_warlord.vsndevts",
  209. "soundevents/game_sounds_heroes/game_sounds_venomancer.vsndevts",
  210. "soundevents/game_sounds_heroes/game_sounds_gyrocopter.vsndevts",
  211. "soundevents/game_sounds_heroes/game_sounds_jakiro.vsndevts",
  212. "soundevents/game_sounds_heroes/game_sounds_lich.vsndevts",
  213. "soundevents/game_sounds_heroes/game_sounds_queenofpain.vsndevts",
  214. "soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",
  215. "particles/units/heroes/hero_lycan/lycan_weapon_blur_b.vpcf",
  216. "particles/econ/items/necrolyte/necrophos_sullen/necro_sullen_pulse_enemy.vpcf",
  217. "particles/units/unit_greevil/loot_greevil_death.vpcf",
  218. "soundevents/game_sounds_ui.vsndevts",
  219. "soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
  220. "soundevents/game_sounds_heroes/game_sounds_sandking.vsndevts",
  221. "particles/units/heroes/hero_omniknight/omniknight_purification.vpcf",
  222. "particles/dire_fx/bad_ancient002_destroy_fire.vpcf",
  223. "soundevents/game_sounds_heroes/game_sounds_witchdoctor.vsndevts",
  224. "soundevents/game_sounds_heroes/game_sounds_tusk.vsndevts",
  225. "soundevents/game_sounds_heroes/game_sounds_crystalmaiden.vsndevts",
  226. "soundevents/game_sounds_heroes/game_sounds_axe.vsndevts",
  227. "soundevents/game_sounds_heroes/game_sounds_enchantress.vsndevts",
  228. "soundevents/game_sounds_heroes/game_sounds_ogre_magi.vsndevts",
  229. "soundevents/game_sounds_heroes/game_sounds_antimage.vsndevts",
  230. "soundevents/game_sounds_heroes/game_sounds_rattletrap.vsndevts",
  231. "soundevents/game_sounds_heroes/game_sounds_shadowshaman.vsndevts",
  232. "soundevents/game_sounds_heroes/game_sounds_bounty_hunter.vsndevts",
  233. "soundevents/game_sounds_heroes/game_sounds_witchdoctor.vsndevts",
  234. "soundevents/game_sounds_heroes/game_sounds_tinker.vsndevts",
  235. "soundevents/game_sounds_heroes/game_sounds_beastmaster.vsndevts",
  236. "soundevents/game_sounds_heroes/game_sounds_juggernaut.vsndevts",
  237. "soundevents/game_sounds_heroes/game_sounds_lycan.vsndevts",
  238. "soundevents/game_sounds_heroes/game_sounds_shredder.vsndevts",
  239. "soundevents/game_sounds_heroes/game_sounds_phantom_assassin.vsndevts",
  240. "soundevents/game_sounds_heroes/game_sounds_puck.vsndevts",
  241. "soundevents/game_sounds_heroes/game_sounds_slardar.vsndevts",
  242. "soundevents/game_sounds_heroes/game_sounds_chaos_knight.vsndevts",
  243. "soundevents/game_sounds_heroes/game_sounds_drowranger.vsndevts",
  244. "soundevents/game_sounds_heroes/game_sounds_keeper_of_the_light.vsndevts",
  245. "soundevents/game_sounds_heroes/game_sounds_razor.vsndevts",
  246. "soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
  247. "soundevents/game_sounds_heroes/game_sounds_windrunner.vsndevts",
  248. "soundevents/game_sounds_heroes/game_sounds_sandking.vsndevts",
  249. "soundevents/game_sounds_heroes/game_sounds_abaddon.vsndevts",
  250. "soundevents/game_sounds_heroes/game_sounds_slark.vsndevts",
  251. "soundevents/game_sounds_heroes/game_sounds_sniper.vsndevts",
  252. "soundevents/game_sounds_heroes/game_sounds_kunkka.vsndevts",
  253. "soundevents/game_sounds_heroes/game_sounds_doombringer.vsndevts",
  254. "soundevents/game_sounds_heroes/game_sounds_lina.vsndevts",
  255. "soundevents/game_sounds_heroes/game_sounds_troll_warlord.vsndevts",
  256. "soundevents/game_sounds_heroes/game_sounds_venomancer.vsndevts",
  257. "soundevents/game_sounds_heroes/game_sounds_necrolyte.vsndevts",
  258. "soundevents/game_sounds_heroes/game_sounds_templar_assassin.vsndevts",
  259. "soundevents/game_sounds_heroes/game_sounds_gyrocopter.vsndevts",
  260. "soundevents/game_sounds_heroes/game_sounds_lich.vsndevts",
  261. "soundevents/game_sounds_heroes/game_sounds_queenofpain.vsndevts",
  262. "soundevents/game_sounds_heroes/game_sounds_tidehunter.vsndevts",
  263. "soundevents/game_sounds_heroes/game_sounds_enigma.vsndevts",
  264. "models/props_gameplay/donkey.vmdl",
  265. "models/items/courier/bearzky/bearzky.vmdl",
  266. "models/items/courier/bajie_pig/bajie_pig.vmdl",
  267. "models/courier/mech_donkey/mech_donkey.vmdl",
  268. "models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl",
  269. "models/items/courier/baekho/baekho.vmdl",
  270. "models/items/courier/green_jade_dragon/green_jade_dragon.vmdl",
  271. "models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl",
  272. "models/items/courier/pw_zombie/pw_zombie.vmdl",
  273. "models/courier/drodo/drodo.vmdl",
  274. "models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl",
  275. "particles/generic_gameplay/rune_bounty_prespawn.vpcf",
  276. "particles/prime/hero_spawn_hero_level_2_base_ring.vpcf",
  277. "particles/econ/items/treant_protector/ti7_shoulder/treant_ti7_livingarmor_seedlings_parent.vpcf",
  278. "particles/econ/items/bloodseeker/bloodseeker_eztzhok_weapon/bloodseeker_bloodrage_ground_eztzhok_arc.vpcf",
  279. "particles/econ/items/treant_protector/ti7_shoulder/treant_ti7_crimson_livingarmor.vpcf",
  280. "particles/units/heroes/hero_puck/puck_base_attack_warmup.vpcf",
  281. "particles/units/heroes/hero_phantom_assassin/phantom_assassin_attack_blur_crit.vpcf",
  282. "particles/units/heroes/hero_lycan/lycan_weapon_blur_both.vpcf",
  283. "particles/units/heroes/hero_juggernaut/jugg_attack_blur.vpcf",
  284. "particles/econ/items/juggernaut/jugg_ti8_sword/juggernaut_ti8_sword_attack_b.vpcf",
  285. "particles/econ/items/juggernaut/jugg_ti8_sword/juggernaut_ti8_sword_attack_a.vpcf",
  286. "particles/units/heroes/hero_windrunner/wr_taunt_kiss.vpcf",
  287. "effect/big.vpcf",
  288. "effect/arrow/1.vpcf",
  289. "effect/arrow/2.vpcf",
  290. "effect/arrow/3.vpcf",
  291. "effect/arrow/4.vpcf",
  292. "effect/arrow/5.vpcf",
  293. "effect/arrow/star1.vpcf",
  294. "effect/arrow/star2.vpcf",
  295. "effect/arrow/star3.vpcf",
  296. "particles/error/error.vpcf",
  297. "particles/units/heroes/hero_chaos_knight/chaos_knight_weapon_blur.vpcf",
  298. "particles/units/heroes/hero_lycan/lycan_claw_blur.vpcf",
  299. "soundevents/voscripts/game_sounds_vo_tusk.vsndevts",
  300. "soundevents/voscripts/game_sounds_vo_crystalmaiden.vsndevts",
  301. 'models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl',
  302.  
  303.  
  304. "particles/econ/items/templar_assassin/templar_assassin_focal/templar_assassin_meld_focal_attack_shockwave.vpcf",
  305.  
  306. "models/props_gameplay/donkey.vmdl",
  307. "models/courier/skippy_parrot/skippy_parrot.vmdl",
  308. "models/courier/smeevil_mammoth/smeevil_mammoth.vmdl",
  309. "models/items/courier/arneyb_rabbit/arneyb_rabbit.vmdl",
  310. "models/items/courier/axolotl/axolotl.vmdl",
  311. "models/items/courier/coco_the_courageous/coco_the_courageous.vmdl",
  312. "models/items/courier/coral_furryfish/coral_furryfish.vmdl",
  313. "models/items/courier/corsair_ship/corsair_ship.vmdl",
  314. "models/items/courier/duskie/duskie.vmdl",
  315. "models/items/courier/itsy/itsy.vmdl",
  316. "models/items/courier/jumo/jumo.vmdl",
  317. "models/items/courier/mighty_chicken/mighty_chicken.vmdl",
  318. "models/items/courier/nexon_turtle_05_green/nexon_turtle_05_green.vmdl",
  319. "models/items/courier/pumpkin_courier/pumpkin_courier.vmdl",
  320. "models/items/courier/pw_ostrich/pw_ostrich.vmdl",
  321. "models/items/courier/scuttling_scotty_penguin/scuttling_scotty_penguin.vmdl",
  322. "models/items/courier/shagbark/shagbark.vmdl",
  323. "models/items/courier/snaggletooth_red_panda/snaggletooth_red_panda.vmdl",
  324. "models/items/courier/snail/courier_snail.vmdl",
  325. "models/items/courier/teron/teron.vmdl",
  326. "models/items/courier/xianhe_stork/xianhe_stork.vmdl",
  327. "models/items/courier/starladder_grillhound/starladder_grillhound.vmdl",
  328. "models/items/courier/pw_zombie/pw_zombie.vmdl",
  329. "models/items/courier/raiq/raiq.vmdl",
  330. "models/courier/frog/frog.vmdl",
  331. "models/courier/godhorse/godhorse.vmdl",
  332. "models/courier/imp/imp.vmdl",
  333. "models/courier/mighty_boar/mighty_boar.vmdl",
  334. "models/items/courier/onibi_lvl_03/onibi_lvl_03.vmdl",
  335. "models/items/courier/echo_wisp/echo_wisp.vmdl", --蠕行水母
  336. "models/courier/sw_donkey/sw_donkey.vmdl", --驴法师new
  337. "models/items/courier/gnomepig/gnomepig.vmdl", --丰臀公主new
  338. "models/items/furion/treant/ravenous_woodfang/ravenous_woodfang.vmdl",--焚牙树精new
  339. "models/courier/mechjaw/mechjaw.vmdl",--机械咬人箱new
  340. "models/items/courier/mole_messenger/mole_messenger.vmdl",--1级矿车老鼠
  341. "models/courier/doom_demihero_courier/doom_demihero_courier.vmdl",
  342. "models/courier/huntling/huntling.vmdl",
  343. "models/courier/minipudge/minipudge.vmdl",
  344. "models/courier/seekling/seekling.vmdl",
  345. "models/items/courier/baekho/baekho.vmdl",
  346. "models/items/courier/basim/basim.vmdl",
  347. "models/items/courier/devourling/devourling.vmdl",
  348. "models/items/courier/faceless_rex/faceless_rex.vmdl",
  349. "models/items/courier/tinkbot/tinkbot.vmdl",
  350. "models/items/courier/lilnova/lilnova.vmdl",
  351. "models/items/courier/amphibian_kid/amphibian_kid.vmdl",
  352. "models/courier/venoling/venoling.vmdl",
  353. "models/courier/juggernaut_dog/juggernaut_dog.vmdl",
  354. "models/courier/otter_dragon/otter_dragon.vmdl",
  355. "models/items/courier/boooofus_courier/boooofus_courier.vmdl",
  356. "models/courier/baby_winter_wyvern/baby_winter_wyvern.vmdl",
  357. "models/courier/yak/yak.vmdl",
  358. "models/items/furion/treant/eternalseasons_treant/eternalseasons_treant.vmdl",
  359. "models/items/courier/blue_lightning_horse/blue_lightning_horse.vmdl",
  360. "models/items/courier/waldi_the_faithful/waldi_the_faithful.vmdl",
  361. "models/items/courier/bajie_pig/bajie_pig.vmdl",
  362. "models/items/courier/courier_faun/courier_faun.vmdl",
  363. "models/items/courier/livery_llama_courier/livery_llama_courier.vmdl",
  364. "models/items/courier/onibi_lvl_10/onibi_lvl_10.vmdl",
  365. "models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl", --胆小南瓜人
  366. "models/items/courier/hermit_crab/hermit_crab.vmdl", --螃蟹1
  367. "models/items/courier/hermit_crab/hermit_crab_boot.vmdl", --螃蟹2
  368. "models/items/courier/hermit_crab/hermit_crab_shield.vmdl", --螃蟹3
  369. "models/courier/donkey_unicorn/donkey_unicorn.vmdl", --竭智法师new
  370. "models/items/courier/white_the_crystal_courier/white_the_crystal_courier.vmdl", --蓝心白隼new
  371. "models/items/furion/treant/furion_treant_nelum_red/furion_treant_nelum_red.vmdl",--莲花人new
  372. "models/courier/beetlejaws/mesh/beetlejaws.vmdl",--甲虫咬人箱new
  373. "models/courier/smeevil_bird/smeevil_bird.vmdl",
  374. "models/items/courier/mole_messenger/mole_messenger_lvl4.vmdl",--蜡烛头矿车老鼠
  375. "models/items/courier/bookwyrm/bookwyrm.vmdl",
  376. "models/items/courier/captain_bamboo/captain_bamboo.vmdl",
  377. "models/items/courier/kanyu_shark/kanyu_shark.vmdl",
  378. "models/items/courier/tory_the_sky_guardian/tory_the_sky_guardian.vmdl",
  379. "models/items/courier/shroomy/shroomy.vmdl",
  380. "models/items/courier/courier_janjou/courier_janjou.vmdl",
  381. "models/items/courier/green_jade_dragon/green_jade_dragon.vmdl",
  382. "models/courier/drodo/drodo.vmdl",
  383. "models/courier/mech_donkey/mech_donkey.vmdl",
  384. "models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl",
  385. "models/courier/octopus/octopus.vmdl",
  386. "models/items/courier/scribbinsthescarab/scribbinsthescarab.vmdl",
  387. "models/courier/defense3_sheep/defense3_sheep.vmdl",
  388. "models/items/courier/snapjaw/snapjaw.vmdl",
  389. "models/items/courier/g1_courier/g1_courier.vmdl",
  390. "models/courier/donkey_trio/mesh/donkey_trio.vmdl",
  391. "models/items/courier/boris_baumhauer/boris_baumhauer.vmdl",
  392. "models/courier/baby_rosh/babyroshan.vmdl",
  393. "models/items/courier/bearzky/bearzky.vmdl",
  394. "models/items/courier/defense4_radiant/defense4_radiant.vmdl",
  395. "models/items/courier/defense4_dire/defense4_dire.vmdl",
  396. "models/items/courier/onibi_lvl_20/onibi_lvl_20.vmdl",
  397. "models/items/juggernaut/ward/fortunes_tout/fortunes_tout.vmdl", --招财猫
  398. "models/items/courier/hermit_crab/hermit_crab_necro.vmdl", --螃蟹4
  399. "models/items/courier/hermit_crab/hermit_crab_travelboot.vmdl", --螃蟹5
  400. "models/items/courier/hermit_crab/hermit_crab_lotus.vmdl", --螃蟹6
  401. "models/courier/donkey_ti7/donkey_ti7.vmdl",
  402. "models/items/courier/shibe_dog_cat/shibe_dog_cat.vmdl", --天猫地狗new
  403. "models/items/furion/treant/hallowed_horde/hallowed_horde.vmdl",--万圣树群new
  404. "models/courier/flopjaw/flopjaw.vmdl",--大嘴咬人箱new
  405. "models/courier/lockjaw/lockjaw.vmdl",--咬人箱洛克new
  406. "models/items/courier/butch_pudge_dog/butch_pudge_dog.vmdl",--布狗new
  407. "models/courier/turtle_rider/turtle_rider.vmdl",
  408. "models/courier/smeevil_crab/smeevil_crab.vmdl",
  409. "models/items/courier/mole_messenger/mole_messenger_lvl6.vmdl",--绿钻头矿车老鼠
  410. "models/courier/navi_courier/navi_courier.vmdl",
  411. "models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl",
  412. "models/items/courier/ig_dragon/ig_dragon.vmdl",
  413. "models/items/courier/lgd_golden_skipper/lgd_golden_skipper.vmdl",
  414. "models/items/courier/vigilante_fox_red/vigilante_fox_red.vmdl",
  415. "models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl",
  416. "models/items/courier/throe/throe.vmdl",
  417. "models/items/courier/vaal_the_animated_constructradiant/vaal_the_animated_constructradiant.vmdl",
  418. "models/items/courier/vaal_the_animated_constructdire/vaal_the_animated_constructdire.vmdl",
  419. "models/items/courier/carty/carty.vmdl",
  420. "models/items/courier/carty_dire/carty_dire.vmdl",
  421. "models/items/courier/dc_angel/dc_angel.vmdl",
  422. "models/items/courier/dc_demon/dc_demon.vmdl",
  423. "models/items/courier/vigilante_fox_green/vigilante_fox_green.vmdl",
  424. "models/items/courier/bts_chirpy/bts_chirpy.vmdl",
  425. "models/items/courier/krobeling/krobeling.vmdl",
  426. "models/items/courier/jin_yin_black_fox/jin_yin_black_fox.vmdl",
  427. "models/items/courier/jin_yin_white_fox/jin_yin_white_fox.vmdl",
  428. "models/items/courier/fei_lian_blue/fei_lian_blue.vmdl",
  429. "models/items/courier/gama_brothers/gama_brothers.vmdl",
  430. "models/items/courier/onibi_lvl_21/onibi_lvl_21.vmdl",
  431. "models/items/courier/wabbit_the_mighty_courier_of_heroes/wabbit_the_mighty_courier_of_heroes.vmdl", --小飞侠
  432. "models/items/courier/hermit_crab/hermit_crab_octarine.vmdl", --螃蟹7
  433. "models/items/courier/hermit_crab/hermit_crab_skady.vmdl", --螃蟹8
  434. "models/items/courier/hermit_crab/hermit_crab_aegis.vmdl", --螃蟹9
  435. "models/items/furion/treant_flower_1.vmdl",--绽放树精new
  436. "models/courier/smeevil_magic_carpet/smeevil_magic_carpet.vmdl",
  437. "models/items/courier/mole_messenger/mole_messenger_lvl7.vmdl",--绿钻头金矿车老鼠
  438. "models/items/courier/krobeling_gold/krobeling_gold_flying.vmdl",--金dp
  439. "models/props_gameplay/donkey.vmdl",
  440. "particles/items2_fx/refresher.vpcf",
  441. "soundevents/game_sounds_items.vsndevts",
  442. "particles/speechbubbles/speech_voice.vpcf",
  443.  
  444. "soundevents/game_sounds_heroes/game_sounds_nevermore.vsndevts",
  445. "soundevents/game_sounds_heroes/game_sounds_batrider.vsndevts",
  446. "soundevents/game_sounds_heroes/game_sounds_luna.vsndevts",
  447. "soundevents/game_sounds_heroes/game_sounds_treant.vsndevts",
  448. "soundevents/game_sounds_heroes/game_sounds_dragon_knight.vsndevts",
  449. "soundevents/game_sounds_heroes/game_sounds_viper.vsndevts",
  450. "soundevents/game_sounds_heroes/game_sounds_medusa.vsndevts",
  451. "soundevents/game_sounds_heroes/game_sounds_disruptor.vsndevts",
  452. "soundevents/game_sounds_heroes/game_sounds_alchemist.vsndevts",
  453. "soundevents/game_sounds_heroes/game_sounds_techies.vsndevts",
  454. "particles/econ/events/ti5/dagon_ti5.vpcf",
  455. "particles/units/heroes/hero_monkey_king/monkey_king_fur_army_positions_ring_dragon.vpcf",
  456. "particles/econ/items/legion/legion_overwhelming_odds_ti7/legion_commander_odds_ti7_proj_hit_streaks.vpcf",
  457. "particles/units/heroes/hero_lycan/lycan_shapeshift_cast.vpcf",
  458. "particles/units/heroes/hero_queenofpain/queen_sonic_wave.vpcf",
  459. "models/props_gameplay/donkey_dire.vmdl",
  460. "models/props_gameplay/donkey_dire_wings.vmdl",
  461. "models/courier/baby_rosh/babyroshan_winter18.vmdl",
  462. "effect/dizuo/1.vpcf",
  463. "soundevents/voscripts/game_sounds_vo_lone_druid.vsndevts",
  464. "soundevents/voscripts/game_sounds_vo_furion.vsndevts",
  465. "soundevents/game_sounds_heroes/game_sounds_omniknight.vsndevts",
  466. "soundevents/game_sounds_heroes/game_sounds_morphling.vsndevts",
  467. "soundevents/voscripts/game_sounds_vo_terrorblade.vsndevts",
  468. "particles/units/heroes/hero_chaos_knight/chaos_knight_phantasm.vpcf",
  469. "soundevents/game_sounds_heroes/game_sounds_chaos_knight.vsndevts",
  470. }
  471. print("Precache...")
  472. local t=table.maxn(mxx)
  473. for i=1,t do
  474. if string.find(mxx[i], "vpcf") then
  475. PrecacheResource( "particle", mxx[i], context)
  476. end
  477. if string.find(mxx[i], "vmdl") then
  478. PrecacheResource( "model", mxx[i], context)
  479. end
  480. if string.find(mxx[i], "vsndevts") then
  481. PrecacheResource( "soundfile", mxx[i], context)
  482. end
  483. end
  484. PrecacheUnitByNameSync("chess_tusk", context)
  485. PrecacheUnitByNameSync("chess_cm", context)
  486. PrecacheUnitByNameSync("chess_axe", context)
  487. PrecacheUnitByNameSync("chess_eh", context)
  488. PrecacheUnitByNameSync("chess_om", context)
  489. PrecacheUnitByNameSync("chess_am", context)
  490. PrecacheUnitByNameSync("chess_clock", context)
  491. PrecacheUnitByNameSync("chess_ss", context)
  492. PrecacheUnitByNameSync("chess_bh", context)
  493. PrecacheUnitByNameSync("chess_wd", context)
  494. PrecacheUnitByNameSync("chess_bat", context)
  495. PrecacheUnitByNameSync("chess_tk", context)
  496. PrecacheUnitByNameSync("chess_bm", context)
  497. PrecacheUnitByNameSync("chess_jugg", context)
  498. PrecacheUnitByNameSync("chess_lyc", context)
  499. PrecacheUnitByNameSync("chess_shredder", context)
  500. PrecacheUnitByNameSync("chess_pa", context)
  501. PrecacheUnitByNameSync("chess_puck", context)
  502. PrecacheUnitByNameSync("chess_slardar", context)
  503. PrecacheUnitByNameSync("chess_ck", context)
  504. PrecacheUnitByNameSync("chess_luna", context)
  505. PrecacheUnitByNameSync("chess_tp", context)
  506. PrecacheUnitByNameSync("chess_dr", context)
  507. PrecacheUnitByNameSync("chess_light", context)
  508. PrecacheUnitByNameSync("chess_razor", context)
  509. PrecacheUnitByNameSync("chess_ok", context)
  510. PrecacheUnitByNameSync("chess_wr", context)
  511. PrecacheUnitByNameSync("chess_sk", context)
  512. PrecacheUnitByNameSync("chess_abaddon", context)
  513. PrecacheUnitByNameSync("chess_slark", context)
  514. PrecacheUnitByNameSync("chess_sniper", context)
  515. PrecacheUnitByNameSync("chess_sf", context)
  516. PrecacheUnitByNameSync("chess_dk", context)
  517. PrecacheUnitByNameSync("chess_viper", context)
  518. PrecacheUnitByNameSync("chess_kunkka", context)
  519. PrecacheUnitByNameSync("chess_doom", context)
  520. PrecacheUnitByNameSync("chess_lina", context)
  521. PrecacheUnitByNameSync("chess_troll", context)
  522. PrecacheUnitByNameSync("chess_veno", context)
  523. PrecacheUnitByNameSync("chess_nec", context)
  524. PrecacheUnitByNameSync("chess_ta", context)
  525. PrecacheUnitByNameSync("chess_medusa", context)
  526. PrecacheUnitByNameSync("chess_disruptor", context)
  527. PrecacheUnitByNameSync("chess_ga", context)
  528. PrecacheUnitByNameSync("chess_gyro", context)
  529. PrecacheUnitByNameSync("chess_lich", context)
  530. PrecacheUnitByNameSync("chess_qop", context)
  531. PrecacheUnitByNameSync("chess_th", context)
  532. PrecacheUnitByNameSync("chess_enigma", context)
  533. PrecacheUnitByNameSync("chess_tech", context)
  534. PrecacheUnitByNameSync("chess_ld", context)
  535. PrecacheUnitByNameSync("chess_fur", context)
  536.  
  537. PrecacheUnitByNameSync("chess_tiny", context)
  538. PrecacheUnitByNameSync("chess_morph", context)
  539. PrecacheUnitByNameSync("chess_tb", context)
  540. PrecacheUnitByNameSync("chess_nec_ssr", context)
  541. PrecacheUnitByNameSync("chess_ck_ssr", context)
  542.  
  543.  
  544. print("Precache OK")
  545. end
  546.  
  547. function Activate()
  548. GameRules:GetGameModeEntity().AddonTemplate = DAC()
  549. GameRules:GetGameModeEntity().AddonTemplate:InitGameMode()
  550. end
  551. --1、初始化变量和监听
  552. function DAC:InitGameMode()
  553. AMHCInit()
  554. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_GOODGUYS, 0 )
  555. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_BADGUYS, 0 )
  556. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_1, 1 )
  557. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_2, 1 )
  558. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_3, 1 )
  559. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_4, 1 )
  560. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_5, 1 )
  561. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_6, 1 )
  562. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_7, 1 )
  563. GameRules:SetCustomGameTeamMaxPlayers( DOTA_TEAM_CUSTOM_8, 1 )
  564.  
  565. SetTeamCustomHealthbarColor(DOTA_TEAM_NEUTRALS, 255,0,0)
  566. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_1, 128,255,128)
  567. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_2, 128,255,128)
  568. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_3, 128,255,128)
  569. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_4, 128,255,128)
  570. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_5, 128,255,128)
  571. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_6, 128,255,128)
  572. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_7, 128,255,128)
  573. SetTeamCustomHealthbarColor(DOTA_TEAM_CUSTOM_8, 128,255,128)
  574.  
  575. ListenToGameEvent("player_connect_full", Dynamic_Wrap(DAC,"OnPlayerConnectFull" ),self)
  576. ListenToGameEvent("player_disconnect", Dynamic_Wrap(DAC, "OnPlayerDisconnect"), self)
  577. ListenToGameEvent("player_chat",Dynamic_Wrap(DAC,"OnPlayerChat"),self)
  578. ListenToGameEvent("dota_player_pick_hero",Dynamic_Wrap(DAC,"OnPlayerPickHero"),self)
  579. ListenToGameEvent("entity_killed", Dynamic_Wrap(DAC, "OnEntityKilled"), self)
  580. ListenToGameEvent("dota_player_gained_level", Dynamic_Wrap(DAC,"OnPlayerGainedLevel"), self)
  581.  
  582. --CustomGameEventManager:RegisterListener("gather_steam_ids", Dynamic_Wrap(DAC, "OnGatherSteamIds") )
  583. CustomGameEventManager:RegisterListener("dac_pick_chess", Dynamic_Wrap(DAC, "OnKeyboardPickChess") )
  584. CustomGameEventManager:RegisterListener("battle_deck", Dynamic_Wrap(DAC, "OnDeckReiceived") )
  585. CustomGameEventManager:RegisterListener("select_chess", Dynamic_Wrap(DAC, "OnChessSelected") )
  586. CustomGameEventManager:RegisterListener("pick_chess_position", Dynamic_Wrap(DAC, "OnPickChessPosition") )
  587. CustomGameEventManager:RegisterListener("cancel_pick_chess_position", Dynamic_Wrap(DAC, "OnCancelPickChessPosition") )
  588. CustomGameEventManager:RegisterListener("dac_refresh_chess", Dynamic_Wrap(DAC, "OnRefreshChess") )
  589. CustomGameEventManager:RegisterListener("catch_crab", Dynamic_Wrap(DAC, "OnCatchCrab") )
  590. CustomGameEventManager:RegisterListener("unlock_chess", Dynamic_Wrap(DAC, "OnUnlockChess") )
  591. CustomGameEventManager:RegisterListener("lock_chess", Dynamic_Wrap(DAC, "OnLockChess") )
  592.  
  593. GameRules:GetGameModeEntity().battle_round = 1
  594. GameRules:GetGameModeEntity().steamidlist = ''
  595. GameRules:GetGameModeEntity().steamidlist_heroindex = ''
  596. GameRules:GetGameModeEntity().steamid2playerid = {}
  597. GameRules:GetGameModeEntity().playerid2steamid = {}
  598. GameRules:GetGameModeEntity().steamid2name = {}
  599. GameRules:GetGameModeEntity().stat_info = {}
  600. GameRules:GetGameModeEntity().show_damage = false
  601. GameRules:GetGameModeEntity().upload_lineup = {}
  602. GameRules:GetGameModeEntity().connect_state = {
  603. [0] = false,
  604. [1] = false,
  605. [2] = false,
  606. [3] = false,
  607. [4] = false,
  608. [5] = false,
  609. [6] = false,
  610. [7] = false,
  611. }
  612. GameRules:GetGameModeEntity().battle_boss = {
  613. [1] = { --天辉卫士
  614. [1] = {x=4,y=8,enemy='pve_melee_good'},
  615. [2] = {x=5,y=8,enemy='pve_melee_good'},
  616. },
  617. [2] = { --天辉中军
  618. [1] = {x=4,y=6,enemy='pve_melee_good_mega'},
  619. [2] = {x=5,y=8,enemy='pve_ranged_good'},
  620. [3] = {x=3,y=8,enemy='pve_ranged_good'},
  621. },
  622. [3] = { --天辉统帅
  623. [1] = {x=4,y=6,enemy='pve_melee_good_mega'},
  624. [2] = {x=5,y=6,enemy='pve_melee_good_mega'},
  625. [3] = {x=4,y=8,enemy='pve_ranged_good'},
  626. [4] = {x=5,y=8,enemy='pve_ranged_good'},
  627. [5] = {x=3,y=7,enemy='pve_melee_good'},
  628. [6] = {x=6,y=7,enemy='pve_melee_good'},
  629. },
  630. [10] = { --岩石傀儡
  631. [1] = {x=4,y=6,enemy='pve_stone_a'},
  632. [2] = {x=2,y=7,enemy='pve_stone_b'},
  633. [3] = {x=6,y=7,enemy='pve_stone_b'},
  634. },
  635. [15] = { --群狼
  636. [1] = {x=4,y=6,enemy='pve_wolf_big'},
  637. [2] = {x=5,y=8,enemy='pve_wolf_small'},
  638. [3] = {x=3,y=8,enemy='pve_wolf_small'},
  639. [4] = {x=2,y=7,enemy='pve_wolf_small'},
  640. [5] = {x=6,y=7,enemy='pve_wolf_small'},
  641. },
  642. [20] = { --夺命双熊
  643. [1] = {x=4,y=6,enemy='pve_bear_a'},
  644. [2] = {x=2,y=7,enemy='pve_bear_b'},
  645. },
  646. [25] = { --愤怒的枭兽
  647. [1] = {x=2,y=7,enemy='pve_vulture_a'},
  648. [2] = {x=7,y=7,enemy='pve_vulture_b'},
  649. },
  650. [30] = { --雷隐兽
  651. [1] = {x=4,y=6,enemy='pve_leishou_a'},
  652. [2] = {x=3,y=7,enemy='pve_leishou_b'},
  653. [3] = {x=5,y=7,enemy='pve_leishou_b'},
  654. },
  655. [35] = { --黑龙王
  656. [1] = {x=4,y=5,enemy='pve_black_dragon'},
  657. },
  658. [40] = { --巨魔部落
  659. [1] = {x=3,y=6,enemy='pve_troll_dark_a'},
  660. [2] = {x=4,y=6,enemy='pve_troll_dark_a'},
  661. [3] = {x=5,y=6,enemy='pve_troll_dark_a'},
  662. [4] = {x=6,y=6,enemy='pve_troll_dark_a'},
  663. [5] = {x=3,y=8,enemy='pve_troll_dark_b'},
  664. [6] = {x=6,y=8,enemy='pve_troll_dark_c'},
  665. },
  666. [45] = { --年兽
  667. [1] = {x=4,y=7,enemy='pve_nian'},
  668. },
  669. [50] = { --肉山大魔王
  670. [1] = {x=4,y=7,enemy='pve_roshan'},
  671. },
  672. }
  673. GameRules:GetGameModeEntity():SetFogOfWarDisabled(true)
  674. GameRules:GetGameModeEntity():SetBuybackEnabled(false)
  675. GameRules:GetGameModeEntity().heroindex2steamid = {}
  676. GameRules:GetGameModeEntity().cloudlineup = nil
  677. GameRules:GetGameModeEntity().steamid2heroindex = {}
  678.  
  679. GameRules:GetGameModeEntity().userid2player = {}
  680. GameRules:GetGameModeEntity().team2playerid = {}
  681. GameRules:GetGameModeEntity().playerid2team = {}
  682.  
  683. GameRules:GetGameModeEntity().START_TIME = nil
  684. GameRules:GetGameModeEntity().player_levels = {}
  685. GameRules:GetGameModeEntity():SetUseCustomHeroLevels(true)
  686. GameRules:GetGameModeEntity():SetCustomHeroMaxLevel(10)
  687. GameRules:GetGameModeEntity():SetCustomXPRequiredToReachNextLevel(
  688. {
  689. [1] = 0,
  690. [2] = 1,
  691. [3] = 2,
  692. [4] = 4,
  693. [5] = 8,
  694. [6] = 16,
  695. [7] = 32,
  696. [8] = 56,--64,
  697. [9] = 88,--112,
  698. [10] = 128,--176,
  699. }
  700. )
  701.  
  702. GameRules:GetGameModeEntity().unit = {
  703. [6] = {},
  704. [7] = {},
  705. [8] = {},
  706. [9] = {},
  707. [10] = {},
  708. [11] = {},
  709. [12] = {},
  710. [13] = {},
  711. }
  712. GameRules:GetGameModeEntity().mychess = {
  713. [6] = {},
  714. [7] = {},
  715. [8] = {},
  716. [9] = {},
  717. [10] = {},
  718. [11] = {},
  719. [12] = {},
  720. [13] = {},
  721. }
  722. GameRules:GetGameModeEntity().to_be_destory_list = {
  723. [6] = {},
  724. [7] = {},
  725. [8] = {},
  726. [9] = {},
  727. [10] = {},
  728. [11] = {},
  729. [12] = {},
  730. [13] = {},
  731. }
  732. GameRules:GetGameModeEntity().game_status = 0
  733. GameRules:GetGameModeEntity().prepare_timer = 35
  734. GameRules:GetGameModeEntity().battle_timer = 60
  735. GameRules:GetGameModeEntity().myself = false
  736. GameRules:GetGameModeEntity().is_stop = false
  737. GameRules:GetGameModeEntity().isConnected = {}
  738. GameRules:GetGameModeEntity().is_game_started =false
  739. GameRules:GetGameModeEntity().is_game_ended =false
  740.  
  741. --默认卡池参数
  742. GameRules:GetGameModeEntity().CHESS_POOL_SIZE = 5
  743. GameRules:GetGameModeEntity().CHESS_INIT_COUNT = {
  744. [1] = 9,
  745. [2] = 6,
  746. [3] = 5,
  747. [4] = 3,
  748. [5] = 2,
  749. }
  750.  
  751.  
  752. print("InitGameMode")
  753.  
  754. CustomNetTables:SetTableValue( "dac_table", "curtain_tips", { text = "正在初始化地图", hehe = RandomInt(1,1000)})
  755.  
  756.  
  757. GameRules:GetGameModeEntity().hero = {}
  758. GameRules:GetGameModeEntity().battleid = nil
  759. GameRules:GetGameModeEntity().ended = false
  760. GameRules:GetGameModeEntity().playerid2hero = {}
  761. GameRules:GetGameModeEntity().teamid2hero = {}
  762.  
  763.  
  764. GameRules:GetGameModeEntity().base_vector = {
  765. [6] = Vector(-2496,1728,128),
  766. [7] = Vector(-448,1728,128),
  767. [8] = Vector(1600,1728,128),
  768. [9] = Vector(1600,-320,128),
  769. [10] = Vector(1600,-2368,128),
  770. [11] = Vector(-448,-2368,128),
  771. [12] = Vector(-2496,-2368,128),
  772. [13] = Vector(-2496,-320,128),
  773. }
  774. GameRules:GetGameModeEntity().hand = {
  775. [6] = {0,0,0,0,0,0,0,0},
  776. [7] = {0,0,0,0,0,0,0,0},
  777. [8] = {0,0,0,0,0,0,0,0},
  778. [9] = {0,0,0,0,0,0,0,0},
  779. [10] = {0,0,0,0,0,0,0,0},
  780. [11] = {0,0,0,0,0,0,0,0},
  781. [12] = {0,0,0,0,0,0,0,0},
  782. [13] = {0,0,0,0,0,0,0,0},
  783. }
  784. GameRules:GetGameModeEntity().counterpart = {}
  785. GameRules:GetGameModeEntity().lastrandomn = 0
  786. GameRules:GetGameModeEntity().population = {
  787. [6] = 0,
  788. [7] = 0,
  789. [8] = 0,
  790. [9] = 0,
  791. [10] = 0,
  792. [11] = 0,
  793. [12] = 0,
  794. [13] = 0,
  795. }
  796. GameRules:GetGameModeEntity().population_max = {
  797. [6] = 1,
  798. [7] = 1,
  799. [8] = 1,
  800. [9] = 1,
  801. [10] = 1,
  802. [11] = 1,
  803. [12] = 1,
  804. [13] = 1,
  805. }
  806. --给第i个人提供第j个场地的视野
  807. GameRules:GetGameModeEntity().lights = {
  808. [6] = {},
  809. [7] = {},
  810. [8] = {},
  811. [9] = {},
  812. [10] = {},
  813. [11] = {},
  814. [12] = {},
  815. [13] = {},
  816. }
  817. GameRules:GetGameModeEntity().damage_stat = {
  818. [6] = {},
  819. [7] = {},
  820. [8] = {},
  821. [9] = {},
  822. [10] = {},
  823. [11] = {},
  824. [12] = {},
  825. [13] = {},
  826. }
  827. GameRules:GetGameModeEntity().chess_list_by_mana = {
  828. [1] = {'chess_tusk','chess_axe','chess_eh','chess_om','chess_clock','chess_ss','chess_bh','chess_bat','chess_dr','chess_tk','chess_am','chess_tiny'},
  829. [2] = {'chess_bm','chess_jugg','chess_shredder','chess_puck','chess_ck','chess_slardar','chess_luna','chess_tp','chess_qop','chess_wd','chess_cm','chess_fur','chess_morph'},
  830. [3] = {'chess_ok','chess_razor','chess_wr','chess_sk','chess_abaddon','chess_slark','chess_sniper','chess_sf','chess_viper','chess_lyc','chess_pa','chess_veno','chess_lina','chess_tb'},
  831. [4] = {'chess_kunkka','chess_doom','chess_troll','chess_nec','chess_ta','chess_medusa','chess_disruptor','chess_ga','chess_dk','chess_light','chess_ld'},
  832. [5] = {'chess_gyro','chess_lich','chess_th','chess_enigma','chess_tech'},
  833. }
  834. GameRules:GetGameModeEntity().chess_list_ssr = {'chess_nec_ssr','chess_ck_ssr'}
  835. GameRules:GetGameModeEntity().chess_2_mana = {
  836. chess_tusk = 1,
  837. chess_axe = 1,
  838. chess_eh = 1,
  839. chess_om = 1,
  840. chess_clock = 1,
  841. chess_ss = 1,
  842. chess_bh = 1,
  843. chess_bat = 1,
  844. chess_dr = 1,
  845. chess_tk = 1,
  846. chess_bm = 2,
  847. chess_jugg = 2,
  848. chess_shredder = 2,
  849. chess_puck = 2,
  850. chess_ck = 2,
  851. chess_slardar = 2,
  852. chess_luna = 2,
  853. chess_tp = 2,
  854. chess_qop = 2,
  855. chess_am = 1,
  856. chess_wd = 2,
  857. chess_cm = 2,
  858. chess_light = 4,
  859. chess_ok = 3,
  860. chess_razor = 3,
  861. chess_wr = 3,
  862. chess_sk = 3,
  863. chess_abaddon = 3,
  864. chess_slark = 3,
  865. chess_sniper = 3,
  866. chess_sf = 3,
  867. chess_viper = 3,
  868. chess_lyc = 3,
  869. chess_pa = 3,
  870. chess_kunkka = 4,
  871. chess_doom = 4,
  872. chess_lina = 3,
  873. chess_troll = 4,
  874. chess_veno = 3,
  875. chess_nec = 4,
  876. chess_ta = 4,
  877. chess_medusa = 4,
  878. chess_disruptor = 4,
  879. chess_ga = 4,
  880. chess_dk = 4,
  881. chess_gyro = 5,
  882. chess_lich = 5,
  883. chess_th = 5,
  884. chess_enigma = 5,
  885. chess_tech = 5,
  886. chess_fur = 2,
  887. chess_ld = 4,
  888. --
  889. chess_tiny = 1,
  890. chess_tb = 3,
  891. chess_morph = 2,
  892. chess_nec_ssr = 10,
  893. chess_ck_ssr = 15,
  894. }
  895. GameRules:GetGameModeEntity().chess_pool = {
  896. [1] = {},
  897. [2] = {},
  898. [3] = {},
  899. [4] = {},
  900. [5] = {},
  901. }
  902. GameRules:GetGameModeEntity().chess_gailv = {
  903. [1] = { [101] = 2 },
  904. [2] = { [70] = 2 },
  905. [3] = { [60] = 2, [95] = 3 },
  906. [4] = { [50] = 2, [85] = 3 },
  907. [5] = { [40] = 2, [75] = 3, [98] = 4 },
  908. [6] = { [33] = 2, [63] = 3, [93] = 4 },
  909. [7] = { [30] = 2, [60] = 3, [90] = 4 },
  910. [8] = { [24] = 2, [54] = 3, [84] = 4, [99] = 5 },
  911. [9] = { [22] = 2, [52] = 3, [77] = 4, [97] = 5 },
  912. [10] = { [19] = 2, [44] = 3, [69] = 4, [94] = 5 },
  913. }
  914. GameRules:GetGameModeEntity().drop_item_gailv = {
  915. [1] = { [80] = 1},
  916. [2] = { [60] = 1},
  917. [3] = { [50] = 1},
  918. [4] = { [40] = 1, [80] = 2},
  919. [5] = { [40] = 1, [60] = 2},
  920. [6] = { [30] = 1, [60] = 2, [90] = 3},
  921. [7] = { [20] = 1, [50] = 2, [80] = 3},
  922. [8] = { [0] = 1, [20] = 2, [60] = 3, [90] = 4},
  923. [9] = { [0] = 1, [10] = 2, [50] = 3, [80] = 4},
  924. }
  925. GameRules:GetGameModeEntity().chess_ability_list = {
  926. chess_cm = 'cm_mana_aura',
  927. chess_axe = 'axe_berserkers_call',
  928. chess_dr = 'shooter_aura',
  929. chess_eh = 'enchantress_natures_attendants',
  930. chess_om = 'ogre_magi_bloodlust',
  931. chess_tusk = 'tusk_walrus_punch',
  932. chess_bm = 'beastmaster_wild_axes',
  933. chess_jugg = 'juggernaut_blade_fury',
  934. chess_lyc = 'lyc_wolf',
  935. chess_shredder = 'shredder_whirling_death',
  936. chess_tk = 'a108',
  937. chess_light = 'keeper_of_the_light_illuminate',
  938. chess_ok = 'omniknight_purification',
  939. chess_razor = 'razor_plasma_field',
  940. chess_wr = 'windrunner_powershot',
  941. chess_doom = 'doom_bringer_doom',
  942. chess_kunkka = 'kunkka_ghostship',
  943. chess_lina = 'lina_laguna_blade',
  944. chess_troll = 'troll_warlord_fervor',
  945. chess_veno = 'veno_ward',
  946. chess_gyro = 'gyrocopter_call_down',
  947. chess_jakiro = 'jakiro_macropyre',
  948. chess_lich = 'lich_chain_frost',
  949. chess_qop = 'queenofpain_scream_of_pain',
  950. chess_th = 'tidehunter_ravage',
  951. --
  952. chess_am = 'antimage_mana_break',
  953. chess_bh = 'bounty_hunter_shuriken_toss',
  954. chess_wd = 'witch_doctor_paralyzing_cask',
  955. chess_clock = 'rattletrap_battery_assault',
  956. chess_ss = 'shadow_shaman_voodoo',
  957. chess_pa = 'phantom_assassin_coup_de_grace',
  958. chess_puck = 'puck_illusory_orb',
  959. chess_slardar = 'slardar_amplify_damage',
  960. chess_ck = 'chaos_knight_chaos_bolt',
  961. chess_abaddon = 'abaddon_aphotic_shield',
  962. chess_sk = 'sandking_burrowstrike',
  963. chess_slark = 'slark_shadow_dance',
  964. chess_sniper = 'sniper_assassinate',
  965. chess_nec = 'necrolyte_death_pulse',
  966. chess_ta = 'templar_assassin_refraction',
  967. chess_enigma = 'enigma_midnight_pulse',
  968. --
  969. chess_bat = 'batrider_sticky_napalm',
  970. chess_luna = 'luna_moon_glaive',
  971. chess_tp = 'treant_leech_seed',
  972. chess_sf = 'nevermore_requiem',
  973. chess_dk = 'dragon_knight_elder_dragon_form',
  974. chess_viper = 'viper_viper_strike',
  975. chess_medusa = 'medusa_stone_gaze',
  976. chess_disruptor = 'disruptor_static_storm',
  977. chess_ga = 'alchemist_acid_spray',
  978. chess_tech = 'chess_tech_bomb',
  979. --
  980. chess_fur = 'fur_tree',
  981. chess_ld = 'ld_bear',
  982. --
  983. chess_nec_ssr = 'nec_ssr_scythe',
  984. chess_morph = 'morphling_waveform',
  985. chess_tb = 'tb_mohua',
  986. chess_tiny = 'tiny_touzhi',
  987.  
  988.  
  989. chess_cm1 = 'cm_mana_aura',
  990. chess_axe1 = 'axe_berserkers_call',
  991. chess_dr1 = 'shooter_aura',
  992. chess_eh1 = 'enchantress_natures_attendants',
  993. chess_om1 = 'ogre_magi_bloodlust',
  994. chess_tusk1 = 'tusk_walrus_punch',
  995. chess_bm1 = 'beastmaster_wild_axes',
  996. chess_jugg1 = 'juggernaut_blade_fury',
  997. chess_lyc1 = 'lyc_wolf',
  998. chess_shredder1 = 'shredder_whirling_death',
  999. chess_tk1 = 'a108',
  1000. chess_light1 = 'keeper_of_the_light_illuminate',
  1001. chess_ok1 = 'omniknight_purification',
  1002. chess_razor1 = 'razor_plasma_field',
  1003. chess_wr1 = 'windrunner_powershot',
  1004. chess_doom1 = 'doom_bringer_doom',
  1005. chess_kunkka1 = 'kunkka_ghostship',
  1006. chess_lina1 = 'lina_laguna_blade',
  1007. chess_troll1 = 'troll_warlord_fervor',
  1008. chess_veno1 = 'veno_ward',
  1009. chess_gyro1 = 'gyrocopter_call_down',
  1010. chess_jakiro1 = 'jakiro_macropyre',
  1011. chess_lich1 = 'lich_chain_frost',
  1012. chess_qop1 = 'queenofpain_scream_of_pain',
  1013. chess_th1 = 'tidehunter_ravage',
  1014. --
  1015. chess_am1 = 'antimage_mana_break',
  1016. chess_bh1 = 'bounty_hunter_shuriken_toss',
  1017. chess_wd1 = 'witch_doctor_paralyzing_cask',
  1018. chess_clock1 = 'rattletrap_battery_assault',
  1019. chess_ss1 = 'shadow_shaman_voodoo',
  1020. chess_pa1 = 'phantom_assassin_coup_de_grace',
  1021. chess_puck1 = 'puck_illusory_orb',
  1022. chess_slardar1 = 'slardar_amplify_damage',
  1023. chess_ck1 = 'chaos_knight_chaos_bolt',
  1024. chess_abaddon1 = 'abaddon_aphotic_shield',
  1025. chess_sk1 = 'sandking_burrowstrike',
  1026. chess_slark1 = 'slark_shadow_dance',
  1027. chess_sniper1 = 'sniper_assassinate',
  1028. chess_nec1 = 'necrolyte_death_pulse',
  1029. chess_ta1 = 'templar_assassin_refraction',
  1030. chess_enigma1 = 'enigma_midnight_pulse',
  1031. --
  1032. chess_bat1 = 'batrider_sticky_napalm',
  1033. chess_luna1 = 'luna_moon_glaive',
  1034. chess_tp1 = 'treant_leech_seed',
  1035. chess_sf1 = 'nevermore_requiem',
  1036. chess_dk1 = 'dragon_knight_elder_dragon_form',
  1037. chess_viper1 = 'viper_viper_strike',
  1038. chess_medusa1 = 'medusa_stone_gaze',
  1039. chess_disruptor1 = 'disruptor_static_storm',
  1040. chess_ga1 = 'alchemist_acid_spray',
  1041. chess_tech1 = 'chess_tech_bomb',
  1042. --
  1043. chess_fur1 = 'fur_tree',
  1044. chess_ld1 = 'ld_bear',
  1045. --
  1046. chess_morph1 = 'morphling_waveform',
  1047. chess_tb1 = 'tb_mohua',
  1048. chess_tiny1 = 'tiny_touzhi',
  1049.  
  1050.  
  1051. chess_cm11 = 'cm_mana_aura',
  1052. chess_axe11 = 'axe_berserkers_call',
  1053. chess_dr11 = 'shooter_aura',
  1054. chess_eh11 = 'enchantress_natures_attendants',
  1055. chess_om11 = 'ogre_magi_bloodlust',
  1056. chess_tusk11 = 'tusk_walrus_punch',
  1057. chess_bm11 = 'beastmaster_wild_axes',
  1058. chess_jugg11 = 'juggernaut_blade_fury',
  1059. chess_lyc11 = 'lyc_wolf',
  1060. chess_shredder11 = 'shredder_whirling_death',
  1061. chess_tk11 = 'a108',
  1062. chess_light11 = 'keeper_of_the_light_illuminate',
  1063. chess_ok11 = 'omniknight_purification',
  1064. chess_razor11 = 'razor_plasma_field',
  1065. chess_wr11 = 'windrunner_powershot',
  1066. chess_doom11 = 'doom_bringer_doom',
  1067. chess_kunkka11 = 'kunkka_ghostship',
  1068. chess_lina11 = 'lina_laguna_blade',
  1069. chess_troll11 = 'troll_warlord_fervor',
  1070. chess_veno11 = 'veno_ward',
  1071. chess_gyro11 = 'gyrocopter_call_down',
  1072. chess_jakiro11 = 'jakiro_macropyre',
  1073. chess_lich11 = 'lich_chain_frost',
  1074. chess_qop11 = 'queenofpain_scream_of_pain',
  1075. chess_th11 = 'tidehunter_ravage',
  1076. --
  1077. chess_am11 = 'antimage_mana_break',
  1078. chess_bh11 = 'bounty_hunter_shuriken_toss',
  1079. chess_wd11 = 'witch_doctor_paralyzing_cask',
  1080. chess_clock11 = 'rattletrap_battery_assault',
  1081. chess_ss11 = 'shadow_shaman_voodoo',
  1082. chess_pa11 = 'phantom_assassin_coup_de_grace',
  1083. chess_puck11 = 'puck_illusory_orb',
  1084. chess_slardar11 = 'slardar_amplify_damage',
  1085. chess_ck11 = 'chaos_knight_chaos_bolt',
  1086. chess_abaddon11 = 'abaddon_aphotic_shield',
  1087. chess_sk11 = 'sandking_burrowstrike',
  1088. chess_slark11 = 'slark_shadow_dance',
  1089. chess_sniper11 = 'sniper_assassinate',
  1090. chess_nec11 = 'necrolyte_death_pulse',
  1091. chess_ta11 = 'templar_assassin_refraction',
  1092. chess_enigma11 = 'enigma_midnight_pulse',
  1093. --
  1094. chess_bat11 = 'batrider_sticky_napalm',
  1095. chess_luna11 = 'luna_moon_glaive',
  1096. chess_tp11 = 'treant_leech_seed',
  1097. chess_sf11 = 'nevermore_requiem',
  1098. chess_dk11 = 'dragon_knight_elder_dragon_form',
  1099. chess_viper11 = 'viper_viper_strike',
  1100. chess_medusa11 = 'medusa_stone_gaze',
  1101. chess_disruptor11 = 'disruptor_static_storm',
  1102. chess_ga11 = 'alchemist_acid_spray',
  1103. chess_tech11 = 'chess_tech_bomb',
  1104. --
  1105. chess_fur11 = 'fur_tree',
  1106. chess_ld11 = 'ld_bear',
  1107. --
  1108. chess_morph11 = 'morphling_waveform',
  1109. chess_tb11 = 'tb_mohua',
  1110. chess_tiny11 = 'tiny_touzhi',
  1111.  
  1112. chess_ck_ssr = 'ck_illusion',
  1113. }
  1114. --释放技能:0=被动技能,1=单位目标,2=无目标,3=点目标,4=自己目标,5=近身单位目标,6=先知周边树人,7=随机友军目标(嗜血术),8=随机周围空地目标(炸弹人),9=血量百分比最低的队友,10=等级最高的敌人(末日),11=沙王穿刺
  1115. GameRules:GetGameModeEntity().ability_behavior_list = {
  1116. axe_berserkers_call = 2,
  1117. crystal_maiden_brilliance_aura = 0,
  1118. enchantress_natures_attendants = 2,
  1119. ogre_magi_ignite = 1,
  1120. ogre_magi_bloodlust = 7,
  1121. tusk_walrus_punch = 5,
  1122. beastmaster_wild_axes = 3,
  1123. juggernaut_blade_fury = 2,
  1124. lyc_wolf = 2,
  1125. shredder_whirling_death = 2,
  1126. a108 = 2,
  1127. shooter_aura = 0,
  1128. keeper_of_the_light_illuminate = 3,
  1129. omniknight_purification = 9,
  1130. razor_plasma_field = 2,
  1131. windrunner_powershot = 3,
  1132. doom_bringer_doom = 10,
  1133. kunkka_ghostship = 3,
  1134. lina_laguna_blade = 10,
  1135. troll_warlord_whirling_axes_melee = 2,
  1136. troll_warlord_whirling_axes_ranged = 1,
  1137. troll_warlord_fervor = 0,
  1138. venomancer_poison_nova = 2,
  1139. veno_ward = 8,
  1140. gyrocopter_call_down = 3,
  1141. jakiro_macropyre = 3,
  1142. lich_chain_frost = 1,
  1143. queenofpain_scream_of_pain = 2,
  1144. tidehunter_ravage = 2,
  1145. antimage_mana_break = 0,
  1146. bounty_hunter_shuriken_toss = 1,
  1147. witch_doctor_paralyzing_cask = 1,
  1148. rattletrap_battery_assault = 2,
  1149. shadow_shaman_voodoo = 1,
  1150. phantom_assassin_coup_de_grace = 0,
  1151. puck_illusory_orb = 3,
  1152. slardar_amplify_damage = 1,
  1153. chaos_knight_chaos_bolt = 1,
  1154. abaddon_aphotic_shield = 9,
  1155. bump = 11,
  1156. slark_shadow_dance = 2,
  1157. sniper_assassinate = 1,
  1158. necrolyte_death_pulse = 2,
  1159. templar_assassin_refraction = 2,
  1160. enigma_midnight_pulse = 3,
  1161. --
  1162. batrider_sticky_napalm = 3,
  1163. batrider_firefly = 6,
  1164. luna_moon_glaive = 0,
  1165. treant_leech_seed = 5,
  1166. nevermore_requiem = 2,
  1167. dragon_knight_elder_dragon_form = 2,
  1168. viper_viper_strike = 1,
  1169. medusa_stone_gaze = 2,
  1170. disruptor_static_storm = 3,
  1171. alchemist_acid_spray = 3,
  1172. chess_tech_bomb = 8,
  1173. sven_great_cleave = 0,
  1174. fur_tree = 6,
  1175. ld_bear = 8,
  1176. --
  1177. nec_ssr_scythe = 1,
  1178. morphling_waveform = 11,
  1179. sandking_burrowstrike = 11,
  1180. tb_mohua = 2,
  1181. tiny_touzhi = 12,
  1182. ck_illusion = 2,
  1183. }
  1184.  
  1185. --组合技技能ability
  1186. --组合技条件condition:0=只有唯一1个同职业/种族的友军,1~3=需要1~3名同职业/种族的友军
  1187. --组合技类型type:0=自身有效果,1=所有同职业/种族的友军的有效果,2=所有友军有效果,3=所有敌军有效果,4=随机一个友军有效果,5=随机一个敌军有效果
  1188. GameRules:GetGameModeEntity().combo_ability_type = {
  1189. --职业技能
  1190. is_warrior = { ability = 'is_warrior_buff', condition = 3, type = 1 },
  1191. is_warrior1 = { ability = 'is_warrior_buff_plus', condition = 6, type = 1 },
  1192. is_warrior11 = { ability = 'is_warrior_buff_plus_plus', condition = 9, type = 1 },
  1193. is_mage = { ability = 'is_mage_buff', condition = 3, type = 3 },
  1194. is_mage1 = { ability = 'is_mage_buff_plus', condition = 6, type = 3 },
  1195. is_warlock = { ability = 'is_warlock_buff', condition = 3, type = 2 },
  1196. is_warlock1 = { ability = 'is_warlock_buff_plus', condition = 6, type = 2 },
  1197. is_mech = { ability = 'is_mech_buff', condition = 2, type = 1 },
  1198. is_mech1 = { ability = 'is_mech_buff_plus', condition = 4, type = 1 },
  1199. is_assassin = { ability = 'is_assassin_buff', condition = 3, type = 1 },
  1200. is_assassin1 = { ability = 'is_assassin_buff_plus', condition = 6, type = 1 },
  1201. is_hunter = { ability = 'is_hunter_buff', condition = 3, type = 1 },
  1202. is_hunter1 = { ability = 'is_hunter_buff_plus', condition = 6, type = 1 },
  1203. is_knight = { ability = 'is_knight_buff', condition = 2, type = 1 },
  1204. is_knight1 = { ability = 'is_knight_buff_plus', condition = 4, type = 1 },
  1205. is_knight11 = { ability = 'is_knight_buff_plus_plus', condition = 6, type = 1 },
  1206. is_shaman = {condition = 2 , type = 5},
  1207. is_demonhunter = {condition = 1 , type = 1},
  1208. is_demonhunter1 = {condition = 2 , type = 1},
  1209.  
  1210. --种族技能
  1211. is_troll = { ability = 'is_troll_buff', condition = 2, type = 1 },
  1212. is_troll1 = { ability = 'is_troll_buff_plus', condition = 4, type = 2 },
  1213. is_beast = { ability = 'is_beast_buff', condition = 2, type = 2 },
  1214. is_beast1 = { ability = 'is_beast_buff_plus', condition = 4, type = 2 },
  1215. is_beast11 = { ability = 'is_beast_buff_plus_plus', condition = 6, type = 2 },
  1216. is_elf = { ability = 'is_elf_buff', condition = 3, type = 1 },
  1217. is_elf1 = { ability = 'is_elf_buff_plus', condition = 6, type = 1 },
  1218. is_human = { ability = 'is_human_buff', condition = 2, type = 1 },
  1219. is_human1 = { ability = 'is_human_buff_plus', condition = 4, type = 1 },
  1220. is_human11 = { ability = 'is_human_buff_plus_plus', condition = 6, type = 1 },
  1221. is_undead = { ability = 'is_undead_buff', condition = 2, type = 3 },
  1222. is_undead1 = { ability = 'is_undead_buff_plus', condition = 4, type = 3 },
  1223. is_undead11 = { ability = 'is_undead_buff_plus_plus', condition = 6, type = 3 },
  1224. is_orc = { ability = 'is_orc_buff', condition = 2, type = 1 },
  1225. is_orc1 = { ability = 'is_orc_buff_plus', condition = 4, type = 1 },
  1226. is_orc11 = { ability = 'is_orc_buff_plus_plus', condition = 6, type = 1 },
  1227. is_naga = { ability = 'is_naga_buff', condition = 2, type = 2 },
  1228. is_naga1 = { ability = 'is_naga_buff_plus', condition = 4, type = 2 },
  1229. is_goblin = { ability = 'is_goblin_buff', condition = 3, type = 4 },
  1230. is_goblin1 = { ability = 'is_goblin_buff', condition = 6, type = 1 },
  1231. is_element = { ability = 'is_element_buff', condition = 2, type = 1 },
  1232. is_element1 = { ability = 'is_element_buff', condition = 4, type = 2 },
  1233. is_demon = { ability = 'is_demon_buff', condition = 0, type = 1 },
  1234. is_dwarf = { ability = 'is_dwarf_buff', condition = 1, type = 1 },
  1235. is_ogre = { ability = 'is_ogre_buff', condition = 1, type = 1 },
  1236. is_dragon = {condition = 3 , type = 1},
  1237. is_druid = {condition = 2, type = 1 },
  1238. }
  1239.  
  1240. GameRules:GetGameModeEntity().sm_hero_list = {
  1241. h001 = "models/props_gameplay/donkey.vmdl",
  1242. h002 = "models/props_gameplay/donkey_dire.vmdl",
  1243. --普通信使 beginner
  1244. h101 = "models/courier/skippy_parrot/skippy_parrot.vmdl",
  1245. h102 = "models/courier/smeevil_mammoth/smeevil_mammoth.vmdl",
  1246. h103 = "models/items/courier/arneyb_rabbit/arneyb_rabbit.vmdl",
  1247. h104 = "models/items/courier/axolotl/axolotl.vmdl",
  1248. h105 = "models/items/courier/coco_the_courageous/coco_the_courageous.vmdl",
  1249. h106 = "models/items/courier/coral_furryfish/coral_furryfish.vmdl",
  1250. h107 = "models/items/courier/corsair_ship/corsair_ship.vmdl",
  1251. h108 = "models/items/courier/duskie/duskie.vmdl",
  1252. h109 = "models/items/courier/itsy/itsy.vmdl",
  1253. h110 = "models/items/courier/jumo/jumo.vmdl",
  1254. h111 = "models/items/courier/mighty_chicken/mighty_chicken.vmdl",
  1255. h112 = "models/items/courier/nexon_turtle_05_green/nexon_turtle_05_green.vmdl",
  1256. h113 = "models/items/courier/pumpkin_courier/pumpkin_courier.vmdl",
  1257. h114 = "models/items/courier/pw_ostrich/pw_ostrich.vmdl",
  1258. h115 = "models/items/courier/scuttling_scotty_penguin/scuttling_scotty_penguin.vmdl",
  1259. h116 = "models/items/courier/shagbark/shagbark.vmdl",
  1260. h117 = "models/items/courier/snaggletooth_red_panda/snaggletooth_red_panda.vmdl",
  1261. h118 = "models/items/courier/snail/courier_snail.vmdl",
  1262. h119 = "models/items/courier/teron/teron.vmdl",
  1263. h120 = "models/items/courier/xianhe_stork/xianhe_stork.vmdl",
  1264.  
  1265. h121 = "models/items/courier/starladder_grillhound/starladder_grillhound.vmdl",
  1266. h122 = "models/items/courier/pw_zombie/pw_zombie.vmdl",
  1267. h123 = "models/items/courier/raiq/raiq.vmdl",
  1268. h124 = "models/courier/frog/frog.vmdl",
  1269. h125 = "models/courier/godhorse/godhorse.vmdl",
  1270. h126 = "models/courier/imp/imp.vmdl",
  1271. h127 = "models/courier/mighty_boar/mighty_boar.vmdl",
  1272. h128 = "models/items/courier/onibi_lvl_03/onibi_lvl_03.vmdl",
  1273. h129 = "models/items/courier/echo_wisp/echo_wisp.vmdl", --蠕行水母
  1274.  
  1275. h130 = "models/courier/sw_donkey/sw_donkey.vmdl", --驴法师new
  1276. h131 = "models/items/courier/gnomepig/gnomepig.vmdl", --丰臀公主new
  1277. h132 = "models/items/furion/treant/ravenous_woodfang/ravenous_woodfang.vmdl",--焚牙树精new
  1278. h133 = "models/courier/mechjaw/mechjaw.vmdl",--机械咬人箱new
  1279. h134 = "models/items/courier/mole_messenger/mole_messenger.vmdl",--1级矿车老鼠
  1280.  
  1281. --小英雄信使 ameteur
  1282. h201 = "models/courier/doom_demihero_courier/doom_demihero_courier.vmdl",
  1283. h202 = "models/courier/huntling/huntling.vmdl",
  1284. h203 = "models/courier/minipudge/minipudge.vmdl",
  1285. h204 = "models/courier/seekling/seekling.vmdl",
  1286. h205 = "models/items/courier/baekho/baekho.vmdl",
  1287. h206 = "models/items/courier/basim/basim.vmdl",
  1288. h207 = "models/items/courier/devourling/devourling.vmdl",
  1289. h208 = "models/items/courier/faceless_rex/faceless_rex.vmdl",
  1290. h209 = "models/items/courier/tinkbot/tinkbot.vmdl",
  1291. h210 = "models/items/courier/lilnova/lilnova.vmdl",
  1292.  
  1293. h211 = "models/items/courier/amphibian_kid/amphibian_kid.vmdl",
  1294. h212 = "models/courier/venoling/venoling.vmdl",
  1295. h213 = "models/courier/juggernaut_dog/juggernaut_dog.vmdl",
  1296. h214 = "models/courier/otter_dragon/otter_dragon.vmdl",
  1297. h215 = "models/items/courier/boooofus_courier/boooofus_courier.vmdl",
  1298. h216 = "models/courier/baby_winter_wyvern/baby_winter_wyvern.vmdl",
  1299. h217 = "models/courier/yak/yak.vmdl",
  1300. h218 = "models/items/furion/treant/eternalseasons_treant/eternalseasons_treant.vmdl",
  1301. h219 = "models/items/courier/blue_lightning_horse/blue_lightning_horse.vmdl",
  1302. h220 = "models/items/courier/waldi_the_faithful/waldi_the_faithful.vmdl",
  1303. h221 = "models/items/courier/bajie_pig/bajie_pig.vmdl",
  1304. h222 = "models/items/courier/courier_faun/courier_faun.vmdl",
  1305. h223 = "models/items/courier/livery_llama_courier/livery_llama_courier.vmdl",
  1306. h224 = "models/items/courier/onibi_lvl_10/onibi_lvl_10.vmdl",
  1307. h225 = "models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl", --胆小南瓜人
  1308. h226 = "models/items/courier/hermit_crab/hermit_crab.vmdl", --螃蟹1
  1309. h227 = "models/items/courier/hermit_crab/hermit_crab_boot.vmdl", --螃蟹2
  1310. h228 = "models/items/courier/hermit_crab/hermit_crab_shield.vmdl", --螃蟹3
  1311.  
  1312. h229 = "models/courier/donkey_unicorn/donkey_unicorn.vmdl", --竭智法师new
  1313. h230 = "models/items/courier/white_the_crystal_courier/white_the_crystal_courier.vmdl", --蓝心白隼new
  1314. h231 = "models/items/furion/treant/furion_treant_nelum_red/furion_treant_nelum_red.vmdl",--莲花人new
  1315. h232 = "models/courier/beetlejaws/mesh/beetlejaws.vmdl",--甲虫咬人箱new
  1316. h233 = "models/courier/smeevil_bird/smeevil_bird.vmdl",
  1317. h234 = "models/items/courier/mole_messenger/mole_messenger_lvl4.vmdl",--蜡烛头矿车老鼠
  1318.  
  1319.  
  1320. --珍藏信使 pro
  1321. h301 = "models/items/courier/bookwyrm/bookwyrm.vmdl",
  1322. h302 = "models/items/courier/captain_bamboo/captain_bamboo.vmdl",
  1323. h303 = "models/items/courier/kanyu_shark/kanyu_shark.vmdl",
  1324. h304 = "models/items/courier/tory_the_sky_guardian/tory_the_sky_guardian.vmdl",
  1325. h305 = "models/items/courier/shroomy/shroomy.vmdl",
  1326. h306 = "models/items/courier/courier_janjou/courier_janjou.vmdl",
  1327. h307 = "models/items/courier/green_jade_dragon/green_jade_dragon.vmdl",
  1328. h308 = "models/courier/drodo/drodo.vmdl",
  1329. h309 = "models/courier/mech_donkey/mech_donkey.vmdl",
  1330.  
  1331. h310 = "models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl",
  1332. h311 = "models/courier/octopus/octopus.vmdl",
  1333. h312 = "models/items/courier/scribbinsthescarab/scribbinsthescarab.vmdl",
  1334. h313 = "models/courier/defense3_sheep/defense3_sheep.vmdl",
  1335. h314 = "models/items/courier/snapjaw/snapjaw.vmdl",
  1336. h315 = "models/items/courier/g1_courier/g1_courier.vmdl",
  1337. h316 = "models/courier/donkey_trio/mesh/donkey_trio.vmdl",
  1338. h317 = "models/items/courier/boris_baumhauer/boris_baumhauer.vmdl",
  1339. h318 = "models/courier/baby_rosh/babyroshan.vmdl",
  1340. h319 = "models/items/courier/bearzky/bearzky.vmdl",
  1341. h320 = "models/items/courier/defense4_radiant/defense4_radiant.vmdl",
  1342. h321 = "models/items/courier/defense4_dire/defense4_dire.vmdl",
  1343. h322 = "models/items/courier/onibi_lvl_20/onibi_lvl_20.vmdl",
  1344. h323 = "models/items/juggernaut/ward/fortunes_tout/fortunes_tout.vmdl", --招财猫
  1345. h324 = "models/items/courier/hermit_crab/hermit_crab_necro.vmdl", --螃蟹4
  1346. h325 = "models/items/courier/hermit_crab/hermit_crab_travelboot.vmdl", --螃蟹5
  1347. h326 = "models/items/courier/hermit_crab/hermit_crab_lotus.vmdl", --螃蟹6
  1348. h327 = "models/courier/donkey_ti7/donkey_ti7.vmdl",
  1349.  
  1350. h328 = "models/items/courier/shibe_dog_cat/shibe_dog_cat.vmdl", --天猫地狗new
  1351. h329 = "models/items/furion/treant/hallowed_horde/hallowed_horde.vmdl",--万圣树群new
  1352. h330 = "models/courier/flopjaw/flopjaw.vmdl",--大嘴咬人箱new
  1353. h331 = "models/courier/lockjaw/lockjaw.vmdl",--咬人箱洛克new
  1354. h332 = "models/items/courier/butch_pudge_dog/butch_pudge_dog.vmdl",--布狗new
  1355. h333 = "models/courier/turtle_rider/turtle_rider.vmdl",
  1356. h334 = "models/courier/smeevil_crab/smeevil_crab.vmdl",
  1357. h335 = "models/items/courier/mole_messenger/mole_messenger_lvl6.vmdl",--绿钻头矿车老鼠
  1358.  
  1359. h399 = "models/courier/baby_rosh/babyroshan_winter18.vmdl",--姜饼肉山
  1360.  
  1361. --战队信使 master
  1362. h401 = "models/courier/navi_courier/navi_courier.vmdl",
  1363. h402 = "models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl",
  1364. h403 = "models/items/courier/ig_dragon/ig_dragon.vmdl",
  1365. h404 = "models/items/courier/lgd_golden_skipper/lgd_golden_skipper.vmdl",
  1366. h405 = "models/items/courier/vigilante_fox_red/vigilante_fox_red.vmdl",
  1367. h406 = "models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl",
  1368. h407 = "models/items/courier/throe/throe.vmdl",
  1369.  
  1370. h408 = "models/items/courier/vaal_the_animated_constructradiant/vaal_the_animated_constructradiant.vmdl",
  1371. h409 = "models/items/courier/vaal_the_animated_constructdire/vaal_the_animated_constructdire.vmdl",
  1372. h410 = "models/items/courier/carty/carty.vmdl",
  1373. h411 = "models/items/courier/carty_dire/carty_dire.vmdl",
  1374. h412 = "models/items/courier/dc_angel/dc_angel.vmdl",
  1375. h413 = "models/items/courier/dc_demon/dc_demon.vmdl",
  1376. h414 = "models/items/courier/vigilante_fox_green/vigilante_fox_green.vmdl",
  1377. h415 = "models/items/courier/bts_chirpy/bts_chirpy.vmdl",
  1378. h416 = "models/items/courier/krobeling/krobeling.vmdl",
  1379. h417 = "models/items/courier/jin_yin_black_fox/jin_yin_black_fox.vmdl",
  1380. h418 = "models/items/courier/jin_yin_white_fox/jin_yin_white_fox.vmdl",
  1381. h419 = "models/items/courier/fei_lian_blue/fei_lian_blue.vmdl",
  1382. h420 = "models/items/courier/gama_brothers/gama_brothers.vmdl",
  1383. h421 = "models/items/courier/onibi_lvl_21/onibi_lvl_21.vmdl",
  1384. h422 = "models/items/courier/wabbit_the_mighty_courier_of_heroes/wabbit_the_mighty_courier_of_heroes.vmdl", --小飞侠
  1385. h423 = "models/items/courier/hermit_crab/hermit_crab_octarine.vmdl", --螃蟹7
  1386. h424 = "models/items/courier/hermit_crab/hermit_crab_skady.vmdl", --螃蟹8
  1387. h425 = "models/items/courier/hermit_crab/hermit_crab_aegis.vmdl", --螃蟹9
  1388.  
  1389. h426 = "models/items/furion/treant_flower_1.vmdl",--绽放树精new
  1390. h427 = "models/courier/smeevil_magic_carpet/smeevil_magic_carpet.vmdl",
  1391. h428 = "models/items/courier/mole_messenger/mole_messenger_lvl7.vmdl",--绿钻头金矿车老鼠
  1392.  
  1393. h499 = "models/items/courier/krobeling_gold/krobeling_gold_flying.vmdl",--金dp
  1394. h429 = "models/items/courier/nilbog/nilbog.vmdl",--机械霸王龙
  1395.  
  1396. h444 = "models/props_gameplay/donkey.vmdl",
  1397. }
  1398.  
  1399. GameRules:GetGameModeEntity().hero_model_list = {
  1400. h101 = 'models/props_gameplay/donkey.vmdl',
  1401. h102 = 'models/items/courier/bearzky/bearzky.vmdl',
  1402. h403 = 'models/items/courier/starladder_grillhound/starladder_grillhound.vmdl',--双头狗
  1403. h404 = 'models/items/courier/boooofus_courier/boooofus_courier.vmdl',--小死灵法
  1404. h405 = 'models/items/courier/virtus_werebear_t3/virtus_werebear_t3.vmdl',--VP北极熊
  1405. h406 = 'models/courier/lockjaw/lockjaw.vmdl',--咬人箱洛克
  1406. h201 = 'models/courier/mech_donkey/mech_donkey.vmdl',
  1407. h202 = 'models/items/courier/little_fraid_the_courier_of_simons_retribution/little_fraid_the_courier_of_simons_retribution.vmdl',
  1408. h203 = 'models/items/courier/baekho/baekho.vmdl',
  1409. h301 = 'models/items/courier/green_jade_dragon/green_jade_dragon.vmdl',
  1410. h302 = 'models/courier/donkey_crummy_wizard_2014/donkey_crummy_wizard_2014.vmdl',
  1411. h303 = 'models/items/courier/pw_zombie/pw_zombie.vmdl',
  1412. h401 = 'models/courier/drodo/drodo.vmdl',
  1413. h402 = 'models/items/courier/courier_mvp_redkita/courier_mvp_redkita.vmdl',
  1414. }
  1415. GameRules:GetGameModeEntity().hero_model_scale_list = {
  1416. h101 = 1,
  1417. h102 = 1.2,
  1418. h201 = 1,
  1419. h202 = 1.2,
  1420. h203 = 1.1,
  1421. h301 = 1.1,
  1422. h302 = 1,
  1423. h303 = 1,
  1424. h401 = 1.1,
  1425. h402 = 1.1,
  1426. }
  1427. GameRules:GetGameModeEntity().hero_ability_list = {
  1428. h101 = 'h101_ability',
  1429. h102 = 'is_beast',
  1430. h403 = 'h403_ability',--准备回和抽2个一样的
  1431. h404 = 'h404_ability',--删最后一张牌有50%概率获得一张
  1432. h405 = 'h405_ability',--血量落后全场+10攻击力
  1433. h406 = 'h406_ability',--删牌可以暴击10倍金币
  1434. h201 = 'is_mech',
  1435. h202 = 'h202_ability',
  1436. h203 = 'h203_ability',
  1437. h301 = 'h301_ability',
  1438. h302 = 'h302_ability',
  1439. h303 = 'is_undead',
  1440. h401 = 'h401_ability',
  1441. h402 = 'h402_ability',
  1442. }
  1443. GameRules:GetGameModeEntity().combined_items = {
  1444. [1] = 'item_fengkuangmianju',
  1445. [2] = 'item_shengjian',
  1446. [3] = 'item_qiangxi',
  1447. [4] = 'item_longxin',
  1448. [5] = 'item_renjia',
  1449. [6] = 'item_xianfengdun',
  1450. [7] = 'item_shuijingjian',
  1451. [8] = 'item_dapao',
  1452. [9] = 'item_anmie',
  1453. [10] = 'item_xuanwo',
  1454. [11] = 'item_dadianchui',
  1455. [12] = 'item_jingubang',
  1456. [13] = 'item_tiaozhantoujin',
  1457. [14] = 'item_yinyuezhijing',
  1458.  
  1459. [15] = 'item_jianrenqiu',
  1460. [16] = 'item_shuaxinqiu',
  1461. [17] = 'item_huiguang',
  1462. }
  1463. end
  1464. function InitHeros()
  1465. --拼接要向服务器发送的steamid数据
  1466. for pid,sid in pairs(GameRules:GetGameModeEntity().playerid2steamid) do
  1467. if GameRules:GetGameModeEntity().steamidlist == '' then
  1468. GameRules:GetGameModeEntity().steamidlist = sid
  1469. GameRules:GetGameModeEntity().steamidlist_heroindex = sid..'_'..GameRules:GetGameModeEntity().playerid2hero[pid]:entindex()
  1470. else
  1471. GameRules:GetGameModeEntity().steamidlist = GameRules:GetGameModeEntity().steamidlist..','..sid
  1472. GameRules:GetGameModeEntity().steamidlist_heroindex = GameRules:GetGameModeEntity().steamidlist_heroindex..','..sid..'_'..GameRules:GetGameModeEntity().playerid2hero[pid]:entindex()
  1473. end
  1474. end
  1475. if string.find(GameRules:GetGameModeEntity().steamidlist,'76561198101849234') or string.find(GameRules:GetGameModeEntity().steamidlist,"76561198090931971") or string.find(GameRules:GetGameModeEntity().steamidlist,"76561198132023205") or string.find(GameRules:GetGameModeEntity().steamidlist,"76561198079679584") then
  1476. GameRules:GetGameModeEntity().myself = true
  1477. end
  1478. --防控制台作弊
  1479. if GameRules:GetGameModeEntity().myself ~= true then
  1480. Timers:CreateTimer(1,function()
  1481. if GameRules:IsCheatMode() == true then
  1482. prt('CHEAT MODE! BYEBYE')
  1483. GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
  1484. return
  1485. end
  1486. return 5
  1487. end)
  1488. end
  1489.  
  1490. GameRules:GetGameModeEntity().cloudlineup = {}
  1491. if PlayerResource:GetPlayerCount() == 1 then
  1492. --单人获取云对战列表
  1493. local url = "http://101.200.189.65:431/dac/lineup/list?hehe="..RandomInt(1,10000)
  1494. SendHTTP(url, function(t)
  1495. prt('LOAD CLOUD LINEUP OK!')
  1496. GameRules:GetGameModeEntity().cloudlineup = t.data
  1497. end)
  1498. end
  1499. --从服务器获取玩家信息
  1500. local url = "http://101.200.189.65:431/dac/heros/get/@"..GameRules:GetGameModeEntity().steamidlist_heroindex.."?hehe="..RandomInt(1,10000).."&key="..GetDedicatedServerKey('dac')
  1501. SendHTTP(url, function(t)
  1502. if t.err == 0 then
  1503. prt('CONNECT SERVER OK!')
  1504. for steam_id,user_info in pairs(t.user_info) do
  1505. local hero_index = user_info.hero_index
  1506. local hero = EntIndexToHScript(hero_index)
  1507. local player_id = hero:GetPlayerID()
  1508. if user_info.mmr_level < 19 then
  1509. hero.notbishop = true
  1510. end
  1511. user_info['player_id'] = player_id
  1512. hero.steam_id = steam_id
  1513. if GameRules:GetGameModeEntity().steamid2name[steam_id] ~= nil then
  1514. hero.player_name = GameRules:GetGameModeEntity().steamid2name[steam_id]
  1515. end
  1516.  
  1517. local onduty_hero_long = user_info.onduty_hero
  1518. local onduty_hero = string.split(onduty_hero_long,'_')[1]
  1519. local onduty_hero_effect = string.split(onduty_hero_long,'_')[2] or ''
  1520.  
  1521. user_info['onduty_hero'] = onduty_hero
  1522. user_info['onduty_hero_effect'] = onduty_hero_effect
  1523.  
  1524. local init_hp = 100
  1525. GameRules:GetGameModeEntity().stat_info[steam_id] = {
  1526. hp = init_hp,
  1527. player_id = player_id,
  1528. duration = 0,
  1529. zhugong = onduty_hero,
  1530. zhugong_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero],
  1531. zhugong_effect = onduty_hero_effect,
  1532. round = 0,
  1533. win_round = 0,
  1534. lose_round = 0,
  1535. draw_round = 0,
  1536. kills = 0,
  1537. deaths = 0,
  1538. mmr_level = user_info.mmr_level,
  1539. chess_lineup = '',
  1540. candy = 0,
  1541. }
  1542.  
  1543. local onduty_hero_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero]
  1544.  
  1545. hero:SetOriginalModel(onduty_hero_model)
  1546. hero:SetModel(onduty_hero_model)
  1547. hero:SetModelScale(1)
  1548. hero.ori_model = onduty_hero_model
  1549.  
  1550. hero.steam_id = steam_id
  1551.  
  1552. hero:MoveToPosition(hero:GetAbsOrigin())
  1553. AddAbilityAndSetLevel(hero,'pick_chess')
  1554. AddAbilityAndSetLevel(hero,'recall_chess')
  1555. AddAbilityAndSetLevel(hero,'remove_chess')
  1556. AddAbilityAndSetLevel(hero,'summon_hero')
  1557. AddAbilityAndSetLevel(hero,'exp_book')
  1558.  
  1559. if onduty_hero_effect ~= 'e000' then
  1560. AddAbilityAndSetLevel(hero,onduty_hero_effect)
  1561. end
  1562.  
  1563. AddAbilityAndSetLevel(hero,'jiaoxie_wudi_hero')
  1564. AddAbilityAndSetLevel(hero,'wudi')
  1565. AddAbilityAndSetLevel(hero,'no_hp_add')
  1566. end
  1567. GameRules:GetGameModeEntity().user_info = t.user_info
  1568. CustomNetTables:SetTableValue( "dac_table", "player_info", { info = t.user_info, hehe = RandomInt(1,1000)})
  1569.  
  1570. if t.chess_pool ~= nil then
  1571. if t.chess_pool.pool_size ~= nil then
  1572. GameRules:GetGameModeEntity().CHESS_POOL_SIZE = t.chess_pool.pool_size
  1573. end
  1574. if t.chess_pool.chess_init_1 ~= nil then
  1575. GameRules:GetGameModeEntity().CHESS_INIT_COUNT[1] = t.chess_pool.chess_init_1
  1576. end
  1577. if t.chess_pool.chess_init_2 ~= nil then
  1578. GameRules:GetGameModeEntity().CHESS_INIT_COUNT[2] = t.chess_pool.chess_init_2
  1579. end
  1580. if t.chess_pool.chess_init_3 ~= nil then
  1581. GameRules:GetGameModeEntity().CHESS_INIT_COUNT[3] = t.chess_pool.chess_init_3
  1582. end
  1583. if t.chess_pool.chess_init_4 ~= nil then
  1584. GameRules:GetGameModeEntity().CHESS_INIT_COUNT[4] = t.chess_pool.chess_init_4
  1585. end
  1586. if t.chess_pool.chess_init_5 ~= nil then
  1587. GameRules:GetGameModeEntity().CHESS_INIT_COUNT[5] = t.chess_pool.chess_init_5
  1588. end
  1589. end
  1590.  
  1591. StartGame()
  1592. elseif t.err == 1100 then
  1593. prt('对不起,有玩家没有获得内测资格,游戏无法开始。')
  1594. Timers:CreateTimer(30,function()
  1595. GameRules:SetGameWinner(DOTA_TEAM_BADGUYS)
  1596. end)
  1597. return
  1598. else
  1599. --连接服务器失败了,用默认信使玩
  1600. prt('CONNECT SERVER ERROR : '..t.err)
  1601.  
  1602. local user_info_table = {}
  1603. is_game_can_start = true
  1604. local steamid_table = string.split(GameRules:GetGameModeEntity().steamidlist_heroindex,',')
  1605.  
  1606. --默认玩家数据
  1607. for _,v in pairs(steamid_table) do
  1608. local steamid = string.split(v,'_')[1]
  1609. local hero_index = string.split(v,'_')[2]
  1610. user_info_table[steamid] = {
  1611. steamid = steamid,
  1612. candy = 0,
  1613. mmr = 0,
  1614. match = 0,
  1615. zhugong = {
  1616. [1] = "h001_e000"
  1617. },
  1618. onduty_hero = "h001_e000",
  1619. mmr_level = 0,
  1620. hero_index = tonumber(hero_index),
  1621. }
  1622. end
  1623.  
  1624. for steam_id,user_info in pairs(user_info_table) do
  1625. local hero_index = user_info.hero_index
  1626. local hero = EntIndexToHScript(hero_index)
  1627. local player_id = hero:GetPlayerID()
  1628. user_info['player_id'] = player_id
  1629. hero.steam_id = steam_id
  1630. if GameRules:GetGameModeEntity().steamid2name[steam_id] ~= nil then
  1631. hero.player_name = GameRules:GetGameModeEntity().steamid2name[steam_id]
  1632. end
  1633.  
  1634. local onduty_hero_long = user_info.onduty_hero
  1635. local onduty_hero = string.split(onduty_hero_long,'_')[1]
  1636. local onduty_hero_effect = string.split(onduty_hero_long,'_')[2] or ''
  1637.  
  1638. user_info['onduty_hero'] = onduty_hero
  1639. user_info['onduty_hero_effect'] = onduty_hero_effect
  1640.  
  1641. local init_hp = 100
  1642. GameRules:GetGameModeEntity().stat_info[steam_id] = {
  1643. hp = init_hp,
  1644. player_id = player_id,
  1645. duration = 0,
  1646. zhugong = onduty_hero,
  1647. zhugong_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero],
  1648. zhugong_effect = onduty_hero_effect,
  1649. round = 0,
  1650. win_round = 0,
  1651. lose_round = 0,
  1652. draw_round = 0,
  1653. kills = 0,
  1654. deaths = 0,
  1655. mmr_level = user_info.mmr_level,
  1656. chess_lineup = '',
  1657. candy = 0,
  1658. }
  1659.  
  1660. local onduty_hero_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero]
  1661.  
  1662. hero:SetOriginalModel(onduty_hero_model)
  1663. hero:SetModel(onduty_hero_model)
  1664. hero:SetModelScale(1)
  1665. hero.ori_model = onduty_hero_model
  1666.  
  1667. hero.steam_id = steam_id
  1668.  
  1669. hero:MoveToPosition(hero:GetAbsOrigin())
  1670. AddAbilityAndSetLevel(hero,'pick_chess')
  1671. AddAbilityAndSetLevel(hero,'recall_chess')
  1672. AddAbilityAndSetLevel(hero,'remove_chess')
  1673. AddAbilityAndSetLevel(hero,'summon_hero')
  1674. AddAbilityAndSetLevel(hero,'exp_book')
  1675.  
  1676. if onduty_hero_effect ~= 'e000' then
  1677. AddAbilityAndSetLevel(hero,onduty_hero_effect)
  1678. end
  1679.  
  1680. AddAbilityAndSetLevel(hero,'jiaoxie_wudi_hero')
  1681. AddAbilityAndSetLevel(hero,'wudi')
  1682. AddAbilityAndSetLevel(hero,'no_hp_add')
  1683. end
  1684. GameRules:GetGameModeEntity().user_info = user_info_table
  1685. CustomNetTables:SetTableValue( "dac_table", "player_info", { info = user_info_table, hehe = RandomInt(1,1000)})
  1686. StartGame()
  1687. end
  1688. end, function()
  1689. --连接服务器失败了,用默认信使玩
  1690. prt('CONNECT SERVER ERROR : '..t.err)
  1691.  
  1692. local user_info_table = {}
  1693. is_game_can_start = true
  1694. local steamid_table = string.split(GameRules:GetGameModeEntity().steamidlist_heroindex,',')
  1695.  
  1696. --默认玩家数据
  1697. for _,v in pairs(steamid_table) do
  1698. local steamid = string.split(v,'_')[1]
  1699. local hero_index = string.split(v,'_')[2]
  1700. user_info_table[steamid] = {
  1701. steamid = steamid,
  1702. candy = 0,
  1703. mmr = 0,
  1704. match = 0,
  1705. zhugong = {
  1706. [1] = "h001_e000"
  1707. },
  1708. onduty_hero = "h001_e000",
  1709. mmr_level = 0,
  1710. hero_index = tonumber(hero_index),
  1711. }
  1712. end
  1713.  
  1714. for steam_id,user_info in pairs(user_info_table) do
  1715. local hero_index = user_info.hero_index
  1716. local hero = EntIndexToHScript(hero_index)
  1717. local player_id = hero:GetPlayerID()
  1718. user_info['player_id'] = player_id
  1719. hero.steam_id = steam_id
  1720. if GameRules:GetGameModeEntity().steamid2name[steam_id] ~= nil then
  1721. hero.player_name = GameRules:GetGameModeEntity().steamid2name[steam_id]
  1722. end
  1723.  
  1724. local onduty_hero_long = user_info.onduty_hero
  1725. local onduty_hero = string.split(onduty_hero_long,'_')[1]
  1726. local onduty_hero_effect = string.split(onduty_hero_long,'_')[2] or ''
  1727.  
  1728. user_info['onduty_hero'] = onduty_hero
  1729. user_info['onduty_hero_effect'] = onduty_hero_effect
  1730.  
  1731. local init_hp = 100
  1732. GameRules:GetGameModeEntity().stat_info[steam_id] = {
  1733. hp = init_hp,
  1734. player_id = player_id,
  1735. duration = 0,
  1736. zhugong = onduty_hero,
  1737. zhugong_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero],
  1738. zhugong_effect = onduty_hero_effect,
  1739. round = 0,
  1740. win_round = 0,
  1741. lose_round = 0,
  1742. draw_round = 0,
  1743. kills = 0,
  1744. deaths = 0,
  1745. mmr_level = user_info.mmr_level,
  1746. chess_lineup = '',
  1747. candy = 0,
  1748. }
  1749.  
  1750. local onduty_hero_model = GameRules:GetGameModeEntity().sm_hero_list[onduty_hero]
  1751.  
  1752. hero:SetOriginalModel(onduty_hero_model)
  1753. hero:SetModel(onduty_hero_model)
  1754. hero:SetModelScale(1)
  1755. hero.ori_model = onduty_hero_model
  1756.  
  1757. hero.steam_id = steam_id
  1758.  
  1759. hero:MoveToPosition(hero:GetAbsOrigin())
  1760. AddAbilityAndSetLevel(hero,'pick_chess')
  1761. AddAbilityAndSetLevel(hero,'recall_chess')
  1762. AddAbilityAndSetLevel(hero,'remove_chess')
  1763. AddAbilityAndSetLevel(hero,'summon_hero')
  1764. AddAbilityAndSetLevel(hero,'exp_book')
  1765.  
  1766. if onduty_hero_effect ~= 'e000' then
  1767. AddAbilityAndSetLevel(hero,onduty_hero_effect)
  1768. end
  1769.  
  1770. AddAbilityAndSetLevel(hero,'jiaoxie_wudi_hero')
  1771. AddAbilityAndSetLevel(hero,'wudi')
  1772. AddAbilityAndSetLevel(hero,'no_hp_add')
  1773. end
  1774. GameRules:GetGameModeEntity().user_info = user_info_table
  1775. CustomNetTables:SetTableValue( "dac_table", "player_info", { info = user_info_table, hehe = RandomInt(1,1000)})
  1776. StartGame()
  1777. end)
  1778. end
  1779. --2、自动选英雄后给主公加技能
  1780. function DAC:OnPlayerPickHero(keys)
  1781. if IsServer() == true then
  1782. local player = EntIndexToHScript(keys.player)
  1783. local hero = EntIndexToHScript(keys.heroindex)
  1784. local children = hero:GetChildren()
  1785. for k,child in pairs(children) do
  1786. if child:GetClassname() == "dota_item_wearable" then
  1787. child:RemoveSelf()
  1788. end
  1789. end
  1790. for slot=0,8 do
  1791. if hero:GetItemInSlot(slot)~= nil then
  1792. hero:RemoveItem(hero:GetItemInSlot(slot))
  1793. end
  1794. end
  1795. hero:SetHullRadius(1)
  1796. hero:SetAbilityPoints(0)
  1797. for i=1,16 do
  1798. hero:RemoveAbility("empty"..i)
  1799. end
  1800. hero:SetMana(0)
  1801. -- AddAbilityAndSetLevel(hero,'hero_level_1',1)
  1802.  
  1803. --test particle
  1804. -- PlayParticleOnUnitUntilDeath({
  1805. -- caster = hero,
  1806. -- p = 'effect/dizuo/1.vpcf',
  1807. -- })
  1808.  
  1809. hero.team = hero:GetTeam()
  1810. hero.team_id = hero:GetTeam()
  1811. GameRules:GetGameModeEntity().team2playerid[hero:GetTeam()] = player:GetPlayerID()
  1812. GameRules:GetGameModeEntity().counterpart[hero:GetTeam()] = 0
  1813. GameRules:GetGameModeEntity().playerid2team[player:GetPlayerID()] = hero:GetTeam()
  1814.  
  1815. --将所有玩家的英雄存到一个数组
  1816. local heroindex = keys.heroindex
  1817. GameRules:GetGameModeEntity().hero[heroindex] = EntIndexToHScript(heroindex)
  1818. GameRules:GetGameModeEntity().playerid2hero[player:GetPlayerID()] = EntIndexToHScript(heroindex)
  1819. GameRules:GetGameModeEntity().teamid2hero[hero:GetTeam()] = EntIndexToHScript(heroindex)
  1820. local playercount = 0
  1821. for i,vi in pairs(GameRules:GetGameModeEntity().hero) do
  1822. playercount = playercount +1
  1823. end
  1824.  
  1825. print("PlayerCount: "..playercount.."/"..PlayerResource:GetPlayerCount())
  1826.  
  1827. if playercount == PlayerResource:GetPlayerCount() then
  1828. Timers:CreateTimer(0.1,function()
  1829. InitHeros()
  1830. end)
  1831. end
  1832. end
  1833. end
  1834. --英雄升级
  1835. function DAC:OnPlayerGainedLevel(keys)
  1836. local i = 0
  1837. for i = 6, 13 do
  1838. GameRules:GetGameModeEntity().population_max[i] = GetMaxChessCount(i)
  1839.  
  1840. local hero = TeamId2Hero(i)
  1841.  
  1842. if hero ~= nil then
  1843. hero:SetAbilityPoints(0)
  1844. local level = hero:GetLevel()
  1845. for j=1,10 do
  1846. if hero:FindAbilityByName('hero_level_'..j) ~= nil then
  1847. hero:RemoveAbility('hero_level_'..j)
  1848. hero:RemoveModifierByName('modifier_hero_level'..j)
  1849. end
  1850. end
  1851.  
  1852. AddAbilityAndSetLevel(hero,'hero_level_'..level,level)
  1853. end
  1854.  
  1855. --同步ui人口
  1856. CustomGameEventManager:Send_ServerToTeam(i,"population",{
  1857. max_count = GameRules:GetGameModeEntity().population_max[i],
  1858. count = GameRules:GetGameModeEntity().population[i],
  1859. })
  1860.  
  1861. end
  1862. end
  1863.  
  1864. --每次连接后保存userid到player的映射关系
  1865. function DAC:OnPlayerConnectFull(keys)
  1866. GameRules:GetGameModeEntity().playerid2steamid[keys.PlayerID] = tostring(PlayerResource:GetSteamID(keys.PlayerID))
  1867. GameRules:GetGameModeEntity().steamid2playerid[tostring(PlayerResource:GetSteamID(keys.PlayerID))] = keys.PlayerID
  1868. GameRules:GetGameModeEntity().steamid2name[tostring(PlayerResource:GetSteamID(keys.PlayerID))] = tostring(PlayerResource:GetPlayerName(keys.PlayerID))
  1869. GameRules:GetGameModeEntity().userid2player[keys.userid] = keys.index+1
  1870.  
  1871. GameRules:GetGameModeEntity().connect_state[keys.PlayerID] = true
  1872. if GameRules:GetGameModeEntity().isConnected[keys.index + 1] == true then
  1873. local hero = PlayerId2Hero(keys.PlayerID)
  1874. --重连
  1875. CustomGameEventManager:Send_ServerToAllClients("player_reconnect",{
  1876. id = keys.PlayerID
  1877. })
  1878.  
  1879. Timers:CreateTimer(RandomFloat(0,0.5),function()
  1880. CustomNetTables:SetTableValue( "dac_table", "player_info", {info = GameRules:GetGameModeEntity().user_info, hehe = RandomInt(1,1000)})
  1881. Timers:CreateTimer(RandomFloat(0,0.5),function()
  1882. GameRules:GetGameModeEntity().stat_info[hero.steam_id]['hp'] = hero:GetHealth()
  1883. CustomNetTables:SetTableValue( "dac_table", "user_panel_ranking", {table = GameRules:GetGameModeEntity().stat_info, hehe = RandomInt(1,1000)})
  1884.  
  1885. --同步ui血量
  1886. CustomGameEventManager:Send_ServerToAllClients("sync_hp",{
  1887. player_id = hero:GetPlayerID(),
  1888. hp = hero:GetHealth(),
  1889. hp_max = hero:GetMaxHealth(),
  1890. })
  1891. end)
  1892. end)
  1893. Timers:CreateTimer(RandomFloat(0,0.5),function()
  1894. GameRules:GetGameModeEntity().population_max[hero:GetTeam()] = hero:GetLevel()
  1895.  
  1896. --同步ui人口
  1897. CustomGameEventManager:Send_ServerToTeam(hero:GetTeam(),"population",{
  1898. max_count = GameRules:GetGameModeEntity().population_max[hero:GetTeam()],
  1899. count = GameRules:GetGameModeEntity().population[hero:GetTeam()],
  1900. })
  1901. end)
  1902. Timers:CreateTimer(RandomFloat(0,0.5),function()
  1903. CustomGameEventManager:Send_ServerToTeam(hero:GetTeam(),"show_gold",{
  1904. gold = hero:GetMana(),
  1905. lose_streak = hero.lose_streak or 0,
  1906. win_streak = hero.win_streak or 0,
  1907. })
  1908. end)
  1909. Timers:CreateTimer(RandomFloat(0,0.5),function()
  1910. local cardstr = ''
  1911. for _,card in pairs(hero.curr_chess_table) do
  1912. cardstr = cardstr..card..','
  1913. end
  1914. CustomGameEventManager:Send_ServerToTeam(hero:GetTeam(),"show_draw_card",{
  1915. cards = cardstr,
  1916. curr_money = hero:GetMana(),
  1917. })
  1918. end)
  1919.  
  1920. Timers:CreateTimer(RandomFloat(0,1),function()
  1921. CustomNetTables:SetTableValue( "dac_table", "user_panel_ranking", {table = GameRules:GetGameModeEntity().stat_info, hehe = RandomInt(1,1000)})
  1922.  
  1923. --同步ui血量
  1924. for i=0,PlayerResource:GetPlayerCount()-1 do
  1925. local h = PlayerId2Hero(i)
  1926. if h ~= nil and h:IsNull() == false and h:IsAlive() == true then
  1927. CustomGameEventManager:Send_ServerToTeam(hero:GetTeam(),"sync_hp",{
  1928. player_id = i,
  1929. hp = h:GetHealth(),
  1930. hp_max = h:GetMaxHealth(),
  1931. })
  1932. else
  1933. CustomGameEventManager:Send_ServerToTeam(hero:GetTeam(),"sync_hp",{
  1934. player_id = i,
  1935. hp = 0,
  1936. hp_max = 100,
  1937. })
  1938. end
  1939. end
  1940. end)
  1941.  
  1942.  
  1943.  
  1944.  
  1945. hero.isDisconnected = false
  1946. end
  1947. GameRules:GetGameModeEntity().isConnected[keys.index+1] = true;
  1948. end
  1949. --断线
  1950. function DAC:OnPlayerDisconnect(keys)
  1951. if IsServer() then
  1952. local hero = PlayerId2Hero(keys.PlayerID)
  1953. hero.isDisconnected = true
  1954. GameRules:GetGameModeEntity().connect_state[keys.PlayerID] = false
  1955. CustomNetTables:SetTableValue( "dac_table", "disconnect",
  1956. {
  1957. table = GameRules:GetGameModeEntity().connect_state,
  1958. hehe = RandomInt(1,100000)
  1959. }
  1960. )
  1961. -- CustomGameEventManager:Send_ServerToAllClients("player_disconnect",{
  1962. -- disconnectid = keys.PlayerID
  1963. -- })
  1964. end
  1965. end
  1966. --暂时不用了
  1967. function DAC:OnDeckReiceived(keys)
  1968. if keys.deck == nil then
  1969. keys.deck = GameRules:GetGameModeEntity().steamid2deck2cards[keys.steam_id][keys.deck_id]
  1970. end
  1971.  
  1972. local heroindex_old = tonumber(GameRules:GetGameModeEntity().steamid2heroindex[keys.steam_id])
  1973. local hero = EntIndexToHScript(heroindex_old)
  1974.  
  1975. if hero.is_ready == true then
  1976. return
  1977. end
  1978.  
  1979. local id = hero:GetPlayerID()
  1980. local steam_id = keys.steam_id
  1981. local team_old = hero.team
  1982.  
  1983. keys.hero = GameRules:GetGameModeEntity().HEROS[keys.hero] or keys.hero
  1984.  
  1985. PrecacheUnitByNameAsync( keys.hero, function()
  1986.  
  1987. local hero_new = PlayerResource:ReplaceHeroWith(id,keys.hero,PlayerResource:GetGold(id),0)
  1988.  
  1989. hero_new.steam_id = steam_id
  1990. hero_new.droping = false
  1991. hero_new.drawing = false
  1992. hero_new.team = team_old
  1993. heroindex = hero_new:GetEntityIndex()
  1994. GameRules:GetGameModeEntity().heroindex2steamid[heroindex_old] = nil
  1995. GameRules:GetGameModeEntity().steamid2heroindex[keys.steam_id] = heroindex
  1996. GameRules:GetGameModeEntity().heroindex2steamid[heroindex] = keys.steam_id
  1997.  
  1998. GameRules:GetGameModeEntity().hero[heroindex_old] = nil
  1999. GameRules:GetGameModeEntity().hero[hero_new:GetEntityIndex()] = hero_new
  2000.  
  2001. hero_new.is_ready = true
  2002.  
  2003. --填充手牌
  2004. hero_new.deck = {}
  2005. for u,v in pairs(keys.deck) do
  2006. table.insert(hero_new.deck, v)
  2007. end
  2008.  
  2009.  
  2010. if DEFAULT_DECK ~= nil then
  2011. hero_new.deck = DEFAULT_DECK
  2012. end
  2013.  
  2014. --送tp问题
  2015. for slot=0,8 do
  2016. if hero_new:GetItemInSlot(slot)~= nil then
  2017. hero_new:RemoveItem(hero_new:GetItemInSlot(slot))
  2018. end
  2019. end
  2020.  
  2021. if hero_new:GetModelScale() < 0.1 then
  2022. hero_new:SetModelScale(0.9)
  2023. local children = hero_new:GetChildren()
  2024. for k,child in pairs(children) do
  2025. if child:GetClassname() == "dota_item_wearable" then
  2026. child:RemoveSelf()
  2027. end
  2028. end
  2029. end
  2030. hero_new.hand = {}
  2031.  
  2032. --触发战吼?
  2033. if hero_new:GetUnitName() == "npc_dota_hero_alchemist" then
  2034. hero_new:AddAbility("zibao")
  2035. hero_new:FindAbilityByName("zibao"):SetLevel(1)
  2036. Timers:CreateTimer(0.2,function()
  2037. local newOrder = {
  2038. UnitIndex = hero_new:entindex(),
  2039. OrderType = DOTA_UNIT_ORDER_CAST_NO_TARGET,
  2040. TargetIndex = nil,
  2041. AbilityIndex = hero_new:FindAbilityByName("zibao"):entindex(),
  2042. Position = nil,
  2043. Queue = 0
  2044. }
  2045. ExecuteOrderFromTable(newOrder)
  2046.  
  2047. Timers:CreateTimer(9.8,function()
  2048. hero_new:RemoveAbility("zibao")
  2049. end)
  2050. end)
  2051. end
  2052.  
  2053. if hero_new:GetUnitName() == "npc_dota_hero_invoker" then
  2054. hero_new:AddAbility("no_duplicate")
  2055. hero_new:FindAbilityByName("no_duplicate"):SetLevel(1)
  2056. end
  2057. hero_new:SetMana(0)
  2058.  
  2059.  
  2060.  
  2061. --是否全部ready
  2062. local readyplayercount = 0
  2063. for i,vi in pairs(GameRules:GetGameModeEntity().hero) do
  2064. if vi.is_ready == true then
  2065. readyplayercount = readyplayercount +1
  2066. end
  2067. end
  2068.  
  2069. -- 通知pui游戏开始
  2070. if readyplayercount == PlayerResource:GetPlayerCount() then
  2071. if GameRules:GetGameModeEntity().is_game_started == true then
  2072. return
  2073. end
  2074. GameRules:GetGameModeEntity().is_game_started = true
  2075. Ready2StartGame()
  2076. end
  2077.  
  2078. end, id)
  2079. end
  2080. --游戏循环1——开始一轮准备回合
  2081. function StartAPrepareRound()
  2082. -- StatChess()
  2083.  
  2084. CustomNetTables:SetTableValue( "dac_table", "damage_stat",
  2085. {
  2086. level = GameRules:GetGameModeEntity().level,
  2087. damage_table = GameRules:GetGameModeEntity().damage_stat ,
  2088. time_this_level = 61 - GameRules:GetGameModeEntity().battle_timer,
  2089. hehe = RandomInt(1,100000)
  2090. }
  2091. )
  2092.  
  2093. --50回合以后,疲劳
  2094. if GameRules:GetGameModeEntity().battle_round > 50 then
  2095. local bite_hp = GameRules:GetGameModeEntity().battle_round - 50
  2096. for _,heroent in pairs (GameRules:GetGameModeEntity().hero) do
  2097. if heroent ~= nil and heroent:IsNull() == false and heroent:IsAlive() == true then
  2098. local after_hp = heroent:GetHealth() - bite_hp
  2099. if after_hp <= 0 then
  2100. after_hp = 0
  2101. end
  2102. play_particle("particles/econ/items/legion/legion_overwhelming_odds_ti7/legion_commander_odds_ti7_proj_hit_streaks.vpcf",PATTACH_ABSORIGIN_FOLLOW,heroent,3)
  2103. if after_hp <= 0 then
  2104. --死了
  2105. heroent:ForceKill(false)
  2106. GameRules:GetGameModeEntity().counterpart[heroent:GetTeam()] = -1
  2107. SyncHP(heroent)
  2108. AMHC:CreateNumberEffect(heroent,bite_hp,2,AMHC.MSG_MISS,"red",9)
  2109. ClearHand(heroent:GetTeam())
  2110. return
  2111. end
  2112. heroent:SetHealth(after_hp)
  2113. SyncHP(heroent)
  2114. AMHC:CreateNumberEffect(heroent,bite_hp,2,AMHC.MSG_MISS,"red",9)
  2115. EmitSoundOn("Frostivus.PointScored.Enemy",hero)
  2116. end
  2117. end
  2118. end
  2119.  
  2120. CustomNetTables:SetTableValue( "dac_table", "user_panel_ranking", {table = GameRules:GetGameModeEntity().stat_info, hehe = RandomInt(1,1000)})
  2121. GameRules:SetTimeOfDay(0.8)
  2122. EmitGlobalSound("Loot_Drop_Stinger_Legendary")
  2123. GameRules:GetGameModeEntity().game_status = 1
  2124.  
  2125. GameRules:GetGameModeEntity().prepare_timer = 35
  2126.  
  2127. CustomGameEventManager:Send_ServerToAllClients("battle_info",{
  2128. type = "prepare",
  2129. round = GameRules:GetGameModeEntity().battle_round,
  2130. })
  2131.  
  2132. local alldead = true
  2133. for i,v in pairs (GameRules:GetGameModeEntity().counterpart) do
  2134. if v ~= -1 then
  2135. local hhh = TeamId2Hero(i)
  2136. if hhh.hand_entities ~= nil then
  2137. for _,ent in pairs(hhh.hand_entities) do
  2138. ent:RemoveAbility('outofgame')
  2139. ent:RemoveModifierByName('modifier_outofgame')
  2140. end
  2141. end
  2142. alldead = false
  2143. end
  2144. end
  2145. if alldead == true then
  2146. return
  2147. end
  2148. Timers:CreateTimer(function()
  2149. if GameRules:GetGameModeEntity().prepare_timer <= 10 and GameRules:GetGameModeEntity().prepare_timer > 5 then
  2150. EmitGlobalSound('General.CastFail_AbilityInCooldown')
  2151. end
  2152.  
  2153. if GameRules:GetGameModeEntity().prepare_timer <= 5 then
  2154. if GameRules:GetGameModeEntity().prepare_timer == 5 then
  2155. EmitGlobalSound("GameStart.RadiantAncient")
  2156. end
  2157.  
  2158. if GameRules:GetGameModeEntity().prepare_timer == 2 then
  2159. RandomRecallChess()
  2160. end
  2161.  
  2162. for i,v in pairs (GameRules:GetGameModeEntity().hero) do
  2163. CancelPickChess(v)
  2164. v:FindAbilityByName('pick_chess'):SetActivated(false)
  2165. v:FindAbilityByName('recall_chess'):SetActivated(false)
  2166. end
  2167. end
  2168. if GameRules:GetGameModeEntity().prepare_timer <= 0 then
  2169. GameRules:GetGameModeEntity().game_status = 2
  2170. -- GameRules:SendCustomMessage('战斗回合',0,0)
  2171. StartABattleRound()
  2172. return
  2173. else
  2174. local center_index = ''..Entities:FindByName(nil,"center0"):entindex()..','..Entities:FindByName(nil,"center1"):entindex()..','..Entities:FindByName(nil,"center2"):entindex()..','..Entities:FindByName(nil,"center3"):entindex()..','..Entities:FindByName(nil,"center4"):entindex()..','..Entities:FindByName(nil,"center5"):entindex()..','..Entities:FindByName(nil,"center6"):entindex()..','..Entities:FindByName(nil,"center7"):entindex()
  2175. --发送当前游戏时间给客户端
  2176. if GameRules:GetGameModeEntity().prepare_timer > 5 then
  2177. CustomGameEventManager:Send_ServerToAllClients("show_time",{
  2178. timer_round = GameRules:GetGameModeEntity().prepare_timer - 5,
  2179. round_status = "prepare",
  2180. total_time = math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME),
  2181. center_index = center_index,
  2182. })
  2183. else
  2184. CustomGameEventManager:Send_ServerToAllClients("show_time",{
  2185. timer_round = GameRules:GetGameModeEntity().prepare_timer,
  2186. round_status = "ready",
  2187. total_time = math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME),
  2188. center_index = center_index,
  2189. })
  2190. end
  2191. GameRules:GetGameModeEntity().prepare_timer = GameRules:GetGameModeEntity().prepare_timer - 1
  2192. return 1
  2193. end
  2194. end)
  2195. Timers:CreateTimer(0.3,function()
  2196. for i,v in pairs(GameRules:GetGameModeEntity().hero) do
  2197. if GameRules:GetGameModeEntity().battle_round == 1 and v.notbishop == true and GetMapName() == "bishop+" then
  2198. prt('Sorry, this map is for players ranking higher than bishop-1!')
  2199. prt('对不起,此地图仅对主教一段以上玩家开放')
  2200. v:ForceKill(false)
  2201. GameRules:GetGameModeEntity().counterpart[v:GetTeam()] = -1
  2202. SyncHP(v)
  2203. end
  2204. if v == nil or v:IsNull() == true or v:IsAlive() == true then
  2205. RestoreARound(v:GetTeam())
  2206. AddPickAndRemoveAbility(v)
  2207. SetLordAbilityEnable(v,false)
  2208.  
  2209. if v ~= nil then
  2210. local level = v:GetLevel()
  2211. for j=1,10 do
  2212. if v:FindAbilityByName('hero_level_'..j) ~= nil then
  2213. v:RemoveAbility('hero_level_'..j)
  2214. v:RemoveModifierByName('modifier_hero_level'..j)
  2215. end
  2216. end
  2217.  
  2218. AddAbilityAndSetLevel(v,'hero_level_'..level,level)
  2219. end
  2220.  
  2221. --给蓝
  2222. local mana = GameRules:GetGameModeEntity().battle_round
  2223. if mana> 5 then
  2224. mana = 5
  2225. end
  2226.  
  2227. local lixi = math.floor(v:GetMana()/10)
  2228. if lixi > 5 then
  2229. lixi = 5
  2230. end
  2231. mana = mana + lixi
  2232.  
  2233. local anwei = math.floor(((v.lose_streak or 0)+3)/2 ) - 2
  2234. if anwei < 0 then
  2235. anwei = 0
  2236. end
  2237. if anwei > 3 then
  2238. anwei = 3
  2239. end
  2240. mana = mana + anwei
  2241.  
  2242. local jiangli = math.floor(((v.win_streak or 0)+3)/2 ) - 2
  2243. if jiangli < 0 then
  2244. jiangli = 0
  2245. end
  2246. if jiangli > 3 then
  2247. jiangli = 3
  2248. end
  2249. mana = mana + jiangli
  2250. Timers:CreateTimer(0.5,function()
  2251. AddMana(v, mana)
  2252. CustomGameEventManager:Send_ServerToTeam(v:GetTeam(),"show_gold",{
  2253. gold = v:GetMana(),
  2254. lose_streak = v.lose_streak or 0,
  2255. win_streak = v.win_streak or 0,
  2256. })
  2257. end)
  2258. Timers:CreateTimer(0.01,function()
  2259. PrepareARound(v:GetTeam())
  2260. end)
  2261.  
  2262. --给一点经验
  2263. if GameRules:GetGameModeEntity().battle_round ~= 1 then
  2264. v:AddExperience (1,0,false,false)
  2265. end
  2266.  
  2267. GameRules:GetGameModeEntity().damage_stat[v:GetTeam()] = {}
  2268.  
  2269. end
  2270. end
  2271. end)
  2272. end
  2273. function AddPickAndRemoveAbility(v)
  2274. if v:FindAbilityByName('pick_chess') == nil then
  2275. AddAbilityAndSetLevel(v,'pick_chess')
  2276. end
  2277. if v:FindAbilityByName('recall_chess') == nil then
  2278. AddAbilityAndSetLevel(v,'recall_chess')
  2279. end
  2280. if v:FindAbilityByName('remove_chess') == nil then
  2281. AddAbilityAndSetLevel(v,'remove_chess')
  2282. end
  2283. v:FindAbilityByName('pick_chess'):SetActivated(true)
  2284. v:FindAbilityByName('recall_chess'):SetActivated(true)
  2285. -- v:FindAbilityByName('remove_chess'):SetActivated(true)
  2286. end
  2287. --游戏循环1.1——清理战斗场地并重新摆上自己的随从
  2288. function RestoreARound(teamid)
  2289. ClearARound(teamid)
  2290.  
  2291. for _,v in pairs(GameRules:GetGameModeEntity().mychess[teamid]) do
  2292. local x = CreateUnitByName(v.chess,XY2Vector(v.x,v.y,teamid),true,nil,nil,teamid)
  2293. MakeTiny(x)
  2294. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[teamid],x)
  2295. x:SetForwardVector(Vector(0,1,0))
  2296. AddAbilityAndSetLevel(x,'root_self')
  2297. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  2298. x.y_x = ''..v.y..'_'..v.x
  2299. x.y = v.y
  2300. x.x = v.x
  2301. x.team_id = teamid
  2302. local item_table = v.item
  2303. if table.maxn(item_table) > 0 then
  2304. for p,vp in pairs (item_table) do
  2305. x:AddItemByName(vp)
  2306. end
  2307. end
  2308. GameRules:GetGameModeEntity().mychess[teamid][''..v.y..'_'..v.x]['index'] = x:entindex()
  2309. GameRules:GetGameModeEntity().mychess[teamid][''..v.y..'_'..v.x]['lastitem'] = CopyTable(GameRules:GetGameModeEntity().mychess[teamid][''..v.y..'_'..v.x]['item'])
  2310. GameRules:GetGameModeEntity().mychess[teamid][''..v.y..'_'..v.x]['item'] = {}
  2311.  
  2312. GameRules:GetGameModeEntity().unit[teamid][v.y..'_'..v.x] = 1
  2313. --添加战斗技能
  2314. if GameRules:GetGameModeEntity().chess_ability_list[x:GetUnitName()] ~= nil then
  2315. local a = GameRules:GetGameModeEntity().chess_ability_list[x:GetUnitName()]
  2316. if x:FindAbilityByName(a) == nil then
  2317. AddAbilityAndSetLevel(x,a,0)
  2318. end
  2319. end
  2320. end
  2321. end
  2322. function ClearARound(teamid)
  2323. for _,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  2324. if v ~= nil and v:IsNull() == false then
  2325. -- SaveItem(teamid,v:entindex())
  2326.  
  2327. -- prt('ClearARound保存玩家'..teamid..' '..v:GetUnitName()..'的物品: ROUND '..GameRules:GetGameModeEntity().battle_round)
  2328. SaveItem(teamid,v:entindex())
  2329.  
  2330. --需要手动清除防止遗留的buff
  2331. v:RemoveModifierByName('modifier_slark_shadow_dance')
  2332.  
  2333. if v:GetUnitName() ~= 'chess_medusa' and v:GetUnitName() ~= 'chess_medusa1' and v:GetUnitName() ~= 'chess_medusa11' then
  2334. v:Destroy()
  2335. else
  2336. v:SetAbsOrigin(Vector(0,0,0))
  2337. Timers:CreateTimer(0.1,function()
  2338. v:Destroy()
  2339. end)
  2340. end
  2341. end
  2342. end
  2343. GameRules:GetGameModeEntity().to_be_destory_list[teamid] = {}
  2344. GameRules:GetGameModeEntity().unit[teamid] = {}
  2345.  
  2346. local hero = TeamId2Hero(teamid)
  2347. if hero.mirror_chesser ~= nil then
  2348. hero.mirror_chesser:Destroy()
  2349. hero.mirror_chesser = nil
  2350. end
  2351. end
  2352. function SaveItem(teamid,uindex)
  2353. local thischess = nil
  2354. if uindex == nil then
  2355. return
  2356. end
  2357. local unit = EntIndexToHScript(uindex)
  2358. if unit == nil or unit:IsNull() == true then
  2359. return
  2360. end
  2361. --先清空物品table
  2362. for _,c in pairs (GameRules:GetGameModeEntity().mychess[teamid]) do
  2363. if c.index == uindex then
  2364. c.item = {}
  2365. end
  2366. end
  2367. -- prt('清空完毕:TIME '..math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME))
  2368. --记录装备情况
  2369. for slot=0,8 do
  2370. if unit:GetItemInSlot(slot)~= nil then
  2371. local name = unit:GetItemInSlot(slot):GetAbilityName()
  2372. for i,v in pairs(GameRules:GetGameModeEntity().mychess[teamid]) do
  2373. if v.index == uindex then
  2374. table.insert(v.item,name)
  2375. end
  2376. end
  2377. end
  2378. end
  2379. --跟lastitem比较是否有新物品
  2380. -- local new_item = {}
  2381. -- if thischess ~= nil then
  2382. -- if thischess.lastitem == nil then
  2383. -- thischess.lastitem = {}
  2384. -- end
  2385. -- new_item = DiffTable(thischess.item,thischess.lastitem)
  2386. -- if table.maxn(new_item) > 0 then
  2387. -- for i1,v1 in pairs(new_item) do
  2388. -- if FindValueInTable(GameRules:GetGameModeEntity().combined_items,v1) == true then
  2389. -- --发弹幕
  2390. -- CustomNetTables:SetTableValue( "dac_table", "bullet", {player_id = TeamId2Hero(teamid):GetPlayerID(), target = v1 , hehe = RandomInt(1,100000)})
  2391. -- end
  2392. -- end
  2393. -- end
  2394. -- thischess.lastitem = CopyTable(thischess.item)
  2395. -- end
  2396. -- if unit:IsAlive() == true then
  2397. -- --活棋子
  2398. -- --遍历它身上有的物品,保存到table,重新添加一遍便于合成
  2399. -- for slot=0,8 do
  2400. -- if unit:GetItemInSlot(slot)~= nil then
  2401. -- local name = unit:GetItemInSlot(slot):GetAbilityName()
  2402. -- for i,v in pairs(GameRules:GetGameModeEntity().mychess[teamid]) do
  2403. -- if v.index == uindex then
  2404. -- table.insert(v.item,name)
  2405. -- thischess = GameRules:GetGameModeEntity().mychess[teamid][unit.y_x]
  2406. -- unit:RemoveItem(unit:GetItemInSlot(slot))
  2407. -- unit:AddItemByName(name)
  2408. -- end
  2409. -- end
  2410. -- end
  2411. -- end
  2412. -- --跟lastitem比较是否有新物品
  2413. -- local new_item = {}
  2414. -- if thischess ~= nil then
  2415. -- if thischess.lastitem == nil then
  2416. -- thischess.lastitem = {}
  2417. -- end
  2418. -- new_item = DiffTable(thischess.item,thischess.lastitem)
  2419. -- if table.maxn(new_item) > 0 then
  2420. -- for i1,v1 in pairs(new_item) do
  2421. -- if FindValueInTable(GameRules:GetGameModeEntity().combined_items,v1) == true then
  2422. -- --发弹幕
  2423. -- CustomNetTables:SetTableValue( "dac_table", "bullet", {player_id = TeamId2Hero(teamid):GetPlayerID(), target = v1 , hehe = RandomInt(1,100000)})
  2424. -- end
  2425. -- end
  2426. -- end
  2427. -- thischess.lastitem = CopyTable(thischess.item)
  2428. -- end
  2429. -- else
  2430. -- --死棋子
  2431. -- --遍历它身上有的物品,保存到table
  2432. -- for slot=0,8 do
  2433. -- if unit:GetItemInSlot(slot)~= nil then
  2434. -- local name = unit:GetItemInSlot(slot):GetAbilityName()
  2435. -- for i,v in pairs(GameRules:GetGameModeEntity().mychess[teamid]) do
  2436. -- if v.index == uindex then
  2437. -- table.insert(v.item,name)
  2438. -- end
  2439. -- end
  2440. -- end
  2441. -- end
  2442. -- end
  2443. end
  2444. function FindValueInTable(tbl,value)
  2445. local found = false
  2446. for i,v in pairs(tbl) do
  2447. if v == value then
  2448. found = true
  2449. end
  2450. end
  2451. return found
  2452. end
  2453. function CopyTable(origin_table)
  2454. local new_table = {}
  2455. if origin_table ~= nil then
  2456. for k,v in pairs(origin_table) do
  2457. table.insert(new_table,v)
  2458. end
  2459. return new_table
  2460. else
  2461. return {}
  2462. end
  2463. end
  2464. function DiffTable(big_table,small_table)
  2465. local temp_table = {}
  2466. for k,v in pairs(big_table) do
  2467. table.insert(temp_table,v)
  2468. end
  2469. for k1,v1 in pairs(small_table) do
  2470. RemoveOneKeyInTable(temp_table,v1)
  2471. end
  2472. if table.maxn(temp_table) > 0 then
  2473. return temp_table
  2474. else
  2475. return {}
  2476. end
  2477. end
  2478. function RemoveOneKeyInTable(tbl,key)
  2479. local max = table.maxn(tbl)
  2480. for i = max,1,-1 do
  2481. if key == tbl[i] then
  2482. table.remove(tbl,i)
  2483. break
  2484. end
  2485. end
  2486. end
  2487. function DAC:OnEntityKilled(keys)
  2488. local u = EntIndexToHScript(keys.entindex_killed)
  2489. if u == nil then
  2490. return
  2491. end
  2492. if u:IsHero() == true then
  2493. return
  2494. end
  2495. if u:GetUnitName() == "invisible_unit" then
  2496. return
  2497. end
  2498. if u:GetUnitName() == "chess_tech_bomb" then
  2499. return
  2500. end
  2501. if u:GetUnitName() == "player_image" then
  2502. return
  2503. end
  2504. if GameRules:GetGameModeEntity().game_status == 2 then
  2505. if string.find(u:GetUnitName(),'pve') ~= nil then --pve敌人掉宝
  2506. DropItem(u)
  2507. -- else
  2508. -- if u:GetTeam() == 4 and RandomInt(1,100) < 10 then --pvp的敌人也有概率掉宝
  2509. -- DropItem(u)
  2510. -- end
  2511. end
  2512. local xx = Vector2X(u:GetAbsOrigin(),u.at_team_id or u.team_id)
  2513. local yy = Vector2Y(u:GetAbsOrigin(),u.at_team_id or u.team_id)
  2514. -- local before = GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][u.y_x]
  2515. -- if before == nil then
  2516. -- before = 0
  2517. -- end
  2518. if u.at_team_id ~= nil or u.team_id ~= nil then
  2519. if u.y_x ~= nil then
  2520. GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][u.y_x] = nil
  2521. end
  2522. end
  2523. RemoveFromToBeDestroyList(u)
  2524. if u.team_id ~= 4 then
  2525. -- prt('OnEntityKilled保存玩家'..u.team_id..' '..u:GetUnitName()..'的物品: ROUND '..GameRules:GetGameModeEntity().battle_round)
  2526. SaveItem(u.team_id,u:entindex())
  2527. end
  2528.  
  2529. if u.at_team_id ~= nil then
  2530. AddStat(TeamId2Hero(u.at_team_id):GetPlayerID(),'kills')
  2531. end
  2532. end
  2533. end
  2534. --游戏循环1.2——抽卡
  2535. function PrepareARound(teamid)
  2536. Draw5ChessAndShow(teamid, false)
  2537. end
  2538. --游戏循环1.2.x——抽卡用到的方法(第二个参数可以指定下一个棋子)
  2539. function Draw5ChessAndShow(team_id, unlock)
  2540. local h = TeamId2Hero(team_id)
  2541. if h.chesslock == true then
  2542. return
  2543. end
  2544. --把上次剩的洗回棋库
  2545. if h.curr_chess_table ~= nil and table.maxn(h.curr_chess_table) > 0 then
  2546. for _,chess in pairs(h.curr_chess_table) do
  2547. AddAChessToChessPool(chess)
  2548. end
  2549. end
  2550. h.curr_chess_table = {}
  2551. --抽!
  2552. local cards,curr_chess_table = RandomNDrawChessNew(team_id,5)
  2553. h.curr_chess_table = curr_chess_table
  2554.  
  2555. CustomGameEventManager:Send_ServerToTeam(team_id,"show_draw_card",{
  2556. cards = cards,
  2557. curr_money = h:GetMana(),
  2558. unlock = unlock,
  2559. })
  2560. end
  2561. function RandomNDrawChessNew(team_id,n)
  2562. local new_chess_list_str = ""
  2563. local new_chess_list_table = {}
  2564. local chess_count = 0
  2565.  
  2566. while chess_count < n do
  2567. local new_chess = RandomDrawChessNew(team_id)
  2568. if new_chess ~= nil then
  2569. new_chess_list_str = new_chess_list_str..new_chess..','
  2570. table.insert(new_chess_list_table,new_chess)
  2571. chess_count = chess_count + 1
  2572. end
  2573. end
  2574. return new_chess_list_str,new_chess_list_table
  2575. end
  2576. function RandomDrawChessNew(team_id)
  2577. local h = TeamId2Hero(team_id)
  2578. local this_chess = nil
  2579. local ran = RandomInt(1,100)
  2580. local chess_level = 1
  2581. local curr_per = 0
  2582. local hero_level = h:GetLevel()
  2583.  
  2584. local table_11chess = {}
  2585. for _,chess in pairs(GameRules:GetGameModeEntity().mychess[team_id]) do
  2586. if string.find(chess.chess,'11') then
  2587. table.insert(table_11chess,string.sub(chess.chess,1,-3))
  2588. end
  2589. end
  2590. if h:GetLevel() >= 7 and RandomInt(1,100000000) <= 1 then
  2591. this_chess = GameRules:GetGameModeEntity().chess_list_ssr[RandomInt(1,table.maxn(GameRules:GetGameModeEntity().chess_list_ssr))]
  2592. else
  2593. if GameRules:GetGameModeEntity().chess_gailv[hero_level] ~= nil then
  2594. for per,lv in pairs(GameRules:GetGameModeEntity().chess_gailv[hero_level]) do
  2595. if ran>per and curr_per<=per then
  2596. curr_per = per
  2597. chess_level = lv
  2598. end
  2599. end
  2600. end
  2601. -- this_chess = GameRules:GetGameModeEntity().chess_list_by_mana[chess_level][RandomInt(1,table.maxn(GameRules:GetGameModeEntity().chess_list_by_mana[chess_level]))]
  2602.  
  2603. this_chess = DrawAChessFromChessPool(chess_level, table_11chess)
  2604. end
  2605. return this_chess
  2606. end
  2607. --选好卡进入等待区
  2608. function DAC:OnChessSelected(keys)
  2609. local chess = keys.chess
  2610. local team_id = keys.team
  2611. local mana_required = keys.mana
  2612. if PlayerResource:GetPlayer(GameRules:GetGameModeEntity().team2playerid[team_id]) == nil then
  2613. return
  2614. end
  2615. local h = TeamId2Hero(team_id)
  2616. local mana = h:GetMana()
  2617. if mana_required > mana then
  2618. CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  2619. text = "text_mima_no_mana"
  2620. })
  2621. return
  2622. end
  2623. local index = FindEmptyHandSlot(team_id)
  2624. if index == nil then
  2625. CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  2626. text = "hand full"
  2627. })
  2628. return
  2629. else
  2630. if h.curr_chess_table ~= nil then
  2631. if FindValueInTable(h.curr_chess_table,chess) == true then
  2632. RemoveOneKeyInTable(h.curr_chess_table,chess)
  2633. else
  2634. return
  2635. end
  2636. end
  2637.  
  2638. CostMana(h,mana_required)
  2639.  
  2640. CustomGameEventManager:Send_ServerToTeam(team_id,"show_gold",{
  2641. gold = h:GetMana(),
  2642. lose_streak = h.lose_streak or 0,
  2643. win_streak = h.win_streak or 0,
  2644. })
  2645.  
  2646. local x = nil
  2647. local this_chess = nil
  2648. this_chess = chess
  2649. x = CreateUnitByName(this_chess,HandIndex2Vector(team_id,index),true,nil,nil,team_id)
  2650. MakeTiny(x)
  2651. PlayChessDialogue(x,'spawn')
  2652.  
  2653. GameRules:GetGameModeEntity().hand[team_id][index] = 1
  2654. -- prt(team_id..'手牌'..index..'占领')
  2655. if h.hand_entities == nil then
  2656. h.hand_entities = {}
  2657. end
  2658.  
  2659. h.hand_entities[index] = x
  2660.  
  2661. x:SetForwardVector(Vector(0,1,0))
  2662. x.hand_index = index
  2663. x.team_id = team_id
  2664. x.owner_player_id = GameRules:GetGameModeEntity().team2playerid[team_id]
  2665.  
  2666. AddAbilityAndSetLevel(x,'root_self')
  2667. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  2668.  
  2669. play_particle("particles/econ/items/antimage/antimage_ti7/antimage_blink_start_ti7_ribbon_bright.vpcf",PATTACH_ABSORIGIN_FOLLOW,x,5)
  2670.  
  2671. --添加战斗技能
  2672. if GameRules:GetGameModeEntity().chess_ability_list[x:GetUnitName()] ~= nil then
  2673. local a = GameRules:GetGameModeEntity().chess_ability_list[x:GetUnitName()]
  2674. print(a)
  2675. if x:FindAbilityByName(a) == nil then
  2676. AddAbilityAndSetLevel(x,a,0)
  2677. end
  2678. end
  2679. if TeamId2Hero(team_id):FindAbilityByName('h403_ability') ~= nil and use_crab == true then
  2680. GameRules:GetGameModeEntity().next_crab = this_chess
  2681. end
  2682. end
  2683.  
  2684. CustomGameEventManager:Send_ServerToTeam(team_id,"show_is_hand_full",{
  2685. is_hand_full = IsHandFull(team_id)
  2686. })
  2687.  
  2688. end
  2689. function IsHandFull(team_id)
  2690. if FindEmptyHandSlot(team_id) == nil then
  2691. return true
  2692. else
  2693. return false
  2694. end
  2695. end
  2696. function FindEmptyHandSlot(team_id)
  2697. local empty_index = nil
  2698. for i=1,8 do
  2699. if GameRules:GetGameModeEntity().hand[team_id][i] == 0 then
  2700. empty_index = i
  2701. break
  2702. end
  2703. end
  2704. return empty_index
  2705. end
  2706. function CheckEmptyHandSlot(team_id,index)
  2707. if GameRules:GetGameModeEntity().hand[team_id][index] == 0 then
  2708. return true
  2709. else
  2710. return false
  2711. end
  2712. end
  2713. function ClearHand(team_id)
  2714. local h = TeamId2Hero(team_id)
  2715. if h ~= nil and h.hand_entities ~= nil then
  2716. for _,v in pairs(h.hand_entities) do
  2717. if v ~= nil then
  2718. v:ForceKill(false)
  2719. end
  2720. end
  2721. end
  2722. GameRules:GetGameModeEntity().population[team_id] = 0
  2723. GameRules:GetGameModeEntity().hand[team_id] = {}
  2724. GameRules:GetGameModeEntity().mychess[team_id] = {}
  2725. ClearARound(team_id)
  2726. end
  2727.  
  2728.  
  2729. --游戏循环1.4——上场相关操作
  2730. function RecallChess(keys)
  2731. --撤回手牌
  2732. local picked_chess = keys.target
  2733. local caster = keys.caster
  2734. local team_id = picked_chess.team_id
  2735. local origin_x = picked_chess.x
  2736. local origin_y = picked_chess.y
  2737.  
  2738. CancelPickChess(caster)
  2739.  
  2740. if picked_chess.hand_index ~= nil then
  2741. --已经在手牌了
  2742. CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"mima",{
  2743. text = "text_mima_must_select_a_chess_in_batle_ground"
  2744. })
  2745. EmitSoundOn("General.CastFail_NoMana",keys.caster)
  2746. return
  2747. end
  2748.  
  2749. local target_index = FindEmptyHandSlot(team_id)
  2750.  
  2751. if target_index == nil then
  2752. --手牌已经满了
  2753. CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"mima",{
  2754. text = "text_mima_hand_is_full"
  2755. })
  2756. EmitSoundOn("General.CastFail_NoMana",keys.caster)
  2757. return
  2758. end
  2759.  
  2760. RemoveAbilityAndModifier(picked_chess,'mana_cost1')
  2761. RemoveAbilityAndModifier(picked_chess,'mana_cost2')
  2762. RemoveAbilityAndModifier(picked_chess,'mana_cost3')
  2763. RemoveAbilityAndModifier(picked_chess,'mana_cost4')
  2764. RemoveAbilityAndModifier(picked_chess,'mana_cost5')
  2765.  
  2766. GameRules:GetGameModeEntity().mychess[team_id][''..origin_y..'_'..origin_x] = nil
  2767. GameRules:GetGameModeEntity().unit[team_id][''..origin_y..'_'..origin_x] = nil
  2768. GameRules:GetGameModeEntity().hand[team_id][target_index] = 1
  2769. -- prt(team_id..'手牌'..target_index..'占领')
  2770. if caster.hand_entities == nil then
  2771. caster.hand_entities = {}
  2772. end
  2773.  
  2774. caster.hand_entities[target_index] = picked_chess
  2775. for p,vp in pairs(GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  2776. if vp:entindex() == picked_chess:entindex() then
  2777. table.remove(GameRules:GetGameModeEntity().to_be_destory_list[team_id],p)
  2778. end
  2779. end
  2780.  
  2781. --跳过去
  2782. picked_chess:SetForwardVector((HandIndex2Vector(team_id,target_index) - Vector(0,1,0)):Normalized())
  2783. picked_chess.hand_index = target_index
  2784. picked_chess.team_id = team_id
  2785. picked_chess.owner_player_id = caster
  2786. BlinkChessX({p=HandIndex2Vector(team_id,target_index),caster=picked_chess})
  2787. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] - 1
  2788.  
  2789. --同步ui人口
  2790. CustomGameEventManager:Send_ServerToTeam(team_id,"population",{
  2791. max_count = GameRules:GetGameModeEntity().population_max[team_id],
  2792. count = GameRules:GetGameModeEntity().population[team_id],
  2793. })
  2794.  
  2795. AddAbilityAndSetLevel(picked_chess,'root_self')
  2796. AddAbilityAndSetLevel(picked_chess,'jiaoxie_wudi')
  2797.  
  2798. --战斗技能变0
  2799. if GameRules:GetGameModeEntity().chess_ability_list[picked_chess:GetUnitName()] ~= nil then
  2800. local a = GameRules:GetGameModeEntity().chess_ability_list[picked_chess:GetUnitName()]
  2801. if picked_chess:FindAbilityByName(a) ~= nil then
  2802. picked_chess:FindAbilityByName(a):SetLevel(0)
  2803. end
  2804. end
  2805. CustomGameEventManager:Send_ServerToTeam(team_id,"show_is_hand_full",{
  2806. is_hand_full = IsHandFull(team_id)
  2807. })
  2808. end
  2809. --多余的滚回去
  2810. function RandomRecallChess()
  2811. for i=6,13 do
  2812. local teamcount = GameRules:GetGameModeEntity().population[i]
  2813. local teammax = GameRules:GetGameModeEntity().population_max[i]
  2814. if teamcount > 0 and teammax < teamcount then
  2815. local recall_amount = teamcount - teammax
  2816. if recall_amount > 0 then
  2817. CustomGameEventManager:Send_ServerToTeam(i,"mima",{
  2818. text = "text_mima_chess_max_recall"
  2819. })
  2820. end
  2821. local recalled = 0
  2822. Timers:CreateTimer(function()
  2823. if recalled < recall_amount then
  2824. local smallest_chess = nil
  2825. local smallest_level = 3
  2826. for k,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[i]) do
  2827. local a_level = 1
  2828. if string.find(v:GetUnitName(),'1') then
  2829. a_level = 2
  2830. end
  2831. if string.find(v:GetUnitName(),'11') then
  2832. a_level = 3
  2833. end
  2834. if a_level < smallest_level and v.combining ~= true then
  2835. smallest_chess = v
  2836. smallest_level = a_level
  2837. end
  2838. end
  2839. local target_index = FindEmptyHandSlot(i)
  2840. if target_index == nil then
  2841. RemoveChess({
  2842. caster = GameRules:GetGameModeEntity().teamid2hero[i],
  2843. target = smallest_chess
  2844. })
  2845. else
  2846. RecallChess({
  2847. caster = GameRules:GetGameModeEntity().teamid2hero[i],
  2848. target = smallest_chess
  2849. })
  2850. end
  2851. recalled = recalled + 1
  2852. end
  2853. return 0.1
  2854. end)
  2855. end
  2856. end
  2857. end
  2858. function PickChess(keys)
  2859. local target = keys.target
  2860. local caster = keys.caster
  2861. local team = target.team_id
  2862.  
  2863. CancelPickChess(caster)
  2864.  
  2865. AddAbilityAndSetLevel(target,'chess_picked')
  2866.  
  2867.  
  2868. caster.picked_chess = target
  2869. EmitSoundOn("ui.browser_click_right",caster)
  2870. CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"show_cursor_hero_icon",{
  2871. unit = target:GetUnitName()
  2872. })
  2873. caster:FindAbilityByName('pick_chess'):SetActivated(false)
  2874. caster:FindAbilityByName('recall_chess'):SetActivated(false)
  2875. end
  2876. function GetMinionManaCost(u)
  2877. local mana = 0
  2878. if u:FindAbilityByName('mana_cost1') ~= nil then
  2879. mana = 1
  2880. end
  2881. if u:FindAbilityByName('mana_cost2') ~= nil then
  2882. mana = 2
  2883. end
  2884. if u:FindAbilityByName('mana_cost3') ~= nil then
  2885. mana = 3
  2886. end
  2887. if u:FindAbilityByName('mana_cost4') ~= nil then
  2888. mana = 4
  2889. end
  2890. if u:FindAbilityByName('mana_cost5') ~= nil then
  2891. mana = 5
  2892. end
  2893. return mana
  2894. end
  2895. function CancelPickChess(u)
  2896. if u.picked_chess ~= nil and u.picked_chess:IsNull() ~= true then
  2897. u.picked_chess:RemoveAbility('chess_picked')
  2898. u.picked_chess:RemoveModifierByName('modifier_chess_picked')
  2899. end
  2900. u.picked_chess = nil
  2901. CustomGameEventManager:Send_ServerToTeam(u:GetTeam(),"show_cursor_hero_icon",{})
  2902. if GameRules:GetGameModeEntity().game_status == 1 and GameRules:GetGameModeEntity().prepare_timer > 5 then
  2903. u:FindAbilityByName('pick_chess'):SetActivated(true)
  2904. u:FindAbilityByName('recall_chess'):SetActivated(true)
  2905. end
  2906. end
  2907. function DAC:OnCancelPickChessPosition(keys)
  2908. local caster = PlayerId2Hero(keys.player_id)
  2909. CancelPickChess(caster)
  2910. end
  2911. function DAC:OnPickChessPosition(keys)
  2912. local p = Vector(keys.x,keys.y,keys.z)
  2913. local caster = PlayerId2Hero(keys.player_id)
  2914. local picked_chess = caster.picked_chess
  2915.  
  2916. if picked_chess == nil or picked_chess:IsNull() == true or picked_chess:IsAlive() == false then
  2917. CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"mima",{
  2918. text = "text_mima_must_select_a_chess"
  2919. })
  2920. EmitSoundOn("General.CastFail_NoMana",keys.caster)
  2921. return
  2922. end
  2923.  
  2924. CancelPickChess(caster)
  2925. local x = Vector2X(p,caster:GetTeam())
  2926. local y = Vector2Y(p,caster:GetTeam())
  2927.  
  2928. local team_id = picked_chess.team_id
  2929. local position = XY2Vector(x,y,team_id)
  2930. local origin_p = picked_chess:GetAbsOrigin()
  2931. local origin_x = Vector2X(origin_p,caster:GetTeam())
  2932. local origin_y = Vector2Y(origin_p,caster:GetTeam())
  2933.  
  2934. CustomGameEventManager:Send_ServerToTeam(team_id,"close_draw_card",{
  2935. cards = cards
  2936. })
  2937. if origin_x == x and origin_y == y then
  2938. return
  2939. end
  2940. --要放回手牌
  2941. if CheckTargetPosInHand(p,team_id) ~= false then
  2942. if picked_chess.hand_index ~= nil then
  2943. CancelPickChess(caster)
  2944. return
  2945. end
  2946. local target_index = CheckTargetPosInHand(p,team_id)
  2947.  
  2948. --移除费用
  2949. RemoveAbilityAndModifier(picked_chess,'mana_cost1')
  2950. RemoveAbilityAndModifier(picked_chess,'mana_cost2')
  2951. RemoveAbilityAndModifier(picked_chess,'mana_cost3')
  2952. RemoveAbilityAndModifier(picked_chess,'mana_cost4')
  2953. RemoveAbilityAndModifier(picked_chess,'mana_cost5')
  2954.  
  2955. GameRules:GetGameModeEntity().mychess[team_id][''..origin_y..'_'..origin_x] = nil
  2956. GameRules:GetGameModeEntity().hand[team_id][target_index] = 1
  2957. GameRules:GetGameModeEntity().unit[team_id][''..origin_y..'_'..origin_x] = nil
  2958.  
  2959. if caster.hand_entities == nil then
  2960. caster.hand_entities = {}
  2961. end
  2962.  
  2963. caster.hand_entities[target_index] = picked_chess
  2964. for p,vp in pairs(GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  2965. if vp:entindex() == picked_chess:entindex() then
  2966. table.remove(GameRules:GetGameModeEntity().to_be_destory_list[team_id],p)
  2967. end
  2968. end
  2969.  
  2970. --跳过去
  2971. picked_chess:SetForwardVector((HandIndex2Vector(team_id,target_index)- picked_chess:GetAbsOrigin()):Normalized())
  2972. BlinkChessX({p=HandIndex2Vector(team_id,target_index),caster=picked_chess})
  2973. picked_chess.hand_index = target_index
  2974. picked_chess.team_id = team_id
  2975. picked_chess.owner_player_id = caster
  2976. picked_chess.y_x = nil
  2977. picked_chess.y = nil
  2978. picked_chess.x = nil
  2979. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] - 1
  2980.  
  2981. --同步ui人口
  2982. CustomGameEventManager:Send_ServerToTeam(team_id,"population",{
  2983. max_count = GameRules:GetGameModeEntity().population_max[team_id],
  2984. count = GameRules:GetGameModeEntity().population[team_id],
  2985. })
  2986.  
  2987. AddAbilityAndSetLevel(picked_chess,'root_self')
  2988. AddAbilityAndSetLevel(picked_chess,'jiaoxie_wudi')
  2989.  
  2990. --战斗技能变0
  2991. if GameRules:GetGameModeEntity().chess_ability_list[picked_chess:GetUnitName()] ~= nil then
  2992. local a = GameRules:GetGameModeEntity().chess_ability_list[picked_chess:GetUnitName()]
  2993. if picked_chess:FindAbilityByName(a) ~= nil then
  2994. picked_chess:FindAbilityByName(a):SetLevel(0)
  2995. end
  2996. end
  2997. -- setHandStatus(team_id)
  2998. CustomGameEventManager:Send_ServerToTeam(team_id,"show_is_hand_full",{
  2999. is_hand_full = IsHandFull(team_id)
  3000. })
  3001. else
  3002. --要跳到场上
  3003. if IsInAttackArea(Vector2X(p,team_id),Vector2Y(p,team_id)) == true then
  3004. -- CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  3005. -- text = "text_mima_cannot_enter_attack_area"
  3006. -- })
  3007. -- CancelPickChess(caster)
  3008. -- return
  3009. local proper_pos = GetClosestAvailableArea(x,y,team_id)
  3010. x = proper_pos.x
  3011. y = proper_pos.y
  3012. position = XY2Vector(x,y,team_id)
  3013. end
  3014. if IsInMap(Vector2X(p,team_id),Vector2Y(p,team_id)) == false then
  3015. -- CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  3016. -- text = "text_mima_not_in_map"
  3017. -- })
  3018. -- CancelPickChess(caster)
  3019. -- return
  3020. local proper_pos = GetClosestAvailableArea(x,y,team_id)
  3021. x = proper_pos.x
  3022. y = proper_pos.y
  3023. position = XY2Vector(x,y,team_id)
  3024. end
  3025. if IsBlocked(Vector2X(position,team_id),Vector2Y(position,team_id),team_id) ~= false then
  3026. -- CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  3027. -- text = "text_mima_not_avilable_position"
  3028. -- })
  3029. -- EmitSoundOn("General.CastFail_NoMana",keys.caster)
  3030. -- return
  3031. local proper_pos = GetClosestEmptyArea(x,y,team_id)
  3032. if proper_pos ~= nil then
  3033. x = proper_pos.x
  3034. y = proper_pos.y
  3035. position = XY2Vector(x,y,team_id)
  3036. else
  3037. CustomGameEventManager:Send_ServerToTeam(team_id,"mima",{
  3038. text = "text_mima_not_avilable_position"
  3039. })
  3040. EmitSoundOn("General.CastFail_NoMana",keys.caster)
  3041. return
  3042. end
  3043. end
  3044. --跳过去
  3045. if picked_chess.hand_index ~= nil then
  3046. --是打出的手牌
  3047. GameRules:GetGameModeEntity().hand[team_id][picked_chess.hand_index] = 0
  3048. caster.hand_entities[picked_chess.hand_index] = nil
  3049. picked_chess.hand_index = nil
  3050.  
  3051. picked_chess:RemoveAbility('act_teleport')
  3052. picked_chess:RemoveModifierByName('modifier_act_teleport')
  3053. -- RemoveCostParticle(picked_chess)
  3054. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[team_id],picked_chess)
  3055. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] + 1
  3056.  
  3057. --同步ui人口
  3058. CustomGameEventManager:Send_ServerToTeam(team_id,"population",{
  3059. max_count = GameRules:GetGameModeEntity().population_max[team_id],
  3060. count = GameRules:GetGameModeEntity().population[team_id],
  3061. })
  3062. -- setHandStatus(team_id)
  3063. else
  3064. --是场上的牌
  3065. GameRules:GetGameModeEntity().mychess[team_id][''..origin_y..'_'..origin_x] = nil
  3066. end
  3067. GameRules:GetGameModeEntity().mychess[team_id][''..y..'_'..x] = {
  3068. index = picked_chess:entindex(),
  3069. chess = picked_chess:GetUnitName(),
  3070. item = {},
  3071. x = x,
  3072. y = y,
  3073. }
  3074. picked_chess.y_x = ''..y..'_'..x
  3075. picked_chess.y = y
  3076. picked_chess.x = x
  3077. GameRules:GetGameModeEntity().unit[team_id][''..origin_y..'_'..origin_x] = nil
  3078. GameRules:GetGameModeEntity().unit[team_id][''..y..'_'..x] = 1
  3079.  
  3080. picked_chess:SetForwardVector((position-origin_p):Normalized())
  3081. BlinkChessX({p=position,caster=picked_chess})
  3082. Timers:CreateTimer((position-origin_p):Length2D()/1000+0.5,function()
  3083. TriggerChessCombineAtGrid(x,y,team_id)
  3084. CustomGameEventManager:Send_ServerToTeam(team_id,"show_is_hand_full",{
  3085. is_hand_full = IsHandFull(team_id)
  3086. })
  3087. end)
  3088. end
  3089. end
  3090. function BlinkChessX(keys)
  3091. local caster = keys.caster
  3092. local p = keys.p
  3093. local team_id = caster.at_team_id or caster.team_id
  3094. local x = Vector2X(p,team_id)
  3095. local y = Vector2Y(p,team_id)
  3096. local position = XY2Vector(x,y,team_id)
  3097.  
  3098. caster.y_x = Vector2Y(position,team_id)..'_'..Vector2X(position,team_id)
  3099. caster.y = Vector2Y(position,team_id)
  3100. caster.x = Vector2X(position,team_id)
  3101. caster:Stop()
  3102. if caster:HasModifier("modifier_jump") then
  3103. return
  3104. end
  3105. caster:AddNewModifier(caster,nil,"modifier_jump",{vx = position.x,vy = position.y})
  3106.  
  3107. end
  3108. function RemoveChess(keys)
  3109. local target = keys.target
  3110. local caster = keys.caster
  3111. local position = target:GetAbsOrigin()
  3112. local team_id = target.team_id
  3113. local x = Vector2X(position,team_id)
  3114. local y = Vector2Y(position,team_id)
  3115.  
  3116. if string.find(target:GetUnitName(),'chess_') == nil then
  3117. return
  3118. end
  3119.  
  3120. if target.is_removing == true then
  3121. return
  3122. end if (GameRules:GetGameModeEntity().game_status == 2 and target.hand_index == nil) or (GameRules:GetGameModeEntity().game_status == 1 and target.hand_index == nil and GameRules:GetGameModeEntity().prepare_timer > 33) then
  3123. CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"mima",{
  3124. text = "text_mima_cannot_delete_battle_chess"
  3125. })
  3126. EmitSoundOn("General.CastFail_NoMana",keys.caster)
  3127. return
  3128. end
  3129.  
  3130. play_particle("particles/units/heroes/hero_shadowshaman/shadowshaman_voodoo.vpcf",PATTACH_ABSORIGIN_FOLLOW,target,3)
  3131. EmitSoundOn("Hero_Lion.Voodoo",caster)
  3132. if target.hand_index == nil then
  3133. -- DeepPrintTable(GameRules:GetGameModeEntity().mychess[team_id])
  3134. -- print(target.y_x)
  3135. GameRules:GetGameModeEntity().mychess[team_id][target.y_x] = nil
  3136. -- DeepPrintTable(GameRules:GetGameModeEntity().mychess[team_id])
  3137. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] - 1
  3138.  
  3139. --同步ui人口
  3140. CustomGameEventManager:Send_ServerToTeam(team_id,"population",{
  3141. max_count = GameRules:GetGameModeEntity().population_max[team_id],
  3142. count = GameRules:GetGameModeEntity().population[team_id],
  3143. })
  3144. else
  3145. GameRules:GetGameModeEntity().hand[team_id][target.hand_index] = 0
  3146. -- prt(team_id..'手牌'..target.hand_index..'清空')
  3147. caster.hand_entities[target.hand_index] = nil
  3148. end
  3149. RemoveFromToBeDestroyList(target)
  3150. if target.y_x ~= nil then
  3151. GameRules:GetGameModeEntity().unit[team_id][target.y_x] = nil
  3152. end
  3153.  
  3154. CancelPickChess(caster)
  3155. -- AddPickAndRemoveAbility(caster)
  3156. -- setHandStatus(team_id)
  3157.  
  3158. AddAChessToChessPool(target:GetUnitName())
  3159.  
  3160. local children = target:GetChildren()
  3161. for k,child in pairs(children) do
  3162. if child:GetClassname() == "dota_item_wearable" then
  3163. child:RemoveSelf()
  3164. end
  3165. end
  3166. target.is_removing = true
  3167. AddAbilityAndSetLevel(target,'no_minimap_icon')
  3168. target:SetModelScale(0.0001)
  3169. AddAbilityAndSetLevel(target,'no_hp_bar')
  3170. target:RemoveAbility('act_teleport')
  3171. target:RemoveModifierByName('modifier_act_teleport')
  3172. -- RemoveCostParticle(target)
  3173.  
  3174. --1/2返还魔法
  3175. -- if RandomInt(1,100) < 50 then
  3176. -- if caster:FindAbilityByName('h406_ability') ~= nil and RandomInt(1,100) < 25 then
  3177. -- AddMana(caster, target:GetLevel()*10)
  3178. -- EmitSoundOn("General.CoinsBig",caster)
  3179. -- else
  3180. AddMana(caster, target:GetLevel())
  3181. -- end
  3182.  
  3183. CustomGameEventManager:Send_ServerToTeam(team_id,"show_gold",{
  3184. gold = caster:GetMana(),
  3185. lose_streak = caster.lose_streak or 0,
  3186. win_streak = caster.win_streak or 0,
  3187. })
  3188. -- end
  3189. for slot=0,8 do
  3190. if target:GetItemInSlot(slot)~= nil then
  3191. local name = target:GetItemInSlot(slot):GetAbilityName()
  3192. if name ~= nil then
  3193. DropItemAppointed(caster,target,name)
  3194. end
  3195. end
  3196. end
  3197. local last_chess = false
  3198. if FindEmptyHandSlot(team_id) == 1 then
  3199. last_chess = true
  3200. end
  3201. Timers:CreateTimer(3,function()
  3202. target:Destroy()
  3203. --小死灵法轮回转世
  3204. -- if TeamId2Hero(team_id):FindAbilityByName('h404_ability') ~= nil and RandomInt(0,100) < 25 and last_chess == true then
  3205. -- RandomOneChessInHand(team_id)
  3206. -- end
  3207. end)
  3208.  
  3209. CustomGameEventManager:Send_ServerToTeam(team_id,"show_is_hand_full",{
  3210. is_hand_full = IsHandFull(team_id)
  3211. })
  3212. end
  3213. --触发team_id的场地中i,j这个格子的棋子合成
  3214. function TriggerChessCombineAtGrid(i,j,team_id)
  3215. --找到这个格子上的棋子(obj)
  3216. local curr_chess = GameRules:GetGameModeEntity().mychess[team_id][j..'_'..i]
  3217. if curr_chess == nil then
  3218. return
  3219. end
  3220. local chess_index = curr_chess.index
  3221. local chess = EntIndexToHScript(chess_index)
  3222. local chess_name = chess:GetUnitName()
  3223.  
  3224. --在mychess中找到两个跟chess名字一样的chess obj:u1,u2
  3225. local u1 = nil
  3226. local u2 = nil
  3227. for u,v in pairs(GameRules:GetGameModeEntity().mychess[team_id]) do
  3228. if u1 == nil and v.index ~= chess_index and v.chess == chess_name and v.combining ~= true then
  3229. u1 = v
  3230. elseif u2 == nil and v.index ~= chess_index and v.chess == chess_name and v.combining ~= true then
  3231. u2 = v
  3232. end
  3233. end
  3234. local druid_count = GetDruidCount(team_id)
  3235.  
  3236. --合成
  3237. if u1 ~= nil and chess:FindAbilityByName('is_druid') ~= nil and EntIndexToHScript(u1.index):GetUnitName() == chess_name and string.find(chess_name,'1') == nil and druid_count >= 2 then
  3238. --德鲁伊(2):两个一样的1星可以合
  3239. CombineChess(curr_chess,u1)
  3240. elseif u1 ~= nil and EntIndexToHScript(chess_index):FindAbilityByName('is_druid') ~= nil and EntIndexToHScript(u1.index):GetUnitName() == chess_name and string.find(chess_name,'11') == nil and druid_count >= 4 then
  3241. --德鲁伊(4):两个一样的2星可以合
  3242. CombineChess(curr_chess,u1)
  3243. elseif u1 ~=nil and u2 ~=nil and EntIndexToHScript(u2.index):GetUnitName() == chess_name and EntIndexToHScript(u1.index):GetUnitName() == chess_name and string.find(chess_name,'11') == nil then
  3244. --普通情况:三个一样的可以合
  3245. CombineChess(curr_chess,u1,u2)
  3246. end
  3247. end
  3248. --把chess(unit)、u1(obj)、u2(obj)(可能有)合成chess1
  3249. function CombineChess(u0,u1,u2)
  3250. if u0 == nil or u1 == nil then
  3251. return
  3252. end
  3253.  
  3254. local chess0 = EntIndexToHScript(u0.index)
  3255. local chess1 = EntIndexToHScript(u1.index)
  3256. local chess2
  3257. local chess_name = chess0:GetUnitName()
  3258. local team_id = chess0.team_id
  3259. local p = XY2Vector(chess0.x,chess0.y,team_id)
  3260. local y = u0.y
  3261. local x = u0.x
  3262.  
  3263. local u0_key = u0.y..'_'..u0.x
  3264. local u1_key = u1.y..'_'..u1.x
  3265. local u2_key
  3266. u0.combining = true
  3267. u1.combining = true
  3268. if u2 ~= nil then
  3269. u2.combining = true
  3270. u2_key = u2.y..'_'..u2.x
  3271. chess2 = EntIndexToHScript(u2.index)
  3272. end
  3273.  
  3274. --合成
  3275. local advance_unit_name = chess_name..'1'
  3276. if advance_unit_name ~= nil then
  3277. --收集低级棋子的物品
  3278. local items_table = {}
  3279. for slot=0,8 do
  3280. if chess0:GetItemInSlot(slot)~= nil then
  3281. table.insert(items_table,chess0:GetItemInSlot(slot):GetAbilityName())
  3282. end
  3283. if chess1:GetItemInSlot(slot)~= nil then
  3284. table.insert(items_table,chess1:GetItemInSlot(slot):GetAbilityName())
  3285. end
  3286. if chess2 ~= nil and chess2:GetItemInSlot(slot)~= nil then
  3287. table.insert(items_table,chess2:GetItemInSlot(slot):GetAbilityName())
  3288. end
  3289. end
  3290.  
  3291. --移除三个低级棋子
  3292. GameRules:GetGameModeEntity().mychess[team_id][u0_key]= nil
  3293. GameRules:GetGameModeEntity().mychess[team_id][u1_key] = nil
  3294. GameRules:GetGameModeEntity().unit[team_id][u1_key] = nil
  3295. RemoveFromToBeDestroyList(chess0)
  3296. RemoveFromToBeDestroyList(chess1)
  3297. chess0:Destroy()
  3298. chess1:Destroy()
  3299.  
  3300. if u2 ~= nil then
  3301. GameRules:GetGameModeEntity().mychess[team_id][u2_key] = nil
  3302. GameRules:GetGameModeEntity().unit[team_id][u2_key] = nil
  3303. RemoveFromToBeDestroyList(chess2)
  3304. chess2:Destroy()
  3305. end
  3306.  
  3307.  
  3308. --造高级棋子
  3309. local uu = CreateUnitByName(advance_unit_name, p,false,nil,nil,team_id)
  3310. MakeTiny(uu)
  3311. PlayChessDialogue(uu,'merge')
  3312.  
  3313. --给高级棋子添加棋子技能
  3314. if GameRules:GetGameModeEntity().chess_ability_list[uu:GetUnitName()] ~= nil then
  3315. local a = GameRules:GetGameModeEntity().chess_ability_list[uu:GetUnitName()]
  3316. if uu:FindAbilityByName(a) == nil then
  3317. AddAbilityAndSetLevel(uu,a,0)
  3318. end
  3319. end
  3320.  
  3321. --添加星星特效
  3322. if string.find(advance_unit_name,'11') ~= nil then
  3323. play_particle('effect/arrow/star3.vpcf',PATTACH_OVERHEAD_FOLLOW,uu,5)
  3324. elseif string.find(advance_unit_name,'1') ~= nil then
  3325. play_particle('effect/arrow/star2.vpcf',PATTACH_OVERHEAD_FOLLOW,uu,5)
  3326. end
  3327.  
  3328. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[team_id],uu)
  3329. GameRules:GetGameModeEntity().mychess[team_id][''..y..'_'..x] = {
  3330. index = uu:entindex(),
  3331. chess = uu:GetUnitName(),
  3332. item = {},
  3333. x = x,
  3334. y = y,
  3335. }
  3336. uu.y_x = ''..y..'_'..x
  3337. uu.y = y
  3338. uu.x = x
  3339. uu.team_id = team_id
  3340.  
  3341. uu:SetForwardVector(Vector(0,1,0))
  3342. --添加装备
  3343. for l,vl in pairs(items_table) do
  3344. uu:AddItemByName(vl)
  3345. end
  3346. AddAbilityAndSetLevel(uu,'root_self')
  3347. AddAbilityAndSetLevel(uu,'jiaoxie_wudi')
  3348. --合成特效
  3349. play_particle("particles/units/unit_greevil/loot_greevil_death.vpcf",PATTACH_ABSORIGIN_FOLLOW,uu,3)
  3350. EmitGlobalSound("Loot_Drop_Stinger_Rare")
  3351.  
  3352. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] - 1
  3353. if u2 ~= nil then
  3354. GameRules:GetGameModeEntity().population[team_id] = GameRules:GetGameModeEntity().population[team_id] - 1
  3355. end
  3356.  
  3357. --同步ui人口
  3358. CustomGameEventManager:Send_ServerToTeam(team_id,"population",{
  3359. max_count = GameRules:GetGameModeEntity().population_max[team_id],
  3360. count = GameRules:GetGameModeEntity().population[team_id],
  3361. })
  3362.  
  3363. --发弹幕
  3364. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3365. player_id = TeamId2Hero(team_id):GetPlayerID(),
  3366. target = advance_unit_name,
  3367. })
  3368.  
  3369. --检测能否进一步合成
  3370. Timers:CreateTimer(1,function()
  3371. TriggerChessCombineAtGrid(x,y,team_id)
  3372. end)
  3373. end
  3374. end
  3375.  
  3376. function GetDruidCount(team_id)
  3377. --德鲁伊种族技能
  3378. --统计有多少不同的德鲁伊
  3379. local druid_table = {}
  3380. for w,vw in pairs(GameRules:GetGameModeEntity().mychess[team_id]) do
  3381. local find_name = vw.chess
  3382. if string.find(find_name,'11') ~= nil then
  3383. find_name = string.sub(find_name,1,-2)
  3384. end
  3385. if string.find(find_name,'1') ~= nil then
  3386. find_name = string.sub(find_name,1,-2)
  3387. end
  3388. if (find_name == "chess_eh" or find_name == "chess_ld" or find_name == "chess_tp" or find_name == "chess_fur") and FindValueInTable(druid_table,find_name) ~= true then
  3389. table.insert(druid_table,find_name)
  3390. end
  3391. end
  3392. return table.maxn(druid_table) or 0
  3393. end
  3394.  
  3395. function SyncHP(hero)
  3396. GameRules:GetGameModeEntity().stat_info[hero.steam_id]['hp'] = hero:GetHealth()
  3397. CustomNetTables:SetTableValue( "dac_table", "user_panel_ranking", {table = GameRules:GetGameModeEntity().stat_info, hehe = RandomInt(1,1000)})
  3398.  
  3399. --同步ui血量
  3400. CustomGameEventManager:Send_ServerToAllClients("sync_hp",{
  3401. player_id = hero:GetPlayerID(),
  3402. hp = hero:GetHealth(),
  3403. hp_max = hero:GetMaxHealth(),
  3404. })
  3405.  
  3406. if GameRules:GetGameModeEntity().START_TIME == nil then
  3407. return
  3408. end
  3409. SetStat(hero:GetPlayerID(), 'duration', math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME))
  3410. SetStat(hero:GetPlayerID(), 'round', GameRules:GetGameModeEntity().battle_round)
  3411. if hero:GetHealth() <= 0 then
  3412. --玩家死亡
  3413.  
  3414. --保存最终阵容
  3415. local lineup = ''
  3416. for _,v in pairs(GameRules:GetGameModeEntity().mychess[hero:GetTeam()]) do
  3417. if v ~= nil and v.chess ~= nil then
  3418. lineup = lineup..v.chess..','
  3419. AddAChessToChessPool(v.chess)
  3420. end
  3421. end
  3422. --洗回手牌
  3423. if hero.hand_entities ~= nil then
  3424. for i=1,8 do
  3425. local unitname = ''
  3426. if hero.hand_entities[i] ~= nil then
  3427. unitname = hero.hand_entities[i]:GetUnitName()
  3428. AddAChessToChessPool(unitname)
  3429. end
  3430. end
  3431. end
  3432. SetStat(hero:GetPlayerID(), 'chess_lineup',lineup)
  3433.  
  3434. hero:ForceKill(false)
  3435. if GameRules:GetGameModeEntity().death_stack == nil then
  3436. GameRules:GetGameModeEntity().death_stack = hero.steam_id
  3437. else
  3438. if string.find(GameRules:GetGameModeEntity().death_stack,hero.steam_id) == nil then
  3439. GameRules:GetGameModeEntity().death_stack = hero.steam_id..','..GameRules:GetGameModeEntity().death_stack
  3440. end
  3441. end
  3442.  
  3443. --统计还有多少活着的玩家
  3444. local live_count = 0
  3445. local last_hero = nil
  3446. GameRules:GetGameModeEntity().last_player_steamid = nil
  3447. GameRules:GetGameModeEntity().last_player_hero = nil
  3448. for i,v in pairs (GameRules:GetGameModeEntity().hero) do
  3449. if v ~= nil and v:IsNull() ~= true and v:IsAlive() == true then
  3450. last_hero = v
  3451. live_count = live_count + 1
  3452. GameRules:GetGameModeEntity().last_player_steamid = v.steam_id
  3453. GameRules:GetGameModeEntity().last_player_hero = v
  3454. end
  3455. end
  3456. if live_count == 1 and PlayerResource:GetPlayerCount() > 1 then
  3457. local dur = math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME)+3
  3458. SetStat(GameRules:GetGameModeEntity().last_player_hero:GetPlayerID(), 'duration', dur)
  3459. SetStat(GameRules:GetGameModeEntity().last_player_hero:GetPlayerID(), 'round', GameRules:GetGameModeEntity().battle_round)
  3460. -- last_hero:ForceKill(false)
  3461.  
  3462. --保存最终阵容
  3463. local lineup = ''
  3464. for _,v in pairs(GameRules:GetGameModeEntity().mychess[last_hero:GetTeam()]) do
  3465. if v ~= nil and v.chess ~= nil then
  3466. lineup = lineup..v.chess..','
  3467. end
  3468. end
  3469. SetStat(last_hero:GetPlayerID(), 'chess_lineup',lineup)
  3470.  
  3471.  
  3472. if GameRules:GetGameModeEntity().already_sent == nil then
  3473. GameRules:GetGameModeEntity().already_sent = 1
  3474. prt('END GAME')
  3475. GameRules:GetGameModeEntity().death_stack = GameRules:GetGameModeEntity().last_player_steamid..','..GameRules:GetGameModeEntity().death_stack
  3476. if GetMapName() ~= 'practice' then
  3477. local url = "http://101.200.189.65:431/dac/ranking/add/@"..GameRules:GetGameModeEntity().death_stack.."?hehe="..RandomInt(1,10000).."&winner_lineup="..lineup.."&duration="..dur.."&key="..GetDedicatedServerKey('dac')
  3478. SendHTTP(url, function(t)
  3479. if t.err == 0 then
  3480. prt('POST GAME OK!')
  3481. for u,v in pairs(t.mmr_info) do
  3482. GameRules:GetGameModeEntity().stat_info[u]['mmr_level'] = v.level
  3483. GameRules:GetGameModeEntity().stat_info[u]['candy'] = v.candy or 0
  3484. end
  3485. --展示结束面板,结束游戏!
  3486. PostGame()
  3487. Timers:CreateTimer(3,function()
  3488. GameRules:SetGameWinner(last_hero:GetTeam())
  3489.  
  3490. end)
  3491. else
  3492. prt('POST GAME ERROR : '..t.err)
  3493. PostGame()
  3494. Timers:CreateTimer(3,function()
  3495. GameRules:SetGameWinner(last_hero:GetTeam())
  3496.  
  3497. end)
  3498. end
  3499. end, function()
  3500. prt('POST GAME ERROR')
  3501. PostGame()
  3502. Timers:CreateTimer(3,function()
  3503. GameRules:SetGameWinner(last_hero:GetTeam())
  3504.  
  3505. end)
  3506. end)
  3507. else
  3508. PostGame()
  3509. Timers:CreateTimer(3,function()
  3510. GameRules:SetGameWinner(last_hero:GetTeam())
  3511.  
  3512. end)
  3513. end
  3514.  
  3515. --提交阵容
  3516. if table.maxn(GameRules:GetGameModeEntity().upload_lineup) > 0 then
  3517. local str = ''
  3518. for i,v in pairs(GameRules:GetGameModeEntity().upload_lineup) do
  3519. str = str..json.encode(v)..'|'
  3520. end
  3521. str = string.sub(str,1,-2)
  3522. local url_up = "http://101.200.189.65:431/dac/lineup/add?lineups="..str.."&hehe="..RandomInt(1,10000).."&key="..GetDedicatedServerKey('dac')
  3523. local req_up = CreateHTTPRequestScriptVM("GET", url_up)
  3524. req_up:SetHTTPRequestAbsoluteTimeoutMS(20000)
  3525. req_up:Send(function (result)
  3526. local t_up = json.decode(result["Body"])
  3527. if t_up.err == 0 then
  3528. prt('SAVE CLOUD LINEUP OK!')
  3529. end
  3530. end)
  3531. end
  3532. end
  3533. end
  3534. if live_count == 0 and PlayerResource:GetPlayerCount() == 1 then
  3535. PostGame()
  3536. Timers:CreateTimer(3,function()
  3537. GameRules:SetGameWinner(DOTA_TEAM_NEUTRALS)
  3538.  
  3539. end)
  3540. end
  3541. end
  3542. end
  3543. function PostGame()
  3544. CustomNetTables:SetTableValue( "dac_table", "end_board", { data = GameRules:GetGameModeEntity().stat_info, hehe = RandomInt(1,100000)})
  3545. end
  3546. function LoadPVEEnemy(wave,team)
  3547. if GameRules:GetGameModeEntity().battle_boss[wave] ~= nil then
  3548. for i,vi in pairs(GameRules:GetGameModeEntity().battle_boss[wave]) do
  3549. GameRules:GetGameModeEntity().unit[team][vi.y..'_'..vi.x] = 1
  3550. local x = CreateUnitByName(vi.enemy,XY2Vector(vi.x,vi.y,team),true,nil,nil,DOTA_TEAM_NEUTRALS)
  3551. x:SetForwardVector(Vector(0,-1,0))
  3552. x.y_x = vi.y..'_'..vi.x
  3553. x.y = vi.y
  3554. x.x = vi.x
  3555. x.team_id = 4
  3556. x.at_team_id = team
  3557. AddAbilityAndSetLevel(x,'root_self')
  3558. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  3559. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[team],x)
  3560. end
  3561. end
  3562. Timers:CreateTimer(0.5,function()
  3563. AddComboAbility(team)
  3564. end)
  3565. end
  3566. --掉宝
  3567. function DropItem(unit)
  3568. local ran = RandomInt(1,100)
  3569. local item_level = 0
  3570. local curr_per = 0
  3571. local unit_level = unit:GetLevel()
  3572. if GameRules:GetGameModeEntity().drop_item_gailv[unit_level] ~= nil then
  3573. for per,lv in pairs(GameRules:GetGameModeEntity().drop_item_gailv[unit_level]) do
  3574. if ran >= per and curr_per<=per then
  3575. curr_per = per
  3576. item_level = lv
  3577. end
  3578. end
  3579. end
  3580. local ITEM_LIST = {
  3581. [1] = {
  3582. [1] = 'item_suozijia',
  3583. [2] = 'item_yuandun',
  3584. [3] = 'item_zhiliaozhihuan',
  3585. [4] = 'item_gongjizhizhua',
  3586. [5] = 'item_kuweishi',
  3587. [6] = 'item_duangun',
  3588. [7] = 'item_xixuemianju',
  3589. [8] = 'item_huifuzhihuan',
  3590. [9] = 'item_kangmodoupeng',
  3591. [10] = 'item_xuwubaoshi',
  3592. [11] = 'item_fashichangpao',
  3593. [12] = 'item_wangguan',
  3594. },
  3595. [2] = {
  3596. [1] = 'item_banjia',
  3597. [2] = 'item_huoliqiu',
  3598. [3] = 'item_kuojian',
  3599. [4] = 'item_miyinchui',
  3600. [5] = 'item_biaoqiang',
  3601. [6] = 'item_molifazhang',
  3602. },
  3603. [3] = {
  3604. [1] = 'item_emodaofeng',
  3605. [2] = 'item_zhenfenbaoshi',
  3606. [3] = 'item_jixianfaqiu',
  3607. },
  3608. [4] = {
  3609. [1] = 'item_shengzheyiwu',
  3610. [2] = 'item_dafu',
  3611. [3] = 'item_shenmifazhang',
  3612. },
  3613. }
  3614. if item_level > 0 then
  3615. local hero = TeamId2Hero(unit.at_team_id )
  3616. local i = ITEM_LIST[item_level][RandomInt(1,table.maxn(ITEM_LIST[item_level]))]
  3617. local newItem = CreateItem( i, hero, hero )
  3618. local drop = CreateItemOnPositionForLaunch(unit:GetAbsOrigin(), newItem )
  3619. local dropRadius = RandomFloat( 50, 200 )
  3620. newItem:LaunchLootInitialHeight( false, 0, 200, 0.75, unit:GetAbsOrigin() + RandomVector(dropRadius ))
  3621. end
  3622. end
  3623. function DropItemAppointed(hero,unit,item)
  3624. local newItem = CreateItem( item, hero, hero )
  3625. local drop = CreateItemOnPositionForLaunch(unit:GetAbsOrigin(), newItem )
  3626. local dropRadius = RandomFloat( 10, 100 )
  3627. if unit == nil or unit:IsNull() == true or unit:GetAbsOrigin() == nil then
  3628. unit = hero
  3629. end
  3630. newItem:LaunchLootInitialHeight( false, 0, 200, 0.75, unit:GetAbsOrigin() + RandomVector(dropRadius ))
  3631. end
  3632. function StartAPVERound()
  3633. GameRules:GetGameModeEntity().battle_count = 0
  3634.  
  3635. CustomGameEventManager:Send_ServerToAllClients("battle_info",{
  3636. type = "pve",
  3637. text = ''..GameRules:GetGameModeEntity().battle_round,
  3638. round = GameRules:GetGameModeEntity().battle_round,
  3639. })
  3640.  
  3641. for i,v in pairs (GameRules:GetGameModeEntity().counterpart) do
  3642. if v ~= -1 then
  3643. v = 0
  3644. local h = TeamId2Hero(i)
  3645. CheckChess(i)
  3646. CancelPickChess(h)
  3647. LoadPVEEnemy(GameRules:GetGameModeEntity().battle_round,i)
  3648. local mana = h:GetMana()
  3649. if mana>5 then
  3650. mana = 5
  3651. end
  3652.  
  3653. --主公技可用
  3654. Timers:CreateTimer(3,function()
  3655. SetLordAbilityEnable(h,true)
  3656. end)
  3657. end
  3658. end
  3659. for m,n in pairs (GameRules:GetGameModeEntity().to_be_destory_list) do
  3660. if table.maxn(n) > 0 then
  3661. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count + 1
  3662. Timers:CreateTimer(function()
  3663. if GameRules:GetGameModeEntity().battle_timer <= 0 then
  3664. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3665. -- prt('玩家'..m..'防守成功,因为时间到了')
  3666. EmitGlobalSound('crowd.lv_01')
  3667. AddStat(TeamId2Hero(m):GetPlayerID(),'draw_round')
  3668. --发弹幕
  3669. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3670. player_id = TeamId2Hero(m):GetPlayerID(),
  3671. win = 0,
  3672. draw = 'pve_'..(GameRules:GetGameModeEntity().battle_round-1),
  3673. lose = nil,
  3674. score = '0-0',
  3675. })
  3676. return
  3677. else
  3678. local mychess = 0
  3679. local enemychess = 0
  3680. local my_last_chess = nil
  3681. for p,q in pairs(GameRules:GetGameModeEntity().to_be_destory_list[m]) do
  3682. if q.team_id == m then
  3683. mychess = mychess + 1
  3684. my_last_chess = q
  3685. else
  3686. enemychess = enemychess + 1
  3687. end
  3688. end
  3689. if enemychess == 0 then
  3690. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3691. for a,b in pairs(n) do
  3692. AddAbilityAndSetLevel(b,'act_victory')
  3693. b.alreadywon = true
  3694. end
  3695. -- prt('玩家'..m..'防守成功,因为杀光了所有敌人('..mychess..':'..enemychess..')')
  3696. --发弹幕
  3697. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3698. player_id = TeamId2Hero(m):GetPlayerID(),
  3699. win = 'pve_'..(GameRules:GetGameModeEntity().battle_round-1),
  3700. draw = nil,
  3701. lose = nil,
  3702. score = mychess..'-0',
  3703. })
  3704.  
  3705. EmitGlobalSound('crowd.lv_01')
  3706. AddStat(TeamId2Hero(m):GetPlayerID(),'win_round')
  3707. if my_last_chess ~= nil then
  3708. PlayChessDialogue(my_last_chess,'win')
  3709. end
  3710. return
  3711. elseif mychess == 0 then
  3712. Timers:CreateTimer(0.5,function()
  3713. local enemychess_new = 0
  3714. for p,q in pairs(GameRules:GetGameModeEntity().to_be_destory_list[m]) do
  3715. if q.team_id ~= m then
  3716. enemychess_new = enemychess_new + 1
  3717. end
  3718. end
  3719. if enemychess_new == 0 then
  3720. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3721. for a,b in pairs(n) do
  3722. AddAbilityAndSetLevel(b,'act_victory')
  3723. b.alreadywon = true
  3724. end
  3725. --发弹幕
  3726. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3727. player_id = TeamId2Hero(m):GetPlayerID(),
  3728. win = nil,
  3729. draw = 'pve_'..(GameRules:GetGameModeEntity().battle_round-1),
  3730. lose = nil,
  3731. score = mychess..'-0',
  3732. })
  3733. EmitGlobalSound('crowd.lv_01')
  3734. AddStat(TeamId2Hero(m):GetPlayerID(),'draw_round')
  3735. else
  3736. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3737.  
  3738. local hero = TeamId2Hero(m)
  3739. local curr_hp = hero:GetHealth()
  3740. local delay_time = 0
  3741. local damage_all = 0
  3742. for a,b in pairs(n) do
  3743. AddAbilityAndSetLevel(b,'act_victory')
  3744. b.alreadywon = true
  3745. --主公掉血弹道
  3746. local info =
  3747. {
  3748. Target = hero,
  3749. Source = b,
  3750. Ability = nil,
  3751. EffectName = "particles/econ/items/necrolyte/necrophos_sullen/necro_sullen_pulse_enemy.vpcf",
  3752. bDodgeable = false,
  3753. iMoveSpeed = 1000,
  3754. bProvidesVision = false,
  3755. iVisionRadius = 0,
  3756. iVisionTeamNumber = b:GetTeamNumber(),
  3757. iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_ATTACK_1
  3758. }
  3759. projectile = ProjectileManager:CreateTrackingProjectile(info)
  3760.  
  3761. delay_time = (hero:GetAbsOrigin() - b:GetAbsOrigin()):Length2D() / 1000 --delay time取最后一个
  3762. damage_all = damage_all + math.floor(GetMissDamage(b) or 1)
  3763. AddStat(hero:GetPlayerID(),'deaths')
  3764. end
  3765.  
  3766. damage_all = damage_all
  3767. local after_hp = curr_hp - damage_all--*1000 --千倍伤害
  3768. if after_hp <= 0 then
  3769. after_hp = 0
  3770. end
  3771.  
  3772. Timers:CreateTimer(delay_time,function()
  3773. if after_hp <= 0 then
  3774. --死了
  3775. hero:ForceKill(false)
  3776. GameRules:GetGameModeEntity().counterpart[hero:GetTeam()] = -1
  3777. SyncHP(hero)
  3778. AMHC:CreateNumberEffect(hero,damage_all,2,AMHC.MSG_MISS,"red",9)
  3779. ClearHand(hero:GetTeam())
  3780. return
  3781. end
  3782. hero:SetHealth(after_hp)
  3783. SyncHP(hero)
  3784. AMHC:CreateNumberEffect(hero,damage_all,2,AMHC.MSG_MISS,"red",9)
  3785. EmitSoundOn("Frostivus.PointScored.Enemy",hero)
  3786. end)
  3787. --发弹幕
  3788. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3789. player_id = TeamId2Hero(m):GetPlayerID(),
  3790. win = nil,
  3791. draw = nil,
  3792. lose = 'pve_'..(GameRules:GetGameModeEntity().battle_round-1),
  3793. score = '0-'..enemychess_new,
  3794. })
  3795.  
  3796. EmitGlobalSound('crowd.lv_01')
  3797. AddStat(TeamId2Hero(m):GetPlayerID(),'lose_round')
  3798. end
  3799. return
  3800. end)
  3801. else
  3802. return 1
  3803. end
  3804. end
  3805. end)
  3806. end
  3807. end
  3808. Timers:CreateTimer(function()
  3809. if GameRules:GetGameModeEntity().battle_timer <= 0 then
  3810. GameRules:GetGameModeEntity().game_status = 1
  3811. -- GameRules:SendCustomMessage('准备回合',0,0)
  3812. StartAPrepareRound()
  3813. return
  3814. elseif GameRules:GetGameModeEntity().battle_count == 0 and GameRules:GetGameModeEntity().battle_timer >= 3 then
  3815. Timers:CreateTimer(3,function()
  3816. GameRules:GetGameModeEntity().game_status = 1
  3817. -- GameRules:SendCustomMessage('准备回合',0,0)
  3818. StartAPrepareRound()
  3819. return
  3820. end)
  3821. else
  3822. local center_index = ''..Entities:FindByName(nil,"center0"):entindex()..','..Entities:FindByName(nil,"center1"):entindex()..','..Entities:FindByName(nil,"center2"):entindex()..','..Entities:FindByName(nil,"center3"):entindex()..','..Entities:FindByName(nil,"center4"):entindex()..','..Entities:FindByName(nil,"center5"):entindex()..','..Entities:FindByName(nil,"center6"):entindex()..','..Entities:FindByName(nil,"center7"):entindex()
  3823. --发送当前游戏时间给客户端
  3824. CustomGameEventManager:Send_ServerToAllClients("show_time",{
  3825. timer_round = GameRules:GetGameModeEntity().battle_timer,
  3826. round_status = "battle",
  3827. total_time = math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME),
  3828. center_index = center_index,
  3829. })
  3830. GameRules:GetGameModeEntity().battle_timer = GameRules:GetGameModeEntity().battle_timer - 1
  3831. return 1
  3832. end
  3833. end)
  3834. Timers:CreateTimer(0.1,function()
  3835. --添加战斗技能
  3836. for t = 6,13 do
  3837. for _,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[t]) do
  3838. if GameRules:GetGameModeEntity().chess_ability_list[v:GetUnitName()] ~= nil then
  3839. local a = GameRules:GetGameModeEntity().chess_ability_list[v:GetUnitName()]
  3840.  
  3841. local a_level = 1
  3842. if string.find(v:GetUnitName(),'1') then
  3843. a_level = 2
  3844. end
  3845. if string.find(v:GetUnitName(),'11') then
  3846. a_level = 3
  3847. end
  3848.  
  3849. if v:FindAbilityByName(a) == nil then
  3850. AddAbilityAndSetLevel(v,a,a_level)
  3851. else
  3852. v:FindAbilityByName(a):SetLevel(a_level)
  3853. end
  3854. v:RemoveAbility('jiaoxie_wudi')
  3855. v:RemoveModifierByName('modifier_jiaoxie_wudi')
  3856. if v.is_dragon_zhanhou == nil then
  3857. v:SetMana(0)
  3858. end
  3859. end
  3860. Timers:CreateTimer(function()
  3861. if v == nil or v:IsNull() == true or v:IsAlive() == false and v.alreadywon == true then
  3862. return
  3863. end
  3864. ChessAI(v)
  3865. return 1
  3866. end)
  3867. end
  3868. end
  3869. end)
  3870. end
  3871. --查户口
  3872. function CheckChess(team_id)
  3873. local index_table = {}
  3874. local dup_table = {}
  3875. local chess_count = 0
  3876. local hero_level = TeamId2Hero(team_id):GetLevel()
  3877. for y_x,obj in pairs(GameRules:GetGameModeEntity().mychess[team_id]) do
  3878. if FindValueInTable(index_table,obj.index) == true then
  3879. --重复了
  3880. table.insert(dup_table,y_x)
  3881. else
  3882. table.insert(index_table,obj.index)
  3883. end
  3884. chess_count = chess_count + 1
  3885. end
  3886. GameRules:GetGameModeEntity().population[team_id] = chess_count
  3887. GameRules:GetGameModeEntity().population_max[team_id] = hero_level
  3888.  
  3889. if chess_count > hero_level and table.maxn(dup_table) > 0 then
  3890. prt('CHECK CHESS')
  3891. prt('hero_level:'..hero_level..'/chess_count:'..chess_count)
  3892. for _,y_x in pairs(dup_table) do
  3893. prt('DELETE:'..y_x)
  3894. GameRules:GetGameModeEntity().mychess[team_id][y_x] = nil
  3895. end
  3896. end
  3897. end
  3898. function StartAPVPRound()
  3899. AllocateABattleRound()
  3900. local send_table = {}
  3901. for p,vp in pairs(GameRules:GetGameModeEntity().counterpart) do
  3902. send_table[p] = GameRules:GetGameModeEntity().team2playerid[vp]
  3903. end
  3904. for i,v in pairs (GameRules:GetGameModeEntity().counterpart) do
  3905. if v ~= -1 then
  3906. local h = TeamId2Hero(i)
  3907. if h.hand_entities ~= nil then
  3908. for _,ent in pairs(h.hand_entities) do
  3909. AddAbilityAndSetLevel(ent,'outofgame',1)
  3910. end
  3911. end
  3912. CheckChess(i)
  3913. CancelPickChess(h)
  3914. if PlayerResource:GetPlayerCount() == 1 and GameRules:GetGameModeEntity().cloudlineup[''..GameRules:GetGameModeEntity().battle_round] ~= nil then
  3915. local chesses = nil
  3916. for _,data in pairs(GameRules:GetGameModeEntity().cloudlineup[''..GameRules:GetGameModeEntity().battle_round]) do
  3917. chesses = json.decode(data)
  3918. end
  3919.  
  3920. CustomGameEventManager:Send_ServerToAllClients("battle_info",{
  3921. type = "cloud",
  3922. text = chesses.owner,
  3923. round = GameRules:GetGameModeEntity().battle_round,
  3924. })
  3925. LoadCloudEnemy(GameRules:GetGameModeEntity().battle_round,i)
  3926. h.cloud_opp_name = chesses.owner
  3927. else
  3928. local enemy_id = TeamId2Hero(v):GetPlayerID()
  3929. CustomGameEventManager:Send_ServerToTeam(i,"battle_info",{
  3930. type = "pvp",
  3931. text = enemy_id,
  3932. round = GameRules:GetGameModeEntity().battle_round,
  3933. })
  3934. MirrorARound(i)
  3935. h.cloud_opp_name = nil
  3936. end
  3937. -- local mana = h:GetMana()
  3938. -- if mana>5 then
  3939. -- mana = 5
  3940. -- end
  3941. -- h:AddExperience (mana,0,false,false)
  3942. -- h:SetMana(0)
  3943. -- setHandStatus(h:GetTeam())
  3944. --主公技可用
  3945. Timers:CreateTimer(5,function()
  3946. SetLordAbilityEnable(h,true)
  3947. end)
  3948. end
  3949. end
  3950. GameRules:GetGameModeEntity().battle_count = 0
  3951. for m,n in pairs (GameRules:GetGameModeEntity().to_be_destory_list) do
  3952. if table.maxn(n) > 0 then
  3953. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count + 1
  3954. Timers:CreateTimer(function()
  3955. if GameRules:GetGameModeEntity().battle_timer <= 0 then
  3956. --第一种情况:时间到了,平局
  3957. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3958.  
  3959. --发弹幕
  3960. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3961. player_id = TeamId2Hero(m):GetPlayerID(),
  3962. win = nil,
  3963. draw = TeamId2Hero(GameRules:GetGameModeEntity().counterpart[m]):GetPlayerID(),
  3964. lose = nil,
  3965. score = '0-0',
  3966. cloud_opp_name = TeamId2Hero(m).cloud_opp_name
  3967. })
  3968.  
  3969. EmitGlobalSound('crowd.lv_01')
  3970. AddStat(TeamId2Hero(m):GetPlayerID(),'draw_round')
  3971. RemoveLoseStreak(m)
  3972. RemoveWinStreak(m)
  3973. return
  3974. else
  3975. local mychess = 0
  3976. local enemychess = 0
  3977. local my_last_chess = nil
  3978. for p,q in pairs(GameRules:GetGameModeEntity().to_be_destory_list[m]) do
  3979. if q.team_id == m then
  3980. mychess = mychess + 1
  3981. my_last_chess = q
  3982. else
  3983. enemychess = enemychess + 1
  3984. end
  3985. end
  3986. if enemychess == 0 then
  3987. --第二种情况:敌方死光了,获胜
  3988. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  3989. for a,b in pairs(n) do
  3990. AddAbilityAndSetLevel(b,'act_victory')
  3991. b.alreadywon = true
  3992. end
  3993.  
  3994. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  3995. player_id = TeamId2Hero(m):GetPlayerID(),
  3996. win = TeamId2Hero(GameRules:GetGameModeEntity().counterpart[m]):GetPlayerID(),
  3997. draw = nil,
  3998. lose = nil,
  3999. score = mychess..'-0',
  4000. cloud_opp_name = TeamId2Hero(m).cloud_opp_name
  4001. })
  4002.  
  4003. EmitGlobalSound('crowd.lv_01')
  4004. AddStat(TeamId2Hero(m):GetPlayerID(),'win_round')
  4005. RemoveLoseStreak(m)
  4006. AddWinStreak(m)
  4007. if my_last_chess ~= nil then
  4008. PlayChessDialogue(my_last_chess,'win')
  4009. end
  4010. local hero = TeamId2Hero(m)
  4011. if hero.mirror_chesser ~= nil then
  4012. hero.mirror_chesser:ForceKill(false)
  4013. hero.mirror_chesser = nil
  4014. end
  4015. --得1金币
  4016. AddMana(hero, 1)
  4017. CustomGameEventManager:Send_ServerToTeam(m,"show_gold",{
  4018. gold = hero:GetMana(),
  4019. lose_streak = hero.lose_streak or 0,
  4020. win_streak = hero.win_streak or 0,
  4021. })
  4022.  
  4023. --概率存阵容
  4024. if RandomInt(1,100) < 5 then
  4025. local lineup_table = {}
  4026. for _,savechess in pairs(GameRules:GetGameModeEntity().mychess[m]) do
  4027. table.insert(lineup_table,{
  4028. x = savechess.x,
  4029. y = savechess.y,
  4030. lastitem = CopyTable(savechess.lastitem),
  4031. chess = savechess.chess
  4032. })
  4033. end
  4034. local obj = {
  4035. owner = TeamId2Hero(m).steam_id,
  4036. lineup = lineup_table,
  4037. round = GameRules:GetGameModeEntity().battle_round - 1
  4038. }
  4039. table.insert(GameRules:GetGameModeEntity().upload_lineup,obj)
  4040. end
  4041. return
  4042. elseif mychess == 0 then
  4043. Timers:CreateTimer(0.5,function()
  4044. local enemychess_new = 0
  4045. for p,q in pairs(GameRules:GetGameModeEntity().to_be_destory_list[m]) do
  4046. if q.team_id ~= m then
  4047. enemychess_new = enemychess_new + 1
  4048. end
  4049. end
  4050. if enemychess_new == 0 then
  4051. --第三种情况:敌我都死光了,平局
  4052. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  4053. for a,b in pairs(n) do
  4054. AddAbilityAndSetLevel(b,'act_victory')
  4055. b.alreadywon = true
  4056. end
  4057.  
  4058. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  4059. player_id = TeamId2Hero(m):GetPlayerID(),
  4060. win = nil,
  4061. draw = TeamId2Hero(GameRules:GetGameModeEntity().counterpart[m]):GetPlayerID(),
  4062. lose = nil,
  4063. score = '0-0',
  4064. cloud_opp_name = TeamId2Hero(m).cloud_opp_name
  4065. })
  4066.  
  4067. EmitGlobalSound('crowd.lv_01')
  4068. AddStat(TeamId2Hero(m):GetPlayerID(),'draw_round')
  4069. RemoveLoseStreak(m)
  4070. RemoveWinStreak(m)
  4071. else
  4072. --第四种情况:只剩敌人了,失败
  4073. GameRules:GetGameModeEntity().battle_count = GameRules:GetGameModeEntity().battle_count - 1
  4074.  
  4075. local hero = TeamId2Hero(m)
  4076. local curr_hp = hero:GetHealth()
  4077. local delay_time = 0
  4078. local damage_all = 0
  4079. for a,b in pairs(n) do
  4080. AddAbilityAndSetLevel(b,'act_victory')
  4081. b.alreadywon = true
  4082. --主公掉血弹道
  4083. local info =
  4084. {
  4085. Target = hero,
  4086. Source = b,
  4087. Ability = nil,
  4088. EffectName = "particles/econ/items/necrolyte/necrophos_sullen/necro_sullen_pulse_enemy.vpcf",
  4089. bDodgeable = false,
  4090. iMoveSpeed = 1000,
  4091. bProvidesVision = false,
  4092. iVisionRadius = 0,
  4093. iVisionTeamNumber = b:GetTeamNumber(),
  4094. iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_ATTACK_1
  4095. }
  4096. projectile = ProjectileManager:CreateTrackingProjectile(info)
  4097.  
  4098. delay_time = (hero:GetAbsOrigin() - b:GetAbsOrigin()):Length2D() / 1000 --delay time取最后一个
  4099. damage_all = damage_all + math.floor(GetMissDamage(b) or 1)
  4100. AddStat(hero:GetPlayerID(),'deaths')
  4101. end
  4102.  
  4103. damage_all = damage_all
  4104. local after_hp = curr_hp - damage_all
  4105. if after_hp <= 0 then
  4106. after_hp = 0
  4107. end
  4108.  
  4109. Timers:CreateTimer(delay_time,function()
  4110. if after_hp <= 0 then
  4111. hero:ForceKill(false)
  4112. GameRules:GetGameModeEntity().counterpart[hero:GetTeam()] = -1
  4113. SyncHP(hero)
  4114. AMHC:CreateNumberEffect(hero,damage_all,2,AMHC.MSG_MISS,"red",9)
  4115. ClearHand(hero:GetTeam())
  4116. return
  4117. end
  4118. hero:SetHealth(after_hp)
  4119. SyncHP(hero)
  4120. AMHC:CreateNumberEffect(hero,damage_all,2,AMHC.MSG_MISS,"red",9)
  4121. EmitSoundOn("Frostivus.PointScored.Enemy",hero)
  4122. end)
  4123.  
  4124. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  4125. player_id = TeamId2Hero(m):GetPlayerID(),
  4126. win = nil,
  4127. draw = nil,
  4128. lose = TeamId2Hero(GameRules:GetGameModeEntity().counterpart[m]):GetPlayerID(),
  4129. score = '0-'..enemychess_new,
  4130. cloud_opp_name = TeamId2Hero(m).cloud_opp_name
  4131. })
  4132.  
  4133. EmitGlobalSound('crowd.lv_01')
  4134. AddStat(TeamId2Hero(m):GetPlayerID(),'lose_round')
  4135. AddLoseStreak(m)
  4136. RemoveWinStreak(m)
  4137. end
  4138. return
  4139. end)
  4140. else
  4141. return 1
  4142. end
  4143. end
  4144. end)
  4145. end
  4146. end
  4147. Timers:CreateTimer(function()
  4148. if GameRules:GetGameModeEntity().battle_timer <= 0 then
  4149. GameRules:GetGameModeEntity().game_status = 1
  4150. -- GameRules:SendCustomMessage('准备回合',0,0)
  4151. StartAPrepareRound()
  4152. return
  4153. elseif GameRules:GetGameModeEntity().battle_count == 0 and GameRules:GetGameModeEntity().battle_timer >= 3 then
  4154. Timers:CreateTimer(3,function()
  4155. GameRules:GetGameModeEntity().game_status = 1
  4156. -- GameRules:SendCustomMessage('准备回合',0,0)
  4157. StartAPrepareRound()
  4158. return
  4159. end)
  4160. else
  4161. local center_index = ''..Entities:FindByName(nil,"center0"):entindex()..','..Entities:FindByName(nil,"center1"):entindex()..','..Entities:FindByName(nil,"center2"):entindex()..','..Entities:FindByName(nil,"center3"):entindex()..','..Entities:FindByName(nil,"center4"):entindex()..','..Entities:FindByName(nil,"center5"):entindex()..','..Entities:FindByName(nil,"center6"):entindex()..','..Entities:FindByName(nil,"center7"):entindex()
  4162. --发送当前游戏时间给客户端
  4163. CustomGameEventManager:Send_ServerToAllClients("show_time",{
  4164. timer_round = GameRules:GetGameModeEntity().battle_timer,
  4165. round_status = "battle",
  4166. total_time = math.floor(GameRules:GetGameTime() - GameRules:GetGameModeEntity().START_TIME),
  4167. center_index = center_index
  4168. })
  4169. GameRules:GetGameModeEntity().battle_timer = GameRules:GetGameModeEntity().battle_timer - 1
  4170. return 1
  4171. end
  4172. end)
  4173. Timers:CreateTimer(0.1,function()
  4174. --添加战斗技能
  4175. for t = 6,13 do
  4176. for _,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[t]) do
  4177. if GameRules:GetGameModeEntity().chess_ability_list[v:GetUnitName()] ~= nil then
  4178. local a = GameRules:GetGameModeEntity().chess_ability_list[v:GetUnitName()]
  4179.  
  4180. local a_level = 1
  4181. if string.find(v:GetUnitName(),'1') then
  4182. a_level = 2
  4183. end
  4184. if string.find(v:GetUnitName(),'11') then
  4185. a_level = 3
  4186. end
  4187.  
  4188. if v:FindAbilityByName(a) == nil then
  4189. AddAbilityAndSetLevel(v,a,a_level)
  4190. else
  4191. v:FindAbilityByName(a):SetLevel(a_level)
  4192. end
  4193. v:RemoveAbility('jiaoxie_wudi')
  4194. v:RemoveModifierByName('modifier_jiaoxie_wudi')
  4195.  
  4196. if v.is_dragon_zhanhou == nil then
  4197. v:SetMana(0)
  4198. end
  4199. Timers:CreateTimer(function()
  4200. if v == nil or v:IsNull() == true or v:IsAlive() == false and v.alreadywon == true then
  4201. return
  4202. end
  4203. ChessAI(v)
  4204. return 1
  4205. end)
  4206. end
  4207. end
  4208. end
  4209. end)
  4210. end
  4211. function GetMissDamage(u)
  4212. local d = math.floor(1+(1.0*u:GetLevel()/3))
  4213. return d
  4214. end
  4215. --游戏循环2——开始一轮战斗回合(包括回合结果判断)
  4216. function StartABattleRound()
  4217.  
  4218. CustomNetTables:SetTableValue( "dac_table", "hide_damage_stat",
  4219. {
  4220. hehe = RandomInt(1,100000)
  4221. }
  4222. )
  4223.  
  4224. GameRules:SetTimeOfDay(0.3)
  4225.  
  4226. GameRules:GetGameModeEntity().game_status = 2
  4227. GameRules:GetGameModeEntity().battle_timer = 60
  4228. if GameRules:GetGameModeEntity().battle_round < 4 or (GameRules:GetGameModeEntity().battle_round > 5 and GameRules:GetGameModeEntity().battle_round%5 == 0) then
  4229. -- prt(''..GameRules:GetGameModeEntity().battle_round..'PVE战斗回合开始')
  4230. StartAPVERound()
  4231. else
  4232. -- prt(''..GameRules:GetGameModeEntity().battle_round..'PVP战斗回合开始')
  4233. StartAPVPRound()
  4234. end
  4235. GameRules:GetGameModeEntity().battle_round = GameRules:GetGameModeEntity().battle_round + 1
  4236. -- prt('next round: '..GameRules:GetGameModeEntity().battle_round)
  4237. end
  4238. --游戏循环2.1——分配对手
  4239. function AllocateABattleRound()
  4240. local finished = false
  4241. --local trytime = 0
  4242.  
  4243. -- while finished == false and trytime < 10000 do
  4244. --trytime = trytime + 1
  4245. local alive_player_count = 0
  4246. --统计玩家死活
  4247. for u,v in pairs(GameRules:GetGameModeEntity().counterpart) do
  4248. if TeamId2Hero(u) ~= nil and TeamId2Hero(u):IsNull() == false and TeamId2Hero(u):IsAlive() == true then
  4249. --活玩家
  4250. GameRules:GetGameModeEntity().counterpart[u] = u
  4251. alive_player_count = alive_player_count +1
  4252. else
  4253. --死玩家
  4254. GameRules:GetGameModeEntity().counterpart[u] = -1
  4255. end
  4256. end
  4257. local rann = GameRules:GetGameModeEntity().lastrandomn
  4258. if alive_player_count < 1 then
  4259. return
  4260. elseif alive_player_count == 1 then
  4261. rann = 0
  4262. elseif alive_player_count == 2 then
  4263. rann = 1
  4264. else
  4265. while rann == GameRules:GetGameModeEntity().lastrandomn do
  4266. rann = RandomInt(1,alive_player_count-1)
  4267. end
  4268. end
  4269. GameRules:GetGameModeEntity().lastrandomn = rann
  4270. --给活玩家分配一个随机对手
  4271. for rotate_count = 1,rann do
  4272. for i,j in pairs(GameRules:GetGameModeEntity().counterpart) do
  4273. if j ~= -1 then
  4274. local aliveteam = j
  4275.  
  4276. local n = 1
  4277. local try_count = 0
  4278. while (aliveteam == j or GameRules:GetGameModeEntity().counterpart[aliveteam] == nil or GameRules:GetGameModeEntity().counterpart[aliveteam] == -1) and try_count<10000 do
  4279. aliveteam = aliveteam + 1
  4280. if aliveteam > 13 then
  4281. aliveteam = 6
  4282. end
  4283. try_count = try_count + 1
  4284. end
  4285. GameRules:GetGameModeEntity().counterpart[i] = aliveteam
  4286. end
  4287. end
  4288. end
  4289. -- finished = CheckCounterpart()
  4290. -- end
  4291. end
  4292. -- function FindNextAliveTeam(team)
  4293. -- local aliveteam = GameRules:GetGameModeEntity().counterpart[team]
  4294. -- local n = 1
  4295. -- local try_count = 0
  4296. -- while aliveteam == team or GameRules:GetGameModeEntity().counterpart[aliveteam] == -1 and try_count<10000 do
  4297. -- aliveteam = aliveteam + 1
  4298. -- if aliveteam > PlayerResource:GetPlayerCount() + 5 then
  4299. -- aliveteam = 6
  4300. -- end
  4301. -- try_count = try_count + 1
  4302. -- end
  4303. -- prt(''..team..'的下一个活着的敌人是'..aliveteam)
  4304. -- return aliveteam
  4305. -- end
  4306. -- function RotateTeams()
  4307. -- local rotate_str = ''
  4308. -- for i,j in pairs(GameRules:GetGameModeEntity().counterpart) do
  4309. -- if j ~= -1 then
  4310. -- local aliveteam = j
  4311. -- local n = 1
  4312. -- local try_count = 0
  4313. -- while aliveteam == team or GameRules:GetGameModeEntity().counterpart[aliveteam] == -1 and try_count<10000 do
  4314. -- aliveteam = aliveteam + 1
  4315. -- if aliveteam > PlayerResource:GetPlayerCount() + 5 then
  4316. -- aliveteam = 6
  4317. -- end
  4318. -- try_count = try_count + 1
  4319. -- end
  4320. -- prt(''..team..'的下一个活着的敌人是'..aliveteam)
  4321. -- GameRules:GetGameModeEntity().counterpart[i] = aliveteam
  4322. -- rotate_str = rotate_str..i..'对阵'..GameRules:GetGameModeEntity().counterpart[i]..','
  4323. -- end
  4324. -- end
  4325. -- prt(rotate_str)
  4326. -- end
  4327.  
  4328. --游戏循环2.1.x——分配对手用到的方法
  4329. function CheckCounterpart()
  4330. local all_team_count = 0
  4331. for _,__ in pairs(GameRules:GetGameModeEntity().counterpart) do
  4332. all_team_count = all_team_count + 1
  4333. end
  4334. for team,conter in pairs(GameRules:GetGameModeEntity().counterpart) do
  4335. if team == conter and all_team_count > 1 then
  4336. return false
  4337. end
  4338. end
  4339. return true
  4340. end
  4341. --为teamid的场地上所有的敌我棋子添加组合技还有vp北极熊的技能
  4342. function AddComboAbility(teamid)
  4343. --通用技能
  4344. local combo_chess_table_self = {}
  4345. local combo_chess_table_enemy = {}
  4346. local combo_count_table_self = {}
  4347. local combo_count_table_enemy = {}
  4348. --第一次循环:棋子分组
  4349. for w,vw in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  4350. if vw.team_id == teamid then --我的棋子
  4351. --比较和对手的血量
  4352. local leading_team = teamid
  4353. if GameRules:GetGameModeEntity().counterpart[teamid] ~= 0 and GameRules:GetGameModeEntity().stat_info[TeamId2Hero(teamid).steam_id]['hp'] < GameRules:GetGameModeEntity().stat_info[TeamId2Hero(GameRules:GetGameModeEntity().counterpart[teamid]).steam_id]['hp'] then
  4354. leading_team = GameRules:GetGameModeEntity().counterpart[teamid]
  4355. end
  4356. if leading_team ~= vw.team_id and TeamId2Hero(vw.team_id) ~= nil and TeamId2Hero(vw.team_id):FindAbilityByName('h405_ability') ~= nil then
  4357. AddAbilityAndSetLevel(vw,'h405_ability_inchess')
  4358. end
  4359. for k,vk in pairs(GameRules:GetGameModeEntity().combo_ability_type) do
  4360. if combo_chess_table_self[k] == nil then
  4361. combo_chess_table_self[k] = {}
  4362. end
  4363. if vw:FindAbilityByName(k) ~= nil or vw:FindAbilityByName(string.sub(k,1,-2)) ~= nil or vw:FindAbilityByName(string.sub(k,1,-3)) ~= nil then
  4364. table.insert(combo_chess_table_self[k],vw)
  4365. end
  4366. end
  4367. else --敌人的棋子
  4368. --比较和对手的血量
  4369. local leading_team = vw.at_team_id
  4370. local opp = 0
  4371. --找到被镜像的棋子对手是谁
  4372. for teama,teamb in pairs(GameRules:GetGameModeEntity().counterpart) do
  4373. if teamb == vw.at_team_id then
  4374. opp = teama
  4375. end
  4376. end
  4377. if opp ~= 0 and GameRules:GetGameModeEntity().stat_info[TeamId2Hero(vw.at_team_id).steam_id]['hp'] < GameRules:GetGameModeEntity().stat_info[TeamId2Hero(opp).steam_id]['hp'] then
  4378. leading_team = opp
  4379. end
  4380. if leading_team == teamid and TeamId2Hero(vw.at_team_id) ~= nil and TeamId2Hero(vw.at_team_id):FindAbilityByName('h405_ability') ~= nil then
  4381. AddAbilityAndSetLevel(vw,'h405_ability_inchess')
  4382. end
  4383. for k,vk in pairs(GameRules:GetGameModeEntity().combo_ability_type) do
  4384. if combo_chess_table_enemy[k] == nil then
  4385. combo_chess_table_enemy[k] = {}
  4386. end
  4387. if vw:FindAbilityByName(k) ~= nil or vw:FindAbilityByName(string.sub(k,1,-2)) ~= nil or vw:FindAbilityByName(string.sub(k,1,-3)) ~= nil then
  4388. table.insert(combo_chess_table_enemy[k],vw)
  4389. end
  4390. end
  4391. end
  4392. end
  4393. --第二次循环:计数
  4394. for k,vk in pairs(combo_chess_table_self) do
  4395. --统计不同的种类数
  4396. local diff_count = 0
  4397. local diff_string = ''
  4398. for _,chess in pairs(combo_chess_table_self[k]) do
  4399. --去掉等级变量
  4400. local find_name = chess:GetUnitName()
  4401. if string.find(find_name,'11') ~= nil then
  4402. find_name = string.sub(find_name,1,-3)
  4403. end
  4404. if string.find(find_name,'1') ~= nil then
  4405. find_name = string.sub(find_name,1,-2)
  4406. end
  4407. --搜索是否重复了
  4408. if string.find(diff_string,find_name) == nil then
  4409. diff_count = diff_count + 1
  4410. diff_string = diff_string..'-'..find_name
  4411. end
  4412. end
  4413. if TeamId2Hero(teamid):FindAbilityByName(k) ~= nil then
  4414. diff_count = diff_count + 1
  4415. end
  4416. combo_count_table_self[k] = diff_count
  4417. end
  4418. for k,vk in pairs(combo_chess_table_enemy) do
  4419. --统计不同的种类数
  4420. local diff_count = 0
  4421. local diff_string = ''
  4422. for _,chess in pairs(combo_chess_table_enemy[k]) do
  4423. --去掉等级变量
  4424. local find_name = chess:GetUnitName()
  4425. if string.find(find_name,'11') ~= nil then
  4426. find_name = string.sub(find_name,1,-3)
  4427. end
  4428. if string.find(find_name,'1') ~= nil then
  4429. find_name = string.sub(find_name,1,-2)
  4430. end
  4431. --搜索是否重复了
  4432. if string.find(diff_string,find_name) == nil then
  4433. diff_count = diff_count + 1
  4434. diff_string = diff_string..'-'..find_name
  4435. end
  4436. end
  4437. combo_count_table_enemy[k] = diff_count
  4438. end
  4439. --第三次循环:添加技能
  4440. for p,vp in pairs(combo_chess_table_self) do
  4441. local shaman_gua = false
  4442. local type1 = GameRules:GetGameModeEntity().combo_ability_type[p]['type']
  4443. local condition = GameRules:GetGameModeEntity().combo_ability_type[p]['condition']
  4444. local buff_ability = GameRules:GetGameModeEntity().combo_ability_type[p]['ability']
  4445.  
  4446. if condition == 0 then
  4447. if combo_count_table_self[p] == 1 and combo_count_table_enemy['is_demonhunter'] == 0 then
  4448. for _,chess in pairs(vp) do
  4449. if buff_ability ~= nil then
  4450. AddAbilityAndSetLevel(chess,buff_ability)
  4451. end
  4452. end
  4453. end
  4454. if combo_count_table_self['is_demonhunter'] == 2 then
  4455. for _,chess in pairs(vp) do
  4456. if buff_ability ~= nil then
  4457. AddAbilityAndSetLevel(chess,buff_ability)
  4458. end
  4459. end
  4460. end
  4461. else
  4462. if combo_count_table_self[p] >= condition then
  4463. for _,chess in pairs(combo_chess_table_self[p]) do
  4464. if p == 'is_shaman' and shaman_gua == false then
  4465. shaman_gua = true
  4466. AddAbilityAndSetLevel(chess,'frog_voodoo')
  4467. end
  4468. if p == 'is_dragon' then
  4469. play_particle("particles/units/heroes/hero_monkey_king/monkey_king_fur_army_positions_ring_dragon.vpcf",PATTACH_OVERHEAD_FOLLOW,chess,5)
  4470. EmitSoundOn('Hero_DragonKnight.DragonTail.Target',chess)
  4471. chess.is_dragon_zhanhou = true
  4472. chess:SetMana(100)
  4473. end
  4474. end
  4475. --同类有技能
  4476. if type1 == 1 then
  4477. for _,chess in pairs(combo_chess_table_self[p]) do
  4478. if buff_ability ~= nil then
  4479. AddAbilityAndSetLevel(chess,buff_ability)
  4480. end
  4481. end
  4482. end
  4483. --友军有技能
  4484. if type1 == 2 then
  4485. for _,chess in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  4486. --是友军
  4487. if chess.team_id == teamid then
  4488. if string.find(chess:GetUnitName(),'hero') == nil then
  4489. if buff_ability ~= nil then
  4490. AddAbilityAndSetLevel(chess,buff_ability)
  4491. end
  4492. end
  4493. end
  4494. end
  4495. end
  4496. --敌军有技能
  4497. if type1 == 3 then
  4498. for _,chess in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  4499. --是敌军
  4500. if chess.team_id == 4 then
  4501. if string.find(chess:GetUnitName(),'hero') == nil then
  4502. if buff_ability ~= nil then
  4503. AddAbilityAndSetLevel(chess,buff_ability)
  4504. end
  4505. end
  4506. end
  4507. end
  4508. end
  4509. --随机一个友军有技能
  4510. if type1 == 4 then
  4511. local try_count = 0
  4512. local is_ok = false
  4513. while is_ok == false and try_count < 100 do
  4514. local r = RandomInt(1,table.maxn(GameRules:GetGameModeEntity().to_be_destory_list[teamid]))
  4515. local chess = GameRules:GetGameModeEntity().to_be_destory_list[teamid][r]
  4516. if chess.team_id == teamid then
  4517. if string.find(chess:GetUnitName(),'hero') == nil then
  4518. if buff_ability ~= nil then
  4519. AddAbilityAndSetLevel(chess,buff_ability)
  4520. is_ok = true
  4521. end
  4522. end
  4523. end
  4524. try_count = try_count + 1
  4525. end
  4526. end
  4527. end
  4528. end
  4529. end
  4530. for p,vp in pairs(combo_chess_table_enemy) do
  4531. local shaman_guagua = false
  4532. local type1 = GameRules:GetGameModeEntity().combo_ability_type[p]['type']
  4533. local condition = GameRules:GetGameModeEntity().combo_ability_type[p]['condition']
  4534. local buff_ability = GameRules:GetGameModeEntity().combo_ability_type[p]['ability']
  4535. if condition == 0 then
  4536. if combo_count_table_enemy[p] == 1 and combo_count_table_self['is_demonhunter'] == 0 then
  4537. for _,chess in pairs(vp) do
  4538. if buff_ability ~= nil then
  4539. AddAbilityAndSetLevel(chess,buff_ability)
  4540. end
  4541. end
  4542. end
  4543. if combo_count_table_enemy['is_demonhunter'] == 2 then
  4544. for _,chess in pairs(vp) do
  4545. if buff_ability ~= nil then
  4546. AddAbilityAndSetLevel(chess,buff_ability)
  4547. end
  4548. end
  4549. end
  4550. else
  4551. if combo_count_table_enemy[p] >= condition then
  4552. for _,chess in pairs(combo_chess_table_enemy[p]) do
  4553. if p == 'is_shaman' and shaman_guagua == false then
  4554. AddAbilityAndSetLevel(chess,'frog_voodoo')
  4555. shaman_guagua = true
  4556. end
  4557. if p == 'is_dragon' then
  4558. play_particle("particles/units/heroes/hero_monkey_king/monkey_king_fur_army_positions_ring_dragon.vpcf",PATTACH_OVERHEAD_FOLLOW,chess,5)
  4559. EmitSoundOn('Hero_DragonKnight.DragonTail.Target',chess)
  4560. chess.is_dragon_zhanhou = true
  4561. chess:SetMana(100)
  4562. end
  4563. end
  4564. --同类有技能
  4565. if type1 == 1 then
  4566. for _,chess in pairs(combo_chess_table_enemy[p]) do
  4567. if buff_ability ~= nil then
  4568. AddAbilityAndSetLevel(chess,buff_ability)
  4569. end
  4570. end
  4571. end
  4572. --友军有技能
  4573. if type1 == 2 then
  4574. for _,chess in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  4575. if chess.team_id == 4 then
  4576. if string.find(chess:GetUnitName(),'hero') == nil then
  4577. if buff_ability ~= nil then
  4578. AddAbilityAndSetLevel(chess,buff_ability)
  4579. end
  4580. end
  4581. end
  4582. end
  4583. end
  4584. --敌军有技能
  4585. if type1 == 3 then
  4586. for _,chess in pairs(GameRules:GetGameModeEntity().to_be_destory_list[teamid]) do
  4587. --是敌军
  4588. if chess.team_id == teamid then
  4589. if string.find(chess:GetUnitName(),'hero') == nil then
  4590. if buff_ability ~= nil then
  4591. AddAbilityAndSetLevel(chess,buff_ability)
  4592. end
  4593. end
  4594. end
  4595. end
  4596. end
  4597. --随机一个友军有技能
  4598. if type1 == 4 then
  4599. local try_count = 0
  4600. local is_ok = false
  4601. while is_ok == false and try_count < 100 do
  4602. local r = RandomInt(1,table.maxn(GameRules:GetGameModeEntity().to_be_destory_list[teamid]))
  4603. local chess = GameRules:GetGameModeEntity().to_be_destory_list[teamid][r]
  4604. if chess.team_id == 4 then
  4605. if string.find(chess:GetUnitName(),'hero') == nil then
  4606. if buff_ability ~= nil then
  4607. AddAbilityAndSetLevel(chess,buff_ability)
  4608. is_ok = true
  4609. end
  4610. end
  4611. end
  4612. try_count = try_count + 1
  4613. end
  4614. end
  4615. end
  4616. end
  4617. end
  4618. end
  4619. --游戏循环2.2——镜像要打的敌人和给他们加组合技
  4620. function MirrorARound(teamid)
  4621. local opp = nil
  4622. local my_opp = nil
  4623. -- DeepPrintTable(GameRules:GetGameModeEntity().counterpart)
  4624. for myteam,enemyteam in pairs(GameRules:GetGameModeEntity().counterpart) do
  4625. if enemyteam == teamid then
  4626. opp = myteam
  4627. end
  4628. if myteam == teamid then
  4629. my_opp = enemyteam
  4630. end
  4631. end
  4632. if opp ~= nil then
  4633. --镜像棋手
  4634. Timers:CreateTimer(1,function()
  4635. local opp_hero = TeamId2Hero(my_opp)
  4636. local opp_steam_id = opp_hero.steam_id
  4637. local opp_model = GameRules:GetGameModeEntity().stat_info[opp_steam_id]['zhugong_model']
  4638. local opp_effect = GameRules:GetGameModeEntity().stat_info[opp_steam_id]['zhugong_effect']
  4639. MirrorChesser(teamid,opp_model,opp_effect,opp_hero:GetModelScale())
  4640. end)
  4641.  
  4642. for i=1,4 do
  4643. for j=1,8 do
  4644. if GameRules:GetGameModeEntity().mychess[teamid][i..'_'..j] ~= nil then
  4645. GameRules:GetGameModeEntity().unit[teamid][i..'_'..j] = 1
  4646. GameRules:GetGameModeEntity().unit[opp][(9-i)..'_'..(9-j)] = 1
  4647.  
  4648. --复制棋子
  4649. local x = CreateUnitByName(GameRules:GetGameModeEntity().mychess[teamid][i..'_'..j].chess,XY2Vector(9-j,9-i,opp),true,nil,nil,DOTA_TEAM_NEUTRALS)
  4650. MakeTiny(x)
  4651. x:SetForwardVector(Vector(0,-1,0))
  4652.  
  4653. x.y_x = (9-i)..'_'..(9-j)
  4654. x.y = 9-i
  4655. x.x = 9-j
  4656.  
  4657. x.team_id = 4
  4658. x.at_team_id = opp
  4659. AddAbilityAndSetLevel(x,'root_self')
  4660. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  4661. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[opp],x)
  4662.  
  4663. --复制物品
  4664. local uindex = GameRules:GetGameModeEntity().mychess[teamid][i..'_'..j].index
  4665. for slot=0,8 do
  4666. if EntIndexToHScript(uindex):GetItemInSlot(slot)~= nil then
  4667. local name = EntIndexToHScript(uindex):GetItemInSlot(slot):GetAbilityName()
  4668. if name ~= nil then
  4669. x:AddItemByName(name)
  4670. end
  4671. end
  4672. end
  4673. end
  4674. end
  4675. end
  4676. Timers:CreateTimer(0.1,function()
  4677. AddComboAbility(teamid)
  4678. end)
  4679. end
  4680. end
  4681.  
  4682. --为teamid场地镜像my_opp队伍的敌人棋手镜像
  4683. function MirrorChesser(teamid,opp_model,opp_effect,model_scale)
  4684. local mirror_chesser_position = Entities:FindByName(nil,"center"..(teamid-6)):GetAbsOrigin()
  4685. local mirror_chesser = CreateUnitByName("player_image",mirror_chesser_position+Vector(0,128*6.5,256),true,nil,nil,DOTA_TEAM_NEUTRALS)
  4686. mirror_chesser:SetForwardVector(Vector(0,-1,0))
  4687. if model_scale == nil then
  4688. model_scale = 1
  4689. end
  4690. mirror_chesser:SetModelScale(model_scale)
  4691. TeamId2Hero(teamid).mirror_chesser = mirror_chesser
  4692. --镜像棋手形象
  4693. if opp_model ~= nil then
  4694. local new_m = ChangeFlyingCourierModel(opp_model)
  4695.  
  4696. mirror_chesser:SetOriginalModel(new_m)
  4697. mirror_chesser:SetModel(new_m)
  4698. end
  4699.  
  4700. if opp_effect ~= nil and opp_effect ~= 'e000' then
  4701. AddAbilityAndSetLevel(mirror_chesser,opp_effect)
  4702. end
  4703.  
  4704. end
  4705.  
  4706. function LoadCloudEnemy(wave,team)
  4707. if GameRules:GetGameModeEntity().cloudlineup[''..wave] ~= nil then
  4708. local chesses = nil
  4709. for _,data in pairs(GameRules:GetGameModeEntity().cloudlineup[''..GameRules:GetGameModeEntity().battle_round]) do
  4710. chesses = json.decode(data)
  4711. end
  4712.  
  4713. --镜像棋手
  4714. if chesses['zhugong'] ~= nil then
  4715. local cloud_hero = string.split(chesses['zhugong'],'_')[1]
  4716. local cloud_hero_effect = string.split(chesses['zhugong'],'_')[2] or ''
  4717.  
  4718. local opp_model = GameRules:GetGameModeEntity().sm_hero_list[cloud_hero]
  4719.  
  4720. Timers:CreateTimer(1,function()
  4721. MirrorChesser(team,opp_model,cloud_hero_effect)
  4722. end)
  4723. end
  4724.  
  4725. if chesses ~= nil then
  4726. for i,vi in pairs(chesses.lineup) do
  4727. GameRules:GetGameModeEntity().unit[team][(9-vi.y)..'_'..(9-vi.x)] = 1
  4728. local x = CreateUnitByName(vi.chess,XY2Vector((9-vi.x),(9-vi.y),team),true,nil,nil,DOTA_TEAM_NEUTRALS)
  4729. x:SetForwardVector(Vector(0,-1,0))
  4730. x.y_x = (9-vi.y)..'_'..(9-vi.x)
  4731. x.y = (9-vi.y)
  4732. x.x = (9-vi.x)
  4733. x.team_id = 4
  4734. x.at_team_id = team
  4735. AddAbilityAndSetLevel(x,'root_self')
  4736. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  4737. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[team],x)
  4738. --复制物品
  4739. if vi.lastitem ~= nil then
  4740. for _,it in pairs(vi.lastitem) do
  4741. x:AddItemByName(it)
  4742. end
  4743. end
  4744. end
  4745. end
  4746. end
  4747. Timers:CreateTimer(0.5,function()
  4748. AddComboAbility(team)
  4749. end)
  4750. end
  4751. --游戏循环2.3——自走!
  4752. function ChessAI(u)
  4753. if u.aitimer == nil or Timers.timers[u.aitimer] == nil then
  4754. if u:GetUnitName() == 'chess_sf' then
  4755. AddAbilityAndSetLevel(u,"nevermore_necromastery")
  4756. u:FindModifierByName("modifier_nevermore_necromastery"):SetStackCount(12)
  4757. end
  4758. if u:GetUnitName() == 'chess_sf1' then
  4759. AddAbilityAndSetLevel(u,"nevermore_necromastery")
  4760. u:FindModifierByName("modifier_nevermore_necromastery"):SetStackCount(16)
  4761. end
  4762. if u:GetUnitName() == 'chess_sf11' then
  4763. AddAbilityAndSetLevel(u,"nevermore_necromastery")
  4764. u:FindModifierByName("modifier_nevermore_necromastery"):SetStackCount(20)
  4765. end
  4766. u.aitimer = Timers:CreateTimer(RandomFloat(0.5,2),function()
  4767. RemoveAbilityAndModifier(u,'jiaoxie_wudi')
  4768.  
  4769. if u == nil or u:IsNull() == true or u:IsAlive() == false or u.alreadywon == true then
  4770. return
  4771. end
  4772.  
  4773. local ai_delay = 0
  4774. if u:FindModifierByName('modifier_batrider_sticky_napalm') ~= nil then
  4775. ai_delay = u:FindModifierByName('modifier_batrider_sticky_napalm'):GetStackCount()
  4776. end
  4777.  
  4778. if u:IsStunned() == true then
  4779. return 1
  4780. end
  4781.  
  4782.  
  4783. --使用物品
  4784. local refresh_result = TriggerRefreshOrb(u)
  4785. if refresh_result ~= nil and refresh_result > 0 then
  4786. return refresh_result + ai_delay
  4787. end
  4788.  
  4789. local sheep_result = TriggerSheepStick(u)
  4790. if sheep_result ~= nil and sheep_result > 0 then
  4791. return sheep_result + ai_delay
  4792. end
  4793.  
  4794. local dagon_result = TriggerDagon(u)
  4795. if dagon_result ~= nil and dagon_result > 0 then
  4796. return dagon_result + ai_delay
  4797. end
  4798.  
  4799. local gua_result = TriggerFrogGua(u)
  4800. if gua_result ~= nil and gua_result > 0 then
  4801. return gua_result + ai_delay
  4802. end
  4803.  
  4804.  
  4805. --释放技能:11=新沙王,0=被动技能,1=单位目标,2=无目标,3=点目标,4=自己目标,5=近身单位目标,6=先知在地图边缘招树人,7=随机友军目标(嗜血术),8=随机周围空地目标(炸弹人),9=血量百分比最低的队友,10=等级最高的敌人(末日),11=沙王戳最远的能打到敌人的格子,12=小小投掷身边的敌人到最远的格子
  4806. local a = GameRules:GetGameModeEntity().chess_ability_list[u:GetUnitName()]
  4807. --决定是否要放技能
  4808. if a ~= nil and u:FindModifierByName('modifier_doom_bringer_doom') == nil and u:FindModifierByName('modifier_hexxed') == nil and u:FindModifierByName('modifier_shadow_shaman_voodoo') == nil and u:FindModifierByName('modifier_medusa_stone_gaze_stone') == nil and u:IsSilenced() == false then
  4809. if u:GetMana() >= 100 and GameRules:GetGameModeEntity().ability_behavior_list[a] ~= 0 and u:FindAbilityByName(a):IsCooldownReady() == true then
  4810. --有蓝,释放技能
  4811. if GameRules:GetGameModeEntity().ability_behavior_list[a] == 1 then
  4812. --单位目标
  4813. local unluckydog = FindUnluckyDog(u)
  4814. if unluckydog ~= nil then
  4815. local newOrder = {
  4816. UnitIndex = u:entindex(),
  4817. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4818. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4819. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4820. Position = nil, --Optional. Only used when targeting the ground
  4821. Queue = 0 --Optional. Used for queueing up abilities
  4822. }
  4823. ExecuteOrderFromTable(newOrder)
  4824. return RandomFloat(0.5,2) + ai_delay
  4825. end
  4826. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 2 then
  4827. --无目标
  4828. local newOrder = {
  4829. UnitIndex = u:entindex(),
  4830. OrderType = DOTA_UNIT_ORDER_CAST_NO_TARGET,
  4831. TargetIndex = nil, --Optional. Only used when targeting units
  4832. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4833. Position = nil, --Optional. Only used when targeting the ground
  4834. Queue = 0 --Optional. Used for queueing up abilities
  4835. }
  4836. ExecuteOrderFromTable(newOrder)
  4837. return RandomFloat(0.5,2) + ai_delay
  4838. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 4 then
  4839. --单位目标
  4840. local unluckydog = u
  4841. if unluckydog ~= nil then
  4842. local newOrder = {
  4843. UnitIndex = u:entindex(),
  4844. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4845. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4846. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4847. Position = nil, --Optional. Only used when targeting the ground
  4848. Queue = 0 --Optional. Used for queueing up abilities
  4849. }
  4850. ExecuteOrderFromTable(newOrder)
  4851. return RandomFloat(0.5,2) + ai_delay
  4852. end
  4853. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 5 then
  4854. --近身单位目标
  4855. local unluckydog = FindUnluckyDog190(u)
  4856. if unluckydog ~= nil then
  4857. local newOrder = {
  4858. UnitIndex = u:entindex(),
  4859. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4860. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4861. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4862. Position = nil, --Optional. Only used when targeting the ground
  4863. Queue = 0 --Optional. Used for queueing up abilities
  4864. }
  4865. ExecuteOrderFromTable(newOrder)
  4866. return RandomFloat(0.5,2) + ai_delay
  4867. end
  4868. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 6 then
  4869. --棋盘边缘的空格点目标,先知用
  4870. local unluckypoint = FindUnluckyPoint(u)
  4871. if unluckypoint ~= nil then
  4872. local newOrder = {
  4873. UnitIndex = u:entindex(),
  4874. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  4875. TargetIndex = nil, --Optional. Only used when targeting units
  4876. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4877. Position = unluckypoint, --Optional. Only used when targeting the ground
  4878. Queue = 0 --Optional. Used for queueing up abilities
  4879. }
  4880. ExecuteOrderFromTable(newOrder)
  4881. return RandomFloat(0.5,2) + ai_delay
  4882. end
  4883. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 7 then
  4884. --随机友军单位目标
  4885. local unluckydog = FindUnluckyDogRandomFriend(u)
  4886. if unluckydog ~= nil then
  4887. local newOrder = {
  4888. UnitIndex = u:entindex(),
  4889. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4890. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4891. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4892. Position = nil, --Optional. Only used when targeting the ground
  4893. Queue = 0 --Optional. Used for queueing up abilities
  4894. }
  4895. ExecuteOrderFromTable(newOrder)
  4896. return RandomFloat(0.5,2) + ai_delay
  4897. end
  4898. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 8 then
  4899. --点目标,随机一个空格子
  4900. local unluckypoint = FindEmptyGridAtUnit(u)--FindRandomEmptyGrid(u)
  4901. if unluckypoint ~= nil then
  4902. local newOrder = {
  4903. UnitIndex = u:entindex(),
  4904. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  4905. TargetIndex = nil, --Optional. Only used when targeting units
  4906. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4907. Position = unluckypoint, --Optional. Only used when targeting the ground
  4908. Queue = 0 --Optional. Used for queueing up abilities
  4909. }
  4910. ExecuteOrderFromTable(newOrder)
  4911. return RandomFloat(0.5,2) + ai_delay
  4912. end
  4913. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 9 then
  4914. --随机友军单位目标
  4915. local unluckydog = FindNeedHealFriend(u)
  4916. if unluckydog ~= nil then
  4917. local newOrder = {
  4918. UnitIndex = u:entindex(),
  4919. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4920. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4921. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4922. Position = nil, --Optional. Only used when targeting the ground
  4923. Queue = 0 --Optional. Used for queueing up abilities
  4924. }
  4925. ExecuteOrderFromTable(newOrder)
  4926. return RandomFloat(0.5,2) + ai_delay
  4927. end
  4928. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 10 then
  4929. --等级最高的敌方单位目标
  4930. local unluckydog = FindHighLevelUnluckyDog(u)
  4931. if unluckydog ~= nil then
  4932. local newOrder = {
  4933. UnitIndex = u:entindex(),
  4934. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  4935. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  4936. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4937. Position = nil, --Optional. Only used when targeting the ground
  4938. Queue = 0 --Optional. Used for queueing up abilities
  4939. }
  4940. ExecuteOrderFromTable(newOrder)
  4941. return RandomFloat(0.5,2) + ai_delay
  4942. end
  4943. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 11 then
  4944.  
  4945. local unluckypoint = FindFarthestCanAttackEnemyEmptyGrid(u)
  4946. if unluckypoint ~= nil then
  4947.  
  4948. --先占领目标格子
  4949. local target_x = Vector2X(unluckypoint,u.at_team_id or u.team_id)
  4950. local target_y = Vector2Y(unluckypoint,u.at_team_id or u.team_id)
  4951. GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][target_y..'_'..target_x] = 1
  4952. GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][u.y_x] = nil
  4953. u.y_x = target_y..'_'..target_x
  4954. u.y = target_y
  4955. u.x = target_x
  4956.  
  4957. --穿刺/波浪 过去!
  4958. local newOrder = {
  4959. UnitIndex = u:entindex(),
  4960. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  4961. TargetIndex = nil, --Optional. Only used when targeting units
  4962. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4963. Position = unluckypoint, --Optional. Only used when targeting the ground
  4964. Queue = 0 --Optional. Used for queueing up abilities
  4965. }
  4966. ExecuteOrderFromTable(newOrder)
  4967.  
  4968. local go_duration = (unluckypoint - u:GetAbsOrigin()):Length2D() / 1500
  4969.  
  4970. return RandomFloat(0.5,2) + go_duration + ai_delay
  4971. else
  4972. return RandomFloat(0.5,2)
  4973. end
  4974. elseif GameRules:GetGameModeEntity().ability_behavior_list[a] == 12 then
  4975.  
  4976. local unluckypoint = FindFarthestEmptyGrid(u)
  4977. if unluckypoint ~= nil then
  4978. local newOrder = {
  4979. UnitIndex = u:entindex(),
  4980. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  4981. TargetIndex = nil,--unluckydog:entindex(), --Optional. Only used when targeting units
  4982. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4983. Position = unluckypoint, --Optional. Only used when targeting the ground
  4984. Queue = 0 --Optional. Used for queueing up abilities
  4985. }
  4986. ExecuteOrderFromTable(newOrder)
  4987.  
  4988. return RandomFloat(0.5,2) + ai_delay
  4989. end
  4990. else
  4991. --点目标
  4992. local unluckydog = FindUnluckyDog(u)
  4993. if unluckydog ~= nil then
  4994. local newOrder = {
  4995. UnitIndex = u:entindex(),
  4996. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  4997. TargetIndex = nil,--unluckydog:entindex(), --Optional. Only used when targeting units
  4998. AbilityIndex = u:FindAbilityByName(a):entindex(), --Optional. Only used when casting abilities
  4999. Position = unluckydog:GetAbsOrigin(), --Optional. Only used when targeting the ground
  5000. Queue = 0 --Optional. Used for queueing up abilities
  5001. }
  5002. ExecuteOrderFromTable(newOrder)
  5003.  
  5004. --光法 风行 蓄力
  5005. if a=="keeper_of_the_light_illuminate" or a=="windrunner_powershot" then
  5006. return 3.5 + ai_delay
  5007. else
  5008. return RandomFloat(0.5,2) + ai_delay
  5009. end
  5010. end
  5011. end
  5012. end
  5013. end
  5014.  
  5015. --决定是否要攻击
  5016. local attack_result = FindAClosestEnemyAndAttack(u)
  5017. if attack_result ~= nil and attack_result > 0 then
  5018. return attack_result + ai_delay
  5019. end
  5020.  
  5021. --不攻击就走动
  5022. if u.attack_target == nil then
  5023.  
  5024. local find_ok = nil
  5025. local try_count = 0
  5026.  
  5027. --寻路
  5028. if u:FindAbilityByName('is_assassin') ~= nil then
  5029. find_ok = FindFarthestUnluckyDogAvailablePosition(u)
  5030. else
  5031. find_ok = FindNextSkipPosition(u)
  5032. end
  5033.  
  5034. if find_ok ~= nil then
  5035. --走!
  5036. local x = Vector2X(find_ok,u.at_team_id or u.team_id)
  5037. local y = Vector2Y(find_ok,u.at_team_id or u.team_id)
  5038. local xx = u.x
  5039. local yy = u.y
  5040. GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][y..'_'..x] = 1
  5041. u:SetForwardVector((find_ok - u:GetAbsOrigin()):Normalized())
  5042. BlinkChessX({p=find_ok,caster=u})
  5043. u.y_x = y..'_'..x
  5044. u.y = y
  5045. u.x = x
  5046. GameRules:GetGameModeEntity().unit[u.at_team_id or u.team_id][yy..'_'..xx] = nil
  5047.  
  5048. --计算需要跳多久
  5049. local jump_time = (find_ok - u:GetAbsOrigin()):Length2D() / 1000
  5050.  
  5051. return RandomFloat(jump_time+0.5,jump_time+1) + ai_delay
  5052.  
  5053. end
  5054. return RandomFloat(0.5,1) + ai_delay
  5055. else
  5056. return 1 + ai_delay
  5057. end
  5058. -- end
  5059. return 1 + ai_delay
  5060. end)
  5061. end
  5062. end
  5063. --寻找离我最近的能攻击到指定敌人的空格子
  5064. function FindClosestEmptyGridToAttackUnluckydog(u,dog)
  5065. local team = u.at_team_id or u.team_id
  5066. local attack_range = u:Script_GetAttackRange() or 210
  5067. local closest_range = 9999
  5068. local closet_position = nil
  5069. -- prt('dog.x/dog.y='..dog.x..'/'..dog.y)
  5070. local dog_position = XY2Vector(dog.x,dog.y,team)
  5071. for x=1,8 do
  5072. for y=1,8 do
  5073. local pos = XY2Vector(x,y,team)
  5074. if (pos-dog_position):Length2D() < attack_range - dog:GetHullRadius() then
  5075. --能攻击到dog
  5076. local range = (pos - XY2Vector(u.x,u.y,team)):Length2D()
  5077. if IsEmptyGrid(team,x,y) == true and range < closest_range then
  5078. --离我最近的空格子
  5079. closest_range = range
  5080. closet_position = pos
  5081. end
  5082. end
  5083. end
  5084. end
  5085.  
  5086. local pos = FindPath(XY2Vector(u.x,u.y,team),closet_position,team)
  5087.  
  5088. return pos
  5089. end
  5090. --寻找我的下一跳位置
  5091. function FindNextSkipPosition(u)
  5092. local team_id = u.at_team_id or u.team_id
  5093. local skip_postion = nil
  5094. local length2d = 99999
  5095. local pos1 = XY2Vector(u.x,u.y,team_id)
  5096. for x=1,8 do
  5097. for y=1,8 do
  5098. local pos2 = XY2Vector(x,y,team_id)
  5099. if IsGridCanAttackEnemy(x,y,u) == true then
  5100. local next_skip = IsGridCanReach(x,y,u)
  5101. if next_skip ~= nil and (pos2-pos1):Length2D() < length2d then
  5102. skip_postion = next_skip
  5103. length2d = (pos2-pos1):Length2D()
  5104. end
  5105. end
  5106. end
  5107. end
  5108. return skip_postion
  5109. end
  5110. function IsGridCanAttackEnemy(x,y,u)
  5111. local team_id = u.at_team_id or u.team_id
  5112. local attack_range = u:Script_GetAttackRange() or 210
  5113. --遍历所有单位
  5114. for _,enemy in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5115. if enemy.team_id ~= u.team_id and enemy:IsInvisible() == false and (XY2Vector(x,y,team_id) - enemy:GetAbsOrigin()):Length2D() < attack_range - enemy:GetHullRadius() then
  5116. return true
  5117. end
  5118. end
  5119. return false
  5120. end
  5121. function IsGridCanReach(x,y,u)
  5122. local team_id = u.at_team_id or u.team_id
  5123. local pos1 = XY2Vector(u.x,u.y,team_id)
  5124. local pos2 = XY2Vector(x,y,team_id)
  5125. local pos = FindPath(pos1,pos2,team_id)
  5126. if pos ~= nil then
  5127. return pos
  5128. else
  5129. return nil
  5130. end
  5131. end
  5132.  
  5133.  
  5134. function IsEmptyGrid(team,x,y)
  5135. if GameRules:GetGameModeEntity().unit[team][y..'_'..x] == nil then
  5136. return true
  5137. else
  5138. return false
  5139. end
  5140. end
  5141.  
  5142. function FindFarthestUnluckyDogAvailablePosition(u)
  5143. local team_id = u.at_team_id or u.team_id
  5144. if u.team_id ~= 4 then
  5145. if RandomInt(0,100) > 50 then
  5146. for j=8,1,-1 do
  5147. for i=8,1,-1 do
  5148. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5149. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5150. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < u:Script_GetAttackRange() - unit:GetHullRadius() then
  5151. return XY2Vector(i,j,team_id)
  5152. end
  5153. end
  5154. end
  5155. end
  5156. end
  5157. else
  5158. for j=8,1,-1 do
  5159. for i=1,8 do
  5160. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5161. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5162. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < u:Script_GetAttackRange() - unit:GetHullRadius() then
  5163. return XY2Vector(i,j,team_id)
  5164. end
  5165. end
  5166. end
  5167. end
  5168. end
  5169. end
  5170. else
  5171. if RandomInt(0,100) > 50 then
  5172. for j=1,8 do
  5173. for i=1,8 do
  5174. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5175. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5176. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < u:Script_GetAttackRange() - unit:GetHullRadius() then
  5177. return XY2Vector(i,j,team_id)
  5178. end
  5179. end
  5180. end
  5181. end
  5182. end
  5183. else
  5184. for j=1,8 do
  5185. for i=8,1,-1 do
  5186. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5187. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5188. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < u:Script_GetAttackRange() - unit:GetHullRadius() then
  5189. return XY2Vector(i,j,team_id)
  5190. end
  5191. end
  5192. end
  5193. end
  5194. end
  5195. end
  5196. end
  5197. return nil
  5198. end
  5199. function FindClosestUnluckyDogAvailablePosition(u)
  5200. local team_id = u.at_team_id or u.team_id
  5201. if u.team_id == 4 then
  5202. for j=8,1,-1 do
  5203. for i=8,1,-1 do
  5204. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5205. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5206. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < 192 then
  5207. return XY2Vector(i,j,team_id)
  5208. end
  5209. end
  5210. end
  5211. end
  5212. end
  5213. else
  5214. for j=1,8 do
  5215. for i=1,8 do
  5216. if GameRules:GetGameModeEntity().unit[team_id][j..'_'..i] == nil then
  5217. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[team_id]) do
  5218. if unit.team_id ~= u.team_id and (XY2Vector(i,j,team_id) - XY2Vector(unit.x,unit.y,team_id)):Length2D() < 192 then
  5219. return XY2Vector(i,j,team_id)
  5220. end
  5221. end
  5222. end
  5223. end
  5224. end
  5225. end
  5226.  
  5227. return nil
  5228. end
  5229.  
  5230. function FindEmptyGridAtUnit(u)
  5231. local team_id = u.at_team_id or u.team_id
  5232.  
  5233. --优先选取面前的空格子
  5234. local forward_v = u:GetAbsOrigin() + u:GetForwardVector():Normalized()*128
  5235. local forward_x = Vector2X(forward_v,team_id)
  5236. local forward_y = Vector2Y(forward_v,team_id)
  5237. if IsBlocked(forward_x,forward_y,team_id) == false then
  5238. return XY2Vector(forward_x,forward_y,team_id)
  5239. end
  5240.  
  5241. --遍历身边的格子
  5242. for x = -1,1 do
  5243. for y = -1,1 do
  5244. if IsBlocked(u.x+x,u.y+y,team_id) == false then
  5245. return XY2Vector(u.x+x,u.y+y,team_id)
  5246. end
  5247. end
  5248. end
  5249.  
  5250. for x = -2,2 do
  5251. for y = -2,2 do
  5252. if IsBlocked(u.x+x,u.y+y,team_id) == false then
  5253. return XY2Vector(u.x+x,u.y+y,team_id)
  5254. end
  5255. end
  5256. end
  5257.  
  5258. return nil
  5259. end
  5260.  
  5261. --通用方法之寻找一个倒霉蛋
  5262. function FindUnluckyDog(u)
  5263. local unluckydog = nil
  5264. local try_count = 0
  5265. while unluckydog == nil and try_count < 10 do
  5266. local uu = GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id][RandomInt(1,table.maxn(GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]))]
  5267. if uu ~= nil and uu:IsNull() == false and uu:IsAlive() == true and uu.team_id ~= u.team_id then
  5268. unluckydog = uu
  5269. end
  5270. try_count = try_count + 1
  5271. end
  5272. return unluckydog
  5273. end
  5274. function FindHighLevelUnluckyDog(u)
  5275. local unluckydog = nil
  5276. local max_level = 0
  5277. local team = u.at_team_id or u.team_id
  5278. local my_pos = XY2Vector(u.x,u.y,team)
  5279.  
  5280. if RandomInt(1,100)<30 then
  5281. --30%概率随机找敌人
  5282. return FindUnluckyDogRandom(u)
  5283. end
  5284.  
  5285. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]) do
  5286. local lv = unit:GetLevel()
  5287. if unit:GetMaxMana() <= 0 then
  5288. lv = 1
  5289. end
  5290. local a = GameRules:GetGameModeEntity().chess_ability_list[unit:GetUnitName()]
  5291. local beh = GameRules:GetGameModeEntity().ability_behavior_list[a]
  5292.  
  5293. if lv > max_level and unit.team_id ~= u.team_id and unit:FindModifierByName("modifier_doom_bringer_doom") == nil and beh ~= 0 then
  5294. unluckydog = unit
  5295. max_level = lv
  5296. end
  5297. end
  5298. return unluckydog
  5299. end
  5300. function FindUnluckyDogRandom(u)
  5301. local unluckydog = nil
  5302. local team = u.at_team_id or u.team_id
  5303. local my_pos = XY2Vector(u.x,u.y,team)
  5304. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]) do
  5305. local pos = unit:GetAbsOrigin()
  5306. if unit.team_id ~= u.team_id and unit:IsInvisible() == false then
  5307. unluckydog = unit
  5308. end
  5309. end
  5310. return unluckydog
  5311. end
  5312. function FindUnluckyDogClosest(u)
  5313. local unluckydog = nil
  5314. local length2d = 99999
  5315. local team = u.at_team_id or u.team_id
  5316. local my_pos = XY2Vector(u.x,u.y,team)
  5317. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]) do
  5318. local pos = unit:GetAbsOrigin()
  5319. if (my_pos - pos):Length2D() < length2d and unit.team_id ~= u.team_id and unit:IsInvisible() == false then
  5320. unluckydog = unit
  5321. length2d = (my_pos - pos):Length2D()
  5322. end
  5323. end
  5324. return unluckydog
  5325. end
  5326. function FindUnluckyDogFarthest(u)
  5327. local unluckydog = nil
  5328. local length2d = 0
  5329. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]) do
  5330. if (u:GetAbsOrigin() - unit:GetAbsOrigin()):Length2D() > length2d and unit.team_id ~= u.team_id then
  5331. unluckydog = unit
  5332. length2d = (u:GetAbsOrigin() - unit:GetAbsOrigin()):Length2D()
  5333. end
  5334. end
  5335. return unluckydog
  5336. end
  5337. function FindUnluckyDog190(u)
  5338. local unluckydog = nil
  5339. local try_count = 0
  5340. while unluckydog == nil and try_count < 10 do
  5341. local uu = GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id][RandomInt(1,table.maxn(GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]))]
  5342. if uu ~= nil and uu:IsNull() == false and uu:IsAlive() == true and uu.team_id ~= u.team_id and (uu:GetAbsOrigin()-u:GetAbsOrigin()):Length2D() <= 205 then
  5343. unluckydog = uu
  5344. end
  5345. try_count = try_count + 1
  5346. end
  5347. return unluckydog
  5348. end
  5349. function FindUnluckyDogRandomFriend(u)
  5350. local unluckydog = nil
  5351. local try_count = 0
  5352. while unluckydog == nil and try_count < 30 do
  5353. local uu = GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id][RandomInt(1,table.maxn(GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]))]
  5354. if uu ~= nil and uu:IsNull() == false and uu:IsAlive() == true and uu.team_id == u.team_id and uu:FindModifierByName("modifier_ogre_magi_bloodlust") == nil then
  5355. unluckydog = uu
  5356. end
  5357. try_count = try_count + 1
  5358. end
  5359. return unluckydog
  5360. end
  5361. function FindNeedHealFriend(u)
  5362. local unluckydog = u
  5363. local hp_per = 100
  5364. for _,unit in pairs (GameRules:GetGameModeEntity().to_be_destory_list[u.at_team_id or u.team_id]) do
  5365. if unit.team_id == u.team_id then
  5366. local hp = unit:GetHealth()
  5367. local hp_max = unit:GetMaxHealth()
  5368. local per = 1.0*hp/hp_max*100
  5369.  
  5370. if per < hp_per then
  5371. unluckydog = unit
  5372. hp_per = per
  5373. end
  5374. end
  5375. end
  5376. return unluckydog
  5377. end
  5378.  
  5379. --沙王用:寻找一个最远的能打到敌人的离我最远的格子,(戳过去!)
  5380. function FindFarthestCanAttackEnemyEmptyGrid(u)
  5381. local team_id = u.at_team_id or u.team_id
  5382. local length2d = 0
  5383. local pos1 = u:GetAbsOrigin()
  5384. local skip_postion = nil
  5385.  
  5386. for x=1,8 do
  5387. for y=1,8 do
  5388. local pos2 = XY2Vector(x,y,team_id)
  5389. if IsEmptyGrid(team_id,x,y) and IsGridCanAttackEnemy(x,y,u) == true then
  5390. if (pos2-pos1):Length2D() > length2d then
  5391. skip_postion = pos2
  5392. length2d = (pos2-pos1):Length2D()
  5393. end
  5394. end
  5395. end
  5396. end
  5397.  
  5398. return skip_postion
  5399. end
  5400.  
  5401. function FindUnluckyPoint(u)
  5402. local p = nil
  5403. local try_count = 0
  5404. local team_id = u.at_team_id or u.team_id
  5405. local x = nil
  5406. local y = nil
  5407. while p==nil and try_count<100 do
  5408. if RandomInt(0,100)>50 then
  5409. if RandomInt(0,100)>50 then
  5410. x = 1
  5411. y = RandomInt(1,8)
  5412. else
  5413. x = 8
  5414. y = RandomInt(1,8)
  5415. end
  5416. else
  5417. if RandomInt(0,100)>50 then
  5418. y = 1
  5419. x = RandomInt(1,8)
  5420. else
  5421. y = 8
  5422. x = RandomInt(1,8)
  5423. end
  5424. end
  5425. if GameRules:GetGameModeEntity().unit[team_id][y..'_'..x] == nil then
  5426. if (XY2Vector(x,y,team_id) - u:GetAbsOrigin()):Length2D() > 256 then
  5427. p = XY2Vector(x,y,team_id)
  5428. end
  5429. end
  5430.  
  5431. try_count = try_count + 1
  5432. end
  5433. return p
  5434. end
  5435.  
  5436. function FindRandomEmptyGrid(u)
  5437. local p = nil
  5438. local try_count = 0
  5439. local team_id = u.at_team_id or u.team_id
  5440. local x = nil
  5441. local y = nil
  5442. while p==nil and try_count<100 do
  5443. x = RandomInt(1,8)
  5444. y = RandomInt(1,8)
  5445. if GameRules:GetGameModeEntity().unit[team_id][y..'_'..x] == nil then
  5446. if (XY2Vector(x,y,team_id) - u:GetAbsOrigin()):Length2D() < 200 then
  5447. p = XY2Vector(x,y,team_id)
  5448. end
  5449. end
  5450. try_count = try_count + 1
  5451. end
  5452. return p
  5453. end
  5454.  
  5455. --通用方法之坐标系转换
  5456. function HandIndex2Vector(team_id,index)
  5457. return GameRules:GetGameModeEntity().base_vector[team_id] + Vector((index-1)*128,-2*128,256)
  5458. end
  5459. function CheckTargetPosInHand(p,team_id)
  5460. if Vector2X(p,team_id) >= 1 and Vector2X(p,team_id) <= 8 and Vector2Y(p,team_id) == -1 and CheckEmptyHandSlot(team_id,Vector2X(p,team_id)) == true then
  5461. return Vector2X(p,team_id)
  5462. else
  5463. return false
  5464. end
  5465. end
  5466. function XY2Vector(x,y,team_id)
  5467. return GameRules:GetGameModeEntity().base_vector[team_id] + Vector((x-1)*128,(y-1)*128,256)
  5468. end
  5469. function Vector2X(v,team_id)
  5470. local relative_position = v - GameRules:GetGameModeEntity().base_vector[team_id]
  5471. local x = math.floor((relative_position.x+192)/128)
  5472. -- if x < 1 or x > 8 then
  5473. -- x = -1
  5474. -- end
  5475. return x
  5476. end
  5477. function Vector2Y(v,team_id)
  5478. local relative_position = v - GameRules:GetGameModeEntity().base_vector[team_id]
  5479. local y = math.floor((relative_position.y+192)/128)
  5480. -- if y < 1 or y > 8 then
  5481. -- y = -1
  5482. -- end
  5483. return y
  5484. end
  5485. function CenterVector(team_id)
  5486. return GameRules:GetGameModeEntity().base_vector[team_id] + Vector(3.5*128,2.5*128,0)
  5487. end
  5488. --通用方法之位置判断
  5489. function IsInMap(x,y)
  5490. if x<1 or x>8 or y<1 or y>4 then
  5491. return false
  5492. else
  5493. return true
  5494. end
  5495. end
  5496. function IsInAttackArea(x,y)
  5497. if x>=1 and x<=8 and y>4 and y<=8 then
  5498. return true
  5499. else
  5500. return false
  5501. end
  5502. end
  5503. function GetClosestAvailableArea(x,y,team_id)
  5504. local returnx = x
  5505. local returny = y
  5506. if y>4 then
  5507. returny = 4
  5508. elseif y<1 then
  5509. returny = 1
  5510. end
  5511. if x>8 then
  5512. returnx = 8
  5513. elseif x<1 then
  5514. returnx = 1
  5515. end
  5516. return {x = returnx, y =returny}
  5517. end
  5518. function GetClosestEmptyArea(x,y,team_id)
  5519. for i=-1,1 do
  5520. for j=-1,1 do
  5521. if IsBlocked(x+i,y+j,team_id) == false then
  5522. return {x = x+i, y = y+j}
  5523. end
  5524. end
  5525. end
  5526. return nil
  5527. end
  5528. function IsBlocked(x,y,team_id)
  5529. if IsInMap(x,y) == false then
  5530. return "map"
  5531. end
  5532. if GameRules:GetGameModeEntity().unit[team_id][y..'_'..x] ~= nil then
  5533. return "unit"
  5534. end
  5535. return false
  5536. end
  5537. --自制的tk技能
  5538. function RandomMissile(keys)
  5539. local caster = keys.caster
  5540. local us = FindUnitsInRadius(caster.team_id,caster:GetAbsOrigin(),nil,600,DOTA_UNIT_TARGET_TEAM_ENEMY,DOTA_UNIT_TARGET_ALL,DOTA_UNIT_TARGET_FLAG_NOT_ANCIENTS+DOTA_UNIT_TARGET_FLAG_FOW_VISIBLE+DOTA_UNIT_TARGET_FLAG_NO_INVIS,FIND_CLOSEST,false)
  5541.  
  5542. local unluckydog = us[RandomInt(1,table.maxn(us))]
  5543. local u = CreateUnitByName("invisible_unit", caster:GetAbsOrigin() ,false,nil,nil, caster.team_id)
  5544. u:AddAbility('a108_missile')
  5545. u:FindAbilityByName('a108_missile'):SetLevel(1)
  5546.  
  5547. if unluckydog == nil then
  5548. return
  5549. end
  5550.  
  5551. Timers:CreateTimer(0.1,function()
  5552. local newOrder = {
  5553. UnitIndex = u:entindex(),
  5554. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  5555. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  5556. AbilityIndex = u:FindAbilityByName("a108_missile"):entindex(), --Optional. Only used when casting abilities
  5557. Position = nil, --Optional. Only used when targeting the ground
  5558. Queue = 0 --Optional. Used for queueing up abilities
  5559. }
  5560. ExecuteOrderFromTable(newOrder)
  5561. Timers:CreateTimer(5,function()
  5562. u:ForceKill(false)
  5563. end)
  5564. end)
  5565.  
  5566. Timers:CreateTimer(0.3,function()
  5567. if caster == nil or caster:IsNull() == true or caster:IsAlive() == false then
  5568. return
  5569. end
  5570. unluckydog = us[RandomInt(1,table.maxn(us))]
  5571. local v = CreateUnitByName("invisible_unit", caster:GetAbsOrigin() ,false,nil,nil, caster.team_id)
  5572. v:AddAbility('a108_missile')
  5573. v:FindAbilityByName('a108_missile'):SetLevel(1)
  5574.  
  5575. Timers:CreateTimer(0.1,function()
  5576. local newOrder = {
  5577. UnitIndex = v:entindex(),
  5578. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  5579. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  5580. AbilityIndex = v:FindAbilityByName("a108_missile"):entindex(), --Optional. Only used when casting abilities
  5581. Position = nil, --Optional. Only used when targeting the ground
  5582. Queue = 0 --Optional. Used for queueing up abilities
  5583. }
  5584. ExecuteOrderFromTable(newOrder)
  5585. Timers:CreateTimer(5,function()
  5586. v:ForceKill(false)
  5587. end)
  5588. end)
  5589. end)
  5590. Timers:CreateTimer(0.5,function()
  5591. if caster == nil or caster:IsNull() == true or caster:IsAlive() == false then
  5592. return
  5593. end
  5594. unluckydog = us[RandomInt(1,table.maxn(us))]
  5595. local v = CreateUnitByName("invisible_unit", caster:GetAbsOrigin() ,false,nil,nil, caster.team_id)
  5596. v:AddAbility('a108_missile')
  5597. v:FindAbilityByName('a108_missile'):SetLevel(1)
  5598.  
  5599. Timers:CreateTimer(0.1,function()
  5600. local newOrder = {
  5601. UnitIndex = v:entindex(),
  5602. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  5603. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  5604. AbilityIndex = v:FindAbilityByName("a108_missile"):entindex(), --Optional. Only used when casting abilities
  5605. Position = nil, --Optional. Only used when targeting the ground
  5606. Queue = 0 --Optional. Used for queueing up abilities
  5607. }
  5608. ExecuteOrderFromTable(newOrder)
  5609. Timers:CreateTimer(5,function()
  5610. v:ForceKill(false)
  5611. end)
  5612. end)
  5613. end)
  5614. end
  5615. --通用方法之添加技能
  5616. function AddAbilityAndSetLevel(u,a,l)
  5617. if l == nil then
  5618. l = 1
  5619. end
  5620. if u == nil or u:IsNull() == true then
  5621. return
  5622. end
  5623. if u:FindAbilityByName(a) == nil then
  5624. u:AddAbility(a)
  5625. u:FindAbilityByName(a):SetLevel(l)
  5626. else
  5627. u:FindAbilityByName(a):SetLevel(l)
  5628. end
  5629. end
  5630. function RemoveAbilityAndModifier(u,a)
  5631. if u == nil or u:IsNull() == true then
  5632. return
  5633. end
  5634. if u:FindAbilityByName(a) ~= nil then
  5635. u:RemoveAbility(a)
  5636. u:RemoveModifierByName('modifier_'..a)
  5637. end
  5638. end
  5639. function RemoveFromToBeDestroyList(u)
  5640. for p,q in pairs(GameRules:GetGameModeEntity().to_be_destory_list[(u.at_team_id or u.team_id)]) do
  5641. if q:entindex() == u:entindex() then
  5642. table.remove(GameRules:GetGameModeEntity().to_be_destory_list[(u.at_team_id or u.team_id)],p)
  5643. end
  5644. end
  5645. end
  5646. function SetLordAbilityEnable(hero,b)
  5647. if hero.lord_ability ~= nil and hero:FindAbilityByName(hero.lord_ability) ~= nil then
  5648. hero:FindAbilityByName(hero.lord_ability):SetActivated(b)
  5649. end
  5650. end
  5651. function prt(t)
  5652. GameRules:SendCustomMessage(''..t,0,0)
  5653. end
  5654. function unit2text(u)
  5655. local id1 = u.team_id or 'X'
  5656. local id2 = u.at_team_id or 'X'
  5657. return ''..id1..'-'..id2..'的'..u:GetUnitName()
  5658. end
  5659. function AttackHeal(keys)
  5660. local target = keys.attacker
  5661. local damage = keys.damage
  5662. local per = keys.per
  5663. target:Heal(damage*per, target)
  5664. end
  5665. function AddMaxHPPer(keys)
  5666. local caster = keys.caster
  5667. local per = keys.per
  5668.  
  5669. local hp = caster:GetMaxHealth()
  5670. local hp_per = caster:GetHealth()/caster:GetMaxHealth()
  5671. local hp = hp * ((100 + tonumber(per))/100)
  5672. caster:SetBaseMaxHealth(hp)
  5673. caster:SetMaxHealth(hp)
  5674. caster:SetHealth(hp*hp_per)
  5675. end
  5676. function AddMaxHP(keys)
  5677. local caster = keys.caster
  5678. if caster:IsAncient() == true then
  5679. return
  5680. end
  5681. local hp = keys.hp
  5682. local hp1 = caster:GetMaxHealth()
  5683. local hp_per = caster:GetHealth()/caster:GetMaxHealth()
  5684. local hp1 = hp1 + tonumber(hp)
  5685. caster:SetBaseMaxHealth(hp1)
  5686. caster:SetMaxHealth(hp1)
  5687. caster:SetHealth(hp1*hp_per)
  5688. end
  5689. function UnAddMaxHP(keys)
  5690. local caster = keys.caster
  5691. if caster:IsAncient() == true then
  5692. return
  5693. end
  5694. local hp = keys.hp
  5695. local hp1 = caster:GetMaxHealth()
  5696. local hp_per = caster:GetHealth()/caster:GetMaxHealth()
  5697. local hp1 = hp1 - tonumber(hp)
  5698. caster:SetBaseMaxHealth(hp1)
  5699. caster:SetMaxHealth(hp1)
  5700. caster:SetHealth(hp1*hp_per)
  5701. end
  5702. function Bump(keys)
  5703. local p = keys.target_points[1]
  5704. local caster = keys.caster
  5705. local team_id = caster.at_team_id or caster.team_id
  5706. local position = p
  5707.  
  5708. GameRules:GetGameModeEntity().unit[team_id][caster.y_x] = nil
  5709. GameRules:GetGameModeEntity().unit[team_id][Vector2Y(position,team_id)..'_'..Vector2X(position,team_id)] = 1
  5710. InvisibleUnitCast({
  5711. caster = caster,
  5712. ability = 'sandking_burrowstrike',
  5713. level = 1,
  5714. unluckydog = nil,
  5715. position = position,
  5716. })
  5717.  
  5718. Timers:CreateTimer(0.3,function()
  5719. caster:SetAbsOrigin(position)
  5720. end)
  5721. end
  5722. --辅助功能——创建隐藏单位施法
  5723. function InvisibleUnitCast(keys)
  5724. local shiban = keys.caster
  5725. local shiban_ability = keys.ability
  5726. local ability_level = keys.level
  5727. local unluckydog = keys.unluckydog
  5728. local position = keys.position
  5729.  
  5730. local uu = CreateUnitByName("invisible_unit", shiban:GetAbsOrigin() ,false,nil,nil, shiban:GetTeam())
  5731. uu.ftd = 2009
  5732. uu:SetOwner(shiban)
  5733.  
  5734. uu:AddAbility(shiban_ability)
  5735. uu:FindAbilityByName(shiban_ability):SetLevel(ability_level)
  5736. Timers:CreateTimer(0.05,function()
  5737. if uu:FindAbilityByName(shiban_ability):GetBehavior() == DOTA_ABILITY_BEHAVIOR_UNIT_TARGET then
  5738. local newOrder = {
  5739. UnitIndex = uu:entindex(),
  5740. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  5741. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  5742. AbilityIndex = uu:FindAbilityByName(shiban_ability):entindex(), --Optional. Only used when casting abilities
  5743. Position = nil, --Optional. Only used when targeting the ground
  5744. Queue = 0 --Optional. Used for queueing up abilities
  5745. }
  5746. ExecuteOrderFromTable(newOrder)
  5747. elseif uu:FindAbilityByName(shiban_ability):GetBehavior() == DOTA_ABILITY_BEHAVIOR_NO_TARGET then
  5748. local newOrder = {
  5749. UnitIndex = uu:entindex(),
  5750. OrderType = DOTA_UNIT_ORDER_CAST_NO_TARGET,
  5751. TargetIndex = unluckydog:entindex(), --Optional. Only used when targeting units
  5752. AbilityIndex = uu:FindAbilityByName(shiban_ability):entindex(), --Optional. Only used when casting abilities
  5753. Position = nil, --Optional. Only used when targeting the ground
  5754. Queue = 0 --Optional. Used for queueing up abilities
  5755. }
  5756. ExecuteOrderFromTable(newOrder)
  5757. else
  5758. local newOrder = {
  5759. UnitIndex = uu:entindex(),
  5760. OrderType = DOTA_UNIT_ORDER_CAST_POSITION,
  5761. TargetIndex = nil, --Optional. Only used when targeting units
  5762. AbilityIndex = uu:FindAbilityByName(shiban_ability):entindex(), --Optional. Only used when casting abilities
  5763. Position = position, --Optional. Only used when targeting the ground
  5764. Queue = 0 --Optional. Used for queueing up abilities
  5765. }
  5766. ExecuteOrderFromTable(newOrder)
  5767. end
  5768. Timers:CreateTimer(10,function()
  5769. uu:ForceKill(false)
  5770. uu:Destroy()
  5771. end)
  5772. end)
  5773. end
  5774. function PlayerId2Hero(id)
  5775. return GameRules:GetGameModeEntity().playerid2hero[id]
  5776. end
  5777. function TeamId2Hero(id)
  5778. return GameRules:GetGameModeEntity().teamid2hero[id]
  5779. end
  5780. function GetMaxChessCount(team)
  5781. if TeamId2Hero(team) ~= nil then
  5782. return TeamId2Hero(team):GetLevel()
  5783. else
  5784. return 1
  5785. end
  5786. end
  5787. function GetStat(id,prop)
  5788. local hero = PlayerId2Hero(id)
  5789. if hero == nil or hero.steam_id == nil then
  5790. return nil
  5791. end
  5792. return GameRules:GetGameModeEntity().stat_info[hero.steam_id][prop]
  5793. end
  5794. function SetStat(id,prop,v)
  5795. local hero = PlayerId2Hero(id)
  5796. if hero == nil or hero.steam_id == nil then
  5797. return
  5798. end
  5799. GameRules:GetGameModeEntity().stat_info[hero.steam_id][prop] = v
  5800. end
  5801. function AddStat(id,prop)
  5802. local hero = PlayerId2Hero(id)
  5803. if hero == nil or hero.steam_id == nil then
  5804. return
  5805. end
  5806. GameRules:GetGameModeEntity().stat_info[hero.steam_id][prop] = GameRules:GetGameModeEntity().stat_info[hero.steam_id][prop] + 1
  5807. if prop == 'kills' then
  5808. PlayerResource:IncrementLastHits(id)
  5809. end
  5810. if prop == 'deaths' then
  5811. PlayerResource:IncrementDenies(id)
  5812. end
  5813.  
  5814. if prop == 'win_round' then
  5815. PlayerResource:IncrementKills(id,1)
  5816. end
  5817. if prop == 'lose_round' then
  5818. PlayerResource:IncrementDeaths(id,1)
  5819. end
  5820. if prop == 'draw_round' then
  5821. PlayerResource:IncrementAssists(id,1)
  5822. end
  5823. end
  5824.  
  5825.  
  5826. function StartGame()
  5827. --5秒后开始游戏
  5828. Timers:CreateTimer(5,function()
  5829. if PlayerResource:GetPlayerCount() == 1 then
  5830. prt('tips_1_player')
  5831. else
  5832. prt('GAME START!')
  5833. end
  5834.  
  5835. --初始化棋子库
  5836. InitChessPool(PlayerResource:GetPlayerCount())
  5837.  
  5838. GameRules:GetGameModeEntity().START_TIME = GameRules:GetGameTime()
  5839. StartAPrepareRound()
  5840. end)
  5841. end
  5842. function GameOver()
  5843. GameRules:GetGameModeEntity().is_game_ended = true
  5844. if GameRules:GetGameModeEntity().ended == false then
  5845. CustomNetTables:SetTableValue( "dac_table", "curtain_tips", { text = "#gameover", hehe = RandomInt(1,1000)})
  5846. CustomNetTables:SetTableValue( "dac_table", "game_over", { text = "#gameover", hehe = RandomInt(1,1000)})
  5847.  
  5848. local win_team = 2
  5849. if GameRules:GetGameModeEntity().good_castle.hp > 0 then
  5850. win_team = 2
  5851. end
  5852. if GameRules:GetGameModeEntity().bad_castle.hp > 0 then
  5853. win_team = 3
  5854. end
  5855.  
  5856. for i,v in pairs(GameRules:GetGameModeEntity().hero) do
  5857. if v.team == win_team then
  5858. v:AddAbility('gameover_win')
  5859. v:FindAbilityByName('gameover_win'):SetLevel(1)
  5860. else
  5861. v:AddAbility('gameover_lose')
  5862. v:FindAbilityByName('gameover_lose'):SetLevel(1)
  5863. end
  5864. end
  5865.  
  5866. GameRules:GetGameModeEntity().ended = true
  5867. EmitGlobalSound("Loot_Drop_Stinger_Arcana")
  5868.  
  5869. GameRules:SendCustomMessage('gameover',0,0)
  5870.  
  5871. Timers:CreateTimer(2,function()
  5872. CalScore()
  5873. end)
  5874. end
  5875. end
  5876.  
  5877.  
  5878. --通过聊天输入执行命令
  5879. function DAC:OnPlayerChat(keys)
  5880. local player = GameRules:GetGameModeEntity().userid2player[keys.userid]
  5881. local hero = EntIndexToHScript(player):GetAssignedHero()
  5882. local heroindex = hero:GetEntityIndex()
  5883. local team = hero:GetTeam()
  5884. local tokens = string.split(string.lower(keys.text))
  5885.  
  5886. if (
  5887. tokens[1] == "-lvlup" or
  5888. tokens[1] == "-createhero" or
  5889. tokens[1] == "-item" or
  5890. tokens[1] == "-refresh" or
  5891. tokens[1] == "-startgame" or
  5892. tokens[1] == "-killcreeps" or
  5893. tokens[1] == "-wtf" or
  5894. tokens[1] == "-disablecreepspawn" or
  5895. tokens[1] == "-gold" or
  5896. tokens[1] == "-lvlup" or
  5897. tokens[1] == "-refresh" or
  5898. tokens[1] == "-respawn" or
  5899. tokens[1] == "dota_create_unit" or
  5900. tokens[1] == "-ggsimida"
  5901. ) then
  5902. if hero ~= nil and hero:IsNull() == false and hero:IsAlive() == true then
  5903. hero:ForceKill(false)
  5904. GameRules:GetGameModeEntity().counterpart[hero:GetTeam()] = -1
  5905. SyncHP(hero)
  5906. ClearHand(hero:GetTeam())
  5907. end
  5908. end
  5909.  
  5910. --激活cdkey
  5911. if string.find(keys.text,"^%w%w%w%w%w%p%w%w%w%w%w%p%w%w%w%w%w$") ~= nil then
  5912. local key = string.upper(keys.text)
  5913. local steamid = EntIndexToHScript(heroindex).steam_id
  5914. CustomNetTables:SetTableValue( "dac_table", "cdkey", {
  5915. player_id = player,
  5916. steam_id = steamid,
  5917. text = key,
  5918. hehe = RandomInt(1,10000)
  5919. })
  5920. return
  5921. end
  5922.  
  5923. --特效测试
  5924. if string.find(keys.text,"^e%w%w%w$") ~= nil and GameRules:GetGameModeEntity().myself then
  5925. if hero.effect ~= nil then
  5926. hero:RemoveAbility(hero.effect)
  5927. hero:RemoveModifierByName('modifier_texiao_star')
  5928. end
  5929. hero:AddAbility(keys.text)
  5930. hero:FindAbilityByName(keys.text):SetLevel(1)
  5931. hero.effect = keys.text
  5932. end
  5933.  
  5934. if tokens[1] == '-chesspool' and GameRules:GetGameModeEntity().myself then
  5935. PrintChessPool()
  5936. end
  5937.  
  5938. --测试命令
  5939. if tokens[1] == '-up' and GameRules:GetGameModeEntity().myself then
  5940. local lineup_table = {}
  5941. for _,savechess in pairs(GameRules:GetGameModeEntity().mychess[team]) do
  5942. table.insert(lineup_table,{
  5943. x = savechess.x,
  5944. y = savechess.y,
  5945. lastitem = CopyTable(savechess.lastitem),
  5946. chess = savechess.chess
  5947. })
  5948. end
  5949. local obj = {
  5950. owner = EntIndexToHScript(heroindex).steam_id,
  5951. lineup = lineup_table,
  5952. round = GameRules:GetGameModeEntity().battle_round
  5953. }
  5954. local url = "http://101.200.189.65:431/dac/lineup/add?lineups="..json.encode(obj).."&hehe="..RandomInt(1,10000)
  5955. local req = CreateHTTPRequestScriptVM("GET", url)
  5956. req:SetHTTPRequestAbsoluteTimeoutMS(20000)
  5957. req:Send(function (result)
  5958. local t = json.decode(result["Body"])
  5959. if t.err == 0 then
  5960. prt(''..hero.player_name..'云阵容保存成功')
  5961. end
  5962. end)
  5963. end
  5964. if tokens[1] == '-tp' then
  5965. local p = Entities:FindByName(nil,'center'..(team-6)):GetAbsOrigin()
  5966. hero:SetAbsOrigin(p)
  5967. end
  5968. if tokens[1] == '-crab' and GameRules:GetGameModeEntity().myself == true then
  5969. GameRules:GetGameModeEntity().next_crab = 'chess_'..tokens[2]
  5970. for i=1,3 do
  5971. local x = nil
  5972. local this_chess = nil
  5973. if i == 1 then
  5974. this_chess = GameRules:GetGameModeEntity().next_crab
  5975. elseif i == 2 then
  5976. this_chess = GameRules:GetGameModeEntity().next_crab..'1'
  5977. elseif i == 3 then
  5978. this_chess = GameRules:GetGameModeEntity().next_crab..'11'
  5979. end
  5980. x = CreateUnitByName(this_chess,HandIndex2Vector(hero:GetTeam(),i),true,nil,nil,hero:GetTeam())
  5981. MakeTiny(x)
  5982. PlayChessDialogue(x,'spawn')
  5983.  
  5984.  
  5985.  
  5986. GameRules:GetGameModeEntity().hand[hero:GetTeam()][i] = 1
  5987. if hero.hand_entities == nil then
  5988. hero.hand_entities = {}
  5989. end
  5990.  
  5991. hero.hand_entities[i] = x
  5992.  
  5993. x:SetForwardVector(Vector(0,1,0))
  5994. x.hand_index = i
  5995. x.team_id = hero:GetTeam()
  5996. x.owner_player_id = GameRules:GetGameModeEntity().team2playerid[hero:GetTeam()]
  5997.  
  5998. AddAbilityAndSetLevel(x,'root_self')
  5999. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  6000.  
  6001. play_particle("particles/econ/items/antimage/antimage_ti7/antimage_blink_start_ti7_ribbon_bright.vpcf",PATTACH_ABSORIGIN_FOLLOW,x,5)
  6002. end
  6003. GameRules:GetGameModeEntity().next_crab = nil
  6004. end
  6005. if tokens[1] == '-drop' and GameRules:GetGameModeEntity().myself == true then
  6006. local i = 'item_'..tokens[2]
  6007. local newItem = CreateItem( i, hero, hero )
  6008. local drop = CreateItemOnPositionForLaunch(hero:GetAbsOrigin(), newItem )
  6009. local dropRadius = RandomFloat( 50, 200 )
  6010. newItem:LaunchLootInitialHeight( false, 0, 200, 0.75, hero:GetAbsOrigin() + RandomVector(dropRadius ))
  6011. end
  6012. --添加木桩
  6013. if tokens[1] == "-stub" and GameRules:GetGameModeEntity().myself == true then
  6014. local team_id = hero:GetTeam()
  6015. Timers:CreateTimer(function()
  6016. local grid = GameRules:GetGameModeEntity().unit[team_id]
  6017. for i,iv in pairs(grid) do
  6018. if iv == 1 then
  6019. local x = string.split(i,'_')[2]
  6020. local y = string.split(i,'_')[1]
  6021. local u = CreateUnitByName("stub",XY2Vector(x,y,team_id),true,nil,nil,DOTA_TEAM_BADGUYS)
  6022. u:SetHullRadius(1)
  6023. u:SetForwardVector(Vector(-1,-1,0))
  6024. AddAbilityAndSetLevel(u,'jiaoxie_wudi')
  6025. Timers:CreateTimer(0.5,function()
  6026. u:Destroy()
  6027. end)
  6028. end
  6029. end
  6030. return 0.5
  6031. end)
  6032.  
  6033. prt('add test stub.')
  6034. end
  6035.  
  6036. if tokens[1] == "-choose" and GameRules:GetGameModeEntity().myself == true then
  6037. prt('choose round: '..tokens[2] )
  6038. GameRules:GetGameModeEntity().battle_round = tonumber(tokens[2])
  6039. end
  6040.  
  6041. if tokens[1] == '-mana' and GameRules:GetGameModeEntity().myself == true then
  6042. prt('MANA!!!')
  6043. AddMana(hero, 100)
  6044. end
  6045. if tokens[1] == '-win' and GameRules:GetGameModeEntity().myself == true then
  6046. prt('WIN!!!')
  6047. AddWinStreak(hero:GetTeam())
  6048. end
  6049. if tokens[1] == "-a" and GameRules:GetGameModeEntity().myself == true then
  6050. local level = tonumber(tokens[3]) or 4
  6051. hero:AddAbility(tokens[2])
  6052. hero:FindAbilityByName(tokens[2]):SetLevel(level)
  6053. end
  6054.  
  6055. if tokens[1] == '-hand' and GameRules:GetGameModeEntity().myself == true then
  6056. prt('显示玩家'..player..'(team='..team..')的手牌:')
  6057. for i=1,8 do
  6058. local unitname = ''
  6059. if hero.hand_entities[i] ~= nil then
  6060. unitname = hero.hand_entities[i]:GetUnitName()
  6061. else
  6062. unitname = '空的'
  6063. end
  6064. prt('#'..i..'-->'..GameRules:GetGameModeEntity().hand[team][i]..'('..unitname..')')
  6065. end
  6066. end
  6067.  
  6068. if tokens[1] == '-damage' and GameRules:GetGameModeEntity().myself == true then
  6069. prt('SHOW DAMAGE')
  6070. GameRules:GetGameModeEntity().show_damage = true
  6071. end
  6072. if tokens[1] == '-undamage' and GameRules:GetGameModeEntity().myself == true then
  6073. prt('HIDE DAMAGE')
  6074. GameRules:GetGameModeEntity().show_damage = false
  6075. end
  6076.  
  6077. CustomNetTables:SetTableValue( "dac_table", "say_bubble", {text = keys.text, unit = heroindex, hehe = RandomInt(1,10000)} )
  6078.  
  6079. --发弹幕
  6080. CustomGameEventManager:Send_ServerToAllClients("bullet",{
  6081. player_id = hero:GetPlayerID(),
  6082. text = keys.text
  6083. })
  6084. end
  6085. function play_particle(p, pos, u, d)
  6086. -- if u == nil then
  6087. -- return
  6088. -- end
  6089. local pp = ParticleManager:CreateParticle(p, pos, u)
  6090. -- Timers:CreateTimer(function()
  6091. -- if u:IsNull() ~= false or u:IsAlive() ~= false then
  6092. -- ParticleManager:DestroyParticle(pp,true)
  6093. -- return
  6094. -- end
  6095. -- return 1
  6096. -- end)
  6097. Timers:CreateTimer(d,function()
  6098. if pp ~= nil then
  6099. ParticleManager:DestroyParticle(pp,true)
  6100. end
  6101. end)
  6102. end
  6103. function PlayParticleOnUnitUntilDeath(keys)
  6104. local p = keys.p
  6105. local u = keys.caster
  6106. if u == nil then
  6107. return
  6108. end
  6109. local pos = keys.pos or PATTACH_ABSORIGIN_FOLLOW
  6110. local pp = ParticleManager:CreateParticle(p, pos, u)
  6111. ParticleManager:SetParticleControlEnt( pp, 0, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6112. ParticleManager:SetParticleControlEnt( pp, 1, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6113. ParticleManager:SetParticleControlEnt( pp, 2, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6114. ParticleManager:SetParticleControlEnt( pp, 3, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6115. ParticleManager:SetParticleControlEnt( pp, 4, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6116. ParticleManager:SetParticleControlEnt( pp, 5, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6117. ParticleManager:SetParticleControlEnt( pp, 6, u, PATTACH_ABSORIGIN_FOLLOW, nil, u:GetOrigin(), true );
  6118.  
  6119. Timers:CreateTimer(0.1,function()
  6120. if u == nil or u:IsNull() == true or u:IsAlive() == false then
  6121. ParticleManager:DestroyParticle(pp,true)
  6122. end
  6123. return 0.1
  6124. end)
  6125. end
  6126. --高级选取单位,适应所有team
  6127. function FindUnitsInRadiusByTeam(keys)
  6128. local team = keys.team
  6129. local role = keys.role or 1 --1=队友,2=敌人,3=全部
  6130. local radius = keys.radius or 500
  6131. local position = keys.position or Vector(0,0,0)
  6132. local units = {}
  6133.  
  6134. local all_units = FindUnitsInRadius(
  6135. DOTA_TEAM_BADGUYS,
  6136. Vector(0,0,0),
  6137. nil,
  6138. 9999,
  6139. DOTA_UNIT_TARGET_TEAM_BOTH, --用BOTH可以选到所有team的单位
  6140. DOTA_UNIT_TARGET_ALL,
  6141. DOTA_UNIT_TARGET_FLAG_NONE,
  6142. FIND_ANY_ORDER,
  6143. false)
  6144.  
  6145. for u,v in pairs(all_units) do
  6146. if (v:GetAbsOrigin() - position):Length2D() <= radius then
  6147. if role == 1 and v:GetTeam() == team then
  6148. table.insert(units,v)
  6149. end
  6150. if role == 2 and v:GetTeam() ~= team then
  6151. table.insert(units,v)
  6152. end
  6153. if role == 3 then
  6154. table.insert(units,v)
  6155. end
  6156. end
  6157. end
  6158.  
  6159. return units
  6160. end
  6161.  
  6162. function ApplyDamageInRadius(keys)
  6163. local caster = keys.caster
  6164. local team = keys.team
  6165. local role = keys.role or 2
  6166. local position = keys.position
  6167. local damage = keys.damage or 1
  6168. local radius = keys.radius or 500
  6169. local damage_type = keys.damage_type or DAMAGE_TYPE_MAGICAL
  6170. local delay = keys.delay or 0
  6171.  
  6172. Timers:CreateTimer(delay,function()
  6173. local unlucky_dogs = FindUnitsInRadiusByTeam({
  6174. team = team,
  6175. role = role,
  6176. position = position,
  6177. radius = radius,
  6178. })
  6179. for _,u in pairs(unlucky_dogs) do
  6180. if u ~= nil and u:IsNull() == false and u:IsAlive() == true then
  6181. ApplyDamage({
  6182. victim = u,
  6183. attacker = caster,
  6184. damage_type = damage_type,
  6185. damage = damage
  6186. })
  6187. end
  6188. end
  6189. end)
  6190. end
  6191. function AddModifierInRadius(keys)
  6192. local caster = keys.caster
  6193. local team = caster:GetTeam()
  6194. local role = keys.role or 2
  6195. local radius = keys.radius or 500
  6196. local modifier = keys.modifier
  6197. local ability = keys.ability
  6198. local unlucky_dogs = FindUnitsInRadiusByTeam({
  6199. team = team,
  6200. role = role,
  6201. position = caster:GetAbsOrigin(),
  6202. radius = radius,
  6203. })
  6204. for _,u in pairs(unlucky_dogs) do
  6205. if u ~= nil and u:IsNull() == false and u:IsAlive() == true then
  6206. u:AddNewModifier(caster,keys.ability,modifier,nil)
  6207. end
  6208. end
  6209. end
  6210.  
  6211.  
  6212. function ChangeModelScale(keys)
  6213. local u = keys.caster
  6214. local x = keys.x
  6215. local s = u:GetModelScale()
  6216. -- u:SetModelScale(s*x)
  6217. AddModelScalePlus(u, s*x)
  6218. play_particle("effect/big.vpcf",PATTACH_ABSORIGIN_FOLLOW,u,2)
  6219. end
  6220.  
  6221. function RemoveTableItem(t,item)
  6222. for i,v in pairs (t) do
  6223. if v == item then
  6224. table.remove(t,i)
  6225. return t
  6226. end
  6227. end
  6228. end
  6229. function show_damage(keys)
  6230. local caster = keys.caster
  6231. local attacker = keys.attacker
  6232. local damage = math.floor(keys.DamageTaken)
  6233.  
  6234. --格挡
  6235. local gedang = 0
  6236. local gedang_per = 0
  6237. if caster:FindModifierByName('modifier_item_yuandun') ~= nil then
  6238. gedang = 10
  6239. gedang_per = 100
  6240. end
  6241. if caster:FindModifierByName('modifier_item_xianfengdun') ~= nil then
  6242. gedang = 50
  6243. gedang_per = 50
  6244. end
  6245. if gedang > 0 and RandomInt(1,100) < gedang_per then
  6246. local caster_hp = caster:GetHealth()
  6247. if damage < gedang then
  6248. if caster_hp > damage then
  6249. caster:SetHealth(caster_hp+damage)
  6250. damage = 0
  6251. end
  6252. else
  6253. if caster_hp > damage then
  6254. caster:SetHealth(caster_hp+gedang)
  6255. damage = damage - gedang
  6256. end
  6257. end
  6258. end
  6259.  
  6260. if damage <= 0 then
  6261. return
  6262. end
  6263.  
  6264. if attacker ~= nil and attacker:IsHero() == true then
  6265. return
  6266. end
  6267.  
  6268. --回蓝
  6269.  
  6270. --受到伤害回蓝
  6271. local mana_get = damage/5
  6272. if mana_get > 50 then
  6273. mana_get = 50
  6274. end
  6275. mana_get = RandomInt(mana_get/2,mana_get)
  6276.  
  6277. if caster:FindModifierByName("modifier_item_jixianfaqiu") ~= nil then
  6278. mana_get = math.floor(mana_get * 1.25)
  6279. end
  6280. if caster:FindModifierByName("modifier_item_yangdao") ~= nil then
  6281. mana_get = math.floor(mana_get * 1.5)
  6282. end
  6283. caster:SetMana(caster:GetMana()+mana_get)
  6284.  
  6285. --造成伤害回蓝
  6286. if attacker ~= nil then
  6287. if attacker:FindAbilityByName('is_mage') or attacker:FindAbilityByName('is_warlock') or attacker:FindAbilityByName('is_shaman') then
  6288. mana_get = damage/2.5
  6289. if mana_get > 20 then
  6290. mana_get = 20
  6291. end
  6292. else
  6293. if mana_get > 10 then
  6294. mana_get = 10
  6295. end
  6296. end
  6297.  
  6298. if caster:FindModifierByName("modifier_item_wangguan") ~= nil or caster:FindModifierByName("item_hongzhang_1") ~= nil or caster:FindModifierByName("item_hongzhang_2") ~= nil or caster:FindModifierByName("item_hongzhang_3") ~= nil or caster:FindModifierByName("item_hongzhang_4") ~= nil or caster:FindModifierByName("item_hongzhang_5") ~= nil then
  6299. mana_get = math.floor(mana_get * 1.5)
  6300. end
  6301. if attacker:FindModifierByName("modifier_item_xuwubaoshi") ~= nil or attacker:FindModifierByName("modifier_item_yangdao") ~= nil or caster:FindModifierByName("modifier_item_shenmifazhang") ~= nil then
  6302. mana_get = math.floor(mana_get * 2)
  6303. end
  6304. if attacker:FindModifierByName("modifier_item_jianrenqiu") ~= nil then
  6305. mana_get = math.floor(mana_get * 2)
  6306. end
  6307. if attacker:FindModifierByName("modifier_item_shuaxinqiu") ~= nil then
  6308. mana_get = math.floor(mana_get * 3)
  6309. end
  6310.  
  6311. attacker:SetMana(attacker:GetMana()+mana_get)
  6312. end
  6313.  
  6314. if GameRules:GetGameModeEntity().show_damage == true then
  6315. if attacker:GetTeam() == 4 then
  6316. AMHC:CreateNumberEffect(caster,damage,2,AMHC.MSG_DAMAGE,"red",9)
  6317. else
  6318. AMHC:CreateNumberEffect(caster,damage,2,AMHC.MSG_DAMAGE,"green",9)
  6319. end
  6320. end
  6321.  
  6322. --伤害统计
  6323. if attacker ~= nil then
  6324. local attacker_id = attacker:GetEntityIndex()
  6325. local team_id = attacker.team_id
  6326. -- if attacker.at_team_id == attacker.team_id then
  6327. if team_id == nil or GameRules:GetGameModeEntity().damage_stat[team_id] == nil then
  6328. return
  6329. end
  6330. local curr_damage = GameRules:GetGameModeEntity().damage_stat[team_id][attacker:GetUnitName()]
  6331. if curr_damage == nil then
  6332. curr_damage = 0
  6333. end
  6334. curr_damage = curr_damage + damage
  6335. GameRules:GetGameModeEntity().damage_stat[team_id][attacker:GetUnitName()] = curr_damage
  6336. -- end
  6337.  
  6338. local g_time = GameRules:GetGameTime()
  6339. if GameRules:GetGameModeEntity()['last_g_time'..team_id] == nil then
  6340. GameRules:GetGameModeEntity()['last_g_time'..team_id] = 0
  6341. end
  6342. local time_this_level = 61 - GameRules:GetGameModeEntity().battle_timer
  6343. if g_time - GameRules:GetGameModeEntity()['last_g_time'..team_id] > 1 then
  6344. GameRules:GetGameModeEntity()['last_g_time'..team_id] = g_time
  6345. end
  6346. end
  6347. end
  6348. function RenJia(keys)
  6349. local caster = keys.caster
  6350. local attacker = keys.attacker
  6351. local damage = math.floor(keys.DamageTaken*0.1)
  6352. if damage <= 0 then
  6353. return
  6354. end
  6355. ApplyDamage({
  6356. victim=attacker,
  6357. attacker=caster,
  6358. damage_type=DAMAGE_TYPE_PURE,
  6359. damage=damage
  6360. })
  6361. end
  6362. --电锤技能
  6363. function DianChui(event)
  6364. local caster = event.caster
  6365. local target = event.target
  6366. local ability = event.ability
  6367. local targets = event.targets
  6368. local damage = event.damage
  6369. local particle = event.particle or "particles/units/heroes/hero_shadowshaman/shadowshaman_ether_shock.vpcf"
  6370.  
  6371. -- Make sure the main target is damaged
  6372. local lightningBolt = ParticleManager:CreateParticle(particleName, PATTACH_WORLDORIGIN, caster)
  6373. ParticleManager:SetParticleControl(lightningBolt,0,Vector(caster:GetAbsOrigin().x,caster:GetAbsOrigin().y,caster:GetAbsOrigin().z + caster:GetBoundingMaxs().z ))
  6374. ParticleManager:SetParticleControl(lightningBolt,1,Vector(target:GetAbsOrigin().x,target:GetAbsOrigin().y,target:GetAbsOrigin().z + target:GetBoundingMaxs().z ))
  6375. ApplyDamage({
  6376. victim = target,
  6377. attacker = caster,
  6378. damage = damage,
  6379. damage_type = DAMAGE_TYPE_MAGICAL
  6380. })
  6381.  
  6382. -- local cone_units = GetEnemiesInCone( caster, start_radius, end_radius, end_distance )
  6383. local cone_units = FindUnitsInRadiusByTeam({
  6384. team = caster:GetTeam(),
  6385. role = 2,
  6386. position = caster:GetAbsOrigin(),
  6387. radius = 500,
  6388. })
  6389. local targets_shocked = 1 --Is targets=extra targets or total?
  6390. for _,unit in pairs(cone_units) do
  6391. if targets_shocked < targets then
  6392. if unit ~= target then
  6393. if unit.player == nil or unit.player == caster:GetOwner():GetPlayerID() then
  6394. -- Particle
  6395. local origin = unit:GetAbsOrigin()
  6396.  
  6397. local lightningBolt = ParticleManager:CreateParticle(particle, PATTACH_WORLDORIGIN, caster)
  6398. ParticleManager:SetParticleControl(lightningBolt,0,Vector(caster:GetAbsOrigin().x,caster:GetAbsOrigin().y,caster:GetAbsOrigin().z + caster:GetBoundingMaxs().z ))
  6399. ParticleManager:SetParticleControl(lightningBolt,1,Vector(origin.x,origin.y,origin.z + unit:GetBoundingMaxs().z ))
  6400.  
  6401. -- Damage
  6402. ApplyDamage({
  6403. victim = unit,
  6404. attacker = caster,
  6405. damage = damage,
  6406. damage_type = DAMAGE_TYPE_MAGICAL
  6407. })
  6408.  
  6409. -- Increment counter
  6410. targets_shocked = targets_shocked + 1
  6411. end
  6412.  
  6413. end
  6414. else
  6415. break
  6416. end
  6417. end
  6418. end
  6419.  
  6420.  
  6421. function string.split(s, sep)
  6422. if sep == nil then
  6423. sep = "%s"
  6424. end
  6425. local t={} ; i=1
  6426. for str in string.gmatch(s, "([^"..sep.."]+)") do
  6427. t[i] = str
  6428. i = i + 1
  6429. end
  6430. return t
  6431. end
  6432.  
  6433. --主公的技能
  6434. function h101_ability(h)
  6435. if h~=nil and h:IsNull() ~= true and h:IsAlive() ~= false and h:GetHealth() < h:GetMaxHealth() then
  6436. Timers:CreateTimer(RandomFloat(0,0.2),function()
  6437. h:SetHealth(h:GetHealth()+1)
  6438. play_particle("particles/items2_fx/tranquil_boots_healing.vpcf",PATTACH_ABSORIGIN_FOLLOW,h,2)
  6439. EmitSoundOn('DOTA_Item.TranquilBoots.Activate',h)
  6440. SyncHP(h)
  6441. end)
  6442. end
  6443. end
  6444. function h203_addattackdamage(keys)
  6445. local h = keys.caster
  6446. for i,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[h:GetTeam()]) do
  6447. if v.team_id == h:GetTeam() then
  6448. AddAbilityAndSetLevel(v,'h203_attack_increased')
  6449. EmitSoundOn('Hero_Beastmaster.Call.Boar',v)
  6450. end
  6451. end
  6452. end
  6453. function h301_restoreallhealth(keys)
  6454. local h = keys.caster
  6455. for i,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[h:GetTeam()]) do
  6456. if v.team_id == h:GetTeam() then
  6457. v:SetHealth(v:GetMaxHealth())
  6458. play_particle("particles/units/heroes/hero_omniknight/omniknight_purification.vpcf",PATTACH_ABSORIGIN_FOLLOW,v,2)
  6459. EmitSoundOn('Hero_Omniknight.Purification',v)
  6460. end
  6461. end
  6462. end
  6463. function h302_ability(h)
  6464. AddAbilityAndSetLevel(h,'h302_maxmanaplus20')
  6465. end
  6466. function h401_ability(keys)
  6467. local h = keys.caster
  6468. AMHC:CreateParticle("particles/econ/items/puck/puck_alliance_set/puck_dreamcoil_waves_rope_aproset.vpcf",PATTACH_OVERHEAD_FOLLOW,false,h,5)
  6469. for i,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[h:GetTeam()]) do
  6470. if v.team_id ~= h:GetTeam() then
  6471. AddAbilityAndSetLevel(v,'h401_letaojiao')
  6472. end
  6473. end
  6474. end
  6475. function h402_ability(keys)
  6476. local h = keys.caster
  6477. play_particle("particles/econ/items/shadow_fiend/sf_fire_arcana/sf_fire_arcana_wings_grow_rope.vpcf",PATTACH_ABSORIGIN_FOLLOW,h,5)
  6478. for i,v in pairs(GameRules:GetGameModeEntity().to_be_destory_list[h:GetTeam()]) do
  6479. if v.team_id ~= h:GetTeam() then
  6480. local damageTable = {
  6481. victim=v,
  6482. attacker=h,
  6483. damage_type=DAMAGE_TYPE_MAGICAL,
  6484. damage=v:GetMaxHealth()/2
  6485. }
  6486. ApplyDamage(damageTable)
  6487. play_particle("particles/econ/items/shadow_fiend/sf_fire_arcana/sf_fire_arcana_shadowraze.vpcf",PATTACH_ABSORIGIN_FOLLOW,v,2)
  6488. end
  6489. end
  6490. end
  6491.  
  6492. function DAC:OnRefreshChess(keys)
  6493. local hero = GameRules:GetGameModeEntity().teamid2hero[keys.team]
  6494. if hero:GetMana() < 2 then
  6495. CustomGameEventManager:Send_ServerToTeam(keys.team,"mima",{
  6496. text = "text_mima_no_mana"
  6497. })
  6498. return
  6499. else
  6500. hero:SetMana(hero:GetMana()-2)
  6501. Draw5ChessAndShow(keys.team, true)
  6502. CustomGameEventManager:Send_ServerToTeam(keys.team,"show_gold",{
  6503. gold = hero:GetMana(),
  6504. lose_streak = hero.lose_streak or 0,
  6505. win_streak = hero.win_streak or 0,
  6506. })
  6507. end
  6508. end
  6509.  
  6510. --技能:抽
  6511. function SummonHero(keys)
  6512. local caster = keys.caster
  6513. local team_id = caster:GetTeam()
  6514. caster.chesslock = false
  6515.  
  6516. -- local target_index = FindEmptyHandSlot(team_id)
  6517.  
  6518. -- if target_index == nil then
  6519. -- --手牌已经满了
  6520. -- CustomGameEventManager:Send_ServerToTeam(caster:GetTeam(),"mima",{
  6521. -- text = "text_mima_hand_is_full"
  6522. -- })
  6523. -- EmitSoundOn("General.CastFail_NoMana",keys.caster)
  6524. -- --把蓝加回来
  6525. -- caster:SetMana(caster:GetMana()+2)
  6526. -- CustomNetTables:SetTableValue( "dac_table", "show_gold", { gold = caster:GetMana(), hehe = RandomInt(1,1000)})
  6527. -- return
  6528. -- end
  6529.  
  6530. -- RandomOneChessInHand(team_id)
  6531. AMHC:CreateParticle("particles/econ/items/antimage/antimage_ti7/antimage_blink_start_ti7_ribbon_bright.vpcf",PATTACH_ABSORIGIN_FOLLOW,false,caster,5)
  6532. EmitSoundOn('frostivus_ui_select',caster)
  6533. -- setHandStatus(team_id)
  6534.  
  6535. Draw5ChessAndShow(team_id, true)
  6536.  
  6537. CustomGameEventManager:Send_ServerToTeam(team_id,"show_gold",{
  6538. gold = caster:GetMana(),
  6539. lose_streak = caster.lose_streak or 0,
  6540. win_streak = caster.win_streak or 0,
  6541. })
  6542. end
  6543.  
  6544. function ExpBook(keys)
  6545. local caster = keys.caster
  6546. local team_id = caster:GetTeam()
  6547. caster:AddExperience (4,0,false,false)
  6548. AMHC:CreateParticle("particles/units/heroes/hero_oracle/oracle_false_promise_cast_enemy.vpcf",PATTACH_ABSORIGIN_FOLLOW,false,caster,5)
  6549. -- EmitSoundOn('General.Combine',caster)
  6550. EmitSoundOn('Hero_Omniknight.GuardianAngel',caster)
  6551. -- setHandStatus(team_id)
  6552.  
  6553. AMHC:CreateNumberEffect(caster,4,3,AMHC.MSG_MISS,{255,255,128},0)
  6554. CustomGameEventManager:Send_ServerToTeam(team_id,"show_gold",{
  6555. gold = caster:GetMana(),
  6556. lose_streak = caster.lose_streak or 0,
  6557. win_streak = caster.win_streak or 0,
  6558. })
  6559. end
  6560.  
  6561. function AddMana(unit, mana)
  6562. if mana == nil or mana <= 0 then
  6563. return
  6564. end
  6565. unit:SetMana(unit:GetMana()+mana)
  6566. AMHC:CreateParticle("particles/generic_gameplay/rune_bounty_owner.vpcf",PATTACH_OVERHEAD_FOLLOW,false,unit,5)
  6567. if mana >= 10 then
  6568. EmitSoundOn("General.CoinsBig",unit)
  6569. else
  6570. EmitSoundOn("General.Coins",unit)
  6571. end
  6572.  
  6573. AMHC:CreateNumberEffect(unit,mana,3,AMHC.MSG_MISS,{255,255,0},0)
  6574. end
  6575.  
  6576. function CostMana(unit, mana)
  6577. if mana == nil or mana <= 0 then
  6578. return
  6579. end
  6580. unit:SetMana(unit:GetMana()-mana)
  6581. -- AMHC:CreateNumberEffect(unit,mana,4,AMHC.MSG_EVADE,{255,255,128},3)
  6582. end
  6583.  
  6584. function AddModelScalePlus(unit, scale)
  6585. unit.target_scale = scale
  6586. Timers:CreateTimer(0.01,function()
  6587. if unit == nil or unit:IsNull() == true or unit:IsAlive() == false or unit:GetModelScale() >= unit.target_scale then
  6588. return
  6589. end
  6590. unit:SetModelScale(unit:GetModelScale()+0.01)
  6591. return 0.01
  6592. end)
  6593. end
  6594.  
  6595. function CmManaAura(keys)
  6596. local caster = keys.caster
  6597. local ability_level = keys.ability:GetLevel()
  6598. local at_team_id = caster.at_team_id or caster.team_id
  6599. local team_id = caster.team_id
  6600. local radius = keys.radius or 800
  6601. local mana = keys.mana or 5
  6602.  
  6603. local lucky_dogs = FindUnitsInRadiusByTeam({
  6604. team = team_id,
  6605. role = 1,
  6606. position = caster:GetAbsOrigin(),
  6607. radius = radius,
  6608. })
  6609. for _,unit in pairs(lucky_dogs) do
  6610. --add mana
  6611. if unit:GetMaxMana() == 0 then
  6612. break
  6613. end
  6614. play_particle('particles/units/heroes/hero_obsidian_destroyer/obsidian_destroyer_matter_manasteal.vpcf',PATTACH_OVERHEAD_FOLLOW,unit,3)
  6615. unit:SetMana(unit:GetMana()+mana)
  6616. end
  6617. end
  6618.  
  6619. function PlayChessDialogue(unit,dialogue)
  6620. if unit == nil or unit:IsNull() == true or unit:IsAlive() == false then
  6621. return
  6622. end
  6623. play_particle("particles/speechbubbles/speech_voice.vpcf",PATTACH_OVERHEAD_FOLLOW,unit,3)
  6624. CustomGameEventManager:Send_ServerToTeam(unit:GetTeam(),"play_chess_dialogue",{
  6625. unit_index = unit:GetEntityIndex(),
  6626. unit_name = unit:GetUnitName(),
  6627. dialogue_type = dialogue, --spawn/win/merge
  6628. })
  6629. end
  6630.  
  6631. function TriggerRefreshOrb(u)
  6632. if u:FindModifierByName("modifier_item_shuaxinqiu") == nil then
  6633. return
  6634. end
  6635.  
  6636. for slot=0,8 do
  6637. if u:GetItemInSlot(slot)~= nil then
  6638. local ability = u:GetItemInSlot(slot)
  6639. local name = ability:GetAbilityName()
  6640. local a = GameRules:GetGameModeEntity().chess_ability_list[u:GetUnitName()]
  6641.  
  6642. if name == 'item_shuaxinqiu' and ability:IsCooldownReady() == true and u:FindAbilityByName(a):IsCooldownReady() == false then
  6643. --刷新!!
  6644. ability:StartCooldown(30)
  6645.  
  6646. u:FindAbilityByName(a):EndCooldown()
  6647.  
  6648. play_particle("particles/items2_fx/refresher.vpcf",PATTACH_ABSORIGIN_FOLLOW,u,5)
  6649. EmitSoundOn("DOTA_Item.Refresher.Activate",u)
  6650.  
  6651. return 1
  6652. end
  6653. end
  6654. end
  6655. end
  6656.  
  6657. function TriggerSheepStick(u)
  6658. if u:FindModifierByName("modifier_item_yangdao") == nil then
  6659. return
  6660. end
  6661.  
  6662. for slot=0,8 do
  6663. if u:GetItemInSlot(slot)~= nil then
  6664. local ability = u:GetItemInSlot(slot)
  6665. local name = ability:GetAbilityName()
  6666. if name == 'item_yangdao' and ability:IsCooldownReady() == true then
  6667. if u:FindAbilityByName("crab_voodoo") == nil then
  6668. AddAbilityAndSetLevel(u,'crab_voodoo')
  6669. else
  6670. local dog = FindUnluckyDog(u)
  6671. if u:IsNull() ~= true and dog ~= nil and dog:IsNull() ~= true then
  6672. ability:StartCooldown(30)
  6673. local newOrder = {
  6674. UnitIndex = u:entindex(),
  6675. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  6676. TargetIndex = dog:entindex(),
  6677. AbilityIndex = u:FindAbilityByName("crab_voodoo"):entindex(),
  6678. Position = nil,
  6679. Queue = 0
  6680. }
  6681. ExecuteOrderFromTable(newOrder)
  6682. end
  6683. end
  6684. return 1
  6685. end
  6686. end
  6687. end
  6688. end
  6689.  
  6690. function TriggerFrogGua(u)
  6691. if u:FindAbilityByName("frog_voodoo") == nil then
  6692. return
  6693. end
  6694. local dog = FindUnluckyDog(u)
  6695. if dog ~= nil and u:FindAbilityByName("frog_voodoo"):IsCooldownReady() == true then
  6696. local newOrder = {
  6697. UnitIndex = u:entindex(),
  6698. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  6699. TargetIndex = dog:entindex(),
  6700. AbilityIndex = u:FindAbilityByName("frog_voodoo"):entindex(),
  6701. Position = nil,
  6702. Queue = 0
  6703. }
  6704. ExecuteOrderFromTable(newOrder)
  6705. -- u:FindAbilityByName("frog_voodoo"):StartCooldown(60)
  6706. -- Timers:CreateTimer(2,function()
  6707. -- u:RemoveAbility("frog_voodoo")
  6708. -- end)
  6709. return 1
  6710. end
  6711. end
  6712.  
  6713. function TriggerDagon(u)
  6714. if u:FindModifierByName("modifier_item_hongzhang") == nil then
  6715. return
  6716. end
  6717. for slot=0,8 do
  6718. if u:GetItemInSlot(slot)~= nil then
  6719. local ability = u:GetItemInSlot(slot)
  6720. local name = ability:GetAbilityName()
  6721. local name_table = string.split(name,'_')
  6722. local dog = FindUnluckyDog(u)
  6723. if dog ~= nil and name_table[2] == 'hongzhang' and ability:IsCooldownReady() == true then
  6724. ability:StartCooldown(30)
  6725. EmitSoundOn("DOTA_Item.Dagon.Activate",u)
  6726. local victim = dog
  6727. local info = {
  6728. Target = victim,
  6729. Source = u,
  6730. Ability = nil,
  6731. EffectName = "particles/econ/events/ti5/dagon_ti5.vpcf",
  6732. bDodgeable = false,
  6733. iMoveSpeed = 3000,
  6734. bProvidesVision = false,
  6735. iVisionRadius = 0,
  6736. iVisionTeamNumber = u:GetTeamNumber(),
  6737. iSourceAttachment = DOTA_PROJECTILE_ATTACHMENT_ATTACK_1
  6738. }
  6739. projectile = ProjectileManager:CreateTrackingProjectile(info)
  6740. ApplyDamage({
  6741. victim=victim,
  6742. attacker=u,
  6743. damage_type=DAMAGE_TYPE_MAGICAL,
  6744. damage=300+100*tonumber(name_table[3])
  6745. })
  6746. return 1
  6747. end
  6748. end
  6749. end
  6750. end
  6751.  
  6752. function ChessTechBomb(keys)
  6753. local caster = keys.caster
  6754. local p = keys.target_points[1]
  6755. local explode_time = keys.explode_time or 5
  6756. local damage = keys.damage or 800
  6757. local scale = keys.scale or 1.2
  6758. local range = keys.range or 400
  6759. local at_team = caster.at_team_id or caster.team_id
  6760. local team = caster:GetTeam()
  6761.  
  6762. if p == nil then
  6763. -- prt('DEBUG: 炸药桶的位置是nil')
  6764. return
  6765. end
  6766.  
  6767. local y = Vector2Y(p,at_team)
  6768. local x = Vector2X(p,at_team)
  6769.  
  6770. if (GameRules:GetGameModeEntity().unit[at_team][y..'_'..x] ~= nil) then
  6771. -- prt('DEBUG: 炸药桶的位置不是空格子')
  6772. return
  6773. end
  6774.  
  6775. --创建一个炸弹
  6776. GameRules:GetGameModeEntity().unit[at_team][y..'_'..x] = 1
  6777. local u = CreateUnitByName('enemy_bomb',p,true,nil,nil,team)
  6778. u:SetModelScale(scale)
  6779. EmitSoundOn("Hero_Techies.RemoteMine.Plant",u)
  6780. play_particle("particles/units/heroes/hero_techies/techies_remote_mine.vpcf",PATTACH_ABSORIGIN_FOLLOW,u,3)
  6781.  
  6782. Timers:CreateTimer(explode_time, function()
  6783. GameRules:GetGameModeEntity().unit[at_team][y..'_'..x] = 0
  6784. --爆炸
  6785. EmitSoundOn("Hero_Techies.RemoteMine.Detonate",u)
  6786. play_particle("particles/dac/zhayaotong/zhayaotong.vpcf",PATTACH_ABSORIGIN_FOLLOW,u,2)
  6787. --伤害
  6788. -- prt('爆炸,caster是'..caster:GetTeam()..'队的')
  6789. ApplyDamageInRadius({
  6790. caster = caster,
  6791. team = team,
  6792. radius = range,
  6793. role = 2,
  6794. position = u:GetAbsOrigin(),
  6795. damage = damage,
  6796. damage_type = DAMAGE_TYPE_PHYSICAL,
  6797. })
  6798. u:SetModelScale(0.001)
  6799. Timers:CreateTimer(2,function()
  6800. u:Destroy()
  6801. end)
  6802. end)
  6803. end
  6804.  
  6805. function LycSummonWolf(keys)
  6806. local ability = keys.ability
  6807. local caster = keys.caster
  6808. local level = ability:GetLevel() or 1
  6809. local hp_per = keys.hp_per
  6810. play_particle("particles/units/heroes/hero_lycan/lycan_shapeshift_cast.vpcf",PATTACH_ABSORIGIN_FOLLOW,caster,3)
  6811. EmitSoundOn("Hero_Lycan.Shapeshift.Cast",caster)
  6812.  
  6813. local lyc_model = {
  6814. [1] = "models/items/lycan/ultimate/ambry_true_form/ambry_true_form.vmdl",--"models/heroes/lycan/lycan_wolf.vmdl",
  6815. [2] = "models/items/lycan/ultimate/alpha_trueform9/alpha_trueform9.vmdl",
  6816. [3] = "models/items/lycan/ultimate/hunter_kings_trueform/hunter_kings_trueform.vmdl",
  6817. }
  6818. local shift_model = lyc_model[level]
  6819. if shift_model ~= nil then
  6820. caster:SetOriginalModel(shift_model)
  6821. caster:SetModel(shift_model)
  6822. AddMaxHPPer({
  6823. caster = caster,
  6824. per = hp_per
  6825. })
  6826. end
  6827.  
  6828. Timers:CreateTimer(0.1,function()
  6829. local w = SummonOneMinion(caster,'lyc_wolf'..level)
  6830. ExtendBeastBuff(w,caster)
  6831. Timers:CreateTimer(0.2,function()
  6832. local w = SummonOneMinion(caster,'lyc_wolf'..level)
  6833. ExtendBeastBuff(w,caster)
  6834. end)
  6835. end)
  6836. end
  6837.  
  6838. function TbMohua(keys)
  6839. local ability = keys.ability
  6840. local caster = keys.caster
  6841. local level = ability:GetLevel() or 1
  6842.  
  6843. EmitSoundOn('Hero_Terrorblade.Sunder.Cast',caster)
  6844.  
  6845. play_particle("particles/units/heroes/hero_terrorblade/terrorblade_metamorphosis_transform.vpcf",PATTACH_ABSORIGIN_FOLLOW,caster,3)
  6846.  
  6847. local mohua_model = {
  6848. [1] = "models/heroes/terrorblade/demon.vmdl",
  6849. [2] = "models/items/terrorblade/knight_of_foulfell_demon/knight_of_foulfell_demon.vmdl",
  6850. [3] = "models/items/terrorblade/dotapit_s3_fallen_light_metamorphosis/dotapit_s3_fallen_light_metamorphosis.vmdl",
  6851. }
  6852. local shift_model = mohua_model[level]
  6853. if shift_model ~= nil then
  6854. caster:SetOriginalModel(shift_model)
  6855. caster:SetModel(shift_model)
  6856. end
  6857. end
  6858.  
  6859. function VenoSummonWard(keys)
  6860. local ability = keys.ability
  6861. local caster = keys.caster
  6862. local level = ability:GetLevel() or 1
  6863. local p = keys.target_points[1]
  6864.  
  6865. Timers:CreateTimer(0.1,function()
  6866. local w = SummonOneMinion(caster,'veno_ward'..level, p)
  6867. ExtendBeastBuff(w,caster)
  6868. end)
  6869. end
  6870. --召唤物继承野兽buff
  6871. function ExtendBeastBuff(unit,owner)
  6872. if owner:FindAbilityByName('is_beast_buff')~=nil then
  6873. AddAbilityAndSetLevel(unit,'is_beast_buff')
  6874. end
  6875. if owner:FindAbilityByName('is_beast_buff_plus')~=nil then
  6876. AddAbilityAndSetLevel(unit,'is_beast_buff_plus')
  6877. end
  6878. if owner:FindAbilityByName('is_beast_buff_plus_plus')~=nil then
  6879. AddAbilityAndSetLevel(unit,'is_beast_buff_plus_plus')
  6880. end
  6881. end
  6882. function FurTree(keys)
  6883. local ability = keys.ability
  6884. local caster = keys.caster
  6885. local level = ability:GetLevel() or 1
  6886. local p = keys.target_points[1]
  6887.  
  6888. print(caster:GetAbsOrigin())
  6889. print(p)
  6890.  
  6891. Timers:CreateTimer(0.1,function()
  6892. local w = SummonOneMinion(caster, 'fur_tree'..level, p)
  6893. ExtendBeastBuff(w,caster)
  6894. end)
  6895. end
  6896. function LdBear(keys)
  6897. local ability = keys.ability
  6898. local caster = keys.caster
  6899. local level = ability:GetLevel() or 1
  6900.  
  6901. Timers:CreateTimer(0.1,function()
  6902. local w = SummonOneMinion(caster,'ld_bear'..level)
  6903. ExtendBeastBuff(w,caster)
  6904. end)
  6905. end
  6906. function CKillusion(keys)
  6907. local caster = keys.caster
  6908. play_particle("particles/units/heroes/hero_chaos_knight/chaos_knight_phantasm.vpcf",PATTACH_ABSORIGIN_FOLLOW,caster,3)
  6909. EmitSoundOn("Hero_ChaosKnight.Phantasm",caster)
  6910. Timers:CreateTimer(0.1,function()
  6911. local i1 = SummonOneMinion(caster,'chess_ck_ssr_illusion')
  6912. i1:AddNewModifier(i1,nil,"modifier_illusion",nil)
  6913. Timers:CreateTimer(0.2,function()
  6914. local i2 = SummonOneMinion(caster,'chess_ck_ssr_illusion')
  6915. i2:AddNewModifier(i1,nil,"modifier_illusion",nil)
  6916. Timers:CreateTimer(0.3,function()
  6917. local i3 = SummonOneMinion(caster,'chess_ck_ssr_illusion')
  6918. i3:AddNewModifier(i1,nil,"modifier_illusion",nil)
  6919. end)
  6920. end)
  6921. end)
  6922. end
  6923. function SummonOneMinion(caster, minion, p)
  6924. if caster == nil then
  6925. return
  6926. end
  6927. local v = p or FindEmptyGridAtUnit(caster)
  6928. local teamid = caster.team_id
  6929. local at_teamid = caster.at_team_id or caster.team_id
  6930. if v == nil then
  6931. return
  6932. end
  6933. if teamid == nil then
  6934. return
  6935. end
  6936. if at_teamid == nil then
  6937. return
  6938. end
  6939. local x = CreateUnitByName(minion,v,true,nil,nil,teamid)
  6940.  
  6941. table.insert(GameRules:GetGameModeEntity().to_be_destory_list[at_teamid],x)
  6942. x:SetForwardVector(caster:GetForwardVector())
  6943. AddAbilityAndSetLevel(x,'root_self')
  6944. AddAbilityAndSetLevel(x,'jiaoxie_wudi')
  6945. x.x = Vector2X(v,at_teamid)
  6946. x.y = Vector2Y(v,at_teamid)
  6947. x.y_x = ''..x.y..'_'..x.x
  6948. if caster.at_team_id ~= nil then
  6949. x.at_team_id = caster.at_team_id
  6950. end
  6951. if caster.team_id ~= nil then
  6952. x.team_id = caster.team_id
  6953. end
  6954. GameRules:GetGameModeEntity().unit[at_teamid][x.y..'_'..x.x] = 1
  6955. Timers:CreateTimer(function()
  6956. if x == nil or x:IsNull() == true or x:IsAlive() == false or x.alreadywon == true then
  6957. return
  6958. end
  6959. ChessAI(x)
  6960. return 1
  6961. end)
  6962.  
  6963. return x
  6964. end
  6965.  
  6966. function FindAClosestEnemyAndAttack(u)
  6967. --已经有目标
  6968. if u.attack_target ~= nil and u.attack_target:IsInvisible() == false and u.attack_target:IsNull() == false and u.attack_target:IsAlive() == true and (u.attack_target:GetAbsOrigin() - u:GetAbsOrigin()):Length2D() < u:Script_GetAttackRange() - u.attack_target:GetHullRadius() then
  6969. local newOrder = {
  6970. UnitIndex = u:entindex(),
  6971. OrderType = DOTA_UNIT_ORDER_ATTACK_TARGET,
  6972. TargetIndex = u.attack_target:entindex(),
  6973. Queue = 0
  6974. }
  6975. ExecuteOrderFromTable(newOrder)
  6976. return 1
  6977. end
  6978. local team_id = u.at_team_id or u.team_id
  6979. local all_unit = GameRules:GetGameModeEntity().to_be_destory_list[team_id]
  6980. local attack_range = u:Script_GetAttackRange()
  6981. local closest_enemy = nil
  6982. local closest_distance = 9999
  6983.  
  6984. for _,v in pairs(all_unit) do
  6985. if v ~= nil and v:IsNull() == false and v:IsAlive() == true then
  6986. if v.team_id ~= u.team_id and v:IsInvisible() == false then
  6987. local d = (v:GetAbsOrigin() - u:GetAbsOrigin()):Length2D()
  6988. if d < closest_distance and d < attack_range - v:GetHullRadius() then
  6989. closest_enemy = v
  6990. closest_distance = d
  6991. end
  6992. end
  6993. end
  6994. end
  6995.  
  6996. if closest_enemy ~= nil then
  6997. u.attack_target = closest_enemy
  6998. local newOrder = {
  6999. UnitIndex = u:entindex(),
  7000. OrderType = DOTA_UNIT_ORDER_ATTACK_TARGET,
  7001. TargetIndex = closest_enemy:entindex(),
  7002. Queue = 0
  7003. }
  7004. ExecuteOrderFromTable(newOrder)
  7005. return 1
  7006. else
  7007. u.attack_target = nil
  7008. return nil
  7009. end
  7010. end
  7011.  
  7012. function AddLoseStreak(team)
  7013. local hero = GameRules:GetGameModeEntity().teamid2hero[team]
  7014. if hero.lose_streak == nil then
  7015. hero.lose_streak = 0
  7016. end
  7017. hero.lose_streak = hero.lose_streak + 1
  7018. end
  7019. function RemoveLoseStreak(team)
  7020. local hero = GameRules:GetGameModeEntity().teamid2hero[team]
  7021. hero.lose_streak = 0
  7022. end
  7023. function AddWinStreak(team)
  7024. local hero = GameRules:GetGameModeEntity().teamid2hero[team]
  7025. if hero.win_streak == nil then
  7026. hero.win_streak = 0
  7027. end
  7028. hero.win_streak = hero.win_streak + 1
  7029.  
  7030. --连胜膨胀
  7031. local sca = 1+hero.win_streak*0.1
  7032. if sca >= 2 then
  7033. sca = 2
  7034. --起飞!
  7035. play_particle("particles/units/heroes/hero_shadowshaman/shadowshaman_voodoo.vpcf",PATTACH_ABSORIGIN_FOLLOW,hero,3)
  7036. local new_m = ChangeFlyingCourierModel(hero.ori_model)
  7037. hero:SetOriginalModel(new_m)
  7038. hero:SetModel(new_m)
  7039. end
  7040. hero:SetModelScale(sca)
  7041. if hero.win_streak == 5 or hero.win_streak == 8 or hero.win_streak == 10 then
  7042. CustomGameEventManager:Send_ServerToAllClients("win_streak",{
  7043. player_id = hero:GetPlayerID(),
  7044. streak = hero.win_streak,
  7045. })
  7046. end
  7047. end
  7048. function RemoveWinStreak(team)
  7049. local hero = GameRules:GetGameModeEntity().teamid2hero[team]
  7050. if hero ~= nil and hero.win_streak ~= nil and hero.win_streak >= 5 then
  7051. EmitSoundOn("DOTA_Item.AbyssalBlade.Activate",hero)
  7052. play_particle("particles/items_fx/abyssal_blade_jugger.vpcf",PATTACH_OVERHEAD_FOLLOW,hero,3)
  7053.  
  7054. hero:SetOriginalModel(hero.ori_model)
  7055. hero:SetModel(hero.ori_model)
  7056. end
  7057. hero.win_streak = 0
  7058. hero:SetModelScale(1)
  7059. end
  7060.  
  7061. function DAC:OnKeyboardPickChess(keys)
  7062. if keys.team ~= nil and TeamId2Hero(keys.team) ~= nil and TeamId2Hero(keys.team).hand_entities ~= nil and TeamId2Hero(keys.team).hand_entities[keys.chess_index] ~= nil then
  7063. -- PickChess({
  7064. -- target = TeamId2Hero(keys.team).hand_entities[keys.chess_index],
  7065. -- caster = TeamId2Hero(keys.team),
  7066. -- })
  7067.  
  7068. local hero = TeamId2Hero(keys.team)
  7069. local chess = TeamId2Hero(keys.team).hand_entities[keys.chess_index]
  7070.  
  7071. local newOrder = {
  7072. UnitIndex = hero:entindex(),
  7073. OrderType = DOTA_UNIT_ORDER_CAST_TARGET,
  7074. TargetIndex = chess:entindex(),
  7075. AbilityIndex = hero:FindAbilityByName("pick_chess"):entindex(),
  7076. Position = nil,
  7077. Queue = 0
  7078. }
  7079. ExecuteOrderFromTable(newOrder)
  7080. end
  7081. end
  7082.  
  7083. --调用寻路算法
  7084. function FindPath(p1,p2,team)
  7085. local map = {
  7086. {0,0,0,0,0,0,0,0},
  7087. {0,0,0,0,0,0,0,0},
  7088. {0,0,0,0,0,0,0,0},
  7089. {0,0,0,0,0,0,0,0},
  7090. {0,0,0,0,0,0,0,0},
  7091. {0,0,0,0,0,0,0,0},
  7092. {0,0,0,0,0,0,0,0},
  7093. {0,0,0,0,0,0,0,0},
  7094. }
  7095.  
  7096. for u,v in pairs(GameRules:GetGameModeEntity().unit[team]) do
  7097. local y = tonumber(string.split(u,'_')[1])
  7098. local x = tonumber(string.split(u,'_')[2])
  7099. if v == 1 then
  7100. map[y][x] = 1
  7101. end
  7102. end
  7103.  
  7104. -- Value for walkable tiles
  7105. local walkable = 0
  7106.  
  7107. -- Library setup
  7108. local Grid = require ("pathfinder/grid") -- The grid class
  7109. local Pathfinder = require ("pathfinder/pathfinder") -- The pathfinder lass
  7110.  
  7111. -- Creates a grid object
  7112. local grid = nil
  7113.  
  7114. grid = Grid(map)
  7115. --grid = Grid(map)
  7116.  
  7117. -- Creates a pathfinder object using Jump Point Search
  7118. local myFinder = nil
  7119. myFinder = Pathfinder(grid, 'JPS', walkable)
  7120.  
  7121. -- Define start and goal locations coordinates
  7122. local startx, starty = Vector2X(p1,team),Vector2Y(p1,team)
  7123. local endx, endy = Vector2X(p2,team), Vector2Y(p2,team)
  7124.  
  7125. map[starty][startx] = 0
  7126.  
  7127. --local startx, starty = 2,2
  7128. --local endx, endy = 9,9
  7129.  
  7130. -- Calculates the path, and its length
  7131. local path, length = myFinder:getPath(startx, starty, endx, endy)
  7132.  
  7133. if path then
  7134. local dx = 0
  7135. local dy = 0
  7136. local lastx = -100
  7137. local lasty = -100
  7138. local lastdx = -100
  7139. local lastdy = -100
  7140. local lastd = -100
  7141. local d = 0
  7142. local pppp = {}
  7143.  
  7144. for node, count in path:iter() do
  7145.  
  7146. dx = node.x-lastx
  7147. dy = node.y-lasty
  7148.  
  7149. if dy==0 then
  7150. d = 999
  7151. else
  7152. d = dx/dy
  7153. end
  7154.  
  7155. local lastindex = table.maxn (pppp)
  7156.  
  7157. if d~=lastd or lastindex<=1 then
  7158. table.insert (pppp, node)
  7159. else
  7160. pppp[lastindex] = node
  7161. end
  7162. lastdx = dx
  7163. lastdy = dy
  7164. lastx = node.x
  7165. lasty = node.y
  7166. lastd = d
  7167.  
  7168. end
  7169.  
  7170. --找到路了
  7171. for _,node in pairs(pppp) do
  7172. if node.x ~= startx or node.y ~= starty then
  7173. return XY2Vector(node.x,node.y,team)
  7174. end
  7175. end
  7176.  
  7177. return nil
  7178. else
  7179. -- print('find NO')
  7180. --没找到路
  7181. return nil
  7182. end
  7183. end
  7184.  
  7185. function InitChessPool()
  7186. local chess_pool_times = GameRules:GetGameModeEntity().CHESS_POOL_SIZE or 6
  7187. for cost,v in pairs(GameRules:GetGameModeEntity().chess_list_by_mana) do
  7188. for _,chess in pairs(v) do
  7189. local chess_count = GameRules:GetGameModeEntity().CHESS_INIT_COUNT[cost]*chess_pool_times
  7190. -- if chess == 'chess_eh' or chess == 'chess_fur' or chess == 'chess_tp' or chess == 'chess_ld' then
  7191. -- chess_count = math.floor(chess_count*GameRules:GetGameModeEntity().CHESS_INIT_DRUID_PER)
  7192. -- end
  7193. for i=1,chess_count do
  7194. AddAChessToChessPool(chess)
  7195. end
  7196. end
  7197. end
  7198. prt('INIT CHESS POOL OK!')
  7199. end
  7200.  
  7201. function DrawAChessFromChessPool(cost, table_11chess)
  7202. if table_11chess == nil then
  7203. table_11chess = {}
  7204. end
  7205. if GameRules:GetGameModeEntity().chess_pool[cost] == nil or table.maxn(GameRules:GetGameModeEntity().chess_pool[cost])<1 then
  7206. --棋库空了
  7207. return nil
  7208. end
  7209. local index = RandomInt(1,table.maxn(GameRules:GetGameModeEntity().chess_pool[cost]))
  7210. local chess_name = GameRules:GetGameModeEntity().chess_pool[cost][index]
  7211.  
  7212. if FindValueInTable(table_11chess,chess_name) == true then
  7213. return nil
  7214. end
  7215.  
  7216. table.remove(GameRules:GetGameModeEntity().chess_pool[cost],index)
  7217. return chess_name
  7218. end
  7219.  
  7220. function AddAChessToChessPool(chess)
  7221. if string.find(chess,'ssr') then
  7222. return
  7223. end
  7224. local maxcount = 1
  7225. if string.find(chess,'11') ~= nil and (string.find(chess,'tp') ~= nil or string.find(chess,'eh') ~= nil) then
  7226. chess = string.sub(chess,1,-2)
  7227. maxcount = 4
  7228. end
  7229. if string.find(chess,'1') ~= nil and (string.find(chess,'tp') ~= nil or string.find(chess,'eh') ~= nil) then
  7230. chess = string.sub(chess,1,-2)
  7231. maxcount = 2
  7232. end
  7233. if string.find(chess,'11') ~= nil then
  7234. chess = string.sub(chess,1,-2)
  7235. maxcount = 9
  7236. end
  7237. if string.find(chess,'1') ~= nil then
  7238. chess = string.sub(chess,1,-2)
  7239. maxcount = 3
  7240. end
  7241. for count = 1,maxcount do
  7242. if GameRules:GetGameModeEntity().chess_2_mana[chess] ~= nil and FindValueInTable(GameRules:GetGameModeEntity().chess_list_ssr,chess) == false then
  7243. local cost = GameRules:GetGameModeEntity().chess_2_mana[chess]
  7244. table.insert(GameRules:GetGameModeEntity().chess_pool[cost],chess)
  7245. end
  7246. end
  7247. end
  7248.  
  7249. function PrintChessPool()
  7250. local count = {
  7251. [1] = 0,
  7252. [2] = 0,
  7253. [3] = 0,
  7254. [4] = 0,
  7255. [5] = 0,
  7256. }
  7257. local count_all = 0
  7258.  
  7259. for i=1,5 do
  7260. count[i] = table.maxn(GameRules:GetGameModeEntity().chess_pool[i])
  7261. count_all = count_all + count[i]
  7262. end
  7263.  
  7264. prt('棋库有'..count_all..'个棋子('..count[1]..'/'..count[2]..'/'..count[3]..'/'..count[4]..'/'..count[5]..')')
  7265. end
  7266.  
  7267. function SendHTTP(url, callback, fail_callback)
  7268. local req = CreateHTTPRequestScriptVM('GET', url)
  7269. req:SetHTTPRequestAbsoluteTimeoutMS(30000)
  7270.  
  7271. req:Send(function(res)
  7272. if res.StatusCode ~= 200 or not res.Body then
  7273. -- prt('CONNECT SERVER ERROR:'..res.StatusCode)
  7274. if fail_callback ~= nil then
  7275. fail_callback(obj)
  7276. end
  7277. return
  7278. end
  7279.  
  7280. local obj = json.decode(res.Body)
  7281. if callback ~= nil then
  7282. callback(obj)
  7283. end
  7284. end)
  7285. end
  7286.  
  7287. function StatChess()
  7288. local statinfo = {}
  7289. for i=6,13 do
  7290. for _,chess in pairs(GameRules:GetGameModeEntity().mychess[i]) do
  7291. local find_name = chess.chess
  7292. local chess_count = 1
  7293. if string.find(chess.chess,'11') ~= nil and (string.find(chess.chess,'tp') ~= nil or string.find(chess.chess,'eh') ~= nil) then
  7294. find_name = string.sub(chess.chess,1,-2)
  7295. chess_count = 4
  7296. end
  7297. if string.find(chess.chess,'1') ~= nil and (string.find(chess.chess,'tp') ~= nil or string.find(chess.chess,'eh') ~= nil) then
  7298. find_name = string.sub(chess.chess,1,-2)
  7299. chess_count = 2
  7300. end
  7301. if string.find(chess.chess,'11') then
  7302. chess_count = 9
  7303. find_name = string.sub(chess.chess,1,-3)
  7304. elseif string.find(chess.chess,'1') then
  7305. chess_count = 3
  7306. find_name = string.sub(chess.chess,1,-2)
  7307. end
  7308. if statinfo[find_name] == nil then
  7309. statinfo[find_name] = chess_count
  7310. else
  7311. statinfo[find_name] = statinfo[find_name] + chess_count
  7312. end
  7313. end
  7314. end
  7315. for j=6,13 do
  7316. local hhh = TeamId2Hero(j)
  7317. if hhh ~= nil and hhh.hand_entities ~= nil then
  7318. for _,ent in pairs(hhh.hand_entities) do
  7319. local find_name = ent:GetUnitName()
  7320. local chess_count = 1
  7321. if string.find(ent:GetUnitName(),'11') then
  7322. chess_count = 9
  7323. find_name = string.sub(ent:GetUnitName(),1,-3)
  7324. elseif string.find(ent:GetUnitName(),'1') then
  7325. chess_count = 3
  7326. find_name = string.sub(ent:GetUnitName(),1,-2)
  7327. end
  7328. if statinfo[find_name] == nil then
  7329. statinfo[find_name] = chess_count
  7330. else
  7331. statinfo[find_name] = statinfo[find_name] + chess_count
  7332. end
  7333. end
  7334. end
  7335. end
  7336. CustomNetTables:SetTableValue( "dac_table", "stat_chess", { statinfo = statinfo, hehe = RandomInt(1,1000)})
  7337. end
  7338.  
  7339. --辅助功能——捕捉一只螃蟹,发回pui
  7340. function DAC:OnCatchCrab(keys)
  7341. local url = keys.url.."&key="..GetDedicatedServerKey('dac')
  7342. local cb = keys.cb
  7343. if url == null or cb == null then
  7344. return
  7345. end
  7346. local player_id = keys.player_id
  7347.  
  7348. Timers:CreateTimer(RandomFloat(0,1),function()
  7349. SendHTTP(url, function(t)
  7350. CustomGameEventManager:Send_ServerToPlayer(PlayerResource:GetPlayer(player_id),'send_http_cb',{
  7351. event = cb,
  7352. data = json.encode(t),
  7353. hehe = RandomInt(1,100000),
  7354. })
  7355. end)
  7356. end)
  7357. end
  7358. function DAC:OnUnlockChess(keys)
  7359. local hero = TeamId2Hero(keys.team)
  7360. hero.chesslock = false
  7361. end
  7362. function DAC:OnLockChess(keys)
  7363. local hero = TeamId2Hero(keys.team)
  7364. hero.chesslock = true
  7365. end
  7366.  
  7367. function NecSSRScythe(keys)
  7368. local target = keys.target
  7369. local caster = keys.caster
  7370. local damage = 9999
  7371.  
  7372. play_particle_controlIndex("particles/econ/items/necrolyte/necro_sullen_harvest/necro_ti7_immortal_scythe_start.vpcf",PATTACH_ABSORIGIN_FOLLOW,target,3,1)
  7373. EmitSoundOn("Hero_Necrolyte.ReapersScythe.Target",target)
  7374.  
  7375. EmitSoundOn("necrolyte_necr_kill_10",target)
  7376.  
  7377. -- --如果目标受伤 就斩杀
  7378. -- if target:GetHealth() < target:GetMaxHealth() then
  7379. -- damage = 9999
  7380. -- end
  7381.  
  7382. Timers:CreateTimer(1.5,function()
  7383. local damageTable = {
  7384. victim=target,
  7385. attacker=caster,
  7386. damage_type=DAMAGE_TYPE_PURE,
  7387. damage=damage
  7388. }
  7389. ApplyDamage(damageTable)
  7390. end)
  7391. end
  7392.  
  7393. function play_particle_controlIndex(p, pos, u, d, controlIndex)
  7394. local pp = ParticleManager:CreateParticle(p, pos, u)
  7395. ParticleManager:SetParticleControl(pp,1,u:GetAbsOrigin())
  7396.  
  7397. Timers:CreateTimer(d,function()
  7398. if pp ~= nil then
  7399. ParticleManager:DestroyParticle(pp,true)
  7400. end
  7401. end)
  7402. end
  7403.  
  7404. function MakeTiny(x)
  7405. if x:GetUnitName() == 'chess_tiny11' then
  7406. x.part1 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/burning_stone_giant_head_level_4/burning_stone_giant_head_level_4.vmdl"})
  7407. x.part1:FollowEntity(x,true)
  7408. x.part2 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/burning_stone_giant_body_level_4/burning_stone_giant_body_level_4.vmdl"})
  7409. x.part2:FollowEntity(x,true)
  7410. x.part3 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/burning_stone_giant_right_arm_level_4/burning_stone_giant_right_arm_level_4.vmdl"})
  7411. x.part3:FollowEntity(x,true)
  7412. x.part4 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/burning_stone_giant_left_arm_level_4/burning_stone_giant_left_arm_level_4.vmdl"})
  7413. x.part4:FollowEntity(x,true)
  7414. end
  7415. if x:GetUnitName() == 'chess_tiny1' then
  7416. x.part1 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/scarletquarry_head_t3/scarletquarry_head_t3.vmdl"})
  7417. x.part1:FollowEntity(x,true)
  7418. x.part2 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/scarletquarry_armor_t2/scarletquarry_armor_t2.vmdl"})
  7419. x.part2:FollowEntity(x,true)
  7420. x.part3 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/scarletquarry_arms_t2/scarletquarry_arms_t2.vmdl"})
  7421. x.part3:FollowEntity(x,true)
  7422. x.part4 = SpawnEntityFromTableSynchronous('prop_dynamic',{model="models/items/tiny/scarletquarry_offhand_t2/scarletquarry_offhand_t2.vmdl"})
  7423. x.part4:FollowEntity(x,true)
  7424. end
  7425. end
  7426.  
  7427. function TinyTouzhi(keys)
  7428. local p = keys.target_points[1]
  7429. local caster = keys.caster
  7430. local ability = keys.ability
  7431. local level = ability:GetLevel()
  7432.  
  7433.  
  7434. local radius = keys.radius or 200
  7435. local damage = keys.damage or 100
  7436. local stun = keys.stun or 2
  7437.  
  7438. local target = FindUnluckyDog190(caster)
  7439. if target == nil then
  7440. return
  7441. end
  7442.  
  7443. local team_id = target.at_team_id or target.team_id
  7444. local v = FindFarthestEmptyGrid(target)
  7445. local yy = target.y
  7446. local xx = target.x
  7447.  
  7448. local y = Vector2Y(v,team_id)
  7449. local x = Vector2X(v,team_id)
  7450. local stun_duration = ((v-target:GetAbsOrigin()):Length2D()/1000)
  7451.  
  7452. Timers:CreateTimer(stun_duration,function()
  7453. ApplyDamageInRadius({
  7454. caster = caster,
  7455. team = 2,
  7456. radius = radius,
  7457. role = 2,
  7458. position = target:GetAbsOrigin(),
  7459. damage = damage,
  7460. damage_type = DAMAGE_TYPE_PHYSICAL,
  7461. })
  7462. play_particle("particles/units/heroes/hero_tiny/tiny_toss_impact.vpcf",PATTACH_ABSORIGIN_FOLLOW,target,3)
  7463. EmitSoundOn('Ability.TossImpact',target)
  7464. end)
  7465.  
  7466. target:AddNewModifier(target,nil,"modifier_stunned",{ duration = stun_duration+stun })
  7467.  
  7468. GameRules:GetGameModeEntity().unit[team_id][y..'_'..x] = 1
  7469.  
  7470. BlinkChessX({p=v,caster=target})
  7471. target.y_x = y..'_'..x
  7472. target.y = y
  7473. target.x = x
  7474. GameRules:GetGameModeEntity().unit[team_id][yy..'_'..xx] = nil
  7475. end
  7476.  
  7477. function FindFarthestEmptyGrid(u)
  7478. local team_id = u.at_team_id or u.team_id
  7479. local result_postion = nil
  7480. local length2d = 0
  7481. for x=1,8 do
  7482. for y=1,8 do
  7483. local pos = XY2Vector(x,y,team_id)
  7484. if GameRules:GetGameModeEntity().unit[team_id][y..'_'..x] == nil then
  7485. if (u:GetAbsOrigin() - pos):Length2D() > length2d then
  7486. result_postion = pos
  7487. length2d = (u:GetAbsOrigin() - pos):Length2D()
  7488. end
  7489. end
  7490. end
  7491. end
  7492. return result_postion
  7493. end
  7494. function StatusResistance(keys)
  7495. keys.caster:AddNewModifier(keys.caster,keys.ability,"modifier_status_resistance",nil)
  7496. end
  7497.  
  7498. function QiquWaibiao(keys)
  7499. local attacker = keys.attacker
  7500. local caster = keys.caster
  7501. local duration = keys.duration or 2
  7502.  
  7503. if attacker:Script_GetAttackRange() < 250 then
  7504. --近战
  7505. EmitSoundOn("Hero_Tiny.CraggyExterior",attacker)
  7506. attacker:AddNewModifier(attacker,nil,"modifier_stunned",{ duration = 2 })
  7507. attacker:AddNewModifier(attacker,nil,"modifier_medusa_stone_gaze_stone",{ duration = 2 })
  7508. end
  7509. end
  7510.  
  7511. function DemonAttack(keys)
  7512. local caster = keys.caster
  7513. local target = keys.target
  7514.  
  7515. --获取攻击伤害
  7516. local damage = math.floor((keys.attack_damage or 0) / 2)
  7517. local damageTable = {
  7518. victim=target,
  7519. attacker=caster,
  7520. damage_type=DAMAGE_TYPE_PURE,
  7521. damage=damage
  7522. }
  7523. ApplyDamage(damageTable)
  7524. end
  7525.  
  7526. function ChangeFlyingCourierModel(opp_model)
  7527. local new_m = string.sub(opp_model,1,string.len(opp_model)-5)..'_flying.vmdl'
  7528. if opp_model == "models/courier/mighty_boar/mighty_boar.vmdl" then
  7529. new_m = "models/courier/mighty_boar/mighty_boar_wings.vmdl"
  7530. end
  7531. if opp_model == "models/courier/yak/yak.vmdl" then
  7532. new_m = "models/courier/yak/yak_wings.vmdl"
  7533. end
  7534. if opp_model == "models/props_gameplay/donkey_dire.vmdl" then
  7535. new_m = "models/props_gameplay/donkey_dire_wings.vmdl"
  7536. end
  7537. if opp_model == "models/props_gameplay/donkey.vmdl" then
  7538. new_m = "models/props_gameplay/donkey_wings.vmdl"
  7539. end
  7540. if opp_model == "models/items/juggernaut/ward/fortunes_tout/fortunes_tout.vmdl" then
  7541. new_m = opp_model
  7542. end
  7543. if opp_model == "models/items/furion/treant_flower_1.vmdl" then
  7544. new_m = opp_model
  7545. end
  7546. if opp_model == "models/items/furion/treant/hallowed_horde/hallowed_horde.vmdl" then
  7547. new_m = opp_model
  7548. end
  7549. if opp_model == "models/items/furion/treant/furion_treant_nelum_red/furion_treant_nelum_red.vmdl" then
  7550. new_m = opp_model
  7551. end
  7552. if opp_model == "models/items/furion/treant/ravenous_woodfang/ravenous_woodfang.vmdl" then
  7553. new_m = opp_model
  7554. end
  7555.  
  7556. return new_m
  7557. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement