diff --git a/HeroSkin.txt b/HeroSkin.txt new file mode 100644 index 000000000..09d749b1d --- /dev/null +++ b/HeroSkin.txt @@ -0,0 +1,25 @@ +SKINTOTAL HERO_ID(SKIN0) SKIN1 SKIN2 SKIN3 SKIN4 SKIN5 SKIN6 SKIN7 +7 Hpal Huth Hlgr Hpb1 Hpb2 Hapm Hart Harf +4 Hamg Hgam Hant Haah Hjai nmed Hjas 0 +1 Hmkg Hmbr 0 0 0 0 0 0 +1 Hblm Hkal 0 0 0 0 0 0 +4 Obla Osam Opgh Ogrh Nbbc 0 0 0 +3 Ofar Odrt Oths Othr odkt Ogld Ofth 0 +0 Otch 0 0 0 0 0 0 0 +1 Oshd Orkn 0 0 0 0 0 0 +1 Udea Harf Udef Uart 0 0 0 0 +2 Ulic uktg Uktl uktn Uclc 0 0 0 +6 Udre Ubal Utic Uvar Uvng Udth Umal 0 +1 Ucrl Uanb 0 0 0 0 0 0 +5 Ekee Ecen Ekgg Emfr Efur Emns Ekce 0 +1 Emoo Etyr 0 0 0 0 0 0 +1 Edem Eevi Edef 0 0 0 0 0 +1 Ewar Ewrd 0 0 0 0 0 0 +0 Nalc 0 0 0 0 0 0 0 +1 Nngs Hvsh 0 0 0 0 0 0 +0 Ntin 0 0 0 0 0 0 0 +1 Nbst Orex 0 0 0 0 0 0 +3 Nplh Nmag Npld Nman 0 0 0 0 +0 Nfir 0 0 0 0 0 0 0 +1 Npbm Nsjs 0 0 0 0 0 0 +3 Nbrn Usyl uswb Hvwd 0 0 0 0 \ No newline at end of file diff --git a/REFORGED/custom_common.eai b/REFORGED/custom_common.eai index 1f7f7aa5e..15476a345 100644 --- a/REFORGED/custom_common.eai +++ b/REFORGED/custom_common.eai @@ -11,4 +11,8 @@ boolean AatpAbility = true function VersionCheck takes nothing returns nothing endfunction + +function BlzSetUnitSkinAMAI takes unit u, integer i returns nothing + call BlzSetUnitSkin(u, i) +endfunction #ENDIF diff --git a/ROC/custom_common.eai b/ROC/custom_common.eai index 8205e2009..5391be836 100644 --- a/ROC/custom_common.eai +++ b/ROC/custom_common.eai @@ -48,6 +48,10 @@ function VersionCheck takes nothing returns nothing endif endfunction +function BlzSetUnitSkinAMAI takes unit u, integer i returns nothing + +endfunction + function GetBJMaxPlayers takes nothing returns integer return bj_MAX_PLAYERS_AMAI endfunction @@ -119,4 +123,4 @@ function BlzGroupGetSize takes group whichGroup returns integer set g = null return i endfunction -#ENDIF \ No newline at end of file +#ENDIF diff --git a/TFT/custom_common.eai b/TFT/custom_common.eai index 0df32ee77..232b4c6c2 100644 --- a/TFT/custom_common.eai +++ b/TFT/custom_common.eai @@ -55,6 +55,10 @@ function VersionCheck takes nothing returns nothing endif endfunction +function BlzSetUnitSkinAMAI takes unit u, integer i returns nothing + +endfunction + function GetBJMaxPlayers takes nothing returns integer return bj_MAX_PLAYERS_AMAI endfunction diff --git a/common.eai b/common.eai index defe26e0b..301dbe9dc 100644 --- a/common.eai +++ b/common.eai @@ -9280,6 +9280,57 @@ function GetExistingHero takes nothing returns integer endfunction //============================================================================ +#DEFINE $SKINSTART$ 3 +#DEFINE $SKINEND$ 9 +function GetHeroSkin takes integer hn returns nothing + local integer i = 0 + local integer array skin + if p_rare[profile] < 1 or GetRandomInt(0, 100) < 20 then // not fully use new skin , random int use original skin - 0 : change skin will change proper name (AI Scripts cannot use GetHeroProperName and BlzSetHeroProperName) + return + #INCLUDETABLE #EFR + elseif old_id[hero[hn]] == '%2' then + #FOR $X$ FROM $SKINSTART$ TO $SKINEND$ + set skin[#EVAL{$X$-2}] = '%$X$' + #ENDFOR + set i = GetRandomInt(1, %1) + #AFTERINCLUDE + #ENDINCLUDE + else + return // unknow hero + endif + if skin[i] != '0' then + call BlzSetUnitSkinAMAI(hero_unit[hn], skin[i]) // set skin API at 1.33+ and some unit at 1.32+ , old WE make map cannot use - so just in case check max player num + endif +endfunction +#UNDEF $SKINSTART$ +#UNDEF $SKINEND$ + +function InitHeroInfo takes integer hn returns nothing + if hero_loc[hn] != null then + call RemoveLocation(hero_loc[hn]) + endif + set hero_loc[hn] = GetUnitLoc(hero_unit[hn]) + if hero_enemy_loc[hn] != null then + call RemoveLocation(hero_enemy_loc[hn]) + endif + if hero_ally_loc[hn] != null then + call RemoveLocation(hero_ally_loc[hn]) + endif + set hero_enemy_loc[hn] = Location(0,0) + set hero_ally_loc[hn] = Location(0,0) + set hero_hp[hn] = 1 + call GetHeroSkin(hn) +endfunction + +function SetHeroUnit takes integer hn returns nothing + set hero_unit[hn] = GetOneOfId(hero_unit[hn], ai_player, old_id[hero[hn]]) + if hero_unit[hn] != null then + set hero_built[hn] = true + call InitHeroInfo(hn) + call TQAddJob(1, MICRO_HERO, hn) + endif +endfunction + function ChooseFirstHero takes nothing returns integer local integer i = 0 if hero_built[1] and recalculate_heros then @@ -9293,8 +9344,8 @@ function ChooseFirstHero takes nothing returns integer endloop endif if IsMapFlagSet(MAP_RANDOM_HERO) and hero[1] == null then -// call DisplayToAll("Map flag set") set hero[1] = GetExistingHero() + call SetHeroUnit(1) else call make_hero_rp_positive() set chosen = ChooseHero() @@ -11444,34 +11495,13 @@ endif endfunction //============================================================================ -function InitHeroInfo takes integer hn returns nothing - if hero_loc[hn] != null then - call RemoveLocation(hero_loc[hn]) - endif - set hero_loc[hn] = GetUnitLoc(hero_unit[hn]) - if hero_enemy_loc[hn] != null then - call RemoveLocation(hero_enemy_loc[hn]) - endif - if hero_ally_loc[hn] != null then - call RemoveLocation(hero_ally_loc[hn]) - endif - set hero_enemy_loc[hn] = Location(0,0) - set hero_ally_loc[hn] = Location(0,0) - set hero_hp[hn] = 1 -endfunction - function HeroReviver takes nothing returns nothing local integer i = 1 loop exitwhen i > 3 if GetUnitCountDone(old_id[hero[i]]) > 0 then if not hero_built[i] then - set hero_unit[i] = GetOneOfId(hero_unit[i], ai_player, old_id[hero[i]]) - if hero_unit[i] != null then - set hero_built[i] = true - call InitHeroInfo(i) - call TQAddJob(1, MICRO_HERO, i) - endif + call SetHeroUnit(i) endif elseif hero_built[i] then call BuildUnit(1, hero[i], hero_revive_prio[i]) @@ -13414,8 +13444,13 @@ function SkillArraysAM takes nothing returns integer if level > max_hero_level then set max_hero_level = level endif - if skillfix == true and hero_unit[hn] != null and UnitAlive(hero_unit[hn]) then //Assisted Hero Learning Skills , for war3 1.31 bug - call SelectHeroSkill(hero_unit[hn], skills[(hn - 1) * HERO_LEVEL_NUMBER + level]) + if skillfix == true then + if hero_unit[hn] == null then + set hero_unit[hn] = GetOneOfId(hero_unit[hn], ai_player, hero_id) + endif + if hero_unit[hn] != null and UnitAlive(hero_unit[hn]) then //Assisted Hero Learning Skills , for war3 1.31 bug + call SelectHeroSkill(hero_unit[hn], skills[(hn - 1) * HERO_LEVEL_NUMBER + level]) + endif endif return skills[(hn - 1) * HERO_LEVEL_NUMBER + level] endfunction