native GetUnitGoldCost takes integer unitid returns integer
native GetUnitWoodCost takes integer unitid returns integer
globals
// framehandle udg_FBS_GoldIcon
// framehandle udg_FBS_GoldText
framehandle udg_FBS_Tooltip
framehandle udg_FBS_Portrait
framehandle array udg_FBS_CommandHover
framehandle udg_DebugFrame
endglobals
Name | Type | is_array | initial_value |
AbilitiesToHide | abilcode | Yes | |
AncestralMeditation_Ability | abilcode | No | |
AncestralMeditation_AbilityOff | abilcode | No | |
AncestralMeditation_Aura | abilcode | No | |
AncestralMeditation_Buff | buffcode | No | |
AncestralMeditation_Cooldown | real | No | |
AncestralMeditation_DummyAb | abilcode | No | |
AncestralMeditation_DummyOrd | string | No | |
AncestralMeditation_Range | real | No | |
AncestralMeditation_SoundPath | string | No | |
AncestralMeditation_Threshold | real | No | |
AO_Buff | buffcode | No | |
AO_DamageReturn | real | No | |
AO_EffectPath | string | No | |
AO_LifeTaken | real | No | |
AO_ManaTaken | real | No | |
ArmoreType_Divine | integer | No | |
ArmoreType_Fortified | integer | No | |
ArmoreType_Hero | integer | No | |
ArmoreType_Large | integer | No | |
ArmoreType_Medium | integer | No | |
ArmoreType_Normal | integer | No | |
ArmoreType_Small | integer | No | |
ArmoreType_UnArmored | integer | No | |
AT_Ability | abilcode | No | |
AT_AbilityEviscerate | abilcode | No | |
AT_Buff | buffcode | No | |
AT_DamageFactor | real | No | |
AT_DamageFactorHero | real | No | |
BasilikRejuvenation_Ability | abilcode | No | |
Calibration_ArmorType | integer | No | |
Calibration_DamageType | integer | No | |
CB_Ability | abilcode | No | |
CB_CrocodileDuration | real | No | |
CB_CrocodileEgg | unitcode | No | |
CB_CrocodileEggAbility | abilcode | No | |
CB_Crocodiles | unitcode | Yes | |
CB_EggDuration | real | No | |
CB_TauntRange | real | No | |
ComputerPlayers | force | No | |
CorrosiveBite_Buff | buffcode | No | |
CorrosiveBite_BuffMarker | buffcode | No | |
CorrosiveBite_Duration | real | No | |
CorrosiveBite_SkillSource | abilcode | No | |
CorrosiveBite_SkillTargDeciOff | abilcode | No | |
CorrosiveBite_SkillTargDeciOn | abilcode | No | |
CorrosiveBite_SkillTarget | abilcode | No | |
CrushingBlow_Ability | abilcode | No | |
CrushingBlow_AbilityEviscerate | abilcode | No | |
CrushingBlow_BonusDamage | real | No | |
CrushingBlow_BonusMax | real | No | |
CrushingBlow_EffectPath | string | No | |
CrushingBlow_Research | techcode | No | |
CrushingBlow_TimerDuration | real | No | |
CrushingBlow_WeaponPath | string | No | |
CrushingWave_DummyAbility | abilcode | No | |
CrushingWave_DummyOrder | string | No | |
CrushingWave_Research | techcode | No | |
CrushingWave_SoundPath | string | No | |
CurrentMemory | integer | No | |
DanceOfTheAfterLifeHT | hashtable | No | |
DE_Ability | abilcode | No | |
DE_AttachmentModel | string | No | |
DE_Buff | buffcode | No | |
DE_DummyAbility | abilcode | No | |
DE_DummyOrder | string | No | |
DE_ExplosionDamageRatio | real | No | |
DE_ExplosionRange | real | No | |
DEBUG_MODE | boolean | No | false |
Dict_ASCII_IndexChar | integer | No | |
Dict_Color_IndexHexcode | integer | No | |
Dict_Command_IndexCode | integer | No | |
Dict_DC_IndexBuffAbilities | integer | No | |
Dict_DC_IndexBuffBonus | integer | No | |
Dict_DC_IndexBuffItems | integer | No | |
Dict_DC_IndexItemBonus | integer | No | |
Dict_EA_IndexAttackInterval | integer | No | |
Dict_EA_IndexBackSwing | integer | No | |
Dict_EA_IndexDamagePoint | integer | No | |
Dict_EA_IndexHealthRege | integer | No | |
Dict_EA_IndexProjectileArt | integer | No | |
Dict_EA_IndexWeaponSound | integer | No | |
Dict_Eviscerate_IndexSpells | integer | No | |
Dict_NC_AllocScale | integer | No | |
Dict_NC_IndexBuildTime | integer | No | |
Dict_NC_IndexEndDuration | integer | No | |
Dict_NC_IndexSize | integer | No | |
Dict_NW_AllocRange | integer | No | |
Dict_Research_IndexUpgradeEq | integer | No | |
DictHT | hashtable | No | |
DmgCoeff_Ch | real | No | |
DmgCoeff_He | real | No | |
DmgCoeff_Ma2 | real | No | |
DmgCoeff_No | real | No | |
DmgCoeff_Pi | real | No | |
DmgCoeff_Si | real | No | |
DmgCoeff_Sp | real | No | |
DOTAL_Ability | abilcode | No | |
DOTAL_CasterGroup | group | No | |
DOTAL_DummySpirit | unitcode | No | |
DOTAL_ImpactDamage | real | No | |
DOTAL_ImpactMana | real | No | |
DOTAL_ImpactRange | real | No | |
DOTAL_IndexAttachment | integer | No | |
DOTAL_IndexCaster | integer | No | |
DOTAL_IndexCenter | integer | No | |
DOTAL_IndexPhiAngle | integer | No | |
DOTAL_IndexRadius | integer | No | |
DOTAL_IndexSoundDummy | integer | No | |
DOTAL_IndexSpirit1 | integer | No | |
DOTAL_IndexSpirit2 | integer | No | |
DOTAL_IndexTarget1 | integer | No | |
DOTAL_IndexTarget1Life | integer | No | |
DOTAL_IndexTarget1Mana | integer | No | |
DOTAL_IndexTarget2 | integer | No | |
DOTAL_IndexTarget2Life | integer | No | |
DOTAL_IndexTarget2Mana | integer | No | |
DOTAL_IndexTarget3 | integer | No | |
DOTAL_IndexTarget3Life | integer | No | |
DOTAL_IndexTarget3Mana | integer | No | |
DOTAL_IndexThetaAngle | integer | No | |
DOTAL_IndexTotalCharges | integer | No | |
DOTAL_IndexTrigger | integer | No | |
DOTAL_MaxCharges | integer | No | |
DOTAL_MinimumRange | real | No | |
DOTAL_Order | string | No | |
DOTAL_PathAllyLifeVisual | string | No | |
DOTAL_PathAllyManaVisual | string | No | |
DOTAL_PathAllyVisual | string | No | |
DOTAL_PathCasterVisual | string | No | |
DOTAL_PathEnnemyVisual | string | No | |
DOTAL_PathLoopSound | string | No | |
DOTAL_Radius | real | No | |
DOTAL_RefreshInterval | real | No | |
DOTAL_Speed | real | No | |
Eviscerate_Ability | abilcode | No | |
Eviscerate_HealPath | string | No | |
Eviscerate_LifeRegained | real | No | |
Eviscerate_SpellStealDuration | real | No | |
ExtendedArm_Research | techcode | No | |
ExtendedArm_Unit | unitcode | No | |
FBS_HoveredObjectId | integer | Yes | |
FBS_HT | hashtable | No | |
FBS_SelectedGroup | group | Yes | |
FBS_SelectedUnit | unit | Yes | |
FBS_SelectionFrameCreator | unitcode | No | |
FervorAura_Ability | abilcode | No | |
FervorAura_AOE | real | No | |
FervorAura_BeastAbility | abilcode | No | |
FervorAura_BeastAbilityEvisc | abilcode | No | |
FervorAura_BoostAbility1 | abilcode | No | |
FervorAura_BoostAbility2 | abilcode | No | |
FervorAura_BoostAbility3 | abilcode | No | |
FervorAura_BoostBuff | buffcode | No | |
FervorAura_EmitterGroup | group | No | |
FervorAura_MaxEmitters | integer | No | |
FervorAura_TargetGroup | group | No | |
Frenzy_Ability | abilcode | No | |
Frenzy_AbilityBonusDamage | abilcode | No | |
Frenzy_AbilityBonusSpeed | abilcode | No | |
Frenzy_AbilityLearnable | abilcode | No | |
Frenzy_AbilityVisual | abilcode | No | |
Frenzy_Buff | buffcode | No | |
Frenzy_Cooldown | real | No | |
Frenzy_Duration | real | No | |
Frenzy_ManaCost | real | No | |
Frenzy_Order | string | No | |
FurthestLocation | location | No | |
GlobalTime | real | No | |
GoldMines_CheckOwnerShipAbilit | abilcode | No | |
GoldMines_CheckOwnerShipOrder | string | No | |
GoldMines_CheckTime | real | No | |
GoldMines_GroupToCheck | group | No | |
GoldMines_LowThreshold | integer | No | |
GoldMines_NeUdToCheck | group | No | |
GoldMines_UdToCheckDeath | group | No | |
GoldMines_WorkerRange | real | No | |
HealingFlask_Ability | abilcode | No | |
HealingFlask_DummyAbility | abilcode | No | |
HealingFlask_DummyItem | itemcode | No | |
HealingFlask_DummyOrder | string | No | |
HealingFlask_Speed | real | No | |
Hotkeys_TotalTriggers | integer | No | |
Hotkeys_Triggers | trigger | Yes | |
HotkeysHT | hashtable | No | |
HumanPlayers | force | No | |
HydraGrowth_Ability | abilcode | No | |
HydraGrowth_AllocCaster | integer | No | |
HydraGrowth_AllocDummyType | integer | No | |
HydraGrowth_AllocHydraX | integer | No | |
HydraGrowth_AllocHydraY | integer | No | |
HydraGrowth_AllocTimerL | integer | No | |
HydraGrowth_AllocTimerR | integer | No | |
HydraGrowth_AllocUnitL | integer | No | |
HydraGrowth_AllocUnitR | integer | No | |
HydraGrowth_AllowAttackAndMove | boolean | No | |
HydraGrowth_AlternateGroup | group | No | |
HydraGrowth_AttachmentAbilityL | abilcode | No | |
HydraGrowth_AttachmentAbilityM | abilcode | No | |
HydraGrowth_AttachmentAbilityR | abilcode | No | |
HydraGrowth_AttackDelay | real | No | |
HydraGrowth_Buff | buffcode | No | |
HydraGrowth_DummyL | unitcode | No | |
HydraGrowth_DummyR | unitcode | No | |
HydraGrowth_InactivityDelay | real | No | |
HydraGrowth_IndexAnimTagOn | integer | No | |
HydraGrowth_IndexElapsedTime | integer | No | |
HydraGrowth_IndexIdle | integer | No | |
HydraGrowth_IndexMovingCoeff | integer | No | |
HydraGrowth_MorphDelay | real | No | |
HydraGrowth_SoundMorphPath | string | No | |
HydraGrowth_SoundUnmorphPath | string | No | |
HydraGrowth_TempStunAbility | abilcode | No | |
HydraGrowth_TempStunOrder | string | No | |
HydraGrowth_UnmorphEffectPath | string | No | |
HydraGrowth_UnmorphGroup | group | No | |
HydraGrowthHT | hashtable | No | |
Ingest_Ability | abilcode | No | |
Ingest_Cooldown | real | No | |
Ingest_ExpulseAbility | abilcode | No | |
Ingest_LifeRegen | real | No | |
Ingest_TargetGroup | group | No | |
Kraken_Ability | abilcode | No | |
Kraken_AOE | real | No | |
Kraken_Buff | buffcode | No | |
Kraken_DummyAbility | abilcode | No | |
Kraken_DummyCheckAbility | abilcode | No | |
Kraken_DummyCheckOrder | string | No | |
Kraken_DummyOrder | string | No | |
Kraken_KrakenDummy | unitcode | No | |
Kraken_KrakenGroup | group | No | |
Kraken_ModelPath | string | No | |
Kraken_Order | string | No | |
Kraken_ProtectionDuration | real | No | |
Kraken_TentaclePath | string | No | |
LastInteractionPlayer | player | No | |
LethalSputum_Ability | abilcode | No | |
LethalSputum_BasicManaCost | integer | No | |
LethalSputum_Buff | buffcode | No | |
LethalSputum_ImpactPath | string | No | |
LethalSputum_SoundPath | string | No | |
MA_DummyAbility | abilcode | No | |
MA_DummyOrder | string | No | |
MA_Item | itemcode | No | |
MA_SpecificBuffs | buffcode | Yes | |
MA_TotalSpecificBuffs | integer | No | |
MemoryMax | integer | No | |
MS_Ability | abilcode | No | |
MS_AffectedGroup | group | No | |
MS_Buff | buffcode | No | |
MS_CasterGroup | group | No | |
MS_DetectedGroup | group | No | |
MS_EffectRange | real | No | |
MS_MudUnit | unitcode | No | |
MS_SlowAbility | abilcode | No | |
MS_SlowBuff | buffcode | No | |
MS_SoundGlobalPath | string | No | |
MS_SoundSimplePath | string | No | |
NagaConstruction_AllocUnit | integer | No | |
NagaConstruction_ConstrucGroup | group | No | |
NagaConstruction_DeathPath | string | No | |
NagaConstruction_DefaultEndDur | real | No | |
NagaConstruction_Dummy | unitcode | No | |
NagaConstruction_EndPathL | string | No | |
NagaConstruction_EndPathM | string | No | |
NagaConstruction_EndPathS | string | No | |
NagaConstruction_IndexDamage | integer | No | |
NagaConstruction_IndexEndEff | integer | No | |
NagaConstruction_IndexStruct | integer | No | |
NagaConstructionHT | hashtable | No | |
OceanStrike_Ability | abilcode | No | |
OceanStrike_EffectPath | string | No | |
OceanStrike_EffectSound | string | No | |
OpenWounds_Attachment | string | No | |
OrderWhiteList1 | string | Yes | |
OrderWhiteList2 | string | Yes | |
Parasite_Ability | abilcode | No | |
Parasite_Buff | buffcode | No | |
Parasite_Dummy | unitcode | No | |
Parasite_DummyAbility | abilcode | No | |
Parasite_DummyBuff | buffcode | No | |
Parasite_RegenOff | real | No | |
Parasite_SpellEffect | real | No | |
Parasite_TargetGroup | group | No | |
ParasiteHT | hashtable | No | |
ParasiteHT_LifeCapIndex | integer | No | |
ParasiteHT_MaxLifeIndex | integer | No | |
ParasiteHT_TriggerIndex | integer | No | |
PlayerIndexes | player | Yes | |
PlayingPlayers | force | No | |
PreyTrap_Ability | abilcode | No | |
PreyTrap_AbilityEviscerate | abilcode | No | |
PreyTrap_AOE | real | No | |
PreyTrap_DummyAbility | abilcode | No | |
PreyTrap_DummyOrder | string | No | |
PreyTrap_Duration | real | No | |
PreyTrap_Ward | unitcode | No | |
Races_AIPath | string | Yes | |
Races_ChoiceDialog | dialog | No | |
Races_ChoiceTimer | timer | No | |
Races_ChoiceTimerWindow | timerdialog | No | |
Races_GoldMine | unitcode | Yes | UnitTypeNull |
Races_IndexHuman | integer | No | |
Races_IndexNaga | integer | No | |
Races_IndexNightElf | integer | No | |
Races_IndexOrc | integer | No | |
Races_IndexRandom | integer | No | |
Races_IndexUndead | integer | No | |
Races_MainBuilding | unitcode | Yes | |
Races_MainBuildingOffset | real | Yes | |
Races_Name | string | Yes | |
Races_PlayersRace | integer | Yes | -1 |
Races_Sound_AllyBuildingAttack | sound | Yes | |
Races_Sound_AllyHeroDeath | string | Yes | |
Races_Sound_AllyUnitAttack | sound | Yes | |
Races_Sound_BuildingComplete | string | Yes | |
Races_Sound_GoldMineEmpty | sound | Yes | |
Races_Sound_GoldMineLow | sound | Yes | |
Races_Sound_InventoryFull | sound | Yes | |
Races_Sound_MusicDummy | string | No | |
Races_Sound_Musics | string | Yes | |
Races_Sound_NoFood | sound | Yes | |
Races_Sound_NoGold | sound | Yes | |
Races_Sound_NoLumber | sound | Yes | |
Races_Sound_ResearchComplete | string | Yes | |
Races_Sound_SelfBuildingAttack | sound | Yes | |
Races_Sound_SelfHeroDeath | string | Yes | |
Races_Sound_SelfUnitAttack | sound | Yes | |
Races_Sound_UpgradeComplete | string | Yes | |
Races_TotalRaces | integer | No | |
Races_TotalWorkers1 | integer | Yes | |
Races_TotalWorkers2 | integer | Yes | |
Races_WaitDialog | dialog | No | |
Races_Worker1 | unitcode | Yes | |
Races_Worker1DistanceMine | real | Yes | |
Races_Worker1DistanceWorkers | real | Yes | |
Races_Worker2 | unitcode | Yes | UnitTypeNull |
Races_Worker2DistanceMine | real | Yes | |
RisingWaters_Buff | buffcode | No | |
RisingWaters_DummyAbility | abilcode | No | |
RisingWaters_DummyOrder | string | No | |
RisingWaters_Duration | real | No | |
RisingWaters_HeroDuration | real | No | |
RisingWaters_PenaltyAbility1 | abilcode | No | |
RisingWaters_PenaltyAbility2 | abilcode | No | |
RisingWaters_Research | techcode | No | |
RisingWaters_SoundPath | string | No | |
RisingWaters_TargetGroup | group | No | |
RS_Attack_IdAllyBuildingTimer | integer | No | |
RS_Attack_IdAllyUnitTimer | integer | No | |
RS_Attack_IdSelfBuildingTimer | integer | No | |
RS_Attack_IdSelfUnitTimer | integer | No | |
RS_Attack_ProcRange | real | No | |
RS_Attack_SoundInterval | real | No | |
RS_Units_Marauder_Ready | string | No | |
RS_Units_Ophidian_Ready | string | No | |
RS_Units_SC_Ready | string | No | |
RSAttackAsyncHT | hashtable | No | |
RSConstructionAsyncHT | hashtable | No | |
SBD_HT | hashtable | No | |
SBD_ShopGroup | group | No | |
SBD_ShopRange | real | Yes | |
SBD_Shops | unitcode | Yes | |
SBD_TotalShops | integer | No | |
ShadowDagger_Ability | abilcode | No | |
ShadowDagger_BloodPath | string | No | |
ShadowDagger_CalculatedGroup | group | No | |
ShadowDagger_CalculatingGroup | group | No | |
ShadowDagger_CasterGroup | group | No | |
ShadowDagger_DamageDoneGroup | group | No | |
ShadowDagger_DamageDummy | unitcode | No | |
ShadowDagger_DeathPath | string | No | |
ShadowDagger_HitSound | string | No | |
ShadowDagger_Order | string | No | |
ShadowDagger_SpeedAbility | abilcode | No | |
ShadowDagger_v2_Ability | abilcode | No | |
ShadowDagger_v2_Buff | buffcode | No | |
ShadowDagger_v2_TargetGroup | group | No | |
Skill_Attack_IndexTarget | integer | No | |
Skill_Attack_IndexZone | integer | No | |
Skill_Building_IndexProgress | integer | No | |
Skill_Building_IndexTrainTotal | integer | No | |
Skill_CB_AllocTarget | integer | No | |
Skill_CB_AllocTimer | integer | No | |
Skill_ClickCommand_IndexPlayer | integer | No | |
Skill_CollisionTracker | itemcode | No | |
Skill_CrushingBlow_IndexBonus | integer | No | |
Skill_CrushingBlow_IndexCaster | integer | No | |
Skill_CrushingBlow_IndexEffect | integer | No | |
Skill_CrushingBlow_IndexOff | integer | No | |
Skill_CrushingBlow_IndexTarget | integer | No | |
Skill_CrushingBlow_IndexTimer | integer | No | |
Skill_CrushingBlow_IndexTriggr | integer | No | |
Skill_DummyCaster | unitcode | No | |
Skill_Eviscerate_IndexAbility | integer | No | |
Skill_Eviscerate_IndexCaster | integer | No | |
Skill_Eviscerate_IndexDoomed | integer | No | |
Skill_Eviscerate_IndexTimer | integer | No | |
Skill_Frenzy_IndexAbilityOff | integer | No | |
Skill_Frenzy_IndexTarget | integer | No | |
Skill_GoldMine_IndexCheckTime | integer | No | |
Skill_GoldMine_IndexOwner | integer | No | |
Skill_GoldMine_IndexTriggerGM | integer | No | |
Skill_Ingest_IndexCaster | integer | No | |
Skill_Kraken_IndexCaster | integer | No | |
Skill_Kraken_IndexKraken | integer | No | |
Skill_Kraken_IndexTimer | integer | No | |
Skill_Kraken_IndexTimerTarget | integer | No | |
Skill_LethalSputum_IndexDamage | integer | No | |
Skill_LethalSputum_IndexTarget | integer | No | |
Skill_MiringSwamps_IndexCaster | integer | No | |
Skill_MiringSwamps_IndexLast | integer | No | |
Skill_MiringSwamps_IndexTimer | integer | No | |
Skill_OpenWounds_IndexSource | integer | No | |
Skill_Order_IndexStringOrder | integer | No | |
Skill_Parasite_IndexTarget | integer | No | |
Skill_PT_IndexTrigger | integer | No | |
Skill_PT_IndexWard | integer | No | |
Skill_RacePicker_IndexButton | integer | No | |
Skill_Revival_IndexBuilding | integer | No | |
Skill_RisingWaters_IndexTimer | integer | No | |
Skill_SD2_IndexDamage | integer | No | |
Skill_SD2_IndexDisplayDamage | integer | No | |
Skill_SD2_IndexPosX | integer | No | |
Skill_SD2_IndexPosY | integer | No | |
Skill_SD2_IndexTarget | integer | No | |
Skill_SD2_IndexThrowAngle | integer | No | |
Skill_SD_IndexCalculationDummy | integer | No | |
Skill_SD_IndexCaster | integer | No | |
Skill_SD_IndexDamage | integer | No | |
Skill_SD_IndexDamageDummy | integer | No | |
Skill_SD_IndexTarget | integer | No | |
Skill_SG_IndexArmorType | integer | No | |
Skill_SW_IndexWard | integer | No | |
Skill_TA_IndexBestBuff | integer | No | |
Skill_TA_IndexLifeAdded | integer | No | |
Skill_TidalWave_IndexAngle | integer | No | |
Skill_TidalWave_IndexLevel | integer | No | |
Skill_TidalWave_IndexPosition | integer | No | |
Skill_TidalWave_IndexTargGroup | integer | No | |
Skill_TidalWave_IndexTracker | integer | No | |
Skill_TidalWave_IndexWave | integer | No | |
Skill_TidalWave_IndexWaveCount | integer | No | |
Skill_TOTD_AllocCaster | integer | No | |
Skill_TOTD_AllocLevel | integer | No | |
Skill_TOTD_AllocTimer | integer | No | |
Skill_Water_IndexBorderWave | integer | No | |
SkillHT | hashtable | No | |
SkillOnHitHT | hashtable | No | |
SOH_Abilities | abilcode | Yes | |
SOH_IndexCrushingWave | integer | No | |
SOH_IndexOpenWounds | integer | No | |
SOH_IndexRisingWaters | integer | No | |
SOH_IndexRisingWatersEvisc | integer | No | |
SOH_TotalAbilities | integer | No | |
SOT_Ability | abilcode | No | |
SOT_Effect2Path | string | No | |
SOT_EffectPath | string | No | |
SOT_SoundPath | string | No | |
Sound_IndexSound | integer | No | |
Sound_IndexUnit | integer | No | |
Sound_IndexVolume | integer | No | |
SoundHT | hashtable | No | |
SoundPlayer_Ability | abilcode | No | |
SoundPlayer_Order | string | No | |
SS_Ability | abilcode | No | |
SS_AbilityEviscerate | abilcode | No | |
SS_EffectPath | string | No | |
SS_EvasionFactor | real | No | |
SS_Research | techcode | No | |
StoneGaze_Ability | abilcode | No | |
StoneGaze_AbilityEviscerate | abilcode | No | |
StoneGaze_AbilityItem | abilcode | No | |
StoneGaze_ATOffset | integer | No | |
StoneGaze_Buff | buffcode | No | |
StoneGaze_DeathEffectPath1 | string | No | |
StoneGaze_DeathEffectPath2 | string | No | |
StoneGaze_DeathEffectPath3 | string | No | |
StoneGaze_DummyAbility | abilcode | No | |
StoneGaze_DummyOrder | string | No | |
StoneGaze_EffectPath1 | string | No | |
StoneGaze_SoundPath | string | No | |
StoneGaze_StunBuff | buffcode | No | |
StoneGaze_TargetGroup | group | No | |
SW_Ability | abilcode | No | |
SW_AbilityEviscerate | abilcode | No | |
SW_AbilityItem | abilcode | No | |
SW_AllyBuff | buffcode | No | |
SW_DetectionAbility | abilcode | No | |
SW_DummyAllyAbility | abilcode | No | |
SW_DummyAllyOrder | string | No | |
SW_DummyEnemyAbility | abilcode | No | |
SW_DummyEnemyOrder | string | No | |
SW_DummyWard | unitcode | No | |
SW_EnemyBuffs | buffcode | Yes | |
SW_MaxPlayerNumber | integer | No | |
SW_MaxPlayerNumberWithNeutral | integer | No | |
SW_SoundPath | string | No | |
SW_TargetGroup | group | No | |
Swiftness_Ability | abilcode | No | |
Swiftness_DummyAbility | abilcode | No | |
Swiftness_DummyOrder | string | No | |
TenacityAura_Ability | abilcode | No | |
TenacityAura_Buff | buffcode | No | |
TenacityAura_CasterGroup | group | No | |
TenacityAura_Item | itemcode | No | |
TenacityAura_TargetGroup | group | No | |
TidalWave_Ability | abilcode | No | |
TidalWave_DamageAbility | abilcode | No | |
TidalWave_DamageOrder | string | No | |
TidalWave_Duration | real | No | |
TidalWave_Knockback | real | No | |
TidalWave_MaxTargets | integer | No | |
TidalWave_Range | real | No | |
TidalWave_Sound | string | No | |
TidalWave_StartOffset | real | No | |
TidalWave_Step | real | No | |
TidalWave_TotalWaves | integer | No | |
TidalWave_WaveGroup | group | No | |
TidalWave_WaveInterval | real | No | |
TidalWave_WaveOffset | real | No | |
TidalWave_WaveVisual | string | No | |
TorentialStone_Ability | abilcode | No | |
TotalAbilitiesToHide | integer | No | |
TotalPlayingPlayers | integer | No | |
TOTD_DummyAbility | abilcode | No | |
TOTD_DummyOrder | string | No | |
TOTD_Frequency | real | No | |
TOTD_SourceAbility | abilcode | No | |
TOTD_SourceBuff | buffcode | No | |
TOTD_VisualEffectPath | string | No | |
UnitData_DummyBuyer | unitcode | No | |
UnitData_DummyResearcher | unitcode | No | |
UnitData_DummyShop | unitcode | No | |
UnitData_GoldSound | string | No | |
UnitData_IndexFoodCost | integer | No | |
UnitData_IndexGoldCost | integer | No | |
UnitData_IndexId2Unit | integer | No | |
UnitData_IndexLumberCost | integer | No | |
UnitDataAsyncHT | hashtable | No | |
Water_AuraRangeL | real | No | |
Water_AuraRangeS | real | No | |
Water_AuraTargetGroup | group | No | |
Water_Dummy | unitcode | No | |
Water_ExpansionAbilityL | abilcode | No | |
Water_ExpansionAbilityS | abilcode | No | |
Water_IterationsL | integer | No | |
Water_IterationsS | integer | No | |
Water_ModelPath | string | No | |
Water_ModelPathBubbles | string | No | |
Water_ModelPathWaves | string | No | |
Water_OffsetHeight | real | No | |
Water_Size | integer | No | |
WaterAura_Dummy | unitcode | No | |
WaterAura_DummyGroup | group | No | |
WaterAura_Regen | real | No | |
WaterDisguise_Ability | abilcode | No | |
WaterDisguise_AbilityOff | abilcode | No | |
WaterDisguise_EligibleAbility | abilcode | No | |
WaterDisguise_InvisAbility | abilcode | No | |
WaterDisguise_Order | string | No | |
WaterDisguise_PenaltyAbility1 | abilcode | No | |
WaterDisguise_PenaltyAbility2 | abilcode | No | |
WaterHT | hashtable | No | |
WaterPurge_Ability | abilcode | No | |
WaterPurge_EffectPath | string | No | |
WaterPurge_SoundPath | string | No |
function Ceil takes real r returns integer
return R2I(r+1)
endfunction
function Floor takes real r returns integer
return R2I(r)
endfunction
function RoundUp takes real r returns integer
if R2I(r) == r then
return R2I(r)
endif
return Ceil(r)
endfunction
function IsUnitAWard takes unit u returns boolean
local integer uid = GetUnitTypeId(u)
return uid == 'oeye' or uid == 'nwad' or uid == 'otot' or uid == 'ohwd' or uid == 'osp1' or uid == 'osp2' or uid == 'osp3' or uid == 'osp4' or uid == 'o004'
endfunction
function IsUnitGround takes unit u returns boolean
// required because UNIT_TYPE_GROUND not working for amphibious units
return not IsUnitAWard(u) and not IsUnitType(u, UNIT_TYPE_FLYING) and not IsUnitType(u, UNIT_TYPE_STRUCTURE)
endfunction
// assuming s is of size 1
function S2C takes string s returns integer
if StringCase(s, false) == s then
return LoadIntegerBJ(StringHashBJ(s), udg_Dict_ASCII_IndexChar, udg_DictHT )
endif
return LoadIntegerBJ(StringHashBJ(s+"_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
endfunction
// assuming s is of size 4
function S2ObjectId takes string s returns integer
local integer output
set output = S2C(SubStringBJ(s, 4, 4))
set output = output + 256*S2C(SubStringBJ(s, 3, 3))
set output = output + 65536*S2C(SubStringBJ(s, 2, 2))
set output = output + 16777216*S2C(SubStringBJ(s, 1, 1))
return output
endfunction
function PlaySoundLocally takes sound s, player p returns nothing
if GetLocalPlayer() == p then
call PlaySoundBJ( s )
endif
endfunction
function PlaySoundIfUnplayed takes sound s returns nothing
if not GetSoundIsPlaying(s) then
call PlaySoundBJ( s )
endif
endfunction
function GetPlayerColoredName takes player p returns string
local integer player_index = GetConvertedPlayerId(p)
local string output
// set output = udg_Player2Color[GetConvertedPlayerId(p)]
set output = LoadStringBJ(GetHandleIdBJ(GetPlayerColor(p)), udg_Dict_Color_IndexHexcode, udg_DictHT)
if GetPlayerController(p) == MAP_CONTROL_COMPUTER then
set output = output + "Player " + I2S(GetConvertedPlayerId(p)) + " (Computer - "
if GetAIDifficulty(p) == AI_DIFFICULTY_INSANE then
set output = output + "Insane)"
elseif GetAIDifficulty(p) == AI_DIFFICULTY_NORMAL then
set output = output + "Normal)"
else
set output = output + "Easy)"
endif
else
set output = output + GetPlayerName(p)
endif
set output = output + "|r"
return output
endfunction
function GetClosestGoldMine takes location l returns unit
local group g
local unit gm
local unit closest_gm
local real distance
local real min_distance = -1
local location l2
set g = GetUnitsOfTypeIdAll('ngol')
loop
set gm = FirstOfGroup(g)
exitwhen gm == null
set l2 = GetUnitLoc(gm)
set distance = DistanceBetweenPoints(l2, l)
if min_distance == -1 or distance < min_distance then
set min_distance = distance
set closest_gm = gm
endif
call RemoveLocation(l2)
call GroupRemoveUnit(g, gm)
endloop
call DestroyGroup(g)
set g = null
set gm = null
set l2 = null
return closest_gm
endfunction
function isUnitInCameraDefaultRange takes unit u returns boolean
local real width
local real length
local real angle
local real coeff
set coeff = 0.6
set angle = 360 - ModuloReal(bj_CAMERA_DEFAULT_AOA, 360.00)
set length = coeff*bj_CAMERA_DEFAULT_DISTANCE * CosBJ(angle) // 1680 is more accurate
set width = coeff*bj_CAMERA_DEFAULT_DISTANCE / SinBJ(bj_CAMERA_DEFAULT_FOV) // 1920 is more accurate
set width = width - 0 // 1440 is the limit
set length = length - 0 // 1440 is the limit
set width = 1010
set length = 1100
// call BJDebugMsg("X: " + R2S(GetCameraTargetPositionX() - GetUnitX(u)))
// call BJDebugMsg("Y: " + R2S(GetCameraTargetPositionY() - GetUnitY(u)))
if (GetCameraTargetPositionX() - GetUnitX(u))*(GetCameraTargetPositionX() - GetUnitX(u)) + (GetCameraTargetPositionY() - GetUnitY(u))*(GetCameraTargetPositionY() - GetUnitY(u)) > 1050 * 1050 then
return false
endif
return true
if RAbsBJ( GetCameraTargetPositionX() - GetUnitX(u)) > width then
return false
endif
if RAbsBJ( GetCameraTargetPositionY() - GetUnitY(u)) > length then
return false
endif
return true
endfunction
function AttackType2I takes attacktype at returns integer
if at == ATTACK_TYPE_NORMAL then
return 0
endif
if at == ATTACK_TYPE_MELEE then
return 1
endif
if at == ATTACK_TYPE_PIERCE then
return 2
endif
if at == ATTACK_TYPE_SIEGE then
return 3
endif
if at == ATTACK_TYPE_MAGIC then
return 4
endif
if at == ATTACK_TYPE_CHAOS then
return 5
endif
if at == ATTACK_TYPE_HERO then
return 6
endif
return -1
endfunction
// outdated
function OldCastSpellGeneric takes unit u, integer ability_code, string order_id, integer level, unit target, location spell_loc, unit pos_unit returns boolean
local unit dummy
local location l
local boolean success
set l = GetUnitLoc(pos_unit)
set dummy = CreateUnitAtLoc(GetOwningPlayer(u), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
// set dummy = CreateUnitAtLoc(GetOwningPlayer(u), 'h00D', l, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
// call UnitApplyTimedLifeBJ( 100.00, 'BTLF', dummy )
call UnitAddAbilityBJ( ability_code, dummy )
call SetUnitAbilityLevelSwapped( ability_code, dummy, level )
if not (target == null) then
set success = IssueTargetOrderBJ( dummy, order_id, target )
else
if not (spell_loc == null) then
set success = IssuePointOrderLocBJ( dummy, order_id, spell_loc )
else
set success = IssueImmediateOrderBJ( dummy, order_id )
endif
endif
call RemoveLocation(l)
set dummy = null
set l = null
return success
endfunction
function CastSpellGeneric takes unit caster, integer ability_code, string order_id, integer level, unit target, location spell_loc, location dummy_loc returns boolean
local unit dummy
local boolean success
local location l
if dummy_loc == null then
set l = GetUnitLoc(caster)
set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
// set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00D', l, bj_UNIT_FACING)
else
set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), udg_Skill_DummyCaster, dummy_loc, bj_UNIT_FACING)
// set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00D', dummy_loc, bj_UNIT_FACING)
endif
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
// call UnitApplyTimedLifeBJ( 100.00, 'BTLF', dummy )
call UnitAddAbilityBJ( ability_code, dummy )
call SetUnitAbilityLevelSwapped( ability_code, dummy, level )
if not (target == null) then
set success = IssueTargetOrderBJ( dummy, order_id, target )
else
if not (spell_loc == null) then
set success = IssuePointOrderLocBJ( dummy, order_id, spell_loc )
else
set success = IssueImmediateOrderBJ( dummy, order_id )
endif
endif
if dummy_loc == null then
call RemoveLocation(l)
endif
set l = null
set dummy = null
return success
endfunction
function CastSpellOnUnit takes unit u, integer ability_code, string order_id, integer level, unit target returns boolean
return CastSpellGeneric(u, ability_code, order_id, level, target, null, null)
endfunction
function CastSpellOnPoint takes unit u, integer ability_code, string order_id, integer level, location l returns boolean
return CastSpellGeneric(u, ability_code, order_id, level, null, l, null)
endfunction
function CastSpellNoTarget takes unit u, integer ability_code, string order_id, integer level returns boolean
return CastSpellGeneric(u, ability_code, order_id, level, null, null, null)
endfunction
function CastSpellOnUnitAtUnitPos takes unit u, integer ability_code, string order_id, integer level, unit target returns boolean
local location target_loc = GetUnitLoc(target)
local boolean success = CastSpellGeneric(u, ability_code, order_id, level, target, null, target_loc)
call RemoveLocation(target_loc)
set target_loc = null
return success
endfunction
function CastSpellNoTargetAtLoc takes unit u, integer ability_code, string order_id, integer level, location l returns boolean
return CastSpellGeneric(u, ability_code, order_id, level, null, null, l)
endfunction
function CastSpellFromItemGeneric takes unit caster, integer item_type, unit target, location spell_loc, location dummy_loc returns boolean
local unit dummy
local boolean success
local location l
local item it
if dummy_loc == null then
set l = GetUnitLoc(caster)
set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
// set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00D', l, bj_UNIT_FACING)
else
set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), udg_Skill_DummyCaster, dummy_loc, bj_UNIT_FACING)
// set dummy = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00D', dummy_loc, bj_UNIT_FACING)
endif
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
// call UnitApplyTimedLifeBJ( 100.00, 'BTLF', dummy )
call UnitAddAbilityBJ( 'AInv', dummy )
set it = UnitAddItemByIdSwapped( item_type, dummy )
if not (target == null) then
set success = UnitUseItemTarget( dummy, it, target )
else
if not (spell_loc == null) then
set success = UnitUseItemPointLoc( dummy, it, spell_loc )
else
set success = UnitUseItem( dummy, it )
endif
endif
if dummy_loc == null then
call RemoveLocation(l)
endif
set l = null
set dummy = null
set it = null
return success
endfunction
function CreateFloatingTextOnUnit takes unit u, string s, real red, real green, real blue returns texttag
local real fontsize
local texttag tt
if IsUnitVisible(u, GetLocalPlayer()) then
set fontsize = 10
else
set fontsize = 0
endif
set tt = CreateTextTagUnitBJ( s, u, 10.00, fontsize, red, green, blue, 0 )
call SetTextTagVelocityBJ( tt, 100.00, 90 )
call SetTextTagPermanentBJ( tt, false )
call SetTextTagLifespanBJ( tt, 5.00 )
call SetTextTagFadepointBJ( tt, 1.00 )
return tt
endfunction
function CreateDamageTextOnUnit takes unit u, real damage, real red, real green, real blue returns texttag
return CreateFloatingTextOnUnit(u, I2S(R2I(damage)) + " !", red, green, blue )
endfunction
function CustomPingAt takes player p, location l, integer red, integer green, integer blue, boolean warning returns nothing
local minimapicon mm
local string model_path
set model_path = ""
if GetLocalPlayer() == p then
if warning then
set model_path = "UI\\MiniMap\\Minimap-Ping-Manual-Warning.mdx"
else
set model_path = "UI\\MiniMap\\Minimap-Ping-Manual-Friendly.mdx"
endif
endif
set mm = CreateMinimapIconAtLocBJ( l, red, green, blue, model_path, FOG_OF_WAR_MASKED )
call TriggerSleepAction( 3.00 )
call DestroyMinimapIcon( mm )
set mm = null
endfunction
function CustomPingOnUnit takes player p, unit u, integer red, integer green, integer blue, boolean warning returns nothing
local location l = GetUnitLoc(u)
call CustomPingAt(p, l, red, green, blue, warning)
call RemoveLocation(l)
set l = null
endfunction
globals
constant hashtable structHT = InitHashtable()
constant integer DEFAULT_PERSIST_INDEX = 0
endglobals
module StructModule
static thistype array database[8192]
static method getSelf takes thistype d returns thistype
return d
endmethod
static method moduleAllocation takes nothing returns thistype
local thistype elem = thistype.allocate()
set database[s__Interface3DElem_getSelf(elem)] = elem
return elem
endmethod
static method Data2Struct takes handle t returns thistype
local integer ind = LoadIntegerBJ(DEFAULT_PERSIST_INDEX, GetHandleId(t), structHT)
if ind == 0 then
return 0
endif
return database[ind]
endmethod
method CreateAttributeIndex takes handle t returns nothing
call SaveIntegerBJ(s__Interface3DElem_getSelf(this), DEFAULT_PERSIST_INDEX, GetHandleId(t), structHT)
endmethod
method CleanAttributeIndex takes handle t returns nothing
call RemoveSavedHandle( structHT, GetHandleIdBJ(t), DEFAULT_PERSIST_INDEX)
endmethod
endmodule
function SOHTargetMatchesConditions takes integer skill_index, unit u, unit target returns boolean
if skill_index == udg_SOH_IndexCrushingWave then
return not (IsUnitType(target, UNIT_TYPE_STRUCTURE)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and GetPlayerTechCountSimple(udg_CrushingWave_Research, GetOwningPlayer(u)) > 0
endif
if skill_index == udg_SOH_IndexRisingWaters then
// return (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitType(target, UNIT_TYPE_GROUND)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and GetPlayerTechCountSimple(udg_RisingWaters_Research, GetOwningPlayer(u)) > 0 and not IsUnitIllusionBJ(u)
return (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitGround(target)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and GetPlayerTechCountSimple(udg_RisingWaters_Research, GetOwningPlayer(u)) > 0 and not IsUnitIllusionBJ(u)
// return (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitGround(target)) and GetPlayerTechCountSimple(udg_RisingWaters_Research, GetOwningPlayer(u)) > 0 and not IsUnitIllusionBJ(u)
endif
if skill_index == udg_SOH_IndexRisingWatersEvisc then
// return (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitType(target, UNIT_TYPE_GROUND)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and not IsUnitIllusionBJ(u)
return (IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitGround(target)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and not IsUnitIllusionBJ(u)
endif
if skill_index == udg_SOH_IndexOpenWounds then
return not(IsUnitType(target, UNIT_TYPE_STRUCTURE)) and not (IsUnitAlly(target, GetOwningPlayer(u))) and not IsUnitIllusionBJ(u)
endif
return false
endfunction
function Trig_SkillOnHit_Attack_Actions takes nothing returns nothing
local integer acode
local integer i
local integer alvl
local real percentage
local boolean success = false
set i = 0
loop
exitwhen i >= udg_SOH_TotalAbilities
set acode = udg_SOH_Abilities[i]
set alvl = GetUnitAbilityLevelSwapped(acode, GetAttacker())
if alvl > 0 then
if SOHTargetMatchesConditions(i, GetAttacker(), GetTriggerUnit()) then
set percentage = BlzGetAbilityRealLevelField(BlzGetUnitAbility(GetAttacker(), acode), ABILITY_RLF_DURATION_NORMAL, alvl - 1)
if GetRandomReal(0, 1) <= percentage then
call SaveIntegerBJ( 1, i, GetHandleIdBJ(GetAttacker()), udg_SkillOnHitHT )
set success = true
else
call SaveIntegerBJ( 0, i, GetHandleIdBJ(GetAttacker()), udg_SkillOnHitHT )
endif
else
call SaveIntegerBJ( 0, i, GetHandleIdBJ(GetAttacker()), udg_SkillOnHitHT )
endif
endif
set i = i + 1
endloop
if success then
call SetUnitAnimation( GetAttacker(), "attack slam" )
call QueueUnitAnimationBJ( GetAttacker(), "stand" )
endif
endfunction
//===========================================================================
function InitTrig_SkillOnHit_Attack takes nothing returns nothing
set gg_trg_SkillOnHit_Attack = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SkillOnHit_Attack, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_SkillOnHit_Attack, function Trig_SkillOnHit_Attack_Actions )
endfunction
function Trig_SkillOnHit_Release_Actions takes nothing returns nothing
if not(BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL) then
return
endif
if LoadIntegerBJ(udg_SOH_IndexCrushingWave, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT ) == 1 then
call TriggerExecute( gg_trg_Crushing_Wave_Release )
call SaveIntegerBJ( 0, udg_SOH_IndexCrushingWave, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT )
endif
if LoadIntegerBJ(udg_SOH_IndexRisingWaters, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT ) == 1 then
call TriggerExecute( gg_trg_RisingWaters_Release )
call SaveIntegerBJ( 0, udg_SOH_IndexRisingWaters, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT )
endif
if LoadIntegerBJ(udg_SOH_IndexRisingWatersEvisc, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT ) == 1 then
call TriggerExecute( gg_trg_RisingWaters_Release )
call SaveIntegerBJ( 0, udg_SOH_IndexRisingWatersEvisc, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT )
endif
if LoadIntegerBJ(udg_SOH_IndexOpenWounds, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT ) == 1 then
call TriggerExecute( gg_trg_OpenWounds_Release )
call SaveIntegerBJ( 0, udg_SOH_IndexOpenWounds, GetHandleIdBJ(GetEventDamageSource()), udg_SkillOnHitHT )
endif
endfunction
//===========================================================================
function InitTrig_SkillOnHit_Release takes nothing returns nothing
set gg_trg_SkillOnHit_Release = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SkillOnHit_Release, EVENT_PLAYER_UNIT_DAMAGING )
call TriggerAddAction( gg_trg_SkillOnHit_Release, function Trig_SkillOnHit_Release_Actions )
endfunction
function DCCheckAuraLevel takes unit u, integer buffid returns integer
local group g
local location l
local integer temp_level
local unit temp_u
local integer temp_itemid
local integer temp_abilityid
local integer best_level = 0
local string itemids = LoadStringBJ(buffid, udg_Dict_DC_IndexBuffItems, udg_DictHT )
local string abilityids = LoadStringBJ(buffid, udg_Dict_DC_IndexBuffAbilities, udg_DictHT )
local integer i
local integer loop_max
local string s
set l = GetUnitLoc(u)
set g = GetUnitsInRangeOfLocAll(900.00, l)
loop
set temp_u = FirstOfGroup(g)
exitwhen temp_u == null
if IsPlayerAlly(GetOwningPlayer(u), GetOwningPlayer(temp_u)) then
set temp_level = 0
set loop_max = StringLength(abilityids)
set i = 1
loop
exitwhen i + 3 > loop_max
set s = SubStringBJ(abilityids, i, i+3)
set temp_abilityid = S2ObjectId(s)
set temp_level = GetUnitAbilityLevelSwapped(temp_abilityid, temp_u)
if best_level < temp_level then
set best_level = temp_level
endif
set i = i + 5
endloop
if best_level == 0 then
set loop_max = StringLength(itemids)
set i = 1
loop
exitwhen i + 3 > loop_max
set s = SubStringBJ(itemids, i, i+3)
set temp_itemid = S2ObjectId(s)
if UnitHasItemOfTypeBJ(temp_u, temp_itemid) then
set best_level = 1
set i = loop_max
endif
set i = i + 5
endloop
endif
endif
call GroupRemoveUnit(g, temp_u)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set temp_u = null
return best_level
endfunction
function DCGetDiceAttack takes unit u returns real
local integer main_stat_bonus
local integer main_stat_index
local real damage_min
local real damage_max
local real damage_average
local real extra
local integer aura_level
local integer i
local string buffs
local string aura_buffs
local string s
local integer max
local integer buff_code
if IsUnitType(u, UNIT_TYPE_HERO) then
if BlzGetUnitIntegerField(u, UNIT_IF_PRIMARY_ATTRIBUTE) == 3 then
// call BJDebugMsg("Agility")
set main_stat_index = bj_HEROSTAT_AGI
elseif BlzGetUnitIntegerField(u, UNIT_IF_PRIMARY_ATTRIBUTE) == 1 then
// call BJDebugMsg("Strength")
set main_stat_index = bj_HEROSTAT_STR
else
// call BJDebugMsg("Intelligence")
set main_stat_index = bj_HEROSTAT_INT
endif
set main_stat_bonus = GetHeroStatBJ(main_stat_index, u, true) - GetHeroStatBJ(main_stat_index, u, false)
else
set main_stat_bonus = 0
endif
set damage_min = BlzGetUnitBaseDamage(u, 0) + BlzGetUnitDiceNumber(u, 0) * 1 - main_stat_bonus
set damage_max = BlzGetUnitBaseDamage(u, 0) + BlzGetUnitDiceNumber(u, 0) * BlzGetUnitDiceSides(u, 0) - main_stat_bonus
set damage_average = main_stat_bonus + (damage_min + damage_max) / 2
set extra = main_stat_bonus
set i = 1
loop
exitwhen i > 6
set extra = extra + LoadIntegerBJ(GetItemTypeId(UnitItemInSlotBJ(u, i)), udg_Dict_DC_IndexItemBonus, udg_DictHT)
set i = i + 1
endloop
set buffs = "Broa,Binf,Bcri,BNht,B00Y"
set max = StringLength(buffs)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(buffs, i, i+3)
set buff_code = S2ObjectId(s)
if UnitHasBuffBJ(u, buff_code) then
set extra = extra + LoadRealBJ(buff_code, udg_Dict_DC_IndexBuffBonus, udg_DictHT) * damage_average
endif
set i = i + 5
endloop
set aura_buffs = "Bakb,BOac,BEar,B00R"
set max = StringLength(aura_buffs)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(aura_buffs, i, i+3)
set buff_code = S2ObjectId(s)
if UnitHasBuffBJ(u, buff_code) then
set extra = extra + DCCheckAuraLevel(u, buff_code) * LoadRealBJ(buff_code, udg_Dict_DC_IndexBuffBonus, udg_DictHT) * damage_average
endif
set i = i + 5
endloop
// call BJDebugMsg(I2S(R2I(damage_min)) + " - " + I2S(R2I(damage_max)))
if extra >= 0 then
// call BJDebugMsg("+" + I2S(RoundUp(extra )))
else
// call BJDebugMsg(I2S(RoundUp(extra )))
endif
return GetRandomReal(damage_min, damage_max) + extra
endfunction
function Trig_DC_Init_Actions takes nothing returns nothing
call SaveIntegerBJ( 8, 'rat9', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Claw + 8
call SaveIntegerBJ( 12, 'ratc', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Claw + 12
call SaveIntegerBJ( 4, 'rat6', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Claw + 4
call SaveIntegerBJ( 15, 'ratf', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Claw + 15
call SaveIntegerBJ( 3, 'rat3', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Claw + 3
call SaveIntegerBJ( 6, 'odef', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Shadows
call SaveIntegerBJ( 6, 'ofro', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Frost orb
call SaveIntegerBJ( 5, 'ocor', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Corruption
call SaveIntegerBJ( 5, 'I00U', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Corruption custom
call SaveIntegerBJ( 5, 'ofr2', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Fire orb 1
call SaveIntegerBJ( 5, 'ofir', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Fire orb 2
call SaveIntegerBJ( 5, 'I00F', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Fire orb custom
call SaveIntegerBJ( 6, 'olig', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Lightning orb 1
call SaveIntegerBJ( 5, 'oli2', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Lightning orb 2
call SaveIntegerBJ( 5, 'I00S', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Lightning orb custom
call SaveIntegerBJ( 5, 'oven', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Venom
call SaveIntegerBJ( 5, 'I00W', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Venom
call SaveIntegerBJ( 5, 'I004', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Aquamarine orb
call SaveIntegerBJ( 6, 'oslo', udg_Dict_DC_IndexItemBonus, udg_DictHT ) // Orb of Slow
call SaveRealBJ( 0.25, 'Broa', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Roar
call SaveRealBJ( 0.1, 'Binf', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Inner fire
call SaveRealBJ( -0.5, 'Bcri', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Cripple
call SaveRealBJ( -0.3, 'BNht', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Howl
call SaveRealBJ( -0.15, 'B00Y', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Rising waters
call SaveRealBJ( -0.15, 'B00Y', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Rising waters
call SaveRealBJ( 0.10, 'Bakb', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // War drums
call SaveRealBJ( 0.10, 'BOac', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Command Aura
call SaveRealBJ( 0.10, 'BEar', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Trueshot Aura
call SaveRealBJ( 0.05, 'B00R', udg_Dict_DC_IndexBuffBonus, udg_DictHT ) // Fervor Aura
call SaveStringBJ( "Aakb", 'Bakb', udg_Dict_DC_IndexBuffAbilities, udg_DictHT ) // War drums
call SaveStringBJ( "war2", 'Bakb', udg_Dict_DC_IndexBuffItems, udg_DictHT ) // War drums
call SaveStringBJ( "ACac", 'BOac', udg_Dict_DC_IndexBuffAbilities, udg_DictHT ) // Command Aura
call SaveStringBJ( "ward", 'BOac', udg_Dict_DC_IndexBuffItems, udg_DictHT ) // Command Aura
call SaveStringBJ( "AEar,ACat", 'BEar', udg_Dict_DC_IndexBuffAbilities, udg_DictHT ) // Trueshot Aura
call SaveStringBJ( "afac", 'BEar', udg_Dict_DC_IndexBuffItems, udg_DictHT ) // Trueshot Aura
call SaveStringBJ( "A01P", 'B00R', udg_Dict_DC_IndexBuffAbilities, udg_DictHT ) // Fervor Aura
endfunction
//===========================================================================
function InitTrig_DC_Init takes nothing returns nothing
set gg_trg_DC_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_DC_Init, 0 )
call TriggerAddAction( gg_trg_DC_Init, function Trig_DC_Init_Actions )
endfunction
function Trig_DamageType_Calibration_Actions takes nothing returns nothing
local real coeff
set coeff = GetEventDamage() / 100
// call DisplayTextToForce( GetPlayersAll(), "Damage Type: " + I2S(udg_Calibration_DamageType) + ", Armor Type: " + I2S(udg_Calibration_ArmorType) + ", Coeff: " + R2S(coeff))
endfunction
//===========================================================================
function InitTrig_DamageType_Calibration takes nothing returns nothing
set gg_trg_DamageType_Calibration = CreateTrigger( )
call TriggerAddAction( gg_trg_DamageType_Calibration, function Trig_DamageType_Calibration_Actions )
endfunction
function Trig_Spell_Steal_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'Asps'
endfunction
function Trig_Spell_Steal_Cast_Actions takes nothing returns nothing
local location l
local group g
local unit u
local unit dummy
local integer player_index
set l = GetUnitLoc(GetTriggerUnit())
call PolledWait( 0.5 )
set g = GetUnitsInRangeOfLocAll(800.00, l)
loop
set u = FirstOfGroup(g)
exitwhen u == null
// Parasite
if UnitHasBuffBJ(u, udg_Parasite_Buff) and not UnitHasBuffBJ(u, udg_Parasite_DummyBuff) then
// call CreateRegenerationDetectionTrigger(u, GetUnitStateSwap(UNIT_STATE_LIFE, u))
call ParasiteStart(GetTriggerUnit(), u)
endif
// Stone Gaze
if UnitHasBuffBJ(u, udg_StoneGaze_Buff) and not (IsUnitInGroup(u, udg_StoneGaze_TargetGroup)) then
call PetrifyUnit(GetTriggerUnit(), u)
endif
// Spirit within
set player_index = SpiritWithin_GetBuffIndex(u) // starts from 0
if player_index != -1 then
if player_index > udg_SW_MaxPlayerNumberWithNeutral then
set player_index = udg_SW_MaxPlayerNumber // = udg_SW_MaxPlayerNumberWithNeutral - 1
endif
set dummy = CreateUnitAtLoc(Player(player_index), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
call SpiritWithin_CastOnEnemies(dummy, u)
else
if UnitHasBuffBJ(u, udg_SW_AllyBuff) then
call SpiritWithin_CastOnAllies(u)
endif
endif
call GroupRemoveUnit(g, u)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set l = null
set g = null
set u = null
set dummy = null
endfunction
//===========================================================================
function InitTrig_Spell_Steal_Cast takes nothing returns nothing
set gg_trg_Spell_Steal_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell_Steal_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spell_Steal_Cast, Condition( function Trig_Spell_Steal_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Spell_Steal_Cast, function Trig_Spell_Steal_Cast_Actions )
endfunction
function Trig_Order_Init_Actions takes nothing returns nothing
set udg_OrderWhiteList1[0] = "heal"
set udg_OrderWhiteList1[1] = "repair"
set udg_OrderWhiteList1[2] = "slow"
set udg_OrderWhiteList1[3] = "innerfire"
set udg_OrderWhiteList1[4] = "spellsteal"
set udg_OrderWhiteList1[5] = "bloodlust"
set udg_OrderWhiteList1[6] = "restoration"
set udg_OrderWhiteList1[7] = "web"
set udg_OrderWhiteList1[8] = "frostarmor"
set udg_OrderWhiteList1[9] = "carrionscarabs"
set udg_OrderWhiteList1[10] = "replenishlife"
set udg_OrderWhiteList1[11] = "replenishmana"
set udg_OrderWhiteList1[12] = "curse"
set udg_OrderWhiteList1[13] = "raisedead"
set udg_OrderWhiteList1[14] = "renew"
set udg_OrderWhiteList1[15] = "autodispell"
set udg_OrderWhiteList1[16] = "faeriefire"
set udg_OrderWhiteList1[17] = "phaseshift"
set udg_OrderWhiteList1[18] = "vengeance"
set udg_OrderWhiteList1[19] = "recharge"
set udg_OrderWhiteList1[20] = "incineratearrow"
set udg_OrderWhiteList1[21] = "blackarrow"
set udg_OrderWhiteList1[22] = "parasite"
set udg_OrderWhiteList1[23] = "selfdestruct"
set udg_OrderWhiteList2[0] = "flamingattack"
set udg_OrderWhiteList2[1] = "flamingarrows"
set udg_OrderWhiteList2[2] = "coldarrows"
endfunction
//===========================================================================
function InitTrig_Order_Init takes nothing returns nothing
set gg_trg_Order_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Order_Init, function Trig_Order_Init_Actions )
endfunction
function Trig_Order_Registration_Actions takes nothing returns nothing
local string str_order = OrderId2StringBJ(GetIssuedOrderIdBJ())
local integer i
if str_order == "" then
return
endif
// call DisplayTextToForce( GetPlayersAll(), OrderId2StringBJ(GetIssuedOrderIdBJ()) )
set i = 0
loop
exitwhen udg_OrderWhiteList1[i] == null
// call BJDebugMsg(I2S(i) + " - " + udg_OrderWhiteList1[i])
if str_order == udg_OrderWhiteList1[i] + "on" or str_order == udg_OrderWhiteList1[i] + "off" then
// call BJDebugMsg("on white list")
return
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen udg_OrderWhiteList2[i] == null
// call BJDebugMsg(I2S(i) + " - " + udg_OrderWhiteList2[i])
if str_order == udg_OrderWhiteList2[i] or str_order == "un" + udg_OrderWhiteList2[i] then
// call BJDebugMsg("on white list 2")
return
endif
set i = i + 1
endloop
call SaveStringBJ( str_order, udg_Skill_Order_IndexStringOrder, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
endfunction
//===========================================================================
function InitTrig_Order_Registration takes nothing returns nothing
set gg_trg_Order_Registration = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Registration, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Registration, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Order_Registration, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddAction( gg_trg_Order_Registration, function Trig_Order_Registration_Actions )
endfunction
function Trig_Attack_Zone_Conditions takes nothing returns boolean
return GetIssuedOrderIdBJ() == String2OrderIdBJ("attackground")
endfunction
function Trig_Attack_Zone_Actions takes nothing returns nothing
local location l
set l = LoadLocationHandleBJ( udg_Skill_Attack_IndexZone, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
if l != null then
call RemoveLocation(l)
endif
call SaveLocationHandleBJ( GetOrderPointLoc(), udg_Skill_Attack_IndexZone, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
set l = null
endfunction
//===========================================================================
function InitTrig_Attack_Zone takes nothing returns nothing
set gg_trg_Attack_Zone = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_Zone, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddCondition( gg_trg_Attack_Zone, Condition( function Trig_Attack_Zone_Conditions ) )
call TriggerAddAction( gg_trg_Attack_Zone, function Trig_Attack_Zone_Actions )
endfunction
function SPPlaySound takes string sound_path, location l returns nothing
local unit dummy
set dummy = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
call UnitAddAbilityBJ( udg_SoundPlayer_Ability, dummy )
// call BlzSetAbilityStringFieldBJ( BlzGetUnitAbility(dummy, 'A01H'), ABILITY_SF_EFFECT_SOUND_LOOPING, sound_path )
call BlzSetAbilityStringFieldBJ( BlzGetUnitAbility(dummy, 'A01H'), ABILITY_SF_EFFECT_SOUND, sound_path )
call IssueImmediateOrderBJ( dummy, udg_SoundPlayer_Order)
call RemoveUnit(dummy)
set dummy = null
endfunction
function SPPlayLoopingSound takes string sound_path, location l returns unit
local unit dummy
set dummy = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
call UnitAddAbilityBJ( udg_SoundPlayer_Ability, dummy )
call BlzSetAbilityStringFieldBJ( BlzGetUnitAbility(dummy, 'A01H'), ABILITY_SF_EFFECT_SOUND_LOOPING, sound_path )
call IssueImmediateOrderBJ( dummy, udg_SoundPlayer_Order)
return dummy
endfunction
// Deprecated
function PlayLoopingSound takes sound s, real volume, unit u returns nothing
local timer t
local real duration
set duration = GetSoundDurationBJ(s)
call BJDebugMsg("C'est parti pour une boucle de " + R2S(duration))
set t = CreateTimer()
call SaveSoundHandleBJ(s, udg_Sound_IndexSound, GetHandleIdBJ(t), udg_SoundHT)
call SaveUnitHandleBJ(u, udg_Sound_IndexUnit, GetHandleIdBJ(t), udg_SoundHT)
call SaveRealBJ(volume, udg_Sound_IndexVolume, GetHandleIdBJ(t), udg_SoundHT)
call BJDebugMsg("Working with timer " + I2S(GetHandleIdBJ(t)) + " and sound " + I2S(GetHandleIdBJ(s)))
if u == null then
call PlaySoundBJ(s)
else
call PlaySoundOnUnitBJ( s, volume, u )
endif
call StartTimerBJ(t, true, duration )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Sound_Loop, t)
endfunction
function SPv2CreateSoundGeneric takes string sound_path, boolean looping returns sound
local sound snd
set snd = CreateSound(sound_path, looping, true, true, 0, 0, "DefaultEAXON")
call SetSoundChannel( snd, 0)
call SetSoundDistances( snd, 600.00, 10000.00 )
call SetSoundDistanceCutoff( snd, 3000.00)
call SetSoundDuration( snd, GetSoundFileDuration(sound_path) )
// call SetSoundVolume( snd, 127 )
// call SetSoundConeAngles( snd, 0.0, 0.0, 127 )
call SetSoundConeOrientation( snd, 0.0, 0.0, 0.0 )
call SetSoundPitch( snd, 1.0 )
return snd
endfunction
// function SPv2PlaySoundWithVolume takes string sound_path, integer volume returns nothing
// local sound snd = SPv2CreateSoundGeneric(sound_path, false)
// call SetSoundVolume( snd, volume )
// call SetSoundConeAngles( snd, 0.0, 0.0, volume )
// call PlaySoundBJ(snd)
// call KillSoundWhenDone(snd)
// set snd = null
// endfunction
// function SPv2PlaySound takes string sound_path returns nothing
// call SPv2PlaySoundWithVolume(sound_path, 100)
// endfunction
function SPv2PlaySoundAtPointWithVolume takes string sound_path, integer volume, location l returns sound
local sound snd = SPv2CreateSoundGeneric(sound_path, false)
call PlaySoundAtPointBJ(snd, volume, l, 0.00)
call KillSoundWhenDone(snd)
return snd
endfunction
function SPv2PlaySoundAtPoint takes string sound_path, location l returns sound
return SPv2PlaySoundAtPointWithVolume(sound_path, 100, l)
endfunction
function SPv2PlaySoundOnUnitWithVolume takes string sound_path, integer volume, unit u returns sound
local location l = GetUnitLoc(u)
local sound s = SPv2PlaySoundAtPointWithVolume(sound_path, volume, l)
call RemoveLocation(l)
set l = null
return s
endfunction
function SPv2PlaySoundOnUnit takes string sound_path, unit u returns sound
return SPv2PlaySoundOnUnitWithVolume(sound_path, 100, u)
endfunction
function SPv2CreateAndPlayLoopingSoundAtPoint takes string sound_path, location l returns sound
local sound snd = SPv2CreateSoundGeneric(sound_path, true)
call PlaySoundAtPointBJ(snd, 100, l, 0.00)
return snd
endfunction
function SPv2TerminateLoopingSound takes sound snd returns nothing
call StopSound(snd, true, true)
endfunction
function PlayLoopingSound takes sound s, real volume, unit u returns nothing
local timer t
local real duration
set duration = GetSoundDurationBJ(s)
call BJDebugMsg("C'est parti pour une boucle de " + R2S(duration))
set t = CreateTimer()
call SaveSoundHandleBJ(s, udg_Sound_IndexSound, GetHandleIdBJ(t), udg_SoundHT)
call SaveUnitHandleBJ(u, udg_Sound_IndexUnit, GetHandleIdBJ(t), udg_SoundHT)
call SaveRealBJ(volume, udg_Sound_IndexVolume, GetHandleIdBJ(t), udg_SoundHT)
call BJDebugMsg("Working with timer " + I2S(GetHandleIdBJ(t)) + " and sound " + I2S(GetHandleIdBJ(s)))
if u == null then
call PlaySoundBJ(s)
else
call PlaySoundOnUnitBJ( s, volume, u )
endif
call StartTimerBJ(t, true, duration )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Sound_Loop, t)
endfunction
function Trig_Sound_Loop_Actions takes nothing returns nothing
local sound s
local unit u
local real volume
call BJDebugMsg("On remet la sauce !")
set s = LoadSoundHandleBJ(udg_Sound_IndexSound, GetHandleIdBJ(GetExpiredTimer()), udg_SoundHT)
call BJDebugMsg("Working with timer " + I2S(GetHandleIdBJ(GetExpiredTimer())) + " and sound " + I2S(GetHandleIdBJ(s)))
if s == null then
call BJDebugMsg("Dont play no more !")
call FlushChildHashtableBJ( GetHandleIdBJ(GetExpiredTimer()), udg_SoundHT)
call DestroyTimer(GetExpiredTimer())
else
set u = LoadUnitHandleBJ(udg_Sound_IndexUnit, GetHandleIdBJ(GetExpiredTimer()), udg_SoundHT)
set volume = LoadRealBJ(udg_Sound_IndexVolume, GetHandleIdBJ(GetExpiredTimer()), udg_SoundHT)
call StopSoundBJ(s, false)
if u == null then
call PlaySoundBJ(s)
else
call PlaySoundOnUnitBJ( s, volume, u )
endif
endif
set u = null
set s = null
endfunction
//===========================================================================
function InitTrig_Sound_Loop takes nothing returns nothing
set gg_trg_Sound_Loop = CreateTrigger( )
call TriggerAddAction( gg_trg_Sound_Loop, function Trig_Sound_Loop_Actions )
endfunction
function Trig_AD_Test_1_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'ewsp', Player(1), GetUnitLoc(GetTriggerUnit()), bj_UNIT_FACING )
call IssueTargetOrderBJ( GetTriggerUnit(), "attack", GetLastCreatedUnit() )
// call BlzSetUnitAttackCooldown( GetTriggerUnit(), 0.00, 0 )
call BlzSetUnitWeaponRealFieldBJ( GetTriggerUnit(), UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, 0, 0.00 )
call BlzSetUnitWeaponRealFieldBJ( GetTriggerUnit(), UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, 1, 0.00 )
call BlzSetUnitWeaponRealFieldBJ( GetTriggerUnit(), UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT, 0, 0.00 )
call BlzSetUnitWeaponRealFieldBJ( GetTriggerUnit(), UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT, 1, 0.00 )
call TriggerRegisterUnitEvent( gg_trg_AD_Test_3, GetLastCreatedUnit(), EVENT_UNIT_DAMAGING )
endfunction
//===========================================================================
function InitTrig_AD_Test_1 takes nothing returns nothing
set gg_trg_AD_Test_1 = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_AD_Test_1, Player(0), true )
call TriggerAddAction( gg_trg_AD_Test_1, function Trig_AD_Test_1_Actions )
endfunction
function IsGoldMineRestrictedForPlayer takes unit gm, player p returns boolean
local location l
local location l2
local unit dummy
local boolean success
set l = GetUnitLoc(gm)
set l2 = PolarProjectionBJ(l, 1000, 0)
set dummy = CreateUnitAtLoc(p, udg_Skill_DummyCaster, l2, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
call UnitAddAbilityBJ( udg_GoldMines_CheckOwnerShipAbilit, dummy )
set success = IssueTargetOrderBJ( dummy, udg_GoldMines_CheckOwnerShipOrder, gm )
call RemoveLocation(l)
call RemoveLocation(l2)
call RemoveUnit(dummy)
set l = null
set l2 = null
set dummy = null
return not(success)
endfunction
function IsGoldMineFreetoTake takes unit gm returns boolean
return not(IsGoldMineRestrictedForPlayer(gm, Player(bj_PLAYER_NEUTRAL_VICTIM)))
endfunction
function RefreshGoldMineOwner takes unit gm returns player
local integer i
local player p
local player last_owner
if IsGoldMineFreetoTake(gm) then
// call BJDebugMsg("Owner is Neutral")
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(gm), udg_Skill_GoldMine_IndexOwner)
return null
endif
// to avoid the loop
set last_owner = LoadPlayerHandleBJ(udg_Skill_GoldMine_IndexOwner, GetHandleIdBJ(gm), udg_SkillHT)
if last_owner != null and not(IsGoldMineRestrictedForPlayer(gm, last_owner)) then
// call BJDebugMsg("Owner is " + GetPlayerName(last_owner))
return last_owner
endif
set i = 0
loop
set p = udg_PlayerIndexes[i]
exitwhen i >= udg_TotalPlayingPlayers
if last_owner == null or p != last_owner then
if not(IsGoldMineRestrictedForPlayer(gm, p)) then
// call BJDebugMsg("Owner is " + GetPlayerName(p))
call SavePlayerHandleBJ(p, udg_Skill_GoldMine_IndexOwner, GetHandleIdBJ(gm), udg_SkillHT)
set last_owner = null
return p
endif
endif
set i = i+1
endloop
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(gm), udg_Skill_GoldMine_IndexOwner)
set last_owner = null
set p = null
return null
endfunction
// Old and bugged
function isPeasantInMine takes unit u returns boolean
local location l
// local location tracker_loc
local item tracker
local boolean success
return not(CastSpellOnUnit(u, 'A03B', "rejuvination", 1, u))
set l = GetUnitLoc(u)
set tracker = CreateItemLoc( udg_Skill_CollisionTracker, l )
call BJDebugMsg("X:" + R2S(GetItemX(tracker)) + " " + R2S(GetLocationX(l)))
call BJDebugMsg("Y:" + R2S(GetItemY(tracker)) + " " + R2S(GetLocationY(l)))
if GetItemY(tracker) == GetLocationY(l) and GetItemX(tracker) == GetLocationX(l) then
set success = false
else
set success = true
endif
call RemoveLocation(l)
call RemoveItem(tracker)
call RemoveLocation(l)
set tracker = null
set l = null
return success
endfunction
function GoldMine_Worker_in_Range_Conditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_PEON)
endfunction
function GoldMine_Worker_in_Range_Actions takes nothing returns nothing
local unit gm
local integer resource
set gm = LoadUnitHandleBJ(udg_Skill_GoldMine_IndexTriggerGM, GetHandleIdBJ(GetTriggeringTrigger()), udg_SkillHT)
set resource = GetResourceAmount(gm)
if resource == 10 or resource == 10+udg_GoldMines_LowThreshold then
call SaveRealBJ(udg_GoldMines_CheckTime, udg_Skill_GoldMine_IndexCheckTime, GetHandleIdBJ(gm), udg_SkillHT)
call GroupAddUnitSimple( gm, udg_GoldMines_GroupToCheck )
call EnableTrigger( gg_trg_GoldMine_Refresh_Owner )
endif
set gm = null
endfunction
function Trig_GoldMine_Init_Func001A takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( t, udg_GoldMines_WorkerRange, GetEnumUnit() )
call TriggerAddAction( t, function GoldMine_Worker_in_Range_Actions )
call TriggerAddCondition( t, function GoldMine_Worker_in_Range_Conditions )
call SaveUnitHandleBJ(GetEnumUnit(), udg_Skill_GoldMine_IndexTriggerGM, GetHandleIdBJ(t), udg_SkillHT)
endfunction
function Trig_GoldMine_Init_Actions takes nothing returns nothing
set udg_GoldMines_LowThreshold = 1500
set udg_GoldMines_CheckTime = 1.00
set udg_GoldMines_WorkerRange = 256
set udg_GoldMines_CheckOwnerShipAbilit = 'A03C'
set udg_GoldMines_CheckOwnerShipOrder = "entangle"
call ForGroupBJ( GetUnitsOfTypeIdAll('ngol'), function Trig_GoldMine_Init_Func001A )
endfunction
//===========================================================================
function InitTrig_GoldMine_Init takes nothing returns nothing
set gg_trg_GoldMine_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_GoldMine_Init, function Trig_GoldMine_Init_Actions )
endfunction
function Trig_GoldMine_Refresh_Nearby_Peasants takes nothing returns boolean
return IsUnitType(GetFilterUnit(), UNIT_TYPE_PEON)
endfunction
function Trig_GoldMine_Refresh_Owner_Func001A takes nothing returns nothing
local group g
local location l
local integer resource
local real remaining_time_to_check
// call BJDebugMsg("Refreshing")
call RefreshGoldMineOwner(GetEnumUnit())
set resource = GetResourceAmount(GetEnumUnit())
if resource == 1500 then
call IssueImmediateOrderBJ( GetEnumUnit(), "stop" ) // this triggers the fact that some event occured to the goldmine
call GroupRemoveUnit(udg_GoldMines_GroupToCheck, GetEnumUnit()) // no check needed anymore
endif
if resource == 0 then
call GroupRemoveUnit(udg_GoldMines_GroupToCheck, GetEnumUnit())
endif
set remaining_time_to_check = LoadRealBJ(udg_Skill_GoldMine_IndexCheckTime, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
set l = GetUnitLoc(GetEnumUnit())
set g = GetUnitsInRangeOfLocMatching(56 + udg_GoldMines_WorkerRange, l, Condition(function Trig_GoldMine_Refresh_Nearby_Peasants))
if CountUnitsInGroup(g) > 0 then
set remaining_time_to_check = udg_GoldMines_CheckTime
else
set remaining_time_to_check = remaining_time_to_check - 0.3
endif
if remaining_time_to_check <= 0 then
call SaveRealBJ(0, udg_Skill_GoldMine_IndexCheckTime, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
call GroupRemoveUnit(udg_GoldMines_GroupToCheck, GetEnumUnit())
else
call SaveRealBJ(remaining_time_to_check, udg_Skill_GoldMine_IndexCheckTime, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
endif
call DestroyGroup(g)
call RemoveLocation(l)
set g = null
set l = null
endfunction
function Trig_GoldMine_Refresh_Owner_Actions takes nothing returns nothing
call ForGroupBJ( udg_GoldMines_GroupToCheck, function Trig_GoldMine_Refresh_Owner_Func001A )
if CountUnitsInGroup(udg_GoldMines_GroupToCheck) == 0 then
// call BJDebugMsg("All gold mines are safe")
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_GoldMine_Refresh_Owner takes nothing returns nothing
set gg_trg_GoldMine_Refresh_Owner = CreateTrigger( )
call DisableTrigger( gg_trg_GoldMine_Refresh_Owner )
call TriggerRegisterTimerEventPeriodic( gg_trg_GoldMine_Refresh_Owner, 0.30 )
call TriggerAddAction( gg_trg_GoldMine_Refresh_Owner, function Trig_GoldMine_Refresh_Owner_Actions )
endfunction
function Trig_GoldMine_Special_Creation_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'egol' or GetUnitTypeId(GetTriggerUnit()) == 'ugol'
endfunction
function Trig_GoldMine_Special_Creation_Actions takes nothing returns nothing
local location l
local unit original_gm
set l = GetUnitLoc(GetTriggerUnit())
set original_gm = GetClosestGoldMine(l)
call GroupRemoveUnit(udg_GoldMines_GroupToCheck, original_gm) // no need to check because it has been replaced by a special type
if ( GetResourceAmount(GetTriggerUnit()) > udg_GoldMines_LowThreshold ) then
call GroupAddUnitSimple( GetTriggerUnit(), udg_GoldMines_NeUdToCheck )
call EnableTrigger( gg_trg_GoldMine_Special_Check_Gold )
endif
if GetUnitTypeId(GetTriggerUnit()) == 'ugol' then
call GroupAddUnitSimple( GetTriggerUnit(), udg_GoldMines_UdToCheckDeath )
endif
call RemoveLocation(l)
set l = null
set original_gm = null
endfunction
//===========================================================================
function InitTrig_GoldMine_Special_Creation takes nothing returns nothing
set gg_trg_GoldMine_Special_Creation = CreateTrigger( )
call TriggerRegisterEnterRectSimple( gg_trg_GoldMine_Special_Creation, GetPlayableMapRect() )
call TriggerAddCondition( gg_trg_GoldMine_Special_Creation, Condition( function Trig_GoldMine_Special_Creation_Conditions ) )
call TriggerAddAction( gg_trg_GoldMine_Special_Creation, function Trig_GoldMine_Special_Creation_Actions )
endfunction
function Trig_GoldMine_Special_Destruction_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'egol' or GetUnitTypeId(GetTriggerUnit()) == 'ugol'
endfunction
function Trig_GoldMine_Special_Destruction_Actions takes nothing returns nothing
local location l
local unit original_gm
local integer resource
call GroupRemoveUnitSimple( GetTriggerUnit(), udg_GoldMines_NeUdToCheck )
call GroupRemoveUnitSimple( GetTriggerUnit(), udg_GoldMines_UdToCheckDeath )
if ( GetResourceAmount(GetTriggerUnit()) == 0 ) then
return
endif
if ( GetResourceAmount(GetTriggerUnit()) < udg_GoldMines_LowThreshold ) then // we need to recheck the new gold mine to see if any peasant is about to dig it
set l = GetUnitLoc(GetTriggerUnit())
set original_gm = GetClosestGoldMine(l)
call SaveRealBJ(udg_GoldMines_CheckTime, udg_Skill_GoldMine_IndexCheckTime, GetHandleIdBJ(original_gm), udg_SkillHT)
call GroupAddUnitSimple( original_gm, udg_GoldMines_GroupToCheck )
call EnableTrigger( gg_trg_GoldMine_Refresh_Owner )
call RemoveLocation(l)
endif
set l = null
set original_gm = null
endfunction
//===========================================================================
function InitTrig_GoldMine_Special_Destruction takes nothing returns nothing
set gg_trg_GoldMine_Special_Destruction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_GoldMine_Special_Destruction, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_GoldMine_Special_Destruction, Condition( function Trig_GoldMine_Special_Destruction_Conditions ) )
call TriggerAddAction( gg_trg_GoldMine_Special_Destruction, function Trig_GoldMine_Special_Destruction_Actions )
endfunction
function Trig_GoldMine_Special_Check_Gold_Func001 takes nothing returns nothing
local integer resource
// call BJDebugMsg("Refreshing Special")
set resource = GetResourceAmount(GetEnumUnit())
if resource == udg_GoldMines_LowThreshold then
call IssueImmediateOrderBJ( GetEnumUnit(), "stop" ) // this triggers the fact that some event occured to the goldmine
endif
if resource <= udg_GoldMines_LowThreshold then
call GroupRemoveUnit(udg_GoldMines_NeUdToCheck, GetEnumUnit()) // no check needed anymore
endif
endfunction
function Trig_GoldMine_Special_Check_Gold_Actions takes nothing returns nothing
call ForGroupBJ( udg_GoldMines_NeUdToCheck, function Trig_GoldMine_Special_Check_Gold_Func001 )
if CountUnitsInGroup(udg_GoldMines_NeUdToCheck) == 0 then
// call BJDebugMsg("No more Special to check")
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_GoldMine_Special_Check_Gold takes nothing returns nothing
set gg_trg_GoldMine_Special_Check_Gold = CreateTrigger( )
call DisableTrigger( gg_trg_GoldMine_Special_Check_Gold )
call TriggerRegisterTimerEventPeriodic( gg_trg_GoldMine_Special_Check_Gold, 0.50 )
call TriggerAddAction( gg_trg_GoldMine_Special_Check_Gold, function Trig_GoldMine_Special_Check_Gold_Actions )
endfunction
function Trig_Hotkeys_Triggers_BindKeys takes nothing returns nothing
local integer i = 65
loop
exitwhen i >=91
call BlzTriggerRegisterPlayerKeyEvent(gg_trg_Hotkeys_Triggers_Proc, GetEnumPlayer(), ConvertOsKeyType(i), 0, true)
set i = i+1
endloop
endfunction
function Trig_Hotkeys_Triggers_Init_Actions takes nothing returns nothing
call ForForce( udg_PlayingPlayers, function Trig_Hotkeys_Triggers_BindKeys )
endfunction
//===========================================================================
function InitTrig_Hotkeys_Triggers_Init takes nothing returns nothing
set gg_trg_Hotkeys_Triggers_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Hotkeys_Triggers_Init, 1.00 )
call TriggerAddAction( gg_trg_Hotkeys_Triggers_Init, function Trig_Hotkeys_Triggers_Init_Actions )
endfunction
function Trig_Hotkey_Detector_Init_Actions takes nothing returns nothing
call SaveIntegerBJ( $41, 0, 108, udg_DictHT )
call SaveIntegerBJ( $42, 1, 108, udg_DictHT )
call SaveIntegerBJ( $43, 2, 108, udg_DictHT )
call SaveIntegerBJ( $44, 3, 108, udg_DictHT )
call SaveIntegerBJ( $45, 4, 108, udg_DictHT )
call SaveIntegerBJ( $46, 5, 108, udg_DictHT )
call SaveIntegerBJ( $47, 6, 108, udg_DictHT )
call SaveIntegerBJ( $48, 7, 108, udg_DictHT )
call SaveIntegerBJ( $49, 8, 108, udg_DictHT )
call SaveIntegerBJ( $4A, 9, 108, udg_DictHT )
call SaveIntegerBJ( $4B, 10, 108, udg_DictHT )
call SaveIntegerBJ( $4C, 11, 108, udg_DictHT )
call SaveIntegerBJ( $4D, 12, 108, udg_DictHT )
call SaveIntegerBJ( $4E, 13, 108, udg_DictHT )
call SaveIntegerBJ( $4F, 14, 108, udg_DictHT )
call SaveIntegerBJ( $50, 15, 108, udg_DictHT )
call SaveIntegerBJ( $51, 16, 108, udg_DictHT )
call SaveIntegerBJ( $52, 17, 108, udg_DictHT )
call SaveIntegerBJ( $53, 18, 108, udg_DictHT )
call SaveIntegerBJ( $54, 19, 108, udg_DictHT )
call SaveIntegerBJ( $55, 20, 108, udg_DictHT )
call SaveIntegerBJ( $56, 21, 108, udg_DictHT )
call SaveIntegerBJ( $57, 22, 108, udg_DictHT )
call SaveIntegerBJ( $58, 23, 108, udg_DictHT )
call SaveIntegerBJ( $59, 24, 108, udg_DictHT )
call SaveIntegerBJ( $5A, 25, 108, udg_DictHT )
endfunction
//===========================================================================
function InitTrig_Hotkey_Detector_Init takes nothing returns nothing
set gg_trg_Hotkey_Detector_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Hotkey_Detector_Init, function Trig_Hotkey_Detector_Init_Actions )
endfunction
function Trig_Hotkey_Detector_Registration_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hvlt', Player(0), GetRectCenter(gg_rct_Region_001), bj_UNIT_FACING )
call UnitAddAbilityBJ( 'AInv', GetLastCreatedUnit() )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "neutralinteract", GetLastCreatedUnit() )
call SelectUnitForPlayerSingle( GetLastCreatedUnit(), Player(PLAYER_NEUTRAL_PASSIVE) )
call SetPlayerStateBJ( Player(0), PLAYER_STATE_RESOURCE_GOLD, 10000 )
call SetPlayerStateBJ( Player(0), PLAYER_STATE_RESOURCE_LUMBER, 10000 )
call TriggerSleepAction( 0.10 )
call ForceUIKeyBJ( Player(0), "R" )
endfunction
//===========================================================================
function InitTrig_Hotkey_Detector_Registration takes nothing returns nothing
set gg_trg_Hotkey_Detector_Registration = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Hotkey_Detector_Registration, Player(0), "test", true )
call TriggerAddAction( gg_trg_Hotkey_Detector_Registration, function Trig_Hotkey_Detector_Registration_Actions )
endfunction
// since by default 0 is returned, we increment by one to detect which units have already been treated
function GetUnitFoodCost takes integer unitid returns integer
local location l
local unit u
local integer current_food
local integer food = LoadIntegerBJ(unitid, udg_UnitData_IndexFoodCost, udg_UnitDataAsyncHT )
if food != 0 then
// call BJDebugMsg("food already calculated: " + I2S(food - 1))
return food - 1
endif
set l = GetRandomLocInRect(GetPlayableMapRect())
set current_food = GetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_FOOD_USED)
set u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), unitid, l, 0)
set food = GetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_FOOD_USED) - current_food
call SaveIntegerBJ(food + 1, unitid, udg_UnitData_IndexFoodCost, udg_UnitDataAsyncHT )
//call BJDebugMsg("first time calculating food: " + I2S(food))
call RemoveUnit(u)
call RemoveLocation(l)
set u = null
set l = null
return food
endfunction
// since by default 0 is returned, we increment by one to detect which researches have already been treated
// we need player p because if the search has been clicked it means the techtree requirements are fulfilled for the player
function RetrieveResearchCosts takes integer researchid, integer techlevel, player p returns nothing
local location l
local unit u
local integer gold_cost
local integer wood_cost
local integer original_gold
local integer original_wood
local integer extra_resources = 10000
local integer array resources
local integer hashkey = StringHashBJ(I2S(researchid) + "-" + I2S(techlevel))
set original_gold = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
set original_wood = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, original_gold + extra_resources)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, original_wood + extra_resources)
// set l = GetRandomLocInRect(GetPlayableMapRect())
set l = GetPlayerStartLocationLoc(p)
set u = CreateUnitAtLoc(p, udg_UnitData_DummyResearcher, l, 0)
// if techlevel > 1 then
// call SetPlayerTechResearchedSwap( researchid, techlevel - 1, p )
// endif
call IssueUpgradeOrderByIdBJ(u, researchid)
set gold_cost = original_gold + extra_resources - GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
set wood_cost = original_wood + extra_resources - GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
call IssueImmediateOrderById(u, 851976 )
call SaveIntegerBJ(gold_cost + 1, hashkey, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT )
call SaveIntegerBJ(wood_cost + 1, hashkey, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT )
// call BJDebugMsg("first time calculating costs: " + I2S(gold_cost) + " gold and " + I2S(wood_cost) + " wood. Haskey: " + I2S(hashkey))
call RemoveUnit(u)
call RemoveLocation(l)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, original_gold)
call SetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER, original_wood)
set u = null
set l = null
endfunction
function GetResearchGoldCost takes integer researchid, player p returns integer
local integer techlevel = GetPlayerTechCountSimple(researchid, p)
local integer hashkey = StringHashBJ(I2S(researchid) + "-" + I2S(techlevel+1)) // be careful it's not case sensitive !
local integer gold_cost = LoadIntegerBJ(hashkey, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT )
if gold_cost != 0 then
// call BJDebugMsg("already calculated gold cost: " + I2S(gold_cost - 1))
return gold_cost - 1
endif
call RetrieveResearchCosts(researchid, techlevel + 1, p)
return LoadIntegerBJ(hashkey, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT ) - 1
endfunction
function GetResearchLumberCost takes integer researchid, player p returns integer
local integer techlevel = GetPlayerTechCountSimple(researchid, p)
local integer hashkey = StringHashBJ(I2S(researchid) + "-" + I2S(techlevel+1))
local integer wood_cost = LoadIntegerBJ(hashkey, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT )
if wood_cost != 0 then
// call BJDebugMsg("already calculated wood cost: " + I2S(wood_cost - 1))
return wood_cost - 1
endif
call RetrieveResearchCosts(researchid, techlevel + 1, p)
return LoadIntegerBJ(hashkey, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT ) - 1
endfunction
// since by default 0 is returned, we increment by one to detect which units have already been treated
function RetrieveItemCosts takes integer itemid returns nothing
local location l
local unit shop
local unit buyer
local integer extra_resources = 10000
local integer gold_cost = LoadIntegerBJ(itemid, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT )
local integer lumber_cost
local item it
if gold_cost != 0 then
return
endif
call SetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_GOLD, extra_resources)
call SetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_LUMBER, extra_resources)
set l = GetRandomLocInRect(GetPlayableMapRect())
set buyer = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_UnitData_DummyBuyer, l, 0)
set shop = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_UnitData_DummyShop, l, 0)
set it = UnitAddItemByIdSwapped(itemid, buyer)
call UnitDropItemTarget(buyer, it, shop)
set gold_cost = R2I((GetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_GOLD) - extra_resources)/0.6)
set lumber_cost = R2I((GetPlayerState(Player(PLAYER_NEUTRAL_PASSIVE), PLAYER_STATE_RESOURCE_LUMBER) - extra_resources)/0.6)
call SaveIntegerBJ(gold_cost + 1, itemid, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT )
call SaveIntegerBJ(lumber_cost + 1, itemid, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT )
call RemoveUnit(buyer)
call RemoveUnit(shop)
call RemoveLocation(l)
set buyer = null
set shop = null
set l = null
endfunction
function GetItemGoldCost takes integer itemid returns integer
local integer gold_cost = LoadIntegerBJ(itemid, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT )
if gold_cost != 0 then
return gold_cost - 1
endif
call RetrieveItemCosts(itemid)
return LoadIntegerBJ(itemid, udg_UnitData_IndexGoldCost, udg_UnitDataAsyncHT ) - 1
endfunction
function GetItemLumberCost takes integer itemid returns integer
local integer lumber_cost = LoadIntegerBJ(itemid, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT )
if lumber_cost != 0 then
return lumber_cost - 1
endif
call RetrieveItemCosts(itemid)
return LoadIntegerBJ(itemid, udg_UnitData_IndexLumberCost, udg_UnitDataAsyncHT ) - 1
endfunction
// works only if the selected units have different max life (little hack)
// works only for shops
// has to be called for all players to prevent desync although only the value returned by player p will be taken into account
function FBSGetMainSelectedUnitForPlayer takes player p returns unit
local group g = udg_FBS_SelectedGroup[GetConvertedPlayerId(p)]
local unit u
local string s
local string fhs
if CountUnitsInGroup(g) == 1 then
set u = FirstOfGroup(g)
set g = null
return u
endif
set g = CreateGroup()
call GroupAddGroup( udg_FBS_SelectedGroup[GetConvertedPlayerId(p)], g )
if p == GetLocalPlayer() then
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitAbilityLevelSwapped('Apit', u) > 0 then
set s = I2S(R2I(GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u)))
set fhs = BlzFrameGetText(udg_FBS_Portrait)
set fhs = SubStringBJ(fhs, StringLength(fhs) - StringLength(s) + 1, StringLength(fhs))
if (fhs == s) then
call DestroyGroup(g)
set g = null
return u
endif
endif
call GroupRemoveUnit(g, u)
endloop
endif
call DestroyGroup(g)
set g = null
set u = null
return null
endfunction
function FBSRefreshHoveredObjectId takes nothing returns nothing
local real height
local real text_width
local integer i
local integer position = 0
local integer selected_unit_type
local integer item_type
local integer pid = GetConvertedPlayerId(GetLocalPlayer())
if not(BlzFrameIsVisible(udg_FBS_Tooltip)) then
if udg_FBS_HoveredObjectId[pid] != 0 then
call BlzSendSyncData("UpdateFBSHoveredObject", I2S(0))
endif
return
endif
set i = 0
loop
exitwhen i >= 12
if BlzFrameIsVisible(udg_FBS_CommandHover[i]) then
set position = i
set i = 999
endif
set i = i + 1
endloop
if i != 1000 then
if udg_FBS_HoveredObjectId[pid] != 0 then
call BlzSendSyncData("UpdateFBSHoveredObject", I2S(0))
endif
return
endif
if udg_FBS_SelectedUnit[pid] == null or LoadBooleanBJ(udg_Skill_Building_IndexProgress, GetHandleIdBJ(udg_FBS_SelectedUnit[pid]), udg_SkillHT) then
call BlzSendSyncData("UpdateFBSHoveredObject", I2S(0))
return
endif
set selected_unit_type = GetUnitTypeId(udg_FBS_SelectedUnit[pid])
set item_type = LoadIntegerBJ(position, selected_unit_type, udg_FBS_HT )
if udg_FBS_HoveredObjectId[pid] != item_type then
call BlzSendSyncData("UpdateFBSHoveredObject", I2S(item_type))
endif
endfunction
function FBSCreateHoverFrames takes nothing returns nothing
local trigger t
local timer ti
local integer i
local framehandle commandbutton
set udg_FBS_Tooltip = BlzGetOriginFrame(ORIGIN_FRAME_UBERTOOLTIP, 0)
set i = 0
loop
exitwhen i >= 12
set commandbutton = BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i)
set udg_FBS_CommandHover[i] = BlzCreateFrameByType("SIMPLEFRAME", "", commandbutton, "", 0)
call BlzFrameSetTooltip(commandbutton, udg_FBS_CommandHover[i])
call BlzFrameSetVisible(udg_FBS_CommandHover[i], false)
set i = i + 1
endloop
// Refresh actions
set ti = CreateTimer()
call StartTimerBJ( ti, true, 0.02 )
set t = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( t, ti )
call TriggerAddAction( t, function FBSRefreshHoveredObjectId )
set commandbutton = null
endfunction
function Trig_FBS_Main_Selected_Unit_Actions takes nothing returns nothing
local unit u = null
set u = FBSGetMainSelectedUnitForPlayer(GetTriggerPlayer())
if GetLocalPlayer() == GetTriggerPlayer() then
// call BJDebugMsg("sending data " + I2S(GetHandleIdBJ(u)))
call BlzSendSyncData("UpdateFBSMainSelectedUnit", I2S(GetHandleIdBJ(u)))
endif
set u = null
endfunction
//===========================================================================
function InitTrig_FBS_Main_Selected_Unit takes nothing returns nothing
set gg_trg_FBS_Main_Selected_Unit = CreateTrigger( )
call TriggerAddAction( gg_trg_FBS_Main_Selected_Unit, function Trig_FBS_Main_Selected_Unit_Actions )
endfunction
function Trig_FBS_Main_Selected_Unit_Sync_Actions takes nothing returns nothing
// call BJDebugMsg(GetPlayerColoredName(GetTriggerPlayer()) + " has selected an unit: " + BlzGetTriggerSyncData())
set udg_FBS_SelectedUnit[GetConvertedPlayerId(GetTriggerPlayer())] = LoadUnitHandleBJ(S2I(BlzGetTriggerSyncData()), udg_UnitData_IndexId2Unit, udg_UnitDataAsyncHT)
endfunction
//===========================================================================
function InitTrig_FBS_Main_Selected_Unit_Sync takes nothing returns nothing
set gg_trg_FBS_Main_Selected_Unit_Sync = CreateTrigger( )
call TriggerAddAction( gg_trg_FBS_Main_Selected_Unit_Sync, function Trig_FBS_Main_Selected_Unit_Sync_Actions )
endfunction
function Trig_FBS_Hovered_Object_Sync_Actions takes nothing returns nothing
local integer itemid = S2I(BlzGetTriggerSyncData())
local integer pid = GetConvertedPlayerId(GetTriggerPlayer())
// call BJDebugMsg(GetPlayerColoredName(GetTriggerPlayer()) + " is hovering item : " + BlzGetTriggerSyncData())
set udg_FBS_HoveredObjectId[pid] = itemid
endfunction
//===========================================================================
function InitTrig_FBS_Hovered_Object_Sync takes nothing returns nothing
set gg_trg_FBS_Hovered_Object_Sync = CreateTrigger( )
call TriggerAddAction( gg_trg_FBS_Hovered_Object_Sync, function Trig_FBS_Hovered_Object_Sync_Actions )
endfunction
function SBD_GetRangeByType takes integer unitid returns real
local integer i = 0
loop
exitwhen i >= udg_SBD_TotalShops
if unitid == udg_SBD_Shops[i] then
return udg_SBD_ShopRange[i]
endif
set i = i + 1
endloop
return 0.
endfunction
function SBD_IsUnitCandidate takes unit shop, unit u, player p returns boolean
local boolean success = GetOwningPlayer(u) == p
set success = success or GetPlayerAlliance(GetOwningPlayer(u), p, ALLIANCE_SHARED_CONTROL)
set success = success or GetOwningPlayer(shop) == Player(PLAYER_NEUTRAL_PASSIVE)
set success = success and UnitInventorySizeBJ(u) > 0
set success = success and IsUnitAliveBJ(u)
set success = success and not IsUnitLoadedBJ(u)
return success
endfunction
function SBD_IsUnitCandidateWithRange takes unit shop, unit u, player p, real range returns boolean
local location l
local location l2
local real dist
if not SBD_IsUnitCandidate(shop, u, p) then
return false
endif
set l = GetUnitLoc(shop)
set l2 = GetUnitLoc(u)
set dist = DistanceBetweenPoints(l, l2)
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
return dist <= range
endfunction
function SBD_IsUnitCandidateOld takes unit shop, unit u returns boolean
local boolean success = GetOwningPlayer(u) == GetOwningPlayer(shop)
set success = success or GetPlayerAlliance(GetOwningPlayer(u), GetOwningPlayer(shop), ALLIANCE_SHARED_CONTROL)
set success = success and UnitInventorySizeBJ(u) > 0
set success = success and IsUnitAliveBJ(u)
set success = success and not IsUnitLoadedBJ(u)
return success
endfunction
function SBD_RetrieveClosestTargetForPlayer takes unit shop, player p, real range returns unit
local location l
local location l2
local group g
local boolean hero_only = false
local real min_dist = -1
local real dist
local unit u
local unit selectionned_unit = null
set l = GetUnitLoc(shop)
set g = GetUnitsInRangeOfLocAll(range, l)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if SBD_IsUnitCandidate(shop, u, p) then
set l2 = GetUnitLoc(u)
set dist = DistanceBetweenPoints(l, l2)
call RemoveLocation(l2)
if IsUnitType(u, UNIT_TYPE_HERO) then
if not hero_only then
set hero_only = true
set selectionned_unit = u
set min_dist = dist
else
if min_dist > dist then
set selectionned_unit = u
set min_dist = dist
endif
endif
else
if not hero_only then
if min_dist == -1 or min_dist > dist then
set selectionned_unit = u
set min_dist = dist
endif
endif
endif
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set l = null
set l2 = null
set g = null
return selectionned_unit
endfunction
// function Trig_SBD_Unit_Enters_OLD_Conditions takes nothing returns boolean
// return SBD_IsUnitCandidate(gg_unit_hvlt_0497, GetTriggerUnit())
// endfunction
function Trig_SBD_Unit_Enters_PlayersControllingShopCondition takes nothing returns boolean
return GetPlayerAlliance(GetOwningPlayer(gg_unit_hvlt_0497), GetFilterPlayer(), ALLIANCE_SHARED_CONTROL) or GetOwningPlayer(gg_unit_hvlt_0497) == GetFilterPlayer()
endfunction
function Trig_SBD_Unit_Enters_Func001A takes nothing returns nothing
local unit u
if not SBD_IsUnitCandidate(GetEnumPlayer(), GetTriggerUnit()) then
return
endif
set u = LoadUnitHandleBJ(GetConvertedPlayerId(GetEnumPlayer()), GetHandleIdBJ(gg_unit_hvlt_0497), udg_SBD_HT)
if u == null then
call SaveUnitHandleBJ(GetTriggerUnit(), GetConvertedPlayerId(GetEnumPlayer()), GetHandleIdBJ(gg_unit_hvlt_0497), udg_SBD_HT)
return
endif
if IsUnitType(u, UNIT_TYPE_HERO) then
set u = null
return
endif
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
set u = null
call SaveUnitHandleBJ(GetTriggerUnit(), GetConvertedPlayerId(GetEnumPlayer()), GetHandleIdBJ(gg_unit_hvlt_0497), udg_SBD_HT)
return
endif
set u = null
endfunction
function Trig_SBD_Unit_Enters_OLD_Actions takes nothing returns nothing
call BJDebugMsg("hey go")
call ForForce( GetPlayersMatching(Condition(function Trig_SBD_Unit_Enters_PlayersControllingShopCondition)), function Trig_SBD_Unit_Enters_Func001A )
endfunction
//===========================================================================
function InitTrig_SBD_Unit_Enters_OLD takes nothing returns nothing
set gg_trg_SBD_Unit_Enters_OLD = CreateTrigger( )
// call TriggerAddCondition( gg_trg_SBD_Unit_Enters_OLD, Condition( function Trig_SBD_Unit_Enters_OLD_Conditions ) )
call TriggerAddAction( gg_trg_SBD_Unit_Enters_OLD, function Trig_SBD_Unit_Enters_OLD_Actions )
endfunction
function Trig_SBD_Unit_Selection_Conditions takes nothing returns boolean
return GetIssuedOrderIdBJ() == String2OrderIdBJ("smart") or GetIssuedOrderIdBJ() == String2OrderIdBJ("neutralinteract")
endfunction
function Trig_SBD_Unit_Selection_ForPlayer takes nothing returns nothing
// if not IsUnitSelected(GetTriggerUnit(), GetEnumPlayer()) then
if not IsUnitInGroup(GetTriggerUnit(), udg_FBS_SelectedGroup[GetConvertedPlayerId(GetEnumPlayer())]) then
return
endif
if SBD_IsUnitCandidateWithRange(GetTriggerUnit(), GetOrderTargetUnit(), GetEnumPlayer(), SBD_GetRangeByType(GetUnitTypeId(GetTriggerUnit()))) then
call SaveUnitHandleBJ(GetOrderTargetUnit(), GetConvertedPlayerId(GetEnumPlayer()), GetHandleIdBJ(GetTriggerUnit()), udg_SBD_HT)
endif
endfunction
function Trig_SBD_Unit_Selection_Actions takes nothing returns nothing
local integer i = 0
local boolean isshop = false
loop
exitwhen i >= udg_SBD_TotalShops
if GetUnitTypeId(GetTriggerUnit()) == udg_SBD_Shops[i] then
set isshop = true
set i = udg_SBD_TotalShops
endif
set i = i + 1
endloop
if not isshop then
return
endif
call ForForce( udg_PlayingPlayers, function Trig_SBD_Unit_Selection_ForPlayer )
endfunction
//===========================================================================
function InitTrig_SBD_Unit_Selection takes nothing returns nothing
set gg_trg_SBD_Unit_Selection = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SBD_Unit_Selection, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( gg_trg_SBD_Unit_Selection, Condition( function Trig_SBD_Unit_Selection_Conditions ) )
call TriggerAddAction( gg_trg_SBD_Unit_Selection, function Trig_SBD_Unit_Selection_Actions )
endfunction
function Trig_SBD_Out_Of_Range_ShopPlayer takes nothing returns nothing
local unit target = LoadUnitHandleBJ(GetConvertedPlayerId(GetEnumPlayer()), GetHandleIdBJ(GetEnumUnit()), udg_SBD_HT)
if target != null and not SBD_IsUnitCandidateWithRange(GetEnumUnit(), target, GetEnumPlayer(), SBD_GetRangeByType(GetUnitTypeId(GetEnumUnit()))) then
call RemoveSavedHandle( udg_SBD_HT, GetHandleIdBJ(GetEnumUnit()), GetConvertedPlayerId(GetEnumPlayer()))
// call BJDebugMsg("target out for " + GetUnitName(GetEnumUnit()) + " and player " + GetPlayerColoredName(GetEnumPlayer()))
endif
endfunction
function Trig_SBD_Out_Of_Range_Shop takes nothing returns nothing
call ForForce( udg_PlayingPlayers, function Trig_SBD_Out_Of_Range_ShopPlayer )
endfunction
function Trig_SBD_Out_Of_Range_Actions takes nothing returns nothing
call ForGroupBJ( udg_SBD_ShopGroup, function Trig_SBD_Out_Of_Range_Shop )
endfunction
//===========================================================================
function InitTrig_SBD_Out_Of_Range takes nothing returns nothing
set gg_trg_SBD_Out_Of_Range = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_SBD_Out_Of_Range, 0.50 )
call TriggerAddAction( gg_trg_SBD_Out_Of_Range, function Trig_SBD_Out_Of_Range_Actions )
endfunction
function Trig_Colors_Initialization_Actions takes nothing returns nothing
call SaveStringBJ("|cffff0303", GetHandleIdBJ(ConvertPlayerColor(0)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff0042ff", GetHandleIdBJ(ConvertPlayerColor(1)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff1ce6b9", GetHandleIdBJ(ConvertPlayerColor(2)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff540081", GetHandleIdBJ(ConvertPlayerColor(3)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cfffffc00", GetHandleIdBJ(ConvertPlayerColor(4)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cfffe8a0e", GetHandleIdBJ(ConvertPlayerColor(5)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff20c000", GetHandleIdBJ(ConvertPlayerColor(6)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffe55bb0", GetHandleIdBJ(ConvertPlayerColor(7)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff959697", GetHandleIdBJ(ConvertPlayerColor(8)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff7ebff1", GetHandleIdBJ(ConvertPlayerColor(9)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff106246", GetHandleIdBJ(ConvertPlayerColor(10)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff4a2a04", GetHandleIdBJ(ConvertPlayerColor(11)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff9b0000", GetHandleIdBJ(ConvertPlayerColor(12)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff0000c3", GetHandleIdBJ(ConvertPlayerColor(13)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff00eaff", GetHandleIdBJ(ConvertPlayerColor(14)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffbe00fe", GetHandleIdBJ(ConvertPlayerColor(15)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffebcd87", GetHandleIdBJ(ConvertPlayerColor(16)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cfff8a48b", GetHandleIdBJ(ConvertPlayerColor(17)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffbfff80", GetHandleIdBJ(ConvertPlayerColor(18)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffdcb9eb", GetHandleIdBJ(ConvertPlayerColor(19)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff282828", GetHandleIdBJ(ConvertPlayerColor(20)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffebf0ff", GetHandleIdBJ(ConvertPlayerColor(21)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cff00781e", GetHandleIdBJ(ConvertPlayerColor(22)), udg_Dict_Color_IndexHexcode, udg_DictHT)
call SaveStringBJ("|cffa46f33", GetHandleIdBJ(ConvertPlayerColor(23)), udg_Dict_Color_IndexHexcode, udg_DictHT)
endfunction
//===========================================================================
function InitTrig_Colors_Initialization takes nothing returns nothing
set gg_trg_Colors_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Colors_Initialization, function Trig_Colors_Initialization_Actions )
endfunction
function Trig_Colors_Initialization_Old_Actions takes nothing returns nothing
set udg_Player2Color[1] = "|cffff0303"
set udg_Player2Color[2] = "|cff0042ff"
set udg_Player2Color[3] = "|cff1ce6b9"
set udg_Player2Color[4] = "|cff540081"
set udg_Player2Color[5] = "|cfffffc00"
set udg_Player2Color[6] = "|cfffe8a0e"
set udg_Player2Color[7] = "|cff20c000"
set udg_Player2Color[8] = "|cffe55bb0"
set udg_Player2Color[9] = "|cff959697"
set udg_Player2Color[10] = "|cff7ebff1"
set udg_Player2Color[11] = "|cff106246"
set udg_Player2Color[12] = "|cff4a2a04"
set udg_Player2Color[13] = "|cff9b0000"
set udg_Player2Color[14] = "|cff0000c3"
set udg_Player2Color[15] = "|cff00eaff"
set udg_Player2Color[16] = "|cffbe00fe"
set udg_Player2Color[17] = "|cffebcd87"
set udg_Player2Color[18] = "|cfff8a48b"
set udg_Player2Color[19] = "|cffbfff80"
set udg_Player2Color[20] = "|cffdcb9eb"
set udg_Player2Color[21] = "|cff282828"
set udg_Player2Color[22] = "|cffebf0ff"
set udg_Player2Color[23] = "|cff00781e"
set udg_Player2Color[24] = "|cffa46f33"
endfunction
//===========================================================================
function InitTrig_Colors_Initialization_Old takes nothing returns nothing
set gg_trg_Colors_Initialization_Old = CreateTrigger( )
call TriggerAddAction( gg_trg_Colors_Initialization_Old, function Trig_Colors_Initialization_Old_Actions )
endfunction
function Trig_ASCII_Initialization_Actions takes nothing returns nothing
call SaveIntegerBJ( 'a', StringHashBJ("a"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'b', StringHashBJ("b"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'c', StringHashBJ("c"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'd', StringHashBJ("d"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'e', StringHashBJ("e"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'f', StringHashBJ("f"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'g', StringHashBJ("g"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'h', StringHashBJ("h"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'i', StringHashBJ("i"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'j', StringHashBJ("j"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'k', StringHashBJ("k"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'l', StringHashBJ("l"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'm', StringHashBJ("m"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'n', StringHashBJ("n"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'o', StringHashBJ("o"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'p', StringHashBJ("p"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'q', StringHashBJ("q"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'r', StringHashBJ("r"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 's', StringHashBJ("s"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 't', StringHashBJ("t"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'u', StringHashBJ("u"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'v', StringHashBJ("v"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'w', StringHashBJ("w"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'x', StringHashBJ("x"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'y', StringHashBJ("y"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'z', StringHashBJ("z"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'A', StringHashBJ("A_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'B', StringHashBJ("B_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'C', StringHashBJ("C_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'D', StringHashBJ("D_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'E', StringHashBJ("E_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'F', StringHashBJ("F_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'G', StringHashBJ("G_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'H', StringHashBJ("H_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'I', StringHashBJ("I_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'J', StringHashBJ("J_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'K', StringHashBJ("K_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'L', StringHashBJ("L_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'M', StringHashBJ("M_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'N', StringHashBJ("N_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'O', StringHashBJ("O_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'P', StringHashBJ("P_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'Q', StringHashBJ("Q_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'R', StringHashBJ("R_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'S', StringHashBJ("S_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'T', StringHashBJ("T_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'U', StringHashBJ("U_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'V', StringHashBJ("V_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'W', StringHashBJ("W_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'X', StringHashBJ("X_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'Y', StringHashBJ("Y_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( 'Z', StringHashBJ("Z_"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '0', StringHashBJ("0"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '1', StringHashBJ("1"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '2', StringHashBJ("2"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '3', StringHashBJ("3"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '4', StringHashBJ("4"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '5', StringHashBJ("5"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '6', StringHashBJ("6"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '7', StringHashBJ("7"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '8', StringHashBJ("8"), udg_Dict_ASCII_IndexChar, udg_DictHT )
call SaveIntegerBJ( '9', StringHashBJ("9"), udg_Dict_ASCII_IndexChar, udg_DictHT )
endfunction
//===========================================================================
function InitTrig_ASCII_Initialization takes nothing returns nothing
set gg_trg_ASCII_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_ASCII_Initialization, function Trig_ASCII_Initialization_Actions )
endfunction
function Trig_SS_Effect_Conditions takes nothing returns boolean
local boolean success = GetUnitAbilityLevelSwapped(udg_SS_AbilityEviscerate, GetTriggerUnit()) > 0 or (GetUnitAbilityLevelSwapped(udg_SS_Ability, GetTriggerUnit()) > 0 and GetPlayerTechCountSimple(udg_SS_Research, GetOwningPlayer(GetTriggerUnit())) > 0)
set success = success and (BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL)
set success = success and (BlzGetEventAttackType() == ATTACK_TYPE_PIERCE)
set success = success and (GetRandomReal(0, 1) <= udg_SS_EvasionFactor)
return success
endfunction
function Trig_SS_Effect_Actions takes nothing returns nothing
local texttag tt
local effect e
local location l1
local location l2
local location l3
local real angle
call BlzSetEventDamage( 0.0 )
set l1 = GetUnitLoc(GetTriggerUnit())
set l2 = GetUnitLoc(GetEventDamageSource())
set angle = AngleBetweenPoints(l1, l2)
set l3 = PolarProjectionBJ(l1, 20, angle)
set e = AddSpecialEffectLocBJ( l3, udg_SS_EffectPath )
call BlzSetSpecialEffectYaw( e, Deg2Rad(angle) )
call DestroyEffect(e)
call RemoveLocation(l1)
call RemoveLocation(l2)
call RemoveLocation(l3)
set tt = CreateFloatingTextOnUnit( GetTriggerUnit(), "deflected", 255, 0, 0)
call TriggerSleepAction( 5.00 )
call DestroyTextTag(tt)
set tt = null
set e = null
set l1 = null
set l2 = null
set l3 = null
endfunction
//===========================================================================
function InitTrig_SS_Effect takes nothing returns nothing
set gg_trg_SS_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SS_Effect, EVENT_PLAYER_UNIT_DAMAGING )
call TriggerAddCondition( gg_trg_SS_Effect, Condition( function Trig_SS_Effect_Conditions ) )
call TriggerAddAction( gg_trg_SS_Effect, function Trig_SS_Effect_Actions )
endfunction
function Trig_AT_Effect_Conditions takes nothing returns boolean
local boolean success = GetUnitAbilityLevelSwapped(udg_AT_Ability, GetEventDamageSource()) > 0 or GetUnitAbilityLevelSwapped(udg_AT_AbilityEviscerate, GetEventDamageSource()) > 0
set success = success and GetEventDamage() == 0.00
set success = success and BlzGetEventDamageType() == DAMAGE_TYPE_POISON
set success = success and UnitHasBuffBJ(GetTriggerUnit(), udg_AT_Buff)
return success
endfunction
function Trig_AT_Effect_Actions takes nothing returns nothing
local real damage
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
set damage = udg_AT_DamageFactorHero * GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit())
else
set damage = udg_AT_DamageFactor * GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit())
endif
if damage > 0 then
call UnitDamageTargetBJ( GetEventDamageSource(), GetTriggerUnit(), damage, BlzGetEventAttackType(), BlzGetEventDamageType() )
endif
endfunction
//===========================================================================
function InitTrig_AT_Effect takes nothing returns nothing
set gg_trg_AT_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AT_Effect, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_AT_Effect, Condition( function Trig_AT_Effect_Conditions ) )
call TriggerAddAction( gg_trg_AT_Effect, function Trig_AT_Effect_Actions )
endfunction
function MiringSwampsSlowUnit takes unit u, integer level returns nothing
// little hack to make the aura buff directly to the current level instead of level 1 and then 2 seconds later level X
if GetUnitAbilityLevelSwapped(udg_MS_SlowAbility, u) != level then
call UnitAddAbilityBJ(udg_MS_SlowAbility, u)
call BlzUnitDisableAbility( u, udg_MS_SlowAbility, true, true )
call UnitRemoveBuffBJ( udg_MS_SlowBuff, u )
call SetUnitAbilityLevelSwapped( udg_MS_SlowAbility, u, level )
call BlzUnitDisableAbility( u, udg_MS_SlowAbility, false, true )
endif
call GroupAddUnit(udg_MS_AffectedGroup, u)
endfunction
function MiringSwampsResetUnitSlow takes unit u returns nothing
call UnitRemoveAbilityBJ(udg_MS_SlowAbility, u)
call UnitRemoveBuffBJ(udg_MS_SlowBuff, u)
call GroupRemoveUnit(udg_MS_AffectedGroup, u)
endfunction
function Trig_MS_Refresh_Caster_Func001A takes nothing returns nothing
local unit u
local location l
local unit last_mud
local location last_mud_loc = null
local timer t
set last_mud = LoadUnitHandleBJ(udg_Skill_MiringSwamps_IndexLast, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT )
if UnitHasBuffBJ(GetEnumUnit(), udg_MS_Buff) then
set l = GetUnitLoc(GetEnumUnit())
if last_mud != null then
call UnitPauseTimedLifeBJ( false, last_mud ) // since we can't pause 2 times in a row we unpause every time before pausing
set last_mud_loc = GetUnitLoc(last_mud)
endif
if last_mud == null or not IsUnitAliveBJ(last_mud) or DistanceBetweenPoints(l, last_mud_loc) > 80 then
set u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_MS_MudUnit, l, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', u )
// call TriggerRegisterUnitInRangeSimple( gg_trg_MS_Sound_Local, udg_MS_EffectRange, u )
call SaveUnitHandleBJ(GetEnumUnit(), udg_Skill_MiringSwamps_IndexCaster, GetHandleIdBJ(u), udg_SkillHT )
call SaveUnitHandleBJ(u, udg_Skill_MiringSwamps_IndexLast, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT )
else
call UnitPauseTimedLifeBJ( true, last_mud )
endif
else
call GroupRemoveUnitSimple( GetEnumUnit(), udg_MS_CasterGroup )
if last_mud != null then
call UnitPauseTimedLifeBJ( false, last_mud )
endif
endif
call RemoveLocation(l)
if last_mud != null then
call RemoveLocation(last_mud_loc)
endif
set u = null
set l = null
set last_mud = null
set last_mud_loc = null
set t = null
endfunction
function Trig_MS_Refresh_Caster_Actions takes nothing returns nothing
call ForGroupBJ( udg_MS_CasterGroup, function Trig_MS_Refresh_Caster_Func001A )
if CountUnitsInGroup(udg_MS_CasterGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_MS_Refresh_Caster takes nothing returns nothing
set gg_trg_MS_Refresh_Caster = CreateTrigger( )
call DisableTrigger( gg_trg_MS_Refresh_Caster )
call TriggerRegisterTimerEventPeriodic( gg_trg_MS_Refresh_Caster, 0.30 )
call TriggerAddAction( gg_trg_MS_Refresh_Caster, function Trig_MS_Refresh_Caster_Actions )
endfunction
function Trig_MS_Refresh_Sound takes nothing returns nothing
call SPv2PlaySoundOnUnitWithVolume( udg_MS_SoundGlobalPath, 50, GetEnumUnit())
endfunction
function Trig_MS_Sound_Global_Actions takes nothing returns nothing
call ForGroupBJ( udg_MS_CasterGroup, function Trig_MS_Refresh_Sound )
if CountUnitsInGroup(udg_MS_CasterGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_MS_Sound_Global takes nothing returns nothing
set gg_trg_MS_Sound_Global = CreateTrigger( )
call DisableTrigger( gg_trg_MS_Sound_Global )
call TriggerRegisterTimerEventPeriodic( gg_trg_MS_Sound_Global, 1 )
call TriggerAddAction( gg_trg_MS_Sound_Global, function Trig_MS_Sound_Global_Actions )
endfunction
// Skill_MiringSwamps_IndexTimer
function Trig_MS_Effect_DetectUnits takes nothing returns nothing
local group g
local location l
local integer level
local unit target
local unit caster
local boolean condition_matched
local boolean spell_success
// local effect e
set l = GetUnitLoc(GetEnumUnit())
set g = GetUnitsInRangeOfLocAll(udg_MS_EffectRange, l)
// GetEnumUnit can be a Mud or the Caster
if GetUnitTypeId(GetEnumUnit()) == udg_MS_MudUnit then
set caster = LoadUnitHandleBJ(udg_Skill_MiringSwamps_IndexCaster, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT )
else
set caster = GetEnumUnit()
endif
set level = GetUnitAbilityLevelSwapped(udg_MS_Ability, caster)
loop
set target = FirstOfGroup(g)
exitwhen target == null
set condition_matched = not IsUnitInGroup(target, udg_MS_DetectedGroup)
set condition_matched = condition_matched and IsPlayerEnemy(GetOwningPlayer(caster), GetOwningPlayer(target))
set condition_matched = condition_matched and IsUnitAliveBJ(target)
// set condition_matched = condition_matched and IsUnitType(target, UNIT_TYPE_GROUND)
set condition_matched = condition_matched and IsUnitGround(target)
set condition_matched = condition_matched and not IsUnitType(target, UNIT_TYPE_STRUCTURE)
set condition_matched = condition_matched and not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE)
if condition_matched then
call UnitDamageTargetBJ( caster, target, 4 * level, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
call GroupAddUnit(udg_MS_DetectedGroup, target)
call MiringSwampsSlowUnit(target, level)
endif
call GroupRemoveUnit(g, target)
endloop
call DestroyGroup(g)
call RemoveLocation(l)
set g = null
set l = null
set target = null
set caster = null
// set e = null
endfunction
function Trig_MS_Effect_CleanAffectedGroup takes nothing returns nothing
if not IsUnitInGroup(GetEnumUnit(), udg_MS_DetectedGroup) then
call MiringSwampsResetUnitSlow(GetEnumUnit())
endif
endfunction
function Trig_MS_Effect_Actions takes nothing returns nothing
local group g
call GroupClear( udg_MS_DetectedGroup )
set g = GetUnitsOfTypeIdAll(udg_MS_MudUnit)
call GroupAddGroup( udg_MS_CasterGroup, g )
call ForGroupBJ( g, function Trig_MS_Effect_DetectUnits )
call ForGroupBJ( udg_MS_AffectedGroup, function Trig_MS_Effect_CleanAffectedGroup )
if CountUnitsInGroup(g) == 0 then
call GroupClear( udg_MS_DetectedGroup )
call GroupClear( udg_MS_AffectedGroup )
call DisableTrigger( GetTriggeringTrigger() )
endif
call DestroyGroup(g)
set g = null
endfunction
//===========================================================================
function InitTrig_MS_Effect takes nothing returns nothing
set gg_trg_MS_Effect = CreateTrigger( )
call DisableTrigger( gg_trg_MS_Effect )
call TriggerRegisterTimerEventPeriodic( gg_trg_MS_Effect, 0.50 )
call TriggerAddAction( gg_trg_MS_Effect, function Trig_MS_Effect_Actions )
endfunction
function Trig_SOT_Effect_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_SOT_Ability
endfunction
function Trig_SOT_Effect_Actions takes nothing returns nothing
local location l
local location l2
local effect e
set l = GetUnitLoc(GetSpellTargetUnit())
set l2 = GetUnitLoc(GetTriggerUnit())
call SetUnitX(GetTriggerUnit(), GetLocationX(l))
call SetUnitY(GetTriggerUnit(), GetLocationY(l))
call SetUnitX(GetSpellTargetUnit(), GetLocationX(l2))
call SetUnitY(GetSpellTargetUnit(), GetLocationY(l2))
set e = AddSpecialEffectLocBJ(l , udg_SOT_EffectPath )
call DestroyEffect(e)
set e = AddSpecialEffectLocBJ(l2 , udg_SOT_EffectPath )
call DestroyEffect(e)
set e = AddSpecialEffectLocBJ(l , udg_SOT_Effect2Path )
call DestroyEffect(e)
set e = AddSpecialEffectLocBJ(l2 , udg_SOT_Effect2Path )
call DestroyEffect(e)
call SPv2PlaySoundAtPoint(udg_SOT_SoundPath, l)
call RemoveLocation(l)
call RemoveLocation(l2)
set e = null
set l = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_SOT_Effect takes nothing returns nothing
set gg_trg_SOT_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SOT_Effect, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_SOT_Effect, Condition( function Trig_SOT_Effect_Conditions ) )
call TriggerAddAction( gg_trg_SOT_Effect, function Trig_SOT_Effect_Actions )
endfunction
function Trig_AO_Effect_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_AO_Buff)
endfunction
function Trig_AO_Effect_Actions takes nothing returns nothing
local real life_left
local real mana_left
local effect e
set mana_left = RMaxBJ(GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) - udg_AO_ManaTaken, 0)
set life_left = RMaxBJ(GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) - udg_AO_LifeTaken, 1)
call SetUnitManaBJ( GetTriggerUnit(), mana_left )
call SetUnitLifeBJ( GetTriggerUnit(), life_left )
set e = AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), udg_AO_EffectPath )
call DestroyEffectBJ( e )
set e = null
endfunction
//===========================================================================
function InitTrig_AO_Effect takes nothing returns nothing
set gg_trg_AO_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AO_Effect, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_AO_Effect, Condition( function Trig_AO_Effect_Conditions ) )
call TriggerAddAction( gg_trg_AO_Effect, function Trig_AO_Effect_Actions )
endfunction
function Trig_AO_Effect_v2_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetEventDamageSource(), udg_AO_Buff) and GetTriggerUnit() != GetEventDamageSource() and GetUnitTypeId(GetTriggerUnit()) != udg_ShadowDagger_DamageDummy
endfunction
function Trig_AO_Effect_v2_Actions takes nothing returns nothing
local real life_left
local real mana_left
local effect e
set mana_left = RMaxBJ(GetUnitStateSwap(UNIT_STATE_MANA, GetEventDamageSource()) - udg_AO_ManaTaken*GetEventDamage(), 0)
set life_left = RMaxBJ(GetUnitStateSwap(UNIT_STATE_LIFE, GetEventDamageSource()) - udg_AO_LifeTaken*GetEventDamage(), 1)
call SetUnitManaBJ( GetEventDamageSource(), mana_left )
call SetUnitLifeBJ( GetEventDamageSource(), life_left )
set e = AddSpecialEffectTargetUnitBJ( "origin", GetEventDamageSource(), udg_AO_EffectPath )
call DestroyEffectBJ( e )
set e = null
endfunction
//===========================================================================
function InitTrig_AO_Effect_v2 takes nothing returns nothing
set gg_trg_AO_Effect_v2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AO_Effect_v2, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_AO_Effect_v2, Condition( function Trig_AO_Effect_v2_Conditions ) )
call TriggerAddAction( gg_trg_AO_Effect_v2, function Trig_AO_Effect_v2_Actions )
endfunction
function Trig_Healing_Flask_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_HealingFlask_Ability
endfunction
function Trig_Healing_Flask_Cast_Actions takes nothing returns nothing
local location l
local location l2
local real d
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetSpellTargetLoc()
set d = DistanceBetweenPoints(l, l2)
call PolledWait(0.2 + d / udg_HealingFlask_Speed)
call CastSpellFromItemGeneric(GetTriggerUnit(), udg_HealingFlask_DummyItem, null, null, l2)
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_Healing_Flask_Cast takes nothing returns nothing
set gg_trg_Healing_Flask_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Healing_Flask_Cast, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Healing_Flask_Cast, Condition( function Trig_Healing_Flask_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Healing_Flask_Cast, function Trig_Healing_Flask_Cast_Actions )
endfunction
function Trig_SD_v2_Hit_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_ShadowDagger_v2_Buff)
endfunction
function Trig_SD_v2_Hit_Actions takes nothing returns nothing
local effect e
local location l
local unit target
local real angle
local real damage
call UnitRemoveBuffBJ( udg_ShadowDagger_v2_Buff, GetTriggerUnit() )
set target = LoadUnitHandleBJ(udg_Skill_SD2_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
if target != GetTriggerUnit() then
set target = null
return
endif
if LoadBooleanBJ(udg_Skill_SD2_IndexDisplayDamage, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT) then
set target = null
return
endif
// call BJDebugMsg("hit !")
call GroupRemoveUnitSimple(GetTriggerUnit(), udg_ShadowDagger_v2_TargetGroup)
call SetUnitX(GetTriggerUnit(), LoadRealBJ(udg_Skill_SD2_IndexPosX, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT))
call SetUnitY(GetTriggerUnit(), LoadRealBJ(udg_Skill_SD2_IndexPosY, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT))
set angle = LoadRealBJ(udg_Skill_SD2_IndexThrowAngle, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
set damage = LoadRealBJ(udg_Skill_SD2_IndexDamage, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
set e = AddSpecialEffectTargetUnitBJ( "chest", GetTriggerUnit(), udg_ShadowDagger_DeathPath )
call DestroyEffect(e)
set l = GetUnitLoc(GetTriggerUnit())
set e = AddSpecialEffectLocBJ( l, udg_ShadowDagger_BloodPath )
call BlzSetSpecialEffectYaw( e, Deg2Rad(angle) )
call BlzSetSpecialEffectZ( e, GetUnitFlyHeight(GetTriggerUnit()) )
call DestroyEffect(e)
call RemoveLocation(l)
call SaveBooleanBJ(true, udg_Skill_SD2_IndexDisplayDamage, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
call UnitDamageTargetBJ( GetEventDamageSource(), GetTriggerUnit(), damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
call SPv2PlaySoundOnUnitWithVolume( udg_ShadowDagger_HitSound, 70, GetTriggerUnit() )
set e = null
set target = null
set l = null
endfunction
//===========================================================================
function InitTrig_SD_v2_Hit takes nothing returns nothing
set gg_trg_SD_v2_Hit = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_v2_Hit, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_SD_v2_Hit, Condition( function Trig_SD_v2_Hit_Conditions ) )
call TriggerAddAction( gg_trg_SD_v2_Hit, function Trig_SD_v2_Hit_Actions )
endfunction
function Trig_SD_v2_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_ShadowDagger_v2_Ability
endfunction
function Trig_SD_v2_Cast_Actions takes nothing returns nothing
local real angle
local location l
local location l2
local integer ability_level
local real damage
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetUnitLoc(GetSpellTargetUnit())
set angle = AngleBetweenPoints(l, l2)
call RemoveLocation(l)
call RemoveLocation(l2)
set ability_level = GetUnitAbilityLevelSwapped(udg_ShadowDagger_v2_Ability, GetTriggerUnit())
set damage = DCGetDiceAttack(GetTriggerUnit())
call SaveBooleanBJ(false, udg_Skill_SD2_IndexDisplayDamage, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetSpellTargetUnit(), udg_Skill_SD2_IndexTarget, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveRealBJ(angle, udg_Skill_SD2_IndexThrowAngle, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveRealBJ(damage*(1 + 2*ability_level), udg_Skill_SD2_IndexDamage, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call GroupAddUnitSimple(GetSpellTargetUnit(), udg_ShadowDagger_v2_TargetGroup)
// call UnitAddAbilityBJ('AHds', GetSpellTargetUnit())
// call IssueImmediateOrderBJ( GetSpellTargetUnit(), "divineshield" )
set l = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_SD_v2_Cast takes nothing returns nothing
set gg_trg_SD_v2_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_v2_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_SD_v2_Cast, Condition( function Trig_SD_v2_Cast_Conditions ) )
call TriggerAddAction( gg_trg_SD_v2_Cast, function Trig_SD_v2_Cast_Actions )
endfunction
function Trig_SD_v2_Display_Damage_Conditions takes nothing returns boolean
local boolean b = GetTriggerUnit() == LoadUnitHandleBJ(udg_Skill_SD2_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
set b = b and LoadBooleanBJ(udg_Skill_SD2_IndexDisplayDamage, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
set b = b and GetEventDamageSource() != null
return b
endfunction
function Trig_SD_v2_Display_Damage_Actions takes nothing returns nothing
local texttag tt
// call BJDebugMsg("display !")
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(GetEventDamageSource()), udg_Skill_SD2_IndexTarget)
set tt = CreateDamageTextOnUnit( GetTriggerUnit(), GetEventDamage(), 100, 0, 0)
call TriggerSleepAction(5.00)
call DestroyTextTag(tt)
set tt = null
endfunction
//===========================================================================
function InitTrig_SD_v2_Display_Damage takes nothing returns nothing
set gg_trg_SD_v2_Display_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_v2_Display_Damage, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_SD_v2_Display_Damage, Condition( function Trig_SD_v2_Display_Damage_Conditions ) )
call TriggerAddAction( gg_trg_SD_v2_Display_Damage, function Trig_SD_v2_Display_Damage_Actions )
endfunction
function ShadowDaggerSaveUnitProperties takes unit u returns nothing
local integer unitid = GetUnitTypeId(u)
if LoadRealBJ(udg_Dict_EA_IndexDamagePoint, unitid, udg_DictHT ) == 0 then
call SaveRealBJ(BlzGetUnitWeaponRealField( u, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, 0), udg_Dict_EA_IndexDamagePoint, unitid, udg_DictHT )
endif
if LoadRealBJ(udg_Dict_EA_IndexBackSwing, unitid, udg_DictHT ) == 0 then
call SaveRealBJ(BlzGetUnitWeaponRealField( u, UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT, 0), udg_Dict_EA_IndexBackSwing, unitid, udg_DictHT )
endif
// if LoadRealBJ(udg_Dict_EA_IndexAttackInterval, unitid, udg_DictHT ) == 0 then
// call SaveRealBJ(BlzGetUnitAttackCooldown( u, 0), udg_Dict_EA_IndexAttackInterval, unitid, udg_DictHT )
// endif
if LoadIntegerBJ(udg_Dict_EA_IndexWeaponSound, unitid, udg_DictHT ) == 0 then
call SaveIntegerBJ(BlzGetUnitWeaponIntegerField( u, UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND, 0), udg_Dict_EA_IndexWeaponSound, unitid, udg_DictHT )
endif
if LoadStringBJ(udg_Dict_EA_IndexProjectileArt, unitid, udg_DictHT ) == "" then
call SaveStringBJ(BlzGetUnitWeaponStringField( u, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, 0), udg_Dict_EA_IndexProjectileArt, unitid, udg_DictHT )
endif
endfunction
function ShadowDaggerSetPropertiesToNull takes unit u returns nothing
call BlzSetUnitWeaponRealFieldBJ( u, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, 0, 0.00 )
call BlzSetUnitWeaponRealFieldBJ( u, UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT, 0, 0.00 )
call BlzSetUnitWeaponIntegerFieldBJ( u, UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND, 0, 0 )
call BlzSetUnitWeaponStringFieldBJ( u, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, 0, "" )
call UnitAddAbilityBJ( udg_ShadowDagger_SpeedAbility, u )
// call BlzSetUnitAttackCooldown( u, 0.10, 0 )
endfunction
function ShadowDaggerResetProperties takes unit u returns nothing
local integer unitid = GetUnitTypeId(u)
call BlzSetUnitWeaponRealFieldBJ( u, UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT, 0, LoadRealBJ(udg_Dict_EA_IndexDamagePoint, unitid, udg_DictHT ) )
call BlzSetUnitWeaponRealFieldBJ( u, UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT, 0, LoadRealBJ(udg_Dict_EA_IndexBackSwing, unitid, udg_DictHT ) )
call BlzSetUnitWeaponIntegerFieldBJ( u, UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND, 0, LoadIntegerBJ(udg_Dict_EA_IndexWeaponSound, unitid, udg_DictHT ) )
call BlzSetUnitWeaponStringFieldBJ( u, UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART, 0, LoadStringBJ(udg_Dict_EA_IndexProjectileArt, unitid, udg_DictHT ) )
// call BlzSetUnitAttackCooldown( u, LoadRealBJ(udg_Dict_EA_IndexAttackInterval, unitid, udg_DictHT ), 0 )
call UnitRemoveAbilityBJ( udg_ShadowDagger_SpeedAbility, u )
endfunction
function ShadowDaggerAbortSpell takes unit u, boolean compensate_spell returns nothing
local unit damage_dummy = LoadUnitHandleBJ(udg_Skill_SD_IndexDamageDummy, GetHandleIdBJ(u), udg_SkillHT)
local unit calculation_dummy = LoadUnitHandleBJ(udg_Skill_SD_IndexCalculationDummy, GetHandleIdBJ(u), udg_SkillHT)
local integer ability_level
local real mana_cost
// call DisplayTextToForce( GetPlayersAll(), "Spell aborted" )
call ShadowDaggerResetProperties(u)
call SetUnitTimeScalePercent( u, 100.00 )
call ResetUnitAnimation( u )
call GroupRemoveUnitSimple(u, udg_ShadowDagger_CalculatingGroup)
call GroupRemoveUnitSimple(u, udg_ShadowDagger_CalculatedGroup)
call GroupRemoveUnitSimple(u, udg_ShadowDagger_CasterGroup)
if compensate_spell then
set ability_level = GetUnitAbilityLevelSwapped(udg_ShadowDagger_Ability, u)
set mana_cost = BlzGetUnitAbilityManaCost(u, udg_ShadowDagger_Ability, ability_level-1)
call BlzEndUnitAbilityCooldown( u, udg_ShadowDagger_Ability )
call SetUnitManaBJ( u, ( GetUnitStateSwap(UNIT_STATE_MANA, u) + mana_cost ) )
endif
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(u), udg_Skill_SD_IndexTarget)
if damage_dummy != null then
call GroupRemoveUnitSimple(damage_dummy, udg_ShadowDagger_DamageDoneGroup)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(damage_dummy), udg_Skill_SD_IndexCaster)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(u), udg_Skill_SD_IndexDamageDummy)
call RemoveUnit(damage_dummy)
endif
if calculation_dummy != null then
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(calculation_dummy), udg_Skill_SD_IndexCaster)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(u), udg_Skill_SD_IndexCalculationDummy)
call RemoveUnit(calculation_dummy)
endif
set damage_dummy = null
set calculation_dummy = null
endfunction
function Trig_SD_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_ShadowDagger_Ability
endfunction
function Trig_SD_Cast_Actions takes nothing returns nothing
local unit calculation_dummy
local unit damage_dummy
local location l
local location l2
local location l3
local unit target
set target = LoadUnitHandleBJ(udg_Skill_SD_IndexTarget, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if IsUnitInGroup(GetTriggerUnit(), udg_ShadowDagger_CalculatedGroup) then
if target != GetSpellTargetUnit() then
// we have to remove it from the group otherwise the 'stop' order will be considered as a manoeuvre from the player and not the trigger and therefore the spell will be canceled
call GroupRemoveUnitSimple(GetTriggerUnit(), udg_ShadowDagger_CasterGroup)
call IssueImmediateOrderBJ( GetTriggerUnit(), "stop" )
call GroupAddUnitSimple(GetTriggerUnit(), udg_ShadowDagger_CasterGroup)
call IssueTargetOrderBJ( GetTriggerUnit(), udg_ShadowDagger_Order, target )
set target = null
return
endif
set l = GetUnitLoc(GetTriggerUnit())
set damage_dummy = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_ShadowDagger_DamageDummy, l, bj_UNIT_FACING)
call RemoveLocation(l)
call UnitApplyTimedLifeBJ( 1, 'BTLF', damage_dummy )
call UnitAddAbilityBJ( 'Aloc', damage_dummy )
call BlzSetUnitWeaponBooleanField( damage_dummy, UNIT_WEAPON_BF_ATTACKS_ENABLED, 0, true )
call UnitRemoveBuffsBJ( bj_REMOVEBUFFS_ALL, damage_dummy )
if not IssueTargetOrderBJ( damage_dummy, "attack", target ) then
call ShadowDaggerAbortSpell(GetTriggerUnit(), false)
set target = null
set l = null
set damage_dummy = null
return
endif
call SaveUnitHandleBJ(damage_dummy, udg_Skill_SD_IndexDamageDummy, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_SD_IndexCaster, GetHandleIdBJ(damage_dummy), udg_SkillHT)
else
call ShadowDaggerSaveUnitProperties(GetTriggerUnit())
call ShadowDaggerSetPropertiesToNull(GetTriggerUnit())
call GroupAddUnitSimple(GetTriggerUnit(), udg_ShadowDagger_CalculatingGroup)
call GroupAddUnitSimple(GetTriggerUnit(), udg_ShadowDagger_CasterGroup)
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetUnitLoc(GetSpellTargetUnit())
set l3 = PolarProjectionBJ(l, 70.00, AngleBetweenPoints(l, l2))
set calculation_dummy = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_ShadowDagger_DamageDummy, l3, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 0.50, 'BTLF', calculation_dummy )
call SaveUnitHandleBJ(GetSpellTargetUnit(), udg_Skill_SD_IndexTarget, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(calculation_dummy, udg_Skill_SD_IndexCalculationDummy, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_SD_IndexCaster, GetHandleIdBJ(calculation_dummy), udg_SkillHT)
call IssueTargetOrderBJ( GetTriggerUnit(), "attack", calculation_dummy )
// since the unit will attack before casting a spell, we don't want to see the animations twice so we slow down the first one
// so that no one will notice it gets interrupted
call SetUnitTimeScalePercent( GetTriggerUnit(), 50.00 )
call RemoveLocation(l)
call RemoveLocation(l2)
call RemoveLocation(l3)
// test failure
// call CastSpellOnUnit(GetTriggerUnit(), 'AHbn', "banish", 3, GetTriggerUnit())
endif
set l = null
set l2 = null
set l3 = null
set calculation_dummy = null
set damage_dummy = null
set target = null
endfunction
//===========================================================================
function InitTrig_SD_Cast takes nothing returns nothing
set gg_trg_SD_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Cast, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_SD_Cast, Condition( function Trig_SD_Cast_Conditions ) )
call TriggerAddAction( gg_trg_SD_Cast, function Trig_SD_Cast_Actions )
endfunction
function Trig_SD_Prevent_Dummy_Other_Attacks_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == udg_ShadowDagger_DamageDummy
endfunction
function Trig_SD_Prevent_Dummy_Other_Attacks_Actions takes nothing returns nothing
local unit caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if caster == GetAttacker() then
set caster = null
return
endif
call BlzUnitInterruptAttack( GetAttacker() )
set caster = null
endfunction
//===========================================================================
function InitTrig_SD_Prevent_Dummy_Other_Attacks takes nothing returns nothing
set gg_trg_SD_Prevent_Dummy_Other_Attacks = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Prevent_Dummy_Other_Attacks, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_SD_Prevent_Dummy_Other_Attacks, Condition( function Trig_SD_Prevent_Dummy_Other_Attacks_Conditions ) )
call TriggerAddAction( gg_trg_SD_Prevent_Dummy_Other_Attacks, function Trig_SD_Prevent_Dummy_Other_Attacks_Actions )
endfunction
function Trig_SD_Force_Cancel_After_Calculation_Conditions takes nothing returns boolean
return IsUnitInGroup(GetTriggerUnit(), udg_ShadowDagger_CalculatingGroup)
endfunction
function Trig_SD_Force_Cancel_After_Calculation_Actions takes nothing returns nothing
local unit damage_dummy = LoadUnitHandleBJ(udg_Skill_SD_IndexCalculationDummy, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if damage_dummy == null then
return
endif
if GetOrderTargetUnit() != damage_dummy or GetIssuedOrderIdBJ() != String2OrderIdBJ("attack") then
call ShadowDaggerAbortSpell(GetTriggerUnit(), false)
// we have to disable trigger then renable it to prevent infinite loop (if the unit cannot attack, its order will become move and the trigger will proc again)
// call DisableTrigger( GetTriggeringTrigger() )
// call IssueTargetOrderBJ( GetTriggerUnit(), "attack", damage_dummy )
// call EnableTrigger( GetTriggeringTrigger() )
endif
set damage_dummy = null
endfunction
//===========================================================================
function InitTrig_SD_Force_Cancel_After_Calculation takes nothing returns nothing
set gg_trg_SD_Force_Cancel_After_Calculation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Force_Cancel_After_Calculation, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Force_Cancel_After_Calculation, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Force_Cancel_After_Calculation, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_SD_Force_Cancel_After_Calculation, Condition( function Trig_SD_Force_Cancel_After_Calculation_Conditions ) )
call TriggerAddAction( gg_trg_SD_Force_Cancel_After_Calculation, function Trig_SD_Force_Cancel_After_Calculation_Actions )
endfunction
function Trig_SD_Damage_Calculation_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == udg_ShadowDagger_DamageDummy
endfunction
function Trig_SD_Damage_Calculation_Actions takes nothing returns nothing
// GetTriggerUnit() is calculation dummy
local real damage
local unit caster
local unit target
local integer ability_level
set caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if caster != GetEventDamageSource() then
set caster = null
return
endif
call ShadowDaggerResetProperties(caster)
call GroupRemoveUnitSimple(caster, udg_ShadowDagger_CalculatingGroup)
call GroupAddUnitSimple(caster, udg_ShadowDagger_CalculatedGroup)
set damage = GetEventDamage()
set ability_level = GetUnitAbilityLevelSwapped(udg_ShadowDagger_Ability, caster)
// call SaveRealBJ(damage*(1.5+1.5*ability_level), udg_Skill_SD_IndexDamage, GetHandleIdBJ(caster), udg_SkillHT)
call SaveRealBJ(damage*(1+2*ability_level), udg_Skill_SD_IndexDamage, GetHandleIdBJ(caster), udg_SkillHT)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(GetTriggerUnit()), udg_Skill_SD_IndexCaster)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(caster), udg_Skill_SD_IndexCalculationDummy)
call RemoveUnit( GetTriggerUnit() )
// we have to remove it from the group otherwise the 'stop' order will be considered as a manoeuvre from the player and not the trigger and therefore the spell will be canceled
call GroupRemoveUnitSimple(caster, udg_ShadowDagger_CasterGroup)
call IssueImmediateOrderBJ( caster, "stop" )
call GroupAddUnitSimple(caster, udg_ShadowDagger_CasterGroup)
set target = LoadUnitHandleBJ(udg_Skill_SD_IndexTarget, GetHandleIdBJ(caster), udg_SkillHT)
call IssueTargetOrderBJ( caster, udg_ShadowDagger_Order, target )
call SetUnitTimeScalePercent( caster, 100.00 )
if UnitHasBuffBJ(caster, udg_HydraGrowth_Buff) then
call SetUnitAnimation( caster, "attack spell alternate gold" )
else
call SetUnitAnimation( caster, "spell throw" )
endif
// test failure
// call CastSpellOnUnit(target, 'AHbn', "banish", 3, target)
set caster = null
set target = null
endfunction
//===========================================================================
function InitTrig_SD_Damage_Calculation takes nothing returns nothing
set gg_trg_SD_Damage_Calculation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Damage_Calculation, EVENT_PLAYER_UNIT_DAMAGING )
call TriggerAddCondition( gg_trg_SD_Damage_Calculation, Condition( function Trig_SD_Damage_Calculation_Conditions ) )
call TriggerAddAction( gg_trg_SD_Damage_Calculation, function Trig_SD_Damage_Calculation_Actions )
endfunction
function Trig_SD_Damage_Calculation_Failure_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == udg_ShadowDagger_DamageDummy
endfunction
function Trig_SD_Damage_Calculation_Failure_Actions takes nothing returns nothing
local unit caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if caster == null then
return
endif
call BJDebugMsg("dummy never attacked")
call ShadowDaggerAbortSpell(caster, false)
set caster = null
endfunction
//===========================================================================
function InitTrig_SD_Damage_Calculation_Failure takes nothing returns nothing
set gg_trg_SD_Damage_Calculation_Failure = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Damage_Calculation_Failure, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_SD_Damage_Calculation_Failure, Condition( function Trig_SD_Damage_Calculation_Failure_Conditions ) )
call TriggerAddAction( gg_trg_SD_Damage_Calculation_Failure, function Trig_SD_Damage_Calculation_Failure_Actions )
endfunction
function Trig_SD_Dummy_Attack_Success_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) == udg_ShadowDagger_DamageDummy
endfunction
function Trig_SD_Dummy_Attack_Success_Actions takes nothing returns nothing
local real cooldown
local real mana_cost
local unit target
local unit caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetAttacker()), udg_SkillHT)
if caster == null then
return
endif
set target = LoadUnitHandleBJ(udg_Skill_SD_IndexTarget, GetHandleIdBJ(caster), udg_SkillHT)
if target != GetTriggerUnit() then // it means the dummy is attacking someone else because the target cannot be attacked
call ShadowDaggerAbortSpell(caster, true)
set caster = null
set target = null
return
endif
call UnitPauseTimedLifeBJ( true, GetAttacker() )
call GroupRemoveUnitSimple(caster, udg_ShadowDagger_CalculatedGroup)
// test failure
// call CastSpellOnUnit(target, 'AHbn', "banish", 3, target)
call PolledWait(0.2) // cast animation time
if IsUnitInGroup(caster, udg_ShadowDagger_CasterGroup) then // if spell hasn't been interrupted
set cooldown = BlzGetAbilityRealLevelField(BlzGetUnitAbility(caster, udg_ShadowDagger_Ability), ABILITY_RLF_COOLDOWN, 0)
set mana_cost = BlzGetUnitAbilityManaCost(caster, udg_ShadowDagger_Ability, 0)
call BlzStartUnitAbilityCooldown( caster, udg_ShadowDagger_Ability, cooldown )
call SetUnitManaBJ( caster, ( GetUnitStateSwap(UNIT_STATE_MANA, caster) - mana_cost ) )
call GroupRemoveUnitSimple(caster, udg_ShadowDagger_CasterGroup)
// test failure
// call CastSpellOnUnit(target, 'AHbn', "banish", 3, target)
endif
set caster = null
set target = null
endfunction
//===========================================================================
function InitTrig_SD_Dummy_Attack_Success takes nothing returns nothing
set gg_trg_SD_Dummy_Attack_Success = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Dummy_Attack_Success, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_SD_Dummy_Attack_Success, Condition( function Trig_SD_Dummy_Attack_Success_Conditions ) )
call TriggerAddAction( gg_trg_SD_Dummy_Attack_Success, function Trig_SD_Dummy_Attack_Success_Actions )
endfunction
function Trig_SD_Apply_Damage_Conditions takes nothing returns boolean
return GetUnitTypeId(GetEventDamageSource()) == udg_ShadowDagger_DamageDummy and not IsUnitInGroup(GetEventDamageSource(), udg_ShadowDagger_DamageDoneGroup)
endfunction
function Trig_SD_Apply_Damage_Actions takes nothing returns nothing
local real damage
local unit caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
if caster == null then
return
endif
set damage = LoadRealBJ(udg_Skill_SD_IndexDamage, GetHandleIdBJ(caster), udg_SkillHT)
call GroupAddUnitSimple(GetEventDamageSource(), udg_ShadowDagger_DamageDoneGroup)
call UnitDamageTargetBJ( GetEventDamageSource(), GetTriggerUnit(), damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL )
call SPv2PlaySoundOnUnitWithVolume( udg_ShadowDagger_HitSound, 70, GetTriggerUnit() )
set caster = null
endfunction
//===========================================================================
function InitTrig_SD_Apply_Damage takes nothing returns nothing
set gg_trg_SD_Apply_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Apply_Damage, EVENT_PLAYER_UNIT_DAMAGING )
call TriggerAddCondition( gg_trg_SD_Apply_Damage, Condition( function Trig_SD_Apply_Damage_Conditions ) )
call TriggerAddAction( gg_trg_SD_Apply_Damage, function Trig_SD_Apply_Damage_Actions )
endfunction
function Trig_SD_Display_Damage_Conditions takes nothing returns boolean
return GetUnitTypeId(GetEventDamageSource()) == udg_ShadowDagger_DamageDummy and IsUnitInGroup(GetEventDamageSource(), udg_ShadowDagger_DamageDoneGroup)
endfunction
function Trig_SD_Display_Damage_Actions takes nothing returns nothing
local texttag tt
local effect e
local unit caster
local unit target
local location l
set caster = LoadUnitHandleBJ(udg_Skill_SD_IndexCaster, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
if caster == null then
return
endif
// we must check target in case of Spiritual Link or Ancestral Meditation (in that case the damage dummy may damage another unit than the target)
set target = LoadUnitHandleBJ(udg_Skill_SD_IndexTarget, GetHandleIdBJ(caster), udg_SkillHT)
if target != GetTriggerUnit() then
set caster = null
return
endif
set tt = CreateDamageTextOnUnit( GetTriggerUnit(), GetEventDamage(), 100, 0, 0)
set e = AddSpecialEffectTargetUnitBJ( "chest", GetTriggerUnit(), udg_ShadowDagger_DeathPath )
call DestroyEffect(e)
set l = GetUnitLoc(GetTriggerUnit())
set e = AddSpecialEffectLocBJ( l, udg_ShadowDagger_BloodPath )
call BlzSetSpecialEffectYaw( e, Deg2Rad(GetUnitFacing(GetEventDamageSource())) )
call BlzSetSpecialEffectZ( e, GetUnitFlyHeight(GetTriggerUnit()) )
call DestroyEffect(e)
call RemoveLocation(l)
call GroupRemoveUnitSimple(GetEventDamageSource(), udg_ShadowDagger_DamageDoneGroup)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(GetEventDamageSource()), udg_Skill_SD_IndexCaster)
call RemoveUnit( GetEventDamageSource() )
call TriggerSleepAction( 5.00 )
call DestroyTextTag(tt)
set tt = null
set e = null
set caster = null
set target = null
set l = null
endfunction
//===========================================================================
function InitTrig_SD_Display_Damage takes nothing returns nothing
set gg_trg_SD_Display_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SD_Display_Damage, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_SD_Display_Damage, Condition( function Trig_SD_Display_Damage_Conditions ) )
call TriggerAddAction( gg_trg_SD_Display_Damage, function Trig_SD_Display_Damage_Actions )
endfunction
function Trig_Lethal_Sputum_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_LethalSputum_Ability
endfunction
function Trig_Lethal_Sputum_Cast_Actions takes nothing returns nothing
local real mana_left
local real mana_drained
local real coeff
local integer ability_level
set ability_level = GetUnitAbilityLevelSwapped(udg_LethalSputum_Ability, GetTriggerUnit())
set coeff = 0.5 + ability_level
// set mana_drained = 70 + 5 * ability_level
set mana_drained = 75
set mana_left = GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit())
if mana_drained > mana_left then
set mana_drained = mana_left
endif
call SetUnitManaBJ(GetTriggerUnit(), mana_left - mana_drained + udg_LethalSputum_BasicManaCost )
call SaveUnitHandleBJ( GetSpellTargetUnit(), udg_Skill_LethalSputum_IndexTarget, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
call SaveRealBJ( coeff * mana_drained, udg_Skill_LethalSputum_IndexDamage, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
// call SPv2PlaySoundOnUnit(udg_LethalSputum_SoundPath, GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_Lethal_Sputum_Cast takes nothing returns nothing
set gg_trg_Lethal_Sputum_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lethal_Sputum_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Lethal_Sputum_Cast, Condition( function Trig_Lethal_Sputum_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Lethal_Sputum_Cast, function Trig_Lethal_Sputum_Cast_Actions )
endfunction
function Trig_Lethal_Sputum_Damage_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_LethalSputum_Buff) and GetTriggerUnit() == LoadUnitHandleBJ(udg_Skill_LethalSputum_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
endfunction
function Trig_Lethal_Sputum_Damage_Actions takes nothing returns nothing
local texttag tt
local effect e
local real damage
if GetEventDamage() == 0 then
set e = AddSpecialEffectTargetUnitBJ( "chest", GetTriggerUnit(), udg_LethalSputum_ImpactPath )
call DestroyEffectBJ( e )
set damage = LoadRealBJ(udg_Skill_LethalSputum_IndexDamage, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
call UnitDamageTargetBJ( GetEventDamageSource(), GetTriggerUnit(), damage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
else
call UnitRemoveBuffBJ( udg_LethalSputum_Buff, GetTriggerUnit() )
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(GetEventDamageSource()), udg_Skill_LethalSputum_IndexTarget)
set tt = CreateDamageTextOnUnit( GetTriggerUnit(), GetEventDamage(), 50, 0, 70)
call TriggerSleepAction( 5.00 )
call DestroyTextTag(tt)
endif
set tt = null
set e = null
endfunction
//===========================================================================
function InitTrig_Lethal_Sputum_Damage takes nothing returns nothing
set gg_trg_Lethal_Sputum_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Lethal_Sputum_Damage, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Lethal_Sputum_Damage, Condition( function Trig_Lethal_Sputum_Damage_Conditions ) )
call TriggerAddAction( gg_trg_Lethal_Sputum_Damage, function Trig_Lethal_Sputum_Damage_Actions )
endfunction
function TidalWaveAddWaveVisual takes timer t returns nothing
local location l
local real angle
local effect e
local unit wave
local integer counter
set wave = LoadUnitHandleBJ(udg_Skill_TidalWave_IndexWave, GetHandleIdBJ(t), udg_SkillHT)
set counter = LoadIntegerBJ(udg_Skill_TidalWave_IndexWaveCount, GetHandleIdBJ(wave), udg_SkillHT)
if counter >= udg_TidalWave_TotalWaves then
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_SkillHT)
call PauseTimer(t)
call DestroyTimer(t)
set wave = null
return
endif
set angle = LoadRealBJ(udg_Skill_TidalWave_IndexAngle, GetHandleIdBJ(wave), udg_SkillHT)
set l = LoadLocationHandleBJ(udg_Skill_TidalWave_IndexPosition, GetHandleIdBJ(wave), udg_SkillHT)
set e = AddSpecialEffectLocBJ( l, udg_TidalWave_WaveVisual )
call BlzSetSpecialEffectOrientation(e, ( angle * ( bj_PI / 180.00 ) ), 0.00, 0.00 )
call BlzSetSpecialEffectScale(e, 2.50 )
call BlzSetSpecialEffectTimeScale(e, 1.70 )
call DestroyEffectBJ(e )
call SaveIntegerBJ(counter + 1, udg_Skill_TidalWave_IndexWaveCount, GetHandleIdBJ(wave), udg_SkillHT)
set l = null
set e = null
set wave = null
endfunction
function Trig_Tidal_Wave_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_TidalWave_Ability
endfunction
function Trig_Tidal_Wave_Cast_Actions takes nothing returns nothing
local unit wave
local location caster_loc
local location target_loc
local location wave_loc
local integer i
local real angle
local effect e
local item tracker
local timer t
set caster_loc = GetUnitLoc(GetTriggerUnit())
set target_loc = GetSpellTargetLoc()
set angle = AngleBetweenPoints(target_loc, caster_loc)
set wave_loc = PolarProjectionBJ(target_loc, udg_TidalWave_StartOffset, 180 + angle)
set wave = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_Skill_DummyCaster, wave_loc, bj_UNIT_FACING)
call GroupAddUnitSimple(wave, udg_TidalWave_WaveGroup)
call UnitApplyTimedLifeBJ( udg_TidalWave_Duration, 'BTLF', wave )
call SPv2PlaySoundAtPoint( udg_TidalWave_Sound, caster_loc )
set tracker = CreateItemLoc( udg_Skill_CollisionTracker, caster_loc )
call SetItemInvulnerableBJ( tracker, true )
call SetItemVisibleBJ( false, tracker )
set t = CreateTimer()
call TriggerRegisterTimerExpireEventBJ( gg_trg_Tidal_Wave_Visual_Effect, t )
call StartTimerBJ( t, true, udg_TidalWave_WaveInterval )
call SaveUnitHandleBJ(wave, udg_Skill_TidalWave_IndexWave, GetHandleIdBJ(t), udg_SkillHT)
call SaveRealBJ(angle, udg_Skill_TidalWave_IndexAngle, GetHandleIdBJ(wave), udg_SkillHT)
call SaveLocationHandleBJ(wave_loc, udg_Skill_TidalWave_IndexPosition, GetHandleIdBJ(wave), udg_SkillHT)
call SaveItemHandleBJ(tracker, udg_Skill_TidalWave_IndexTracker, GetHandleIdBJ(wave), udg_SkillHT)
call SaveGroupHandleBJ(CreateGroup(), udg_Skill_TidalWave_IndexTargGroup, GetHandleIdBJ(wave), udg_SkillHT)
call SaveIntegerBJ(GetUnitAbilityLevelSwapped(udg_TidalWave_Ability, GetTriggerUnit()), udg_Skill_TidalWave_IndexLevel, GetHandleIdBJ(wave), udg_SkillHT)
call SaveIntegerBJ(0, udg_Skill_TidalWave_IndexWaveCount, GetHandleIdBJ(wave), udg_SkillHT)
call EnableTrigger(gg_trg_Tidal_Wave_Update_Wave )
call TidalWaveAddWaveVisual(t)
call RemoveLocation(target_loc)
call RemoveLocation(caster_loc)
set t = null
set caster_loc = null
set wave_loc = null
set target_loc = null
set tracker = null
set e = null
set wave = null
endfunction
//===========================================================================
function InitTrig_Tidal_Wave_Cast takes nothing returns nothing
set gg_trg_Tidal_Wave_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Tidal_Wave_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Tidal_Wave_Cast, Condition( function Trig_Tidal_Wave_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Tidal_Wave_Cast, function Trig_Tidal_Wave_Cast_Actions )
endfunction
function Trig_Tidal_Wave_Visual_Effect_Actions takes nothing returns nothing
call TidalWaveAddWaveVisual(GetExpiredTimer())
endfunction
//===========================================================================
function InitTrig_Tidal_Wave_Visual_Effect takes nothing returns nothing
set gg_trg_Tidal_Wave_Visual_Effect = CreateTrigger( )
call TriggerAddAction( gg_trg_Tidal_Wave_Visual_Effect, function Trig_Tidal_Wave_Visual_Effect_Actions )
endfunction
function Trig_Tidal_Wave_MoveUnits takes unit wave, real angle, location l returns nothing
local group g
local location wave_adjusted_loc
local location target_loc
local location new_target_loc
local location tracker_loc
local unit u
local real sin
local boolean spell_success
local boolean knockback_success
local item tracker
local group already_hit_g
local integer ability_level
local integer total_hit_targets
set ability_level = LoadIntegerBJ(udg_Skill_TidalWave_IndexLevel, GetHandleIdBJ(wave), udg_SkillHT)
set tracker = LoadItemHandleBJ(udg_Skill_TidalWave_IndexTracker, GetHandleIdBJ(wave), udg_SkillHT)
set already_hit_g = LoadGroupHandleBJ(udg_Skill_TidalWave_IndexTargGroup, GetHandleIdBJ(wave), udg_SkillHT)
set total_hit_targets = CountUnitsInGroup(already_hit_g)
set wave_adjusted_loc = PolarProjectionBJ(l, udg_TidalWave_WaveOffset, 180 + angle)
call SetUnitPositionLoc(wave, wave_adjusted_loc)
set g = GetUnitsInRangeOfLocAll(udg_TidalWave_Range, wave_adjusted_loc)
loop
set u = FirstOfGroup(g)
exitwhen u == null
set target_loc = GetUnitLoc(u)
set sin = SinBJ(AngleBetweenPoints(l, target_loc) - angle + 90)
set knockback_success = false
if sin > 0 then
if IsUnitType(u, UNIT_TYPE_STRUCTURE) and not IsUnitAlly(u, GetOwningPlayer(wave)) then
if not IsUnitInGroup(u, already_hit_g) then // buildings don't add the target count
call GroupAddUnit(already_hit_g, u)
call UnitDamageTargetBJ( wave, u, 25 + 50*ability_level, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_ENHANCED )
endif
else
if IsUnitInGroup(u, already_hit_g) then
set spell_success = true
else
if total_hit_targets >= udg_TidalWave_MaxTargets then
set ability_level = 4 // we cant do more damage but the units will still be pushed away
endif
set spell_success = CastSpellOnUnit(wave, udg_TidalWave_DamageAbility, udg_TidalWave_DamageOrder, ability_level, u)
endif
if spell_success then
if not IsUnitInGroup(u, already_hit_g) then
set total_hit_targets = total_hit_targets + 1
endif
call GroupAddUnit(already_hit_g, u)
if IsUnitType(u, UNIT_TYPE_FLYING) and not(IsUnitType(u, UNIT_TYPE_SNARED)) then
set knockback_success = true
else
set new_target_loc = PolarProjectionBJ(target_loc, udg_TidalWave_Knockback, angle)
call SetItemVisibleBJ( true, tracker )
call SetItemPositionLoc( tracker, new_target_loc )
set tracker_loc = GetItemLoc(tracker)
if GetLocationY(new_target_loc) == GetLocationY(tracker_loc) and GetLocationX(new_target_loc) == GetLocationX(tracker_loc) then
set knockback_success = true
endif
call RemoveLocation(tracker_loc)
call RemoveLocation(new_target_loc)
call SetItemVisibleBJ( false, tracker )
endif
endif
endif
if knockback_success then
call SetUnitX(u, GetUnitX(u) + CosBJ(angle)*udg_TidalWave_Knockback)
call SetUnitY(u, GetUnitY(u) + SinBJ(angle)*udg_TidalWave_Knockback)
endif
endif
call RemoveLocation(target_loc)
call GroupRemoveUnit(g, u)
endloop
call RemoveLocation(wave_adjusted_loc)
call DestroyGroup(g)
set g = null
set target_loc = null
set wave_adjusted_loc = null
set new_target_loc = null
set tracker_loc = null
set u = null
set tracker = null
set already_hit_g = null
endfunction
function Trig_Tidal_Wave_Update_Wave_Enum takes nothing returns nothing
local location l
local location l2
local real angle
set l = LoadLocationHandleBJ(udg_Skill_TidalWave_IndexPosition, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
set angle = LoadRealBJ(udg_Skill_TidalWave_IndexAngle, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
if l == null then
return
endif
call Trig_Tidal_Wave_MoveUnits(GetEnumUnit(), angle, l)
set l2 = PolarProjectionBJ(l, udg_TidalWave_Step, angle)
call SaveLocationHandleBJ(l2, udg_Skill_TidalWave_IndexPosition, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
call RemoveLocation(l)
set l = null
set l2 = null
endfunction
function Trig_Tidal_Wave_Update_Wave_Actions takes nothing returns nothing
call ForGroupBJ( udg_TidalWave_WaveGroup, function Trig_Tidal_Wave_Update_Wave_Enum )
if IsUnitGroupEmptyBJ(udg_TidalWave_WaveGroup) then
call DisableTrigger(GetTriggeringTrigger())
endif
endfunction
//===========================================================================
function InitTrig_Tidal_Wave_Update_Wave takes nothing returns nothing
set gg_trg_Tidal_Wave_Update_Wave = CreateTrigger( )
call DisableTrigger( gg_trg_Tidal_Wave_Update_Wave )
call TriggerRegisterTimerEventPeriodic( gg_trg_Tidal_Wave_Update_Wave, 0.02 )
call TriggerAddAction( gg_trg_Tidal_Wave_Update_Wave, function Trig_Tidal_Wave_Update_Wave_Actions )
endfunction
function Trig_Ocean_Strike_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_OceanStrike_Ability
endfunction
function Trig_Ocean_Strike_Cast_Actions takes nothing returns nothing
local location l
local effect e
set l = GetSpellTargetLoc()
set e = AddSpecialEffectLocBJ( l, udg_OceanStrike_EffectPath )
call BlzSetSpecialEffectTimeScale( e, 3 )
call SPv2PlaySoundAtPoint( udg_OceanStrike_EffectSound, l )
call DestroyEffect(e)
call RemoveLocation(l)
set e = null
set l = null
endfunction
//===========================================================================
function InitTrig_Ocean_Strike_Cast takes nothing returns nothing
set gg_trg_Ocean_Strike_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Ocean_Strike_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Ocean_Strike_Cast, Condition( function Trig_Ocean_Strike_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Ocean_Strike_Cast, function Trig_Ocean_Strike_Cast_Actions )
endfunction
function FervorAuraSetBonusLevel takes unit u, integer level returns nothing
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility1, true, true )
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility2, true, true )
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility3, true, true )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
call SetUnitAbilityLevelSwapped( udg_FervorAura_BoostAbility1, u, level )
call SetUnitAbilityLevelSwapped( udg_FervorAura_BoostAbility2, u, level )
call SetUnitAbilityLevelSwapped( udg_FervorAura_BoostAbility3, u, level )
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility1, false, true )
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility2, false, true )
call BlzUnitDisableAbility( u, udg_FervorAura_BoostAbility3, false, true )
endfunction
function FervorAuraAddTarget takes unit u returns nothing
call GroupAddUnitSimple( u, udg_FervorAura_TargetGroup )
call UnitAddAbilityBJ( udg_FervorAura_BoostAbility1, u )
call UnitAddAbilityBJ( udg_FervorAura_BoostAbility2, u )
call UnitAddAbilityBJ( udg_FervorAura_BoostAbility3, u )
call FervorAuraSetBonusLevel(u, 1)
call EnableTrigger( gg_trg_Fervor_Aura_Refresh )
endfunction
function FervorAuraRemoveTarget takes unit u returns nothing
call GroupRemoveUnitSimple( u, udg_FervorAura_TargetGroup )
call UnitRemoveAbilityBJ( udg_FervorAura_BoostAbility1, u )
call UnitRemoveAbilityBJ( udg_FervorAura_BoostAbility2, u )
call UnitRemoveAbilityBJ( udg_FervorAura_BoostAbility3, u )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
call UnitRemoveBuffBJ( udg_FervorAura_BoostBuff, u )
endfunction
function FervorAuraAddCasterUnit takes unit u returns nothing
call GroupAddUnitSimple( u, udg_FervorAura_EmitterGroup )
call TriggerRegisterUnitInRangeSimple( gg_trg_Fervor_Aura_New_Target, udg_FervorAura_AOE, u )
call TriggerRegisterUnitInRangeSimple( gg_trg_Fervor_Aura_New_Target, ( udg_FervorAura_AOE - 50.00 ), u )
endfunction
function Trig_Fervor_Aura_EmitterCondition takes nothing returns boolean
return IsUnitInGroup(GetFilterUnit(), udg_FervorAura_EmitterGroup) and IsUnitAliveBJ(GetFilterUnit()) and IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit()))
endfunction
function Trig_Fervor_Aura_Refresh_Target takes nothing returns nothing
local integer total_emitters
local group emitters_around
local location l
local integer current_level
set l = GetUnitLoc(GetEnumUnit())
set emitters_around = GetUnitsInRangeOfLocMatching(udg_FervorAura_AOE, l, Condition(function Trig_Fervor_Aura_EmitterCondition))
set total_emitters = CountUnitsInGroup(emitters_around)
if total_emitters > udg_FervorAura_MaxEmitters then
set total_emitters = udg_FervorAura_MaxEmitters
endif
if ( total_emitters > 0 ) then
if GetUnitAbilityLevelSwapped(udg_FervorAura_BoostAbility1, GetEnumUnit()) != total_emitters then
call FervorAuraSetBonusLevel(GetEnumUnit(), total_emitters)
endif
else
call FervorAuraRemoveTarget(GetEnumUnit())
endif
call RemoveLocation(l)
call DestroyGroup(emitters_around)
set l = null
set emitters_around = null
endfunction
function Trig_Fervor_Aura_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_FervorAura_TargetGroup, function Trig_Fervor_Aura_Refresh_Target )
if CountUnitsInGroup(udg_FervorAura_TargetGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_Fervor_Aura_Refresh takes nothing returns nothing
set gg_trg_Fervor_Aura_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_Fervor_Aura_Refresh )
call TriggerRegisterTimerEventPeriodic( gg_trg_Fervor_Aura_Refresh, 0.50 )
call TriggerAddAction( gg_trg_Fervor_Aura_Refresh, function Trig_Fervor_Aura_Refresh_Actions )
endfunction
function EviscerateRemoveAbility takes unit u returns nothing
local integer current_ability_id
set current_ability_id = LoadIntegerBJ(udg_Skill_Eviscerate_IndexAbility, GetHandleIdBJ(u), udg_SkillHT )
if current_ability_id != 0 then
call UnitRemoveAbilityBJ( current_ability_id, u )
endif
// in case the previous ability was being a beast
call FervorAuraRemoveTarget(u)
endfunction
function Trig_Eviscerate_Init_Actions takes nothing returns nothing
set udg_Eviscerate_Ability = 'A02U'
set udg_Eviscerate_SpellStealDuration = 45
set udg_Eviscerate_LifeRegained = 0.5
set udg_Eviscerate_HealPath = "Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl"
// Human
call SaveIntegerBJ( 'A00F', 'hfoo', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A01Y', 'hkni', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A01Z', 'hmtm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02V', 'hgry', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A027', 'hmpr', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A028', 'hsor', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A029', 'hspt', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02A', 'hdhw', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
// Orc
call SaveIntegerBJ( 'A02B', 'opeo', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02B', 'ogru', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A01V', 'orai', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02G', 'otau', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02W', 'ohun', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A020', 'okod', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02C', 'owyv', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02D', 'otbr', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02F', 'odoc', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02E', 'oshm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02H', 'ospw', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02X', 'osw2', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02X', 'osw3', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02H', 'ospm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02W', 'otbk', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
// Undead
call SaveIntegerBJ( 'A02Y', 'ushd', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02I', 'ugho', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02I', 'uabo', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02J', 'ucry', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02K', 'uban', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02L', 'unec', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02M', 'ufro', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02J', 'ucrm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ( 'A02N', 'ubsp', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
// Night Elf
call SaveIntegerBJ('A02O', 'earc', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A00E', 'esen', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02P', 'edry', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02O', 'ehpr', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02T', 'echm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02R', 'edot', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02Q', 'edoc', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A030', 'emtg', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02S', 'efdr', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02R', 'edtm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02Q', 'edcm', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A02Z', 'espv', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
// Naga
call SaveIntegerBJ('A03H', 'e005', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03L', 'e002', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03F', 'e003', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03F', 'e004', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03F', 'h008', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03F', 'h00C', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03J', 'h002', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03K', 'u000', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A042', 'n00G', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03I', 'n00C', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03F', 'n00D', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A00G', 'n00A', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
call SaveIntegerBJ('A03D', 'n00B', udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
endfunction
//===========================================================================
function InitTrig_Eviscerate_Init takes nothing returns nothing
set gg_trg_Eviscerate_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Eviscerate_Init, function Trig_Eviscerate_Init_Actions )
endfunction
function Trig_Eviscerate_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_Eviscerate_Ability
endfunction
function Trig_Eviscerate_Cast_Actions takes nothing returns nothing
local integer new_ability_id
local integer current_ability_id
local timer t
local player p
local effect e
set p = GetOwningPlayer(GetSpellTargetUnit())
call SetUnitLifeBJ( GetTriggerUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) + ( udg_Eviscerate_LifeRegained * GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetSpellTargetUnit()) ) ) )
set e = AddSpecialEffectTargetUnitBJ( "origin", GetTriggerUnit(), udg_Eviscerate_HealPath )
call DestroyEffect(e)
call SaveBooleanBJ(true, udg_Skill_Eviscerate_IndexDoomed, GetHandleIdBJ(GetSpellTargetUnit()), udg_SkillHT)
call UnitDamageTargetBJ( GetTriggerUnit(), GetSpellTargetUnit(), 9999999.00, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL )
call UnitDamageTargetBJ( GetTriggerUnit(), GetSpellTargetUnit(), 9999999.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNIVERSAL )
call EviscerateRemoveAbility(GetTriggerUnit())
set t = LoadTimerHandleBJ(udg_Skill_Eviscerate_IndexTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if t == null then
set t = CreateTimer()
call SaveTimerHandleBJ(t, udg_Skill_Eviscerate_IndexTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_Eviscerate_IndexCaster, GetHandleIdBJ(t), udg_SkillHT)
call TriggerRegisterTimerExpireEventBJ( gg_trg_Eviscerate_Expiration, t )
endif
set new_ability_id = LoadIntegerBJ(GetUnitTypeId(GetSpellTargetUnit()), udg_Dict_Eviscerate_IndexSpells, udg_DictHT )
if new_ability_id != 0 then
call UnitAddAbilityBJ( new_ability_id, GetTriggerUnit() )
call SaveIntegerBJ(new_ability_id, udg_Skill_Eviscerate_IndexAbility, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
call StartTimerBJ( t, false, udg_Eviscerate_SpellStealDuration )
endif
set p = null
set t = null
set e = null
endfunction
//===========================================================================
function InitTrig_Eviscerate_Cast takes nothing returns nothing
set gg_trg_Eviscerate_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Eviscerate_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Eviscerate_Cast, Condition( function Trig_Eviscerate_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Eviscerate_Cast, function Trig_Eviscerate_Cast_Actions )
endfunction
function Trig_Eviscerate_Expiration_Actions takes nothing returns nothing
local timer t
local unit caster
local integer ability_id
set t = GetExpiredTimer()
set caster = LoadUnitHandleBJ(udg_Skill_Eviscerate_IndexCaster, GetHandleIdBJ(t), udg_SkillHT)
call EviscerateRemoveAbility(caster)
endfunction
//===========================================================================
function InitTrig_Eviscerate_Expiration takes nothing returns nothing
set gg_trg_Eviscerate_Expiration = CreateTrigger( )
call TriggerAddAction( gg_trg_Eviscerate_Expiration, function Trig_Eviscerate_Expiration_Actions )
endfunction
function Trig_OpenWounds_Release_Actions takes nothing returns nothing
// not necessary theoretically
if not (SOHTargetMatchesConditions(udg_SOH_IndexOpenWounds, GetEventDamageSource(), GetTriggerUnit())) then
return
endif
// this trigger needs event unit_damaged event not but SOH provides unit_damaging event.
// So we create a new trigger for unit damaged event
call SaveUnitHandleBJ(GetEventDamageSource(), udg_Skill_OpenWounds_IndexSource, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
endfunction
//===========================================================================
function InitTrig_OpenWounds_Release takes nothing returns nothing
set gg_trg_OpenWounds_Release = CreateTrigger( )
call TriggerAddAction( gg_trg_OpenWounds_Release, function Trig_OpenWounds_Release_Actions )
endfunction
function Trig_OpenWounds_Apply_Damage_Conditions takes nothing returns boolean
return GetEventDamageSource() == LoadUnitHandleBJ(udg_Skill_OpenWounds_IndexSource, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT) and GetEventDamageSource() != null
endfunction
function Trig_OpenWounds_Apply_Damage_Actions takes nothing returns nothing
local texttag tt
local real coeff
local real extra_damage
local effect e
set e = AddSpecialEffectTargetUnitBJ( "chest", GetTriggerUnit(), udg_OpenWounds_Attachment )
call DestroyEffect(e)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(GetTriggerUnit()), udg_Skill_OpenWounds_IndexSource)
set coeff = ( 0.05 * I2R(GetUnitAbilityLevelSwapped(udg_SOH_Abilities[udg_SOH_IndexOpenWounds], GetEventDamageSource())) )
set extra_damage = coeff*RMinBJ(GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit()), GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetEventDamageSource()))
call UnitDamageTargetBJ( GetEventDamageSource(), GetTriggerUnit(), extra_damage, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED )
set tt = CreateDamageTextOnUnit(GetTriggerUnit(), GetEventDamage() + extra_damage, 70, 30, 10)
call TriggerSleepAction(5.00)
call DestroyTextTag(tt)
set tt = null
set e = null
endfunction
//===========================================================================
function InitTrig_OpenWounds_Apply_Damage takes nothing returns nothing
set gg_trg_OpenWounds_Apply_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_OpenWounds_Apply_Damage, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_OpenWounds_Apply_Damage, Condition( function Trig_OpenWounds_Apply_Damage_Conditions ) )
call TriggerAddAction( gg_trg_OpenWounds_Apply_Damage, function Trig_OpenWounds_Apply_Damage_Actions )
endfunction
function FrenzyGetBonusDamage takes integer level returns integer
if level == 1 then
return 2
endif
if level == 2 then
return 2
endif
return 3
endfunction
function FrenzyGetBonusSpeed takes integer level returns real
if level == 1 then
return 0.03
endif
if level == 2 then
return 0.06
endif
return 0.09
endfunction
function FrenzyResetAbilitySettings takes unit u returns nothing
local integer level
local unit target
local integer offset
// can target flying + target is flying or null: 1
// can target flying + target is on the ground: 2
// cannot target flying + target is flying or null: 3
// cannot target flying + target is on the ground: 4
if IsUnitType(u, UNIT_TYPE_ATTACKS_FLYING) then
set offset = 0
else
set offset = 2
endif
set target = LoadUnitHandleBJ(udg_Skill_Frenzy_IndexTarget, GetHandleIdBJ(u), udg_SkillHT )
if target == null or (IsUnitType(target, UNIT_TYPE_FLYING) and not(IsUnitType(target, UNIT_TYPE_SNARED))) then
set level = offset + 1
else
set level = offset + 2
endif
call SetUnitAbilityLevelSwapped( udg_Frenzy_Ability, u, level )
set target = null
endfunction
function FrenzyIncreaseEffect takes unit u returns nothing
local integer current_level
local integer damage_step
local integer speed_step
local integer damage_level
local integer speed_level
local real current_mana
set current_mana = GetUnitStateSwap(UNIT_STATE_MANA, u)
if BlzGetUnitAbilityCooldownRemaining(u, udg_Frenzy_Ability) > 0.00 or current_mana < udg_Frenzy_ManaCost then
return
endif
call BlzStartUnitAbilityCooldown( u, udg_Frenzy_Ability, udg_Frenzy_Cooldown )
call SetUnitManaBJ( u, current_mana - udg_Frenzy_ManaCost )
set current_level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityLearnable, u)
set damage_step = FrenzyGetBonusDamage(current_level)
set speed_step = R2I(FrenzyGetBonusSpeed(current_level) / 0.03)
set damage_level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityBonusDamage, u) + damage_step
set speed_level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityBonusSpeed, u) + speed_step
call SetUnitAbilityLevelSwapped( udg_Frenzy_AbilityBonusDamage, u, damage_level )
call SetUnitAbilityLevelSwapped( udg_Frenzy_AbilityBonusSpeed, u, speed_level )
call UnitAddAbilityBJ( udg_Frenzy_AbilityVisual, u )
call BlzUnitDisableAbility( u, udg_Frenzy_AbilityVisual, false, true )
call PolledWait(udg_Frenzy_Duration)
set damage_level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityBonusDamage, u) - damage_step
set speed_level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityBonusSpeed, u) - speed_step
call SetUnitAbilityLevelSwapped( udg_Frenzy_AbilityBonusDamage, u, damage_level )
call SetUnitAbilityLevelSwapped( udg_Frenzy_AbilityBonusSpeed, u, speed_level )
if damage_level <= 1 then
call UnitRemoveAbilityBJ( udg_Frenzy_AbilityVisual, u )
call UnitRemoveBuffBJ( udg_Frenzy_Buff, u )
endif
endfunction
function Trig_Frenzy_AutoCast_Conditions takes nothing returns boolean
return GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityLearnable, GetTriggerUnit()) > 0
endfunction
function Trig_Frenzy_AutoCast_Actions takes nothing returns nothing
if ( GetIssuedOrderIdBJ() == String2OrderIdBJ(( udg_Frenzy_Order + "on" )) ) then
call BlzSetAbilityIntegerFieldBJ( BlzGetUnitAbility(GetTriggerUnit(), udg_Frenzy_Ability), ABILITY_IF_MISSILE_SPEED, 1 )
else
if ( GetIssuedOrderIdBJ() == String2OrderIdBJ(( udg_Frenzy_Order + "off" )) ) then
call BlzSetAbilityIntegerFieldBJ( BlzGetUnitAbility(GetTriggerUnit(), udg_Frenzy_Ability), ABILITY_IF_MISSILE_SPEED, 0 )
endif
endif
endfunction
//===========================================================================
function InitTrig_Frenzy_AutoCast takes nothing returns nothing
set gg_trg_Frenzy_AutoCast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Frenzy_AutoCast, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_Frenzy_AutoCast, Condition( function Trig_Frenzy_AutoCast_Conditions ) )
call TriggerAddAction( gg_trg_Frenzy_AutoCast, function Trig_Frenzy_AutoCast_Actions )
endfunction
function Trig_Frenzy_Learn_Conditions takes nothing returns boolean
return GetLearnedSkillBJ() == udg_Frenzy_AbilityLearnable
endfunction
function Trig_Frenzy_Learn_Actions takes nothing returns nothing
local string s
local integer level
local integer damage_bonus
local integer speed_bonus
call BlzUnitHideAbility( GetTriggerUnit(), udg_Frenzy_AbilityLearnable, true )
call UnitAddAbilityBJ( udg_Frenzy_Ability, GetTriggerUnit() )
call UnitAddAbilityBJ( udg_Frenzy_AbilityBonusDamage, GetTriggerUnit() )
call UnitAddAbilityBJ( udg_Frenzy_AbilityBonusSpeed, GetTriggerUnit() )
call FrenzyResetAbilitySettings(GetTriggerUnit())
set level = GetUnitAbilityLevelSwapped(udg_Frenzy_AbilityLearnable, GetTriggerUnit())
set damage_bonus = FrenzyGetBonusDamage(level)
set speed_bonus = R2I(100*FrenzyGetBonusSpeed(level))
set s = "Frenzy - |cffffcc00level " + I2S(level) + "|r"
call BlzSetAbilityStringLevelFieldBJ( BlzGetUnitAbility(GetTriggerUnit(), udg_Frenzy_Ability), ABILITY_SLF_TOOLTIP_NORMAL, 0, s)
set s = "Each attack consumes 8 mana point ands adds " + I2S(damage_bonus) + " extra damage point(s) and increases the attack speed by " + I2S(speed_bonus) + "%."
set s = s + " The bonus lasts for " + I2S(R2I(udg_Frenzy_Duration)) + " seconds and can stack indefinitely."
call BlzSetAbilityStringLevelFieldBJ( BlzGetUnitAbility(GetTriggerUnit(), udg_Frenzy_Ability), ABILITY_SLF_TOOLTIP_NORMAL_EXTENDED, 0, s)
if not LoadBooleanBJ(udg_Skill_Frenzy_IndexAbilityOff, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT ) and GetUnitAbilityLevelSwapped(udg_WaterDisguise_InvisAbility, GetTriggerUnit()) > 0 then
call BlzUnitDisableAbility( GetTriggerUnit(), udg_Frenzy_Ability, true, false )
call SaveBooleanBJ(true, udg_Skill_Frenzy_IndexAbilityOff, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
endif
endfunction
//===========================================================================
function InitTrig_Frenzy_Learn takes nothing returns nothing
set gg_trg_Frenzy_Learn = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Frenzy_Learn, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_Frenzy_Learn, Condition( function Trig_Frenzy_Learn_Conditions ) )
call TriggerAddAction( gg_trg_Frenzy_Learn, function Trig_Frenzy_Learn_Actions )
endfunction
function KrakenDeleteKraken takes unit kraken returns nothing
local location l
local location l2
local effect e
// we have to manually create an effect for death because altering the animations of the kraken made them bug (no display on death)
set l = GetUnitLoc(kraken)
set l2 = OffsetLocation(l, -20.00, 0)
set e = AddSpecialEffectLocBJ( l2, udg_Kraken_ModelPath )
call DestroyEffect(e)
call RemoveLocation(l)
call RemoveLocation(l2)
call GroupRemoveUnitSimple(kraken, udg_Kraken_KrakenGroup)
// call ResetUnitAnimation( kraken )
// call SetUnitAnimation(kraken, "death" )
// call KillUnit(kraken)
// call QueueUnitAnimationBJ(kraken, "death" )
call FlushChildHashtableBJ( GetHandleIdBJ(kraken), udg_SkillHT)
call RemoveUnit(kraken)
set l = null
set l2 = null
set e = null
endfunction
function KrakenStop takes unit caster returns nothing
local unit kraken
set kraken = LoadUnitHandleBJ(udg_Skill_Kraken_IndexKraken, GetHandleIdBJ(caster), udg_SkillHT)
if kraken != null then
call KrakenDeleteKraken(kraken)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(caster), udg_Skill_Kraken_IndexKraken)
endif
set kraken = null
endfunction
function Trig_Kraken_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_Kraken_Ability
endfunction
function Trig_Kraken_Cast_Actions takes nothing returns nothing
local unit kraken
local location l
call KrakenStop(GetTriggerUnit())
set l = GetSpellTargetLoc()
set kraken = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_Kraken_KrakenDummy, l, 0.00)
call SetUnitAnimation(kraken, "birth" )
call QueueUnitAnimationBJ(kraken, "stand" )
call SetUnitTimeScalePercent( kraken, 200.00 )
call SaveUnitHandleBJ(kraken, udg_Skill_Kraken_IndexKraken, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_Kraken_IndexCaster, GetHandleIdBJ(kraken), udg_SkillHT)
call PropagateWaterAroundUnit(kraken)
call GroupAddUnitSimple(kraken, udg_Kraken_KrakenGroup)
call EnableTrigger(gg_trg_Kraken_Attack)
call RemoveLocation(l)
set kraken = null
set l = null
endfunction
//===========================================================================
function InitTrig_Kraken_Cast takes nothing returns nothing
set gg_trg_Kraken_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Kraken_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Kraken_Cast, Condition( function Trig_Kraken_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Kraken_Cast, function Trig_Kraken_Cast_Actions )
endfunction
function Trig_Kraken_Attack_TargetCondition takes nothing returns boolean
local boolean success
set success = not IsPlayerAlly(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(GetEnumUnit()))
set success = success and not(IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING))
set success = success and not(UnitHasBuffBJ(GetFilterUnit(), 'BUim'))
set success = success and not(UnitHasBuffBJ(GetFilterUnit(), udg_Kraken_Buff))
set success = success and IsUnitAliveBJ(GetFilterUnit())
set success = success and LoadTimerHandleBJ(udg_Skill_Kraken_IndexTimer, GetHandleIdBJ(GetFilterUnit()), udg_SkillHT) == null
return success
endfunction
function Trig_Kraken_Attack_Single takes nothing returns nothing
local unit caster
local unit current_kraken
local group g
local location l
local unit target
local timer target_timer
local boolean spell_success
// in case attack is missed, we display a randomky positionned tentacle
local real miss_angle
local real miss_distance
local location miss_tentacle_loc
local effect miss_tentacle_effect
set caster = LoadUnitHandleBJ(udg_Skill_Kraken_IndexCaster, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
if caster == null then
call KrakenDeleteKraken(GetEnumUnit())
return
endif
set current_kraken = LoadUnitHandleBJ(udg_Skill_Kraken_IndexKraken, GetHandleIdBJ(caster), udg_SkillHT)
if current_kraken != GetEnumUnit() then
call KrakenDeleteKraken(GetEnumUnit())
set current_kraken = null
return
endif
if ( GetUnitCurrentOrder(caster) != String2OrderIdBJ(udg_Kraken_Order) ) then
call KrakenStop(caster)
endif
set l = GetUnitLoc(GetEnumUnit())
set g = GetUnitsInRangeOfLocMatching(udg_Kraken_AOE, l, Condition(function Trig_Kraken_Attack_TargetCondition))
set spell_success = false
loop
set target = GroupPickRandomUnit(g)
exitwhen target == null
set spell_success = CastSpellOnUnitAtUnitPos(GetEnumUnit(), udg_Kraken_DummyCheckAbility, udg_Kraken_DummyCheckOrder, 1, target)
if spell_success then
call CastSpellOnUnitAtUnitPos(GetEnumUnit(), udg_Kraken_DummyAbility, udg_Kraken_DummyOrder, 1, target)
set target_timer = CreateTimer()
call StartTimerBJ( target_timer, false, udg_Kraken_ProtectionDuration )
call TriggerRegisterTimerExpireEventBJ( gg_trg_Kraken_Protection_Timer, target_timer )
call SaveTimerHandleBJ(target_timer, udg_Skill_Kraken_IndexTimer, GetHandleIdBJ(target), udg_SkillHT)
call SaveUnitHandleBJ(target, udg_Skill_Kraken_IndexTimerTarget, GetHandleIdBJ(target_timer), udg_SkillHT)
call GroupClear(g)
endif
call GroupRemoveUnit(g, target)
endloop
call SetUnitAnimation(GetEnumUnit(), "attack" )
call QueueUnitAnimationBJ(GetEnumUnit(), "stand" )
if not spell_success then
set miss_angle = GetRandomReal(0, 360)
set miss_distance = GetRandomReal(150, udg_Kraken_AOE - 25)
set miss_tentacle_loc = PolarProjectionBJ(l, miss_distance, miss_angle)
set miss_tentacle_effect = AddSpecialEffectLocBJ( miss_tentacle_loc, udg_Kraken_TentaclePath )
call DestroyEffect(miss_tentacle_effect)
call RemoveLocation(miss_tentacle_loc)
endif
call DestroyGroup(g)
call RemoveLocation(l)
set g = null
set l = null
set miss_tentacle_loc = null
set miss_tentacle_effect = null
set caster = null
set current_kraken = null
set target = null
set target_timer = null
endfunction
function Trig_Kraken_Attack_Actions takes nothing returns nothing
if CountUnitsInGroup(udg_Kraken_KrakenGroup) == 0 then
call DisableTrigger(GetTriggeringTrigger())
return
endif
call ForGroupBJ( udg_Kraken_KrakenGroup, function Trig_Kraken_Attack_Single )
endfunction
//===========================================================================
function InitTrig_Kraken_Attack takes nothing returns nothing
set gg_trg_Kraken_Attack = CreateTrigger( )
call DisableTrigger( gg_trg_Kraken_Attack )
call TriggerRegisterTimerEventPeriodic( gg_trg_Kraken_Attack, 0.5 )
call TriggerAddAction( gg_trg_Kraken_Attack, function Trig_Kraken_Attack_Actions )
endfunction
function Trig_Kraken_Protection_Timer_Actions takes nothing returns nothing
local unit target
set target = LoadUnitHandleBJ(udg_Skill_Kraken_IndexTimerTarget, GetHandleIdBJ(GetExpiredTimer()), udg_SkillHT)
if target != null then
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(target), udg_Skill_Kraken_IndexTimer)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(GetExpiredTimer()), udg_SkillHT)
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
set target = null
endfunction
//===========================================================================
function InitTrig_Kraken_Protection_Timer takes nothing returns nothing
set gg_trg_Kraken_Protection_Timer = CreateTrigger( )
call TriggerAddAction( gg_trg_Kraken_Protection_Timer, function Trig_Kraken_Protection_Timer_Actions )
endfunction
function PreyTrapRemoveWard takes unit ward returns nothing
local trigger t
set t = LoadTriggerHandleBJ(udg_Skill_PT_IndexTrigger, GetHandleIdBJ(ward), udg_SkillHT)
if t != null then
call DestroyTrigger(t)
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_SkillHT)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(ward), udg_SkillHT)
call RemoveUnit(ward)
set t = null
endfunction
function PreyTrapEntering_Actions takes nothing returns nothing
local unit ward
local boolean match
local boolean cast_success
// call BJDebugMsg(GetUnitName(GetTriggerUnit()) + " is within range")
set ward = LoadUnitHandleBJ(udg_Skill_PT_IndexWard, GetHandleIdBJ(GetTriggeringTrigger()), udg_SkillHT)
set match = not(IsUnitAlly(ward, GetOwningPlayer(GetTriggerUnit())))
set match = not(IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE))
set match = match and not(IsUnitType(GetTriggerUnit(), UNIT_TYPE_FLYING))
set match = match and not(IsUnitType(GetTriggerUnit(), UNIT_TYPE_RESISTANT))
if match then
set cast_success = CastSpellOnUnit(ward, udg_PreyTrap_DummyAbility, udg_PreyTrap_DummyOrder, 1, GetTriggerUnit())
if (cast_success) then
call PreyTrapRemoveWard(ward)
endif
endif
set ward = null
endfunction
function PreyTrapCreateEnteringEventTrigger takes unit ward returns nothing
local trigger t = CreateTrigger()
call TriggerAddAction( t, function PreyTrapEntering_Actions )
call TriggerRegisterUnitInRangeSimple( t, udg_PreyTrap_AOE, ward )
call SaveUnitHandleBJ(ward, udg_Skill_PT_IndexWard, GetHandleIdBJ(t), udg_SkillHT)
call SaveTriggerHandleBJ(t, udg_Skill_PT_IndexTrigger, GetHandleIdBJ(ward), udg_SkillHT)
endfunction
function Trig_PreyTrap_Death_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == udg_PreyTrap_Ward
endfunction
function Trig_PreyTrap_Death_Actions takes nothing returns nothing
call PreyTrapRemoveWard(GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_PreyTrap_Death takes nothing returns nothing
set gg_trg_PreyTrap_Death = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PreyTrap_Death, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_PreyTrap_Death, Condition( function Trig_PreyTrap_Death_Conditions ) )
call TriggerAddAction( gg_trg_PreyTrap_Death, function Trig_PreyTrap_Death_Actions )
endfunction
function Trig_PreyTrap_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_PreyTrap_Ability or GetSpellAbilityId() == udg_PreyTrap_AbilityEviscerate
endfunction
function Trig_PreyTrap_Cast_Actions takes nothing returns nothing
local location l
local location l2
local real time_offset
local integer missile_speed
local unit ward
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetSpellTargetLoc()
set missile_speed = BlzGetAbilityIntegerField(BlzGetUnitAbility(GetTriggerUnit(), GetSpellAbilityId()), ABILITY_IF_MISSILE_SPEED)
set time_offset = 0.1 + DistanceBetweenPoints(l, l2) / R2I(missile_speed)
call PolledWait(time_offset)
set ward = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_PreyTrap_Ward, l2, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( udg_PreyTrap_Duration, 'BTLF', ward )
call SetUnitAnimation( ward, "birth" )
call QueueUnitAnimationBJ( ward, "stand" )
call PreyTrapCreateEnteringEventTrigger(ward)
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
set ward = null
endfunction
//===========================================================================
function InitTrig_PreyTrap_Cast takes nothing returns nothing
set gg_trg_PreyTrap_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_PreyTrap_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_PreyTrap_Cast, Condition( function Trig_PreyTrap_Cast_Conditions ) )
call TriggerAddAction( gg_trg_PreyTrap_Cast, function Trig_PreyTrap_Cast_Actions )
endfunction
function ParasiteOnDamageTaken takes nothing returns nothing
local real life_cap
local real offset
local real previous_max_life
local real current_max_life
local real previous_life_ratio
if not (UnitHasBuffBJ(GetTriggerUnit(), udg_Parasite_Buff)) then
call FlushChildHashtableBJ(GetHandleIdBJ(GetTriggerUnit()), udg_ParasiteHT )
call DestroyTrigger(GetTriggeringTrigger())
return
endif
// if the increase in life is due to items or aura and not regeneration or heal, we have to maintain the ratio
set life_cap = LoadRealBJ(udg_ParasiteHT_LifeCapIndex, GetHandleIdBJ(GetTriggerUnit()), udg_ParasiteHT )
set previous_max_life = LoadRealBJ(udg_ParasiteHT_MaxLifeIndex, GetHandleIdBJ(GetTriggerUnit()), udg_ParasiteHT )
set current_max_life = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit())
if previous_max_life != 0 and previous_max_life != current_max_life then
set previous_life_ratio = life_cap / previous_max_life
set life_cap = Ceil(previous_life_ratio * current_max_life)
// call BJDebugMsg("previous_life_ratio was at " + R2S(previous_life_ratio) + ". We maintain it with new_life_cap of " + R2S(life_cap))
call SaveRealBJ(life_cap, udg_ParasiteHT_LifeCapIndex, GetHandleIdBJ(GetTriggerUnit()), udg_ParasiteHT )
call SetUnitLifeBJ( GetTriggerUnit(), previous_life_ratio * current_max_life - 1 )
call TriggerExecute( gg_trg_Parasite_Reset_Life_Cap )
return
endif
set offset = GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) - life_cap
if offset <= udg_Parasite_RegenOff then
call SetUnitLifeBJ( GetTriggerUnit(), life_cap )
else
call SetUnitLifeBJ( GetTriggerUnit(), life_cap + (offset - udg_Parasite_RegenOff) * udg_Parasite_SpellEffect )
call TriggerExecute( gg_trg_Parasite_Reset_Life_Cap )
// Why not CreateRegenerationDetectionTrigger. Because it's declared below it
endif
endfunction
function CreateRegenerationDetectionTrigger takes unit u, real new_life_cap returns nothing
local real current_life_cap
local trigger old_t
local trigger t
call SaveRealBJ(GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u), udg_ParasiteHT_MaxLifeIndex, GetHandleIdBJ(u), udg_ParasiteHT )
set new_life_cap = Ceil(new_life_cap)
set current_life_cap = LoadRealBJ(udg_ParasiteHT_LifeCapIndex, GetHandleIdBJ(u), udg_ParasiteHT )
if new_life_cap == current_life_cap then
return
endif
set old_t = LoadTriggerHandleBJ(udg_ParasiteHT_TriggerIndex, GetHandleIdBJ(u), udg_ParasiteHT)
if not (old_t == null) then
call DestroyTrigger(old_t)
call RemoveSavedHandle( udg_ParasiteHT, GetHandleIdBJ(u), udg_ParasiteHT_TriggerIndex)
endif
call SaveRealBJ(new_life_cap, udg_ParasiteHT_LifeCapIndex, GetHandleIdBJ(u), udg_ParasiteHT )
// call BJDebugMsg("new life cap of: " + R2S(new_life_cap))
set t = CreateTrigger()
// call TriggerRegisterUnitLifeEvent( t, u, GREATER_THAN, new_life_cap+0.5 )
call TriggerRegisterUnitLifeEvent( t, u, GREATER_THAN, new_life_cap )
call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DEATH )
call TriggerAddAction( t, function ParasiteOnDamageTaken )
call SaveTriggerHandleBJ(t, 1, GetHandleIdBJ(u), udg_ParasiteHT)
set old_t = null
set t = null
endfunction
function Trig_Parasite_Item_Drop_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_Parasite_Buff)
endfunction
function Trig_Parasite_Item_Drop_Actions takes nothing returns nothing
local real current_max_life
local real new_max_life
set current_max_life = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit())
call TriggerSleepAction( 0.01 )
set new_max_life = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit())
if new_max_life == current_max_life then
return
endif
// call DisplayTextToForce( GetPlayersAll(), "Resetting life cap" )
call CreateRegenerationDetectionTrigger(GetTriggerUnit(), GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()))
endfunction
//===========================================================================
function InitTrig_Parasite_Item_Drop takes nothing returns nothing
set gg_trg_Parasite_Item_Drop = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Parasite_Item_Drop, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddCondition( gg_trg_Parasite_Item_Drop, Condition( function Trig_Parasite_Item_Drop_Conditions ) )
call TriggerAddAction( gg_trg_Parasite_Item_Drop, function Trig_Parasite_Item_Drop_Actions )
endfunction
function Trig_Parasite_Reset_Life_Cap_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_Parasite_Buff) and GetEventDamage() > 0.00 and GetEventDamage() < GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit())
endfunction
function Trig_Parasite_Reset_Life_Cap_Actions takes nothing returns nothing
call CreateRegenerationDetectionTrigger(GetTriggerUnit(), GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit()) - GetEventDamage())
endfunction
//===========================================================================
function InitTrig_Parasite_Reset_Life_Cap takes nothing returns nothing
set gg_trg_Parasite_Reset_Life_Cap = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Parasite_Reset_Life_Cap, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Parasite_Reset_Life_Cap, Condition( function Trig_Parasite_Reset_Life_Cap_Conditions ) )
call TriggerAddAction( gg_trg_Parasite_Reset_Life_Cap, function Trig_Parasite_Reset_Life_Cap_Actions )
endfunction
function Trig_Parasite_SpellSteal_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'Asps'
endfunction
function Trig_Parasite_SpellSteal_Actions takes nothing returns nothing
local location l
local group g
local unit u
set l = GetUnitLoc(GetTriggerUnit())
call TriggerSleepAction( 0.50 )
set g = GetUnitsInRangeOfLocAll(800.00, l)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if UnitHasBuffBJ(u, udg_Parasite_Buff) then
call CreateRegenerationDetectionTrigger(u, GetUnitStateSwap(UNIT_STATE_LIFE, u))
endif
call GroupRemoveUnit(g, u)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set l = null
set g = null
set u = null
endfunction
//===========================================================================
function InitTrig_Parasite_SpellSteal takes nothing returns nothing
set gg_trg_Parasite_SpellSteal = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Parasite_SpellSteal, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Parasite_SpellSteal, Condition( function Trig_Parasite_SpellSteal_Conditions ) )
call TriggerAddAction( gg_trg_Parasite_SpellSteal, function Trig_Parasite_SpellSteal_Actions )
endfunction
function ParasiteStart takes unit caster, unit u returns nothing
local unit damager
local location l
local location l2
local location l3
set l = GetUnitLoc(caster)
set l2 = GetUnitLoc(u)
set l3 = PolarProjectionBJ(l, 100000, AngleBetweenPoints(l2, l))
set damager = CreateUnitAtLoc(GetOwningPlayer(caster), udg_Parasite_Dummy, l3, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 1.5, 'BTLF', damager )
call SaveUnitHandleBJ(u, udg_Skill_Parasite_IndexTarget, GetHandleIdBJ(damager), udg_SkillHT)
call IssueTargetOrderBJ( damager, "attack", u )
call RemoveLocation(l)
call RemoveLocation(l2)
call RemoveLocation(l3)
set l = null
set l2 = null
set l3 = null
set damager = null
endfunction
function ParasiteRefreshHealthRegenerationEffect takes unit u returns nothing
if IsUnitType(u, UNIT_TYPE_HERO) then
call BlzSetUnitRealFieldBJ( u, UNIT_RF_HIT_POINTS_REGENERATION_RATE, 0.00 - GetHeroStatBJ(bj_HEROSTAT_STR, u, true)*0.050 )
else
call BlzSetUnitRealFieldBJ( u, UNIT_RF_HIT_POINTS_REGENERATION_RATE, 0.00 )
endif
endfunction
function ParasiteStopEffect takes unit u returns nothing
call BlzSetUnitRealFieldBJ( u, UNIT_RF_HIT_POINTS_REGENERATION_RATE, LoadRealBJ(udg_Dict_EA_IndexHealthRege, GetUnitTypeId(u), udg_DictHT) )
call UnitRemoveBuffBJ( udg_Parasite_Dummy, u )
call UnitRemoveBuffBJ( udg_Parasite_DummyBuff, u )
call GroupRemoveUnitSimple( u, udg_Parasite_TargetGroup )
endfunction
function Trig_Parasite_v2_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_Parasite_Ability
endfunction
function Trig_Parasite_v2_Cast_Actions takes nothing returns nothing
call ParasiteStart(GetTriggerUnit(), GetSpellTargetUnit())
endfunction
//===========================================================================
function InitTrig_Parasite_v2_Cast takes nothing returns nothing
set gg_trg_Parasite_v2_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Parasite_v2_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Parasite_v2_Cast, Condition( function Trig_Parasite_v2_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Parasite_v2_Cast, function Trig_Parasite_v2_Cast_Actions )
endfunction
function Trig_Parasite_v2_Start_Effect_Conditions takes nothing returns boolean
return GetUnitTypeId(GetEventDamageSource()) == udg_Parasite_Dummy
endfunction
function Trig_Parasite_v2_Start_Effect_Actions takes nothing returns nothing
if ( GetTriggerUnit() == LoadUnitHandleBJ(udg_Skill_Parasite_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT) ) then
if LoadRealBJ(udg_Dict_EA_IndexHealthRege, GetUnitTypeId(GetTriggerUnit()), udg_DictHT ) == 0 then
call SaveRealBJ(BlzGetUnitRealField( GetTriggerUnit(), UNIT_RF_HIT_POINTS_REGENERATION_RATE), udg_Dict_EA_IndexHealthRege, GetUnitTypeId(GetTriggerUnit()), udg_DictHT )
endif
call GroupAddUnitSimple( GetTriggerUnit(), udg_Parasite_TargetGroup )
call EnableTrigger( gg_trg_Parasite_v2_Refresh )
call ParasiteRefreshHealthRegenerationEffect(GetTriggerUnit())
endif
call KillUnit( GetEventDamageSource() )
endfunction
//===========================================================================
function InitTrig_Parasite_v2_Start_Effect takes nothing returns nothing
set gg_trg_Parasite_v2_Start_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Parasite_v2_Start_Effect, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Parasite_v2_Start_Effect, Condition( function Trig_Parasite_v2_Start_Effect_Conditions ) )
call TriggerAddAction( gg_trg_Parasite_v2_Start_Effect, function Trig_Parasite_v2_Start_Effect_Actions )
endfunction
function TenacityAuraSetLifeBonus takes unit u, real percent_bonus returns nothing
local real current_life_perc
local integer current_life_bonus
local integer new_life_bonus
local real life_without_bonus
set current_life_bonus = LoadIntegerBJ(udg_Skill_TA_IndexLifeAdded, GetHandleIdBJ(u), udg_SkillHT)
// call BJDebugMsg("current bonus:" + I2S(current_life_bonus))
set life_without_bonus = GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u) - current_life_bonus
// call BJDebugMsg("base life:" + R2S(life_without_bonus))
set new_life_bonus = R2I(percent_bonus * life_without_bonus)
// call BJDebugMsg("new_life_bonus:" + I2S(new_life_bonus))
set current_life_perc = GetUnitLifePercent(u)
call BlzSetUnitMaxHP( u, R2I(life_without_bonus) + new_life_bonus )
call SetUnitLifePercentBJ( u, current_life_perc )
call SaveIntegerBJ( new_life_bonus, udg_Skill_TA_IndexLifeAdded, GetHandleIdBJ(u), udg_SkillHT )
// since parasite is based on life variation, we need to recalculate the variables when the unit has tenacity aura
if UnitHasBuffBJ(u, udg_Parasite_Buff) and new_life_bonus != current_life_bonus then
call CreateRegenerationDetectionTrigger(u, GetUnitStateSwap(UNIT_STATE_LIFE, u))
endif
endfunction
function Trig_TA_Learn_Conditions takes nothing returns boolean
return GetLearnedSkillBJ() == udg_TenacityAura_Ability
endfunction
function Trig_TA_Learn_Actions takes nothing returns nothing
call GroupAddUnitSimple(GetTriggerUnit(), udg_TenacityAura_CasterGroup)
call EnableTrigger(gg_trg_TA_Refresh)
endfunction
//===========================================================================
function InitTrig_TA_Learn takes nothing returns nothing
set gg_trg_TA_Learn = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_TA_Learn, EVENT_PLAYER_HERO_SKILL )
call TriggerAddCondition( gg_trg_TA_Learn, Condition( function Trig_TA_Learn_Conditions ) )
call TriggerAddAction( gg_trg_TA_Learn, function Trig_TA_Learn_Actions )
endfunction
function Trig_TA_Refresh_TargetHasBuff takes nothing returns boolean
return UnitHasBuffBJ(GetFilterUnit(), udg_TenacityAura_Buff)
endfunction
function Trig_TA_Refresh_AddLifeToNewTargets takes nothing returns nothing
local unit caster
local integer level
local group g
local unit target
local location l
local integer best_buff
set caster = GetEnumUnit()
set level = GetUnitAbilityLevelSwapped(udg_TenacityAura_Ability, caster)
if level == 0 and UnitHasItemOfTypeBJ(caster, udg_TenacityAura_Item) then
set level = 1
endif
if level == 0 then
call GroupRemoveUnitSimple(caster, udg_TenacityAura_CasterGroup)
return
endif
set l = GetUnitLoc(caster)
set g = GetUnitsInRangeOfLocMatching(900.00, l, Condition(function Trig_TA_Refresh_TargetHasBuff))
loop
set target = FirstOfGroup(g)
exitwhen target == null
if IsPlayerAlly(GetOwningPlayer(caster), GetOwningPlayer(target)) then
set best_buff = LoadIntegerBJ(udg_Skill_TA_IndexBestBuff, GetHandleIdBJ(target), udg_SkillHT )
if best_buff < level then
call TenacityAuraSetLifeBonus(target, 0.05 * I2R(level))
call SaveIntegerBJ( level, udg_Skill_TA_IndexBestBuff, GetHandleIdBJ(target), udg_SkillHT )
call GroupAddUnitSimple(target, udg_TenacityAura_TargetGroup )
endif
endif
call GroupRemoveUnit(g, target)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set caster = null
set g = null
set l = null
set target = null
endfunction
function Trig_TA_Refresh_ManageOldTargets takes nothing returns nothing
if UnitHasBuffBJ(GetEnumUnit(), udg_TenacityAura_Buff) then
call SaveIntegerBJ( 0, udg_Skill_TA_IndexBestBuff, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT )
else
call TenacityAuraSetLifeBonus(GetEnumUnit(), 0)
call GroupRemoveUnitSimple(GetEnumUnit(), udg_TenacityAura_TargetGroup )
endif
endfunction
function Trig_TA_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_TenacityAura_CasterGroup, function Trig_TA_Refresh_AddLifeToNewTargets )
call ForGroupBJ( udg_TenacityAura_TargetGroup, function Trig_TA_Refresh_ManageOldTargets )
if IsUnitGroupEmptyBJ(udg_TenacityAura_CasterGroup) and IsUnitGroupEmptyBJ(udg_TenacityAura_TargetGroup) then
call DisableTrigger(GetTriggeringTrigger())
endif
endfunction
//===========================================================================
function InitTrig_TA_Refresh takes nothing returns nothing
set gg_trg_TA_Refresh = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_TA_Refresh, 0.25 )
call TriggerAddAction( gg_trg_TA_Refresh, function Trig_TA_Refresh_Actions )
call DisableTrigger( gg_trg_TA_Refresh )
endfunction
function Trig_AM_Damage_Split_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetTriggerUnit(), udg_AncestralMeditation_Buff) and GetEventDamage() < udg_AncestralMeditation_Threshold and GetEventDamage() > 0
endfunction
function Trig_AM_Damage_MatchingLeviathans takes nothing returns boolean
local boolean success
set success = GetUnitAbilityLevelSwapped(udg_AncestralMeditation_Aura, GetFilterUnit()) > 0
set success = success and not (IsUnitIllusionBJ(GetFilterUnit()))
set success = success and IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))
set success = success and not IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEventDamageSource()))
set success = success and IsUnitAliveBJ(GetFilterUnit())
set success = success and not (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
set success = success and not (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL))
return success
endfunction
function Trig_AM_Damage_Split_Actions takes nothing returns nothing
local group g
local location l
local location l2
local unit u
local real unit_life
local lightning lt = null
set l = GetUnitLoc(GetTriggerUnit())
set g = GetUnitsInRangeOfLocMatching(udg_AncestralMeditation_Range, l, Condition(function Trig_AM_Damage_MatchingLeviathans))
if IsUnitGroupEmptyBJ(g) then
call UnitRemoveBuffBJ(udg_AncestralMeditation_Buff, GetTriggerUnit())
else
set u = GroupPickRandomUnit(g)
set l2 = GetUnitLoc(u)
set unit_life = GetUnitStateSwap(UNIT_STATE_LIFE, GetTriggerUnit())
if unit_life > 1 then
call SetUnitLifeBJ( GetTriggerUnit(), unit_life - 1) // in order to healing wave to work
endif
call CastSpellOnUnit(u, udg_AncestralMeditation_DummyAb, udg_AncestralMeditation_DummyOrd, 1, GetTriggerUnit())
call SPPlaySound(udg_AncestralMeditation_SoundPath, l2)
call RemoveLocation(l2)
call UnitDamageTargetBJ( GetEventDamageSource(), u, GetEventDamage()/2, BlzGetEventAttackType(), BlzGetEventDamageType() )
call BlzSetEventDamage( GetEventDamage()/2 )
endif
call DestroyGroup(g)
call RemoveLocation(l)
call PolledWait( 0.1 )
if lt != null then
call DestroyLightningBJ( lt )
endif
set g = null
set l = null
set l2 = null
set lt = null
set u = null
endfunction
//===========================================================================
function InitTrig_AM_Damage_Split takes nothing returns nothing
set gg_trg_AM_Damage_Split = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AM_Damage_Split, EVENT_PLAYER_UNIT_DAMAGING )
call TriggerAddCondition( gg_trg_AM_Damage_Split, Condition( function Trig_AM_Damage_Split_Conditions ) )
call TriggerAddAction( gg_trg_AM_Damage_Split, function Trig_AM_Damage_Split_Actions )
endfunction
function Trig_Ingest_Effect_OnUnit takes nothing returns nothing
local unit eater
set eater = LoadUnitHandleBJ(udg_Skill_Ingest_IndexCaster, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT)
if ( IsUnitInTransportBJ(GetEnumUnit(), eater) ) then
call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + ( ( 0.50 * udg_Ingest_LifeRegen ) * GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetEnumUnit()) ) ) )
else
call BlzUnitDisableAbility( eater, udg_AncestralMeditation_Ability, false, false )
call BlzUnitDisableAbility( eater, udg_AncestralMeditation_AbilityOff, true, true )
call GroupRemoveUnitSimple( GetEnumUnit(), udg_Ingest_TargetGroup )
endif
set eater = null
endfunction
function Trig_Ingest_Effect_Actions takes nothing returns nothing
call ForGroupBJ( udg_Ingest_TargetGroup, function Trig_Ingest_Effect_OnUnit )
if ( CountUnitsInGroup(udg_Ingest_TargetGroup) == 0 ) then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_Ingest_Effect takes nothing returns nothing
set gg_trg_Ingest_Effect = CreateTrigger( )
call DisableTrigger( gg_trg_Ingest_Effect )
call TriggerRegisterTimerEventPeriodic( gg_trg_Ingest_Effect, 0.50 )
call TriggerAddAction( gg_trg_Ingest_Effect, function Trig_Ingest_Effect_Actions )
endfunction
function SpiritWithin_GetBuffIndex takes unit u returns integer
local integer i
set i = 0
loop
exitwhen i >= udg_SW_MaxPlayerNumberWithNeutral
if UnitHasBuffBJ(u, udg_SW_EnemyBuffs[i]) then
return i
endif
set i = i + 1
endloop
return -1
endfunction
function SpiritWithin_RemoveWard takes unit ward_target returns nothing
local unit ward
local integer i
set i = 0
loop
exitwhen i >= udg_SW_MaxPlayerNumberWithNeutral
call UnitRemoveBuffBJ(udg_SW_EnemyBuffs[i], ward_target)
set i = i + 1
endloop
set ward = LoadUnitHandleBJ(udg_Skill_SW_IndexWard, GetHandleIdBJ(ward_target), udg_SkillHT )
if ward != null then
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(ward_target), udg_Skill_SW_IndexWard)
call RemoveUnit(ward)
endif
call GroupRemoveUnitSimple( ward_target, udg_SW_TargetGroup )
set ward = null
endfunction
function SpiritWithin_CreateWard takes player caster_player, unit target returns nothing
local unit ward
local location l
call SpiritWithin_RemoveWard(target)
// call BJDebugMsg("creating ward for player " + GetPlayerName(caster_player) + " on unit " + GetUnitName(target))
set l = GetUnitLoc(target)
set ward = CreateUnitAtLoc(caster_player, udg_SW_DummyWard, l, bj_UNIT_FACING)
call UnitAddAbilityBJ( udg_SW_DetectionAbility, ward )
call SaveUnitHandleBJ( ward, udg_Skill_SW_IndexWard, GetHandleIdBJ(target), udg_SkillHT )
call GroupAddUnitSimple( target, udg_SW_TargetGroup )
call EnableTrigger( gg_trg_Spirit_Within_Refresh )
call RemoveLocation(l)
set l = null
set ward = null
endfunction
function SpiritWithin_CastOnEnemies takes unit caster, unit target returns nothing
local integer level
set level = GetConvertedPlayerId(GetOwningPlayer(target)) // starts at 1
if level > udg_SW_MaxPlayerNumber then
set level = udg_SW_MaxPlayerNumberWithNeutral
// call BJDebugMsg("Casting on Neutral")
endif
// call BJDebugMsg("Casting on Player " + I2S(level))
call CastSpellOnUnit(caster, udg_SW_DummyEnemyAbility, udg_SW_DummyEnemyOrder, level, target)
endfunction
function SpiritWithin_CastOnAllies takes unit target returns nothing
call CastSpellOnUnit(target, udg_SW_DummyAllyAbility, udg_SW_DummyAllyOrder, 1, target)
endfunction
function Trig_Spirit_Within_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_SW_Ability or GetSpellAbilityId() == udg_SW_AbilityEviscerate or GetSpellAbilityId() == udg_SW_AbilityItem
endfunction
function Trig_Spirit_Within_Cast_Actions takes nothing returns nothing
call SPv2PlaySoundOnUnit(udg_SW_SoundPath, GetSpellTargetUnit())
if (IsUnitAlly(GetSpellTargetUnit(), GetOwningPlayer(GetTriggerUnit())) and GetOwningPlayer(GetSpellTargetUnit()) != Player(PLAYER_NEUTRAL_PASSIVE)) then
call SpiritWithin_CastOnAllies(GetSpellTargetUnit())
else
call SpiritWithin_CastOnEnemies(GetTriggerUnit(), GetSpellTargetUnit())
endif
endfunction
//===========================================================================
function InitTrig_Spirit_Within_Cast takes nothing returns nothing
set gg_trg_Spirit_Within_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spirit_Within_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spirit_Within_Cast, Condition( function Trig_Spirit_Within_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Spirit_Within_Cast, function Trig_Spirit_Within_Cast_Actions )
endfunction
function Trig_Spirit_Within_Dummy_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_SW_DummyEnemyAbility or GetSpellAbilityId() == udg_SW_DummyAllyAbility
endfunction
function Trig_Spirit_Within_Dummy_Cast_Actions takes nothing returns nothing
call SpiritWithin_CreateWard(GetOwningPlayer(GetTriggerUnit()), GetSpellTargetUnit())
endfunction
//===========================================================================
function InitTrig_Spirit_Within_Dummy_Cast takes nothing returns nothing
set gg_trg_Spirit_Within_Dummy_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spirit_Within_Dummy_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spirit_Within_Dummy_Cast, Condition( function Trig_Spirit_Within_Dummy_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Spirit_Within_Dummy_Cast, function Trig_Spirit_Within_Dummy_Cast_Actions )
endfunction
function Trig_Spirit_RepositionWard takes unit u returns nothing
local unit ward
set ward = LoadUnitHandleBJ(udg_Skill_SW_IndexWard, GetHandleIdBJ(u), udg_SkillHT )
call SetUnitX( ward, GetUnitX(u) )
call SetUnitY( ward, GetUnitY(u) )
set ward = null
endfunction
function Trig_Spirit_Within_Refresh_Unit takes nothing returns nothing
local integer i
if UnitHasBuffBJ(GetEnumUnit(), udg_SW_AllyBuff) then
call Trig_Spirit_RepositionWard(GetEnumUnit())
return
endif
set i = 0
loop
exitwhen i >= udg_SW_MaxPlayerNumberWithNeutral // With neutral
if UnitHasBuffBJ(GetEnumUnit(), udg_SW_EnemyBuffs[i]) then
call Trig_Spirit_RepositionWard(GetEnumUnit())
return
endif
set i = i + 1
endloop
call SpiritWithin_RemoveWard(GetEnumUnit())
endfunction
function Trig_Spirit_Within_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_SW_TargetGroup, function Trig_Spirit_Within_Refresh_Unit )
if CountUnitsInGroup(udg_SW_TargetGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_Spirit_Within_Refresh takes nothing returns nothing
set gg_trg_Spirit_Within_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_Spirit_Within_Refresh )
call TriggerRegisterTimerEventPeriodic( gg_trg_Spirit_Within_Refresh, 0.50 )
call TriggerAddAction( gg_trg_Spirit_Within_Refresh, function Trig_Spirit_Within_Refresh_Actions )
endfunction
function Trig_Spirit_Within_SpellSteal_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'Asps'
endfunction
function Trig_Spirit_Within_SpellSteal_Actions takes nothing returns nothing
local location l
local group g
local unit u
local unit dummy
local integer player_index
set l = GetUnitLoc(GetTriggerUnit())
call TriggerSleepAction( 0.50 )
set g = GetUnitsInRangeOfLocAll(800.00, l)
loop
set u = FirstOfGroup(g)
exitwhen u == null
set player_index = SpiritWithin_GetBuffIndex(u) // starts from 0
if player_index != -1 then
if player_index > udg_SW_MaxPlayerNumberWithNeutral then
set player_index = udg_SW_MaxPlayerNumber // = udg_SW_MaxPlayerNumberWithNeutral - 1
endif
call BJDebugMsg("New spell steal target detected on enemy buff!")
call BJDebugMsg(GetUnitName(u) + ": " + I2S(player_index))
set dummy = CreateUnitAtLoc(Player(player_index), udg_Skill_DummyCaster, l, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', dummy )
call SpiritWithin_CastOnEnemies(dummy, u)
return
endif
if UnitHasBuffBJ(u, udg_SW_AllyBuff) then
call BJDebugMsg("New spell steal target detected on allied buff!")
call SpiritWithin_CastOnAllies(u)
return
endif
call GroupRemoveUnit(g, u)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set l = null
set g = null
set u = null
endfunction
//===========================================================================
function InitTrig_Spirit_Within_SpellSteal takes nothing returns nothing
set gg_trg_Spirit_Within_SpellSteal = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spirit_Within_SpellSteal, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spirit_Within_SpellSteal, Condition( function Trig_Spirit_Within_SpellSteal_Conditions ) )
call TriggerAddAction( gg_trg_Spirit_Within_SpellSteal, function Trig_Spirit_Within_SpellSteal_Actions )
endfunction
function DOTALStopDance takes unit u returns nothing
local location center
local trigger t
local effect e
local unit spirit1
local unit spirit2
local unit sound_dummy
call GroupRemoveUnitSimple(u, udg_DOTAL_CasterGroup )
set center = LoadLocationHandleBJ(udg_DOTAL_IndexCenter, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if center != null then
call RemoveLocation(center)
endif
set spirit1 = LoadUnitHandleBJ(udg_DOTAL_IndexSpirit1, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
set e = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(spirit1), udg_DanceOfTheAfterLifeHT)
if e != null then
call BlzSetSpecialEffectScale( e, 0 )
call DestroyEffect(e)
endif
set t = LoadTriggerHandleBJ(udg_DOTAL_IndexTrigger, GetHandleIdBJ(spirit1), udg_DanceOfTheAfterLifeHT)
if t != null then
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_DanceOfTheAfterLifeHT)
call DestroyTrigger(t)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(spirit1), udg_DanceOfTheAfterLifeHT)
call KillUnit(spirit1)
set spirit2 = LoadUnitHandleBJ(udg_DOTAL_IndexSpirit2, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
set e = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(spirit2), udg_DanceOfTheAfterLifeHT)
if e != null then
call BlzSetSpecialEffectScale( e, 0 )
call DestroyEffect(e)
endif
set t = LoadTriggerHandleBJ(udg_DOTAL_IndexTrigger, GetHandleIdBJ(spirit2), udg_DanceOfTheAfterLifeHT)
if t != null then
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_DanceOfTheAfterLifeHT)
call DestroyTrigger(t)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(spirit2), udg_DanceOfTheAfterLifeHT)
call KillUnit(spirit2)
set sound_dummy = LoadUnitHandleBJ(udg_DOTAL_IndexSoundDummy, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if sound_dummy != null then
call RemoveUnit(sound_dummy)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
set center = null
set t = null
set e = null
set sound_dummy = null
set spirit1 = null
set spirit2 = null
endfunction
function DOTALHealAlly takes unit caster, unit u returns nothing
local integer total_charges
local effect target_effect
local effect caster_effect
local integer life_index
local integer mana_index
local real mana_healed
local real life_healed
local animtype new_anim
// Checking if at least one charge
set total_charges = LoadIntegerBJ(udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == 0 then
return
endif
// Getting mana and life data
if total_charges == 3 then
set life_index = udg_DOTAL_IndexTarget3Life
set mana_index = udg_DOTAL_IndexTarget3Mana
set new_anim = ANIM_TYPE_SLEEP
else
if total_charges == 2 then
set life_index = udg_DOTAL_IndexTarget2Life
set mana_index = udg_DOTAL_IndexTarget2Mana
set new_anim = ANIM_TYPE_PORTRAIT
else
set life_index = udg_DOTAL_IndexTarget1Life
set mana_index = udg_DOTAL_IndexTarget1Mana
set new_anim = ANIM_TYPE_STAND
endif
endif
// Healing target
set life_healed = LoadRealBJ(life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set mana_healed = LoadRealBJ(mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
// we dont use a charge if health and mana are full
if GetUnitStateSwap(UNIT_STATE_LIFE, u) == GetUnitStateSwap(UNIT_STATE_MAX_LIFE, u) and (GetUnitStateSwap(UNIT_STATE_MANA, u) == GetUnitStateSwap(UNIT_STATE_MAX_MANA, u) or mana_healed == 0) then
set new_anim = null
return
endif
call SetUnitLifeBJ( u, GetUnitStateSwap(UNIT_STATE_LIFE, u) + life_healed )
call SetUnitManaBJ( u, GetUnitStateSwap(UNIT_STATE_MANA, u) + mana_healed )
set caster_effect = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call BlzPlaySpecialEffect( caster_effect, new_anim )
// Displayer target effect
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyVisual )
call DestroyEffect(target_effect)
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyLifeVisual )
call DestroyEffect(target_effect)
if mana_healed > 0 and GetUnitStateSwap(UNIT_STATE_MAX_MANA, u) > 0 then
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyManaVisual )
call DestroyEffect(target_effect)
endif
// Removing a charge
call SaveRealBJ(0, life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(0, mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveIntegerBJ(total_charges - 1, udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set target_effect = null
set caster_effect = null
set new_anim = null
endfunction
function DOTALInflictDamageToEnnemy takes unit caster, unit u returns nothing
local real life_before
local real life_after
local real mana_before
local real mana_after
local integer total_charges
local effect caster_effect
local effect target_effect
local integer life_index
local integer mana_index
// Checking if max charges reached
set total_charges = LoadIntegerBJ(udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == udg_DOTAL_MaxCharges then
return
endif
// Inflicting damage
set life_before = GetUnitStateSwap(UNIT_STATE_LIFE, u)
call UnitDamageTargetBJ( caster, u, udg_DOTAL_ImpactDamage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
set life_after = GetUnitStateSwap(UNIT_STATE_LIFE, u)
// Checking if immune or not
if life_after == life_before then
return
endif
// Displayer target effect
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathEnnemyVisual )
call DestroyEffect(target_effect)
// Stealing Mana
set mana_before = GetUnitStateSwap(UNIT_STATE_MANA, u)
call SetUnitManaBJ( u, mana_before - udg_DOTAL_ImpactMana )
set mana_after = GetUnitStateSwap(UNIT_STATE_MANA, u)
// Saving new target data
set caster_effect = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == 0 then
set life_index = udg_DOTAL_IndexTarget1Life
set mana_index = udg_DOTAL_IndexTarget1Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_PORTRAIT )
else
if total_charges == 1 then
set life_index = udg_DOTAL_IndexTarget2Life
set mana_index = udg_DOTAL_IndexTarget2Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_SLEEP )
else
set life_index = udg_DOTAL_IndexTarget3Life
set mana_index = udg_DOTAL_IndexTarget3Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_WALK )
endif
endif
call SaveRealBJ(life_before - life_after, life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(mana_before - mana_after, mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveIntegerBJ(total_charges + 1, udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set caster_effect = null
set target_effect = null
endfunction
function DOTALCollision takes nothing returns nothing
local unit spirit
// Checking if spirit really exists
set spirit = LoadUnitHandleBJ(udg_DOTAL_IndexCaster, GetHandleIdBJ(GetTriggeringTrigger()), udg_DanceOfTheAfterLifeHT)
if spirit == null then
call FlushChildHashtableBJ( GetHandleIdBJ(GetTriggeringTrigger()), udg_DanceOfTheAfterLifeHT)
call DestroyTrigger(GetTriggeringTrigger())
return
endif
// Checking if target is structure or mechanical
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_MECHANICAL) then
return
endif
// Checking target ownership
if IsUnitAlly(GetTriggerUnit(), GetOwningPlayer(spirit)) then
call DOTALHealAlly(spirit, GetTriggerUnit())
else
call DOTALInflictDamageToEnnemy(spirit, GetTriggerUnit())
endif
set spirit = null
endfunction
function DOTALStartDance takes unit u, location l returns nothing
local trigger t1
local trigger t2
local effect e1
local effect e2
local unit spirit1
local unit spirit2
local unit sound_dummy
call DOTALStopDance(u)
set spirit1 = CreateUnitAtLoc(GetOwningPlayer(u), udg_DOTAL_DummySpirit, l, 90)
call AddUnitAnimationPropertiesBJ( true, "alternate", spirit1 )
set e1 = AddSpecialEffectTargetUnitBJ( "origin", spirit1, udg_DOTAL_PathCasterVisual )
call BlzSetSpecialEffectScale( e1, 0.50 )
set t1 = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( t1, udg_DOTAL_ImpactRange, spirit1 )
call TriggerAddAction( t1, function DOTALCollision )
set spirit2 = CreateUnitAtLoc(GetOwningPlayer(u), udg_DOTAL_DummySpirit, l, -90)
call AddUnitAnimationPropertiesBJ( true, "alternate", spirit2 )
set e2 = AddSpecialEffectTargetUnitBJ( "origin", spirit2, udg_DOTAL_PathCasterVisual )
call BlzSetSpecialEffectScale( e2, 0.50 )
set t2 = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( t2, udg_DOTAL_ImpactRange, spirit2 )
call TriggerAddAction( t2, function DOTALCollision )
set sound_dummy = SPPlayLoopingSound(udg_DOTAL_PathLoopSound, l)
call SaveLocationHandleBJ(l, udg_DOTAL_IndexCenter, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(90, udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(0, udg_DOTAL_IndexRadius, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(sound_dummy, udg_DOTAL_IndexSoundDummy, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(spirit1, udg_DOTAL_IndexSpirit1, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(spirit2, udg_DOTAL_IndexSpirit2, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveEffectHandleBJ(e1, udg_DOTAL_IndexAttachment, GetHandleIdBJ(spirit1), udg_DanceOfTheAfterLifeHT)
call SaveTriggerHandleBJ(t1, udg_DOTAL_IndexTrigger, GetHandleIdBJ(spirit1), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(spirit1, udg_DOTAL_IndexCaster, GetHandleIdBJ(t1), udg_DanceOfTheAfterLifeHT)
call SaveEffectHandleBJ(e2, udg_DOTAL_IndexAttachment, GetHandleIdBJ(spirit2), udg_DanceOfTheAfterLifeHT)
call SaveTriggerHandleBJ(t2, udg_DOTAL_IndexTrigger, GetHandleIdBJ(spirit2), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(spirit2, udg_DOTAL_IndexCaster, GetHandleIdBJ(t2), udg_DanceOfTheAfterLifeHT)
call GroupAddUnitSimple( u, udg_DOTAL_CasterGroup )
call EnableTrigger( gg_trg_DOTAL_v2_Refresh )
set t1 = null
set t2 = null
set e1 = null
set e2 = null
set spirit1 = null
set spirit2 = null
set sound_dummy = null
endfunction
function Trig_DOTAL_v2_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_DOTAL_Ability
endfunction
function Trig_DOTAL_v2_Cast_Actions takes nothing returns nothing
local location l
set l = GetSpellTargetLoc()
// StopDance previously called when the order is initiated
call DOTALStartDance(GetTriggerUnit(), l)
// call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function InitTrig_DOTAL_v2_Cast takes nothing returns nothing
set gg_trg_DOTAL_v2_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_DOTAL_v2_Cast, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_DOTAL_v2_Cast, Condition( function Trig_DOTAL_v2_Cast_Conditions ) )
call TriggerAddAction( gg_trg_DOTAL_v2_Cast, function Trig_DOTAL_v2_Cast_Actions )
endfunction
function Trig_DOTAL_Refresh_Caster takes nothing returns nothing
local location center
local real angle
local real facing_angle
local real radius
local unit spirit1
local unit spirit2
if ( GetUnitCurrentOrder(GetEnumUnit()) == String2OrderIdBJ(udg_DOTAL_Order) ) then
set center = LoadLocationHandleBJ(udg_DOTAL_IndexCenter, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set angle = LoadRealBJ(udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set radius = LoadRealBJ(udg_DOTAL_IndexRadius, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
if radius < udg_DOTAL_Radius then
set radius = radius + 6*udg_DOTAL_Speed
set facing_angle = angle
else
set angle = angle - udg_DOTAL_Speed
set facing_angle = angle - 90
set radius = udg_DOTAL_Radius
endif
set spirit1 = LoadUnitHandleBJ(udg_DOTAL_IndexSpirit1, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
call SetUnitX(spirit1, GetLocationX(center) + radius*CosBJ(angle))
call SetUnitY(spirit1, GetLocationY(center) + radius*SinBJ(angle))
call SetUnitFacingTimed( spirit1, facing_angle, 0 )
set spirit2 = LoadUnitHandleBJ(udg_DOTAL_IndexSpirit2, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
call SetUnitX(spirit2, GetLocationX(center) + radius*CosBJ(angle+180))
call SetUnitY(spirit2, GetLocationY(center) + radius*SinBJ(angle+180))
call SetUnitFacingTimed( spirit2, facing_angle-180, 0 )
call SaveRealBJ(angle, udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(radius, udg_DOTAL_IndexRadius, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
else
call DOTALStopDance(GetEnumUnit())
endif
set center = null
set spirit1 = null
set spirit2 = null
endfunction
function Trig_DOTAL_v2_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_DOTAL_CasterGroup, function Trig_DOTAL_Refresh_Caster )
if CountUnitsInGroup(udg_DOTAL_CasterGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_DOTAL_v2_Refresh takes nothing returns nothing
set gg_trg_DOTAL_v2_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_DOTAL_v2_Refresh )
call TriggerRegisterTimerEventPeriodic( gg_trg_DOTAL_v2_Refresh, 0.01 )
call TriggerAddAction( gg_trg_DOTAL_v2_Refresh, function Trig_DOTAL_v2_Refresh_Actions )
endfunction
function DOTALStopDance takes unit u returns nothing
local location center
local trigger t
local effect e
local unit sound_dummy
call GroupRemoveUnitSimple(u, udg_DOTAL_CasterGroup )
set center = LoadLocationHandleBJ(udg_DOTAL_IndexCenter, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if center != null then
call RemoveLocation(center)
endif
set e = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if e != null then
call BlzSetSpecialEffectScale( e, 0 )
call DestroyEffect(e)
endif
set t = LoadTriggerHandleBJ(udg_DOTAL_IndexTrigger, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if t != null then
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_DanceOfTheAfterLifeHT)
call DestroyTrigger(t)
endif
set sound_dummy = LoadUnitHandleBJ(udg_DOTAL_IndexSoundDummy, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
if sound_dummy != null then
call RemoveUnit(sound_dummy)
endif
call FlushChildHashtableBJ( GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
set center = null
set t = null
set e = null
set sound_dummy = null
endfunction
function DOTALHealAlly takes unit caster, unit u returns nothing
local integer total_charges
local effect target_effect
local effect caster_effect
local integer target_index
local integer life_index
local integer mana_index
local real mana_healed
local real life_healed
// Checking if at least one charge
set total_charges = LoadIntegerBJ(udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == 0 then
// call BJDebugMsg("No charge")
return
endif
// Getting mana and life data
set caster_effect = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == 3 then
set target_index = udg_DOTAL_IndexTarget3
set life_index = udg_DOTAL_IndexTarget3Life
set mana_index = udg_DOTAL_IndexTarget3Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_SLEEP )
else
if total_charges == 2 then
set target_index = udg_DOTAL_IndexTarget2
set life_index = udg_DOTAL_IndexTarget2Life
set mana_index = udg_DOTAL_IndexTarget2Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_PORTRAIT )
else
set target_index = udg_DOTAL_IndexTarget1
set life_index = udg_DOTAL_IndexTarget1Life
set mana_index = udg_DOTAL_IndexTarget1Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_STAND )
endif
endif
// Healing target
set life_healed = LoadRealBJ(life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set mana_healed = LoadRealBJ(mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SetUnitLifeBJ( u, GetUnitStateSwap(UNIT_STATE_LIFE, u) + life_healed )
call SetUnitManaBJ( u, GetUnitStateSwap(UNIT_STATE_MANA, u) + mana_healed )
// call BJDebugMsg(R2S(life_healed) + " life healed, " + R2S(mana_healed) + " mana healed")
// Displayer target effect
// set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, "Abilities\\Spells\\Undead\\UnholyFrenzyAOE\\UnholyFrenzyAOETarget.mdl" )
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyVisual )
// call BlzSetSpecialEffectScale( target_effect, 2.00 )
call DestroyEffect(target_effect)
// call BlzSetSpecialEffectScale( target_effect, 1.00 )
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyLifeVisual )
call DestroyEffect(target_effect)
if mana_healed > 0 and GetUnitStateSwap(UNIT_STATE_MAX_MANA, u) > 0 then
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathAllyManaVisual )
call DestroyEffect(target_effect)
endif
// Removing a charge
call RemoveSavedHandle( udg_DanceOfTheAfterLifeHT, GetHandleIdBJ(caster), target_index)
call SaveRealBJ(0, life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(0, mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveIntegerBJ(total_charges - 1, udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set target_effect = null
set caster_effect = null
endfunction
function DOTALInflictDamageToEnnemy takes unit caster, unit u returns nothing
local real life_before
local real life_after
local real mana_before
local real mana_after
local unit target1
local unit target2
local unit target3
local integer total_charges
local effect caster_effect
local effect target_effect
local integer target_index
local integer life_index
local integer mana_index
// Checking if max charges reached
set total_charges = LoadIntegerBJ(udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == udg_DOTAL_MaxCharges then
// call BJDebugMsg("Max charges reached")
return
endif
// Checking if target already hit
set target1 = LoadUnitHandleBJ(udg_DOTAL_IndexTarget1, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set target2 = LoadUnitHandleBJ(udg_DOTAL_IndexTarget2, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
set target3 = LoadUnitHandleBJ(udg_DOTAL_IndexTarget3, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if target1 == u or target2 == u or target3 == u then
set target1 = null
set target2 = null
set target3 = null
// call BJDebugMsg("Already hit")
return
endif
// Inflicting damage
set life_before = GetUnitStateSwap(UNIT_STATE_LIFE, u)
call UnitDamageTargetBJ( caster, u, udg_DOTAL_ImpactDamage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
set life_after = GetUnitStateSwap(UNIT_STATE_LIFE, u)
// Checking if immune or not
if life_after == life_before then
set target1 = null
set target2 = null
set target3 = null
// call BJDebugMsg("Immune")
return
endif
// Displayer target effect
set target_effect = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathEnnemyVisual )
call DestroyEffect(target_effect)
// Stealing Mana
set mana_before = GetUnitStateSwap(UNIT_STATE_MANA, u)
call SetUnitManaBJ( u, mana_before - udg_DOTAL_ImpactMana )
set mana_after = GetUnitStateSwap(UNIT_STATE_MANA, u)
// Saving new target data
set caster_effect = LoadEffectHandleBJ(udg_DOTAL_IndexAttachment, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
if total_charges == 0 then
set target_index = udg_DOTAL_IndexTarget1
set life_index = udg_DOTAL_IndexTarget1Life
set mana_index = udg_DOTAL_IndexTarget1Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_PORTRAIT )
else
if total_charges == 1 then
set target_index = udg_DOTAL_IndexTarget2
set life_index = udg_DOTAL_IndexTarget2Life
set mana_index = udg_DOTAL_IndexTarget2Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_SLEEP )
else
set target_index = udg_DOTAL_IndexTarget3
set life_index = udg_DOTAL_IndexTarget3Life
set mana_index = udg_DOTAL_IndexTarget3Mana
call BlzPlaySpecialEffect( caster_effect, ANIM_TYPE_WALK )
endif
endif
call SaveUnitHandleBJ(u, target_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(life_before - life_after, life_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(mana_before - mana_after, mana_index, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
call SaveIntegerBJ(total_charges + 1, udg_DOTAL_IndexTotalCharges, GetHandleIdBJ(caster), udg_DanceOfTheAfterLifeHT)
// call BJDebugMsg(R2S(life_before - life_after) + " life stolen, " + R2S(mana_before - mana_after) + " mana stolen")
set target1 = null
set target2 = null
set target3 = null
set caster_effect = null
set target_effect = null
endfunction
function DOTALCollision takes nothing returns nothing
local unit caster
// Checking if caster really exists
set caster = LoadUnitHandleBJ(udg_DOTAL_IndexCaster, GetHandleIdBJ(GetTriggeringTrigger()), udg_DanceOfTheAfterLifeHT)
if caster == null then
call FlushChildHashtableBJ( GetHandleIdBJ(GetTriggeringTrigger()), udg_DanceOfTheAfterLifeHT)
call DestroyTrigger(GetTriggeringTrigger())
return
endif
// Checking if target is structure or mechanical
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) or IsUnitType(GetTriggerUnit(), UNIT_TYPE_MECHANICAL) then
return
endif
// Checking target ownership
if IsUnitAlly(GetTriggerUnit(), GetOwningPlayer(caster)) then
call DOTALHealAlly(caster, GetTriggerUnit())
else
call DOTALInflictDamageToEnnemy(caster, GetTriggerUnit())
endif
set caster = null
endfunction
function DOTALStartDance takes unit u, location l1, location l2 returns nothing
local real phi
local real radius
local location center
local trigger t
local effect e
local unit sound_dummy
call DOTALStopDance(u)
set phi = AngleBetweenPoints(l1, l2)
set radius = RMaxBJ(DistanceBetweenPoints(l1, l2), udg_DOTAL_MinimumRange) / 2
set center = PolarProjectionBJ(l1, radius, phi)
set t = CreateTrigger()
call TriggerRegisterUnitInRangeSimple( t, udg_DOTAL_ImpactRange, u )
call TriggerAddAction( t, function DOTALCollision )
set e = AddSpecialEffectTargetUnitBJ( "origin", u, udg_DOTAL_PathCasterVisual )
call BlzSetSpecialEffectScale( e, 0.50 )
set sound_dummy = SPPlayLoopingSound(udg_DOTAL_PathLoopSound, center)
call SaveLocationHandleBJ(center, udg_DOTAL_IndexCenter, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(phi, udg_DOTAL_IndexPhiAngle, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(180, udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveRealBJ(radius, udg_DOTAL_IndexRadius, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveTriggerHandleBJ(t, udg_DOTAL_IndexTrigger, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveEffectHandleBJ(e, udg_DOTAL_IndexAttachment, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(sound_dummy, udg_DOTAL_IndexSoundDummy, GetHandleIdBJ(u), udg_DanceOfTheAfterLifeHT)
call SaveUnitHandleBJ(u, udg_DOTAL_IndexCaster, GetHandleIdBJ(t), udg_DanceOfTheAfterLifeHT)
call GroupAddUnitSimple( u, udg_DOTAL_CasterGroup )
call EnableTrigger( gg_trg_DOTAL_Refresh )
set center = null
set t = null
set e = null
set sound_dummy = null
endfunction
function Trig_DOTAL_v1_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_DOTAL_Ability
endfunction
function Trig_DOTAL_v1_Cast_Actions takes nothing returns nothing
local location l1
local location l2
set l1 = GetUnitLoc(GetTriggerUnit())
set l2 = GetSpellTargetLoc()
// StopDance previously called when the order is initiated
call DOTALStartDance(GetTriggerUnit(), l1, l2)
call RemoveLocation(l1)
call RemoveLocation(l2)
set l1 = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_DOTAL_v1_Cast takes nothing returns nothing
set gg_trg_DOTAL_v1_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_DOTAL_v1_Cast, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( gg_trg_DOTAL_v1_Cast, Condition( function Trig_DOTAL_v1_Cast_Conditions ) )
call TriggerAddAction( gg_trg_DOTAL_v1_Cast, function Trig_DOTAL_v1_Cast_Actions )
endfunction
function Trig_DOTAL_Refresh_Caster takes nothing returns nothing
local location center
local real theta
local real radius
local real phi
local real a
local real b
local real costheta
local real cosphi
local real sintheta
local real sinphi
if ( GetUnitCurrentOrder(GetEnumUnit()) == String2OrderIdBJ(udg_DOTAL_Order) ) then
set center = LoadLocationHandleBJ(udg_DOTAL_IndexCenter, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set theta = LoadRealBJ(udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set phi = LoadRealBJ(udg_DOTAL_IndexPhiAngle, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set radius = LoadRealBJ(udg_DOTAL_IndexRadius, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
set theta = theta + 50 * ((udg_DOTAL_RefreshInterval * udg_DOTAL_Speed) / radius)
set a = radius
set b = radius/2
set costheta = CosBJ(theta)
set sintheta = SinBJ(theta)
set cosphi = CosBJ(phi)
set sinphi = SinBJ(phi)
call SaveRealBJ(theta, udg_DOTAL_IndexThetaAngle, GetHandleIdBJ(GetEnumUnit()), udg_DanceOfTheAfterLifeHT)
call SetUnitX(GetEnumUnit(), GetLocationX(center) + a*costheta*cosphi - b*sintheta*sinphi)
call SetUnitY(GetEnumUnit(), GetLocationY(center) + a*costheta*sinphi + b*sintheta*cosphi)
//call BlzSetUnitFacingEx( GetEnumUnit(), ( phi + theta + 90.00 ) )
call SetUnitFacingTimed( GetEnumUnit(), phi + theta + 90.00 + 20, 0 )
else
call DOTALStopDance(GetEnumUnit())
endif
set center = null
endfunction
function Trig_DOTAL_v1_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_DOTAL_CasterGroup, function Trig_DOTAL_Refresh_Caster )
if CountUnitsInGroup(udg_DOTAL_CasterGroup) == 0 then
// call BJDebugMsg("No more")
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_DOTAL_v1_Refresh takes nothing returns nothing
set gg_trg_DOTAL_v1_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_DOTAL_v1_Refresh )
call TriggerAddAction( gg_trg_DOTAL_v1_Refresh, function Trig_DOTAL_v1_Refresh_Actions )
endfunction
function Trig_RisingWaters_Release_Actions takes nothing returns nothing
local sound s
local boolean spellon
local location l
local unit target = GetTriggerUnit()
// not necessarily theoretically and since it interferes with Eviscerate, we comment it
// if not (SOHTargetMatchesConditions(udg_SOH_IndexRisingWaters, GetEventDamageSource(), target)) then
// return
// endif
if IsUnitType(target, UNIT_TYPE_STRUCTURE) then // different for buildings
set spellon = CastSpellOnUnit(GetEventDamageSource(), udg_RisingWaters_DummyAbility, udg_RisingWaters_DummyOrder, 1, target)
else
set spellon = true
call UnitAddAbilityBJ(udg_RisingWaters_PenaltyAbility1, target)
call UnitAddAbilityBJ(udg_RisingWaters_PenaltyAbility2, target)
call BlzUnitDisableAbility( target, udg_RisingWaters_PenaltyAbility1, false, true )
call BlzUnitDisableAbility( target, udg_RisingWaters_PenaltyAbility2, false, true )
call GroupAddUnit(udg_RisingWaters_TargetGroup, target)
if IsUnitType(target, UNIT_TYPE_HERO) then
call SaveRealBJ(udg_GlobalTime + udg_RisingWaters_HeroDuration, udg_Skill_RisingWaters_IndexTimer, GetHandleIdBJ(target), udg_SkillHT)
else
call SaveRealBJ(udg_GlobalTime + udg_RisingWaters_Duration, udg_Skill_RisingWaters_IndexTimer, GetHandleIdBJ(target), udg_SkillHT)
endif
call EnableTrigger( gg_trg_RisingWaters_Buff_Refresh )
endif
if IsUnitAliveBJ(target) and spellon then
set l = GetUnitLoc(target)
call SPPlaySound(udg_RisingWaters_SoundPath, l)
call RemoveLocation(l)
endif
set s = null
set target = null
set l = null
endfunction
//===========================================================================
function InitTrig_RisingWaters_Release takes nothing returns nothing
set gg_trg_RisingWaters_Release = CreateTrigger( )
call TriggerAddAction( gg_trg_RisingWaters_Release, function Trig_RisingWaters_Release_Actions )
endfunction
function Trig_RisingWaters_Buff_Refresh_Func001A takes nothing returns nothing
if LoadRealBJ(udg_Skill_RisingWaters_IndexTimer, GetHandleIdBJ(GetEnumUnit()), udg_SkillHT) < udg_GlobalTime then
call UnitRemoveAbilityBJ( udg_RisingWaters_PenaltyAbility1, GetEnumUnit() )
call UnitRemoveAbilityBJ( udg_RisingWaters_PenaltyAbility2, GetEnumUnit() )
call UnitRemoveBuffBJ( udg_RisingWaters_Buff, GetEnumUnit() )
call GroupRemoveUnitSimple( GetEnumUnit(), udg_RisingWaters_TargetGroup )
endif
endfunction
function Trig_RisingWaters_Buff_Refresh_Actions takes nothing returns nothing
call ForGroupBJ( udg_RisingWaters_TargetGroup, function Trig_RisingWaters_Buff_Refresh_Func001A )
if CountUnitsInGroup(udg_RisingWaters_TargetGroup) == 0 then
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_RisingWaters_Buff_Refresh takes nothing returns nothing
set gg_trg_RisingWaters_Buff_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_RisingWaters_Buff_Refresh )
call TriggerRegisterTimerEventPeriodic( gg_trg_RisingWaters_Buff_Refresh, 0.30 )
call TriggerAddAction( gg_trg_RisingWaters_Buff_Refresh, function Trig_RisingWaters_Buff_Refresh_Actions )
endfunction
function Trig_Water_Purge_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_WaterPurge_Ability
endfunction
function Trig_Water_Purge_Cast_Actions takes nothing returns nothing
local effect e
local location l
set l = GetSpellTargetLoc()
set e = AddSpecialEffectLocBJ( l, udg_WaterPurge_EffectPath )
call SPv2PlaySoundAtPoint(udg_WaterPurge_SoundPath, l)
call DestroyEffect(e)
call RemoveLocation(l)
set e = null
set l = null
endfunction
//===========================================================================
function InitTrig_Water_Purge_Cast takes nothing returns nothing
set gg_trg_Water_Purge_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Purge_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Water_Purge_Cast, Condition( function Trig_Water_Purge_Cast_Conditions ) )
call TriggerAddAction( gg_trg_Water_Purge_Cast, function Trig_Water_Purge_Cast_Actions )
endfunction
function Trig_DE_Effect_TargetCondition takes unit source, unit target, boolean forbid_air, boolean forbid_ground returns boolean
local boolean success
set success = GetUnitTypeId(target) != udg_ShadowDagger_DamageDummy
set success = success and not(IsUnitType(target, UNIT_TYPE_STRUCTURE))
set success = success and not(IsUnitAWard(target))
set success = success and not(IsUnitAlly(target, GetOwningPlayer(source)))
if forbid_air then
set success = success and (not(IsUnitType(target, UNIT_TYPE_FLYING)) or IsUnitType(target, UNIT_TYPE_SNARED))
endif
if forbid_ground then
set success = success and IsUnitType(target, UNIT_TYPE_FLYING) and not(IsUnitType(target, UNIT_TYPE_SNARED))
endif
return success
endfunction
function Trig_DE_Effect_Conditions takes nothing returns boolean
return UnitHasBuffBJ(GetEventDamageSource(), udg_DE_Buff) and BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL and Trig_DE_Effect_TargetCondition(GetEventDamageSource(), GetTriggerUnit(), false, false)
endfunction
function Trig_DE_Effect_Actions takes nothing returns nothing
local location l
local effect e
local unit u
local unit enum
local group g
local boolean destroyl = false
local boolean condition_matched = false
local boolean only_air
set u = LoadUnitHandleBJ(udg_Skill_Attack_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
if u == GetTriggerUnit() then
set l = GetUnitLoc(GetTriggerUnit())
set destroyl = true
else
if GetUnitCurrentOrder(GetEventDamageSource()) == String2OrderIdBJ("attackground") then
set l = LoadLocationHandleBJ( udg_Skill_Attack_IndexZone, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT )
else
set u = null
return
endif
endif
call UnitRemoveBuffBJ( udg_DE_Buff, GetEventDamageSource() )
set only_air = IsUnitType(GetTriggerUnit(), UNIT_TYPE_FLYING) and not(IsUnitType(GetTriggerUnit(), UNIT_TYPE_SNARED))
set g = GetUnitsInRangeOfLocAll(udg_DE_ExplosionRange, l)
loop
set enum = FirstOfGroup(g)
exitwhen enum == null
if Trig_DE_Effect_TargetCondition(GetEventDamageSource(), enum, not only_air, only_air) then
call UnitDamageTargetBJ( GetEventDamageSource(), enum, udg_DE_ExplosionDamageRatio * GetEventDamage(), BlzGetEventAttackType(), DAMAGE_TYPE_ENHANCED )
endif
call GroupRemoveUnit(g, enum)
endloop
set e = AddSpecialEffectLocBJ( l, udg_DE_AttachmentModel )
call BlzSetSpecialEffectZ( e, GetUnitFlyHeight(GetTriggerUnit()) )
call DestroyEffect(e)
call DestroyGroup(g)
if destroyl then
call RemoveLocation(l)
endif
set l = null
set e = null
set u = null
set enum = null
set g = null
endfunction
//===========================================================================
function InitTrig_DE_Effect takes nothing returns nothing
set gg_trg_DE_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_DE_Effect, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_DE_Effect, Condition( function Trig_DE_Effect_Conditions ) )
call TriggerAddAction( gg_trg_DE_Effect, function Trig_DE_Effect_Actions )
endfunction
function PetrifyUnit takes unit caster, unit u returns nothing
local effect e
local location l
local integer armor_type // armor type with offset
call CastSpellOnUnit(caster, udg_StoneGaze_DummyAbility, udg_StoneGaze_DummyOrder, 1, u)
call SetUnitVertexColorBJ( u, 75.00, 58.00, 40.00, 0 )
call SetUnitTimeScalePercent( u, 0.00 )
set e = AddSpecialEffectTargetUnitBJ( "chest", u, udg_StoneGaze_EffectPath1 )
set l = GetUnitLoc(u)
call SPv2PlaySoundAtPoint(udg_StoneGaze_SoundPath, l )
call GroupAddUnitSimple(u, udg_StoneGaze_TargetGroup )
set armor_type = LoadIntegerBJ(udg_Skill_SG_IndexArmorType, GetHandleIdBJ(u), udg_SkillHT)
if armor_type == 0 then
set armor_type = BlzGetUnitIntegerField( u, UNIT_IF_DEFENSE_TYPE ) + udg_StoneGaze_ATOffset
call SaveIntegerBJ(armor_type, udg_Skill_SG_IndexArmorType, GetHandleIdBJ(u), udg_SkillHT)
endif
call BlzSetUnitIntegerFieldBJ( u, UNIT_IF_DEFENSE_TYPE, 3 )
call EnableTrigger(gg_trg_Stone_Gaze_Refresh)
call DestroyEffect(e)
call RemoveLocation(l)
set e = null
set l = null
endfunction
function UnpetrifyUnit takes unit u returns nothing
local integer armor_type
set armor_type = LoadIntegerBJ(udg_Skill_SG_IndexArmorType, GetHandleIdBJ(u), udg_SkillHT)
call SetUnitVertexColorBJ( u, 100.00, 100.00, 100.00, 0 )
call SetUnitTimeScalePercent( u, 100.00 )
call UnitRemoveBuffBJ( udg_StoneGaze_Buff, u )
call UnitRemoveBuffBJ( udg_StoneGaze_StunBuff, u )
call BlzSetUnitIntegerFieldBJ( u, UNIT_IF_DEFENSE_TYPE, armor_type - udg_StoneGaze_ATOffset)
call SaveIntegerBJ(0, udg_Skill_SG_IndexArmorType, GetHandleIdBJ(u), udg_SkillHT)
call GroupRemoveUnitSimple(u, udg_StoneGaze_TargetGroup )
endfunction
function ExplodePetrifiedUnit takes unit u returns nothing
local effect e
local location l
set l = GetUnitLoc(u)
set e = AddSpecialEffectLocBJ( l, udg_StoneGaze_DeathEffectPath1 )
call BlzSetSpecialEffectScale( e, 2.00 )
call BlzPlaySpecialEffect( e, ANIM_TYPE_DEATH )
call DestroyEffect(e)
set e = AddSpecialEffectLocBJ( l, udg_StoneGaze_DeathEffectPath2 )
call BlzPlaySpecialEffect( e, ANIM_TYPE_DEATH )
call DestroyEffect(e)
set e = AddSpecialEffectLocBJ( l, udg_StoneGaze_DeathEffectPath3 )
call BlzPlaySpecialEffect( e, ANIM_TYPE_DEATH )
call DestroyEffect(e)
call UnpetrifyUnit(u)
call RemoveUnit(u)
call RemoveLocation(l)
set l = null
set e = null
endfunction
function Trig_Stone_Gaze_Refresh_Actions takes nothing returns nothing
local group target_group = CreateGroup()
local real time_left
local unit target
if ( CountUnitsInGroup(udg_StoneGaze_TargetGroup) == 0 ) then
call DisableTrigger( GetTriggeringTrigger() )
return
endif
call GroupAddGroup( udg_StoneGaze_TargetGroup, target_group ) // copy of udg_StoneGaze_TargetGroup
loop
set target = FirstOfGroup(target_group)
exitwhen target == null
if not (UnitHasBuffBJ(target, udg_StoneGaze_Buff)) then
call UnpetrifyUnit(target)
endif
call GroupRemoveUnit(target_group, target)
endloop
call DestroyGroup(target_group)
set target_group = null
set target = null
endfunction
//===========================================================================
function InitTrig_Stone_Gaze_Refresh takes nothing returns nothing
set gg_trg_Stone_Gaze_Refresh = CreateTrigger( )
call DisableTrigger( gg_trg_Stone_Gaze_Refresh )
call TriggerRegisterTimerEventPeriodic( gg_trg_Stone_Gaze_Refresh, 0.30 )
call TriggerAddAction( gg_trg_Stone_Gaze_Refresh, function Trig_Stone_Gaze_Refresh_Actions )
endfunction
function Trig_Stone_Gaze_SpellSteal_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'Asps'
endfunction
function Trig_Stone_Gaze_SpellSteal_Actions takes nothing returns nothing
local location l
local group g
local unit u
set l = GetUnitLoc(GetTriggerUnit())
call TriggerSleepAction( 0.50 )
set g = GetUnitsInRangeOfLocAll(800.00, l)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if UnitHasBuffBJ(u, udg_StoneGaze_Buff) and not (IsUnitInGroup(u, udg_StoneGaze_TargetGroup)) then
call PetrifyUnit(GetTriggerUnit(), u)
endif
call GroupRemoveUnit(g, u)
endloop
call RemoveLocation(l)
call DestroyGroup(g)
set l = null
set g = null
set u = null
endfunction
//===========================================================================
function InitTrig_Stone_Gaze_SpellSteal takes nothing returns nothing
set gg_trg_Stone_Gaze_SpellSteal = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Stone_Gaze_SpellSteal, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Stone_Gaze_SpellSteal, Condition( function Trig_Stone_Gaze_SpellSteal_Conditions ) )
call TriggerAddAction( gg_trg_Stone_Gaze_SpellSteal, function Trig_Stone_Gaze_SpellSteal_Actions )
endfunction
function Trig_Crushing_Wave_Release_Actions takes nothing returns nothing
local integer level
local location l
// not necessarily theoretically
if not (SOHTargetMatchesConditions(udg_SOH_IndexCrushingWave, GetEventDamageSource(), GetTriggerUnit())) then
return
endif
set level = GetUnitAbilityLevelSwapped(udg_SOH_Abilities[udg_SOH_IndexCrushingWave], GetEventDamageSource())
set l = GetUnitLoc(GetTriggerUnit())
call CastSpellOnPoint(GetEventDamageSource(), udg_CrushingWave_DummyAbility, udg_CrushingWave_DummyOrder, level, l)
call SPv2PlaySoundAtPoint(udg_CrushingWave_SoundPath, l)
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function InitTrig_Crushing_Wave_Release takes nothing returns nothing
set gg_trg_Crushing_Wave_Release = CreateTrigger( )
call TriggerAddAction( gg_trg_Crushing_Wave_Release, function Trig_Crushing_Wave_Release_Actions )
endfunction
function Trig_Naga_Construction_Initialization_Actions takes nothing returns nothing
set udg_NagaConstructionHT = InitHashtableBJ( )
set udg_NagaConstruction_Dummy = 'h006'
set udg_NagaConstruction_DeathPath = "ModelAttachments\\NagaCancelBig.mdx"
set udg_NagaConstruction_EndPathS = "ModelAttachments\\NagaBirthCompleteSmall.mdx"
set udg_NagaConstruction_EndPathM = "ModelAttachments\\NagaBirthCompleteMedium.mdx"
set udg_NagaConstruction_EndPathL = "ModelAttachments\\NagaBirthCompleteLarge.mdx"
set udg_NagaConstruction_DefaultEndDur = 2.5
set udg_NagaConstruction_AllocUnit = 0
set udg_NagaConstruction_IndexDamage = 1
set udg_NagaConstruction_IndexStruct = 2
set udg_NagaConstruction_IndexEndEff = 3
// Dummy Scale
call SaveRealBJ( 85, udg_Dict_NC_AllocScale, 'o002', udg_DictHT )
call SaveRealBJ( 100, udg_Dict_NC_AllocScale, 'o001', udg_DictHT )
call SaveRealBJ( 85, udg_Dict_NC_AllocScale, 'h001', udg_DictHT )
call SaveRealBJ( 100, udg_Dict_NC_AllocScale, 'o000', udg_DictHT )
call SaveRealBJ( 90, udg_Dict_NC_AllocScale, 'h000', udg_DictHT )
call SaveRealBJ( 45, udg_Dict_NC_AllocScale, 'n000', udg_DictHT )
call SaveRealBJ( 65, udg_Dict_NC_AllocScale, 'n004', udg_DictHT )
call SaveRealBJ( 80, udg_Dict_NC_AllocScale, 'n005', udg_DictHT )
call SaveRealBJ( 100, udg_Dict_NC_AllocScale, 'n006', udg_DictHT )
call SaveRealBJ( 130, udg_Dict_NC_AllocScale, 'n002', udg_DictHT )
// Build Time
call SaveIntegerBJ( 70, udg_Dict_NC_IndexBuildTime, 'o002', udg_DictHT )
call SaveIntegerBJ( 60, udg_Dict_NC_IndexBuildTime, 'o001', udg_DictHT )
call SaveIntegerBJ( 60, udg_Dict_NC_IndexBuildTime, 'h001', udg_DictHT )
call SaveIntegerBJ( 70, udg_Dict_NC_IndexBuildTime, 'o000', udg_DictHT )
call SaveIntegerBJ( 60, udg_Dict_NC_IndexBuildTime, 'h000', udg_DictHT )
call SaveIntegerBJ( 35, udg_Dict_NC_IndexBuildTime, 'n000', udg_DictHT )
call SaveIntegerBJ( 50, udg_Dict_NC_IndexBuildTime, 'n004', udg_DictHT )
call SaveIntegerBJ( 70, udg_Dict_NC_IndexBuildTime, 'n005', udg_DictHT )
call SaveIntegerBJ( 60, udg_Dict_NC_IndexBuildTime, 'n006', udg_DictHT )
call SaveIntegerBJ( 180, udg_Dict_NC_IndexBuildTime, 'n002', udg_DictHT )
// Effect Size
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'o002', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'o001', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'h001', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'o000', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'h000', udg_DictHT )
call SaveIntegerBJ( 1, udg_Dict_NC_IndexSize, 'n000', udg_DictHT )
call SaveIntegerBJ( 1, udg_Dict_NC_IndexSize, 'n004', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'n005', udg_DictHT )
call SaveIntegerBJ( 2, udg_Dict_NC_IndexSize, 'n006', udg_DictHT )
call SaveIntegerBJ( 3, udg_Dict_NC_IndexSize, 'n002', udg_DictHT )
call SaveIntegerBJ( 3, udg_Dict_NC_IndexSize, 'h009', udg_DictHT )
call SaveIntegerBJ( 3, udg_Dict_NC_IndexSize, 'h00A', udg_DictHT )
// End Duration
call SaveIntegerBJ( 5, udg_Dict_NC_IndexEndDuration, 'n002', udg_DictHT )
endfunction
//===========================================================================
function InitTrig_Naga_Construction_Initialization takes nothing returns nothing
set gg_trg_Naga_Construction_Initialization = CreateTrigger( )
call TriggerAddAction( gg_trg_Naga_Construction_Initialization, function Trig_Naga_Construction_Initialization_Actions )
endfunction
function Trig_Naga_Construction_Damage_Conditions takes nothing returns boolean
return LoadUnitHandleBJ(udg_NagaConstruction_AllocUnit, GetHandleIdBJ(GetTriggerUnit()), udg_NagaConstructionHT) != null
endfunction
function Trig_Naga_Construction_Damage_Actions takes nothing returns nothing
local real offset
set offset = LoadRealBJ(udg_NagaConstruction_IndexDamage, GetHandleIdBJ(GetTriggerUnit()), udg_NagaConstructionHT )
call SaveRealBJ(offset + GetEventDamage(), udg_NagaConstruction_IndexDamage, GetHandleIdBJ(GetTriggerUnit()), udg_NagaConstructionHT )
endfunction
//===========================================================================
function InitTrig_Naga_Construction_Damage takes nothing returns nothing
set gg_trg_Naga_Construction_Damage = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Construction_Damage, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Naga_Construction_Damage, Condition( function Trig_Naga_Construction_Damage_Conditions ) )
call TriggerAddAction( gg_trg_Naga_Construction_Damage, function Trig_Naga_Construction_Damage_Actions )
endfunction
function Trig_Naga_Construction_Check_Progress_Enum takes nothing returns nothing
local unit u
local real offset
local real progress
local real time_left
local integer build_time
local real end_duration
local integer size
local string end_effect_path
set offset = LoadRealBJ(udg_NagaConstruction_IndexDamage, GetHandleIdBJ(GetEnumUnit()), udg_NagaConstructionHT )
set progress = ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + offset ) / GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetEnumUnit())
set build_time = LoadIntegerBJ( udg_Dict_NC_IndexBuildTime, GetUnitTypeId(GetEnumUnit()), udg_DictHT )
set time_left = (1 - progress) * build_time
set end_duration = LoadIntegerBJ( udg_Dict_NC_IndexEndDuration, GetUnitTypeId(GetEnumUnit()), udg_DictHT )
if end_duration == 0 then
set end_duration = udg_NagaConstruction_DefaultEndDur
endif
set u = LoadUnitHandleBJ(udg_NagaConstruction_AllocUnit, GetHandleIdBJ(GetEnumUnit()), udg_NagaConstructionHT )
if time_left <= 0.7 then
call KillUnit(u)
else
if time_left <= end_duration then
call AddUnitAnimationPropertiesBJ( true, "alternate", u )
call SetUnitTimeScalePercent( u, 70.00 )
if not LoadBooleanBJ(udg_NagaConstruction_IndexEndEff, GetHandleIdBJ(GetEnumUnit()), udg_NagaConstructionHT ) then
set size = LoadIntegerBJ(udg_Dict_NC_IndexSize, GetUnitTypeId(GetEnumUnit()), udg_DictHT )
if size == 1 then
set end_effect_path = udg_NagaConstruction_EndPathS
else
if size == 3 then
set end_effect_path = udg_NagaConstruction_EndPathL
else
set end_effect_path = udg_NagaConstruction_EndPathM
endif
endif
call AddSpecialEffectTargetUnitBJ( "origin", GetEnumUnit(), end_effect_path )
call DestroyEffect(GetLastCreatedEffectBJ())
call SaveBooleanBJ(true, udg_NagaConstruction_IndexEndEff, GetHandleIdBJ(GetEnumUnit()), udg_NagaConstructionHT )
endif
endif
endif
endfunction
function Trig_Naga_Construction_Check_Progress_Actions takes nothing returns nothing
call ForGroupBJ( udg_NagaConstruction_ConstrucGroup, function Trig_Naga_Construction_Check_Progress_Enum )
if IsUnitGroupEmptyBJ(udg_NagaConstruction_ConstrucGroup) then
call DisableTrigger(GetTriggeringTrigger())
endif
endfunction
//===========================================================================
function InitTrig_Naga_Construction_Check_Progress takes nothing returns nothing
set gg_trg_Naga_Construction_Check_Progress = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Naga_Construction_Check_Progress, 0.30 )
call DisableTrigger( gg_trg_Naga_Construction_Check_Progress )
call TriggerAddAction( gg_trg_Naga_Construction_Check_Progress, function Trig_Naga_Construction_Check_Progress_Actions )
endfunction
function Trig_Naga_Construction_Actions takes nothing returns nothing
local real r
local location l
local unit u
set r = LoadRealBJ(udg_Dict_NC_AllocScale, GetUnitTypeId(GetConstructingStructure()), udg_DictHT )
if r == 0.0 then
return
endif
call GroupAddUnitSimple(GetConstructingStructure(), udg_NagaConstruction_ConstrucGroup)
call EnableTrigger(gg_trg_Naga_Construction_Check_Progress)
set l = GetUnitLoc(GetConstructingStructure())
set u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_NagaConstruction_Dummy, l, bj_UNIT_FACING)
call RemoveLocation(l)
call SaveUnitHandleBJ(u, udg_NagaConstruction_AllocUnit, GetHandleIdBJ(GetConstructingStructure()), udg_NagaConstructionHT )
call SetUnitScalePercent(u, r, r, r )
call SetUnitAnimation(u, "birth" )
call QueueUnitAnimationBJ(u, "stand" )
// udg_NagaConstruction_IndexStruct, udg_NagaConstruction_IndexTimer now useless
set l = null
set u = null
endfunction
//===========================================================================
function InitTrig_Naga_Construction takes nothing returns nothing
set gg_trg_Naga_Construction = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Construction, EVENT_PLAYER_UNIT_CONSTRUCT_START )
call TriggerAddAction( gg_trg_Naga_Construction, function Trig_Naga_Construction_Actions )
endfunction
function Trig_Naga_Cancellation_Actions takes nothing returns nothing
local unit u
set u = LoadUnitHandleBJ(udg_NagaConstruction_AllocUnit, GetHandleIdBJ(GetTriggerUnit()), udg_NagaConstructionHT )
if u == null then
return
endif
call RemoveUnit(u)
call GroupRemoveUnitSimple(GetTriggerUnit(), udg_NagaConstruction_ConstrucGroup)
call FlushChildHashtableBJ( GetHandleIdBJ(GetTriggerUnit()), udg_NagaConstructionHT)
set u = null
endfunction
//===========================================================================
function InitTrig_Naga_Cancellation takes nothing returns nothing
set gg_trg_Naga_Cancellation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Cancellation, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Cancellation, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( gg_trg_Naga_Cancellation, function Trig_Naga_Cancellation_Actions )
endfunction
function Trig_Naga_Cancellation_Upgrade_Conditions takes nothing returns boolean
return GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityL, GetTriggerUnit()) >= 1
endfunction
function Trig_Naga_Cancellation_Upgrade_Actions takes nothing returns nothing
local effect e
local location l
set l = GetUnitLoc(GetTriggerUnit())
set e = AddSpecialEffectLocBJ( l, udg_NagaConstruction_DeathPath )
call BlzSetSpecialEffectScale( e, 2.70 )
call DestroyEffectBJ( e )
call RemoveLocation(l)
set e = null
set l = null
endfunction
//===========================================================================
function InitTrig_Naga_Cancellation_Upgrade takes nothing returns nothing
set gg_trg_Naga_Cancellation_Upgrade = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Cancellation_Upgrade, EVENT_PLAYER_UNIT_UPGRADE_CANCEL )
call TriggerAddCondition( gg_trg_Naga_Cancellation_Upgrade, Condition( function Trig_Naga_Cancellation_Upgrade_Conditions ) )
call TriggerAddAction( gg_trg_Naga_Cancellation_Upgrade, function Trig_Naga_Cancellation_Upgrade_Actions )
endfunction
function Trig_Naga_Completed_Actions takes nothing returns nothing
local unit u
set u = LoadUnitHandleBJ(udg_NagaConstruction_AllocUnit, GetHandleIdBJ(GetConstructedStructure()), udg_NagaConstructionHT )
if u == null then
return
endif
call RemoveUnit(u)
call GroupRemoveUnitSimple(GetConstructedStructure(), udg_NagaConstruction_ConstrucGroup)
call FlushChildHashtableBJ( GetHandleIdBJ(GetConstructedStructure()), udg_NagaConstructionHT)
set u = null
endfunction
//===========================================================================
function InitTrig_Naga_Completed takes nothing returns nothing
set gg_trg_Naga_Completed = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Completed, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_Naga_Completed, function Trig_Naga_Completed_Actions )
endfunction
function Trig_Naga_Death_Conditions takes nothing returns boolean
return LoadIntegerBJ(udg_Dict_NC_IndexSize, GetUnitTypeId(GetTriggerUnit()), udg_DictHT) == 3
endfunction
function Trig_Naga_Death_Actions takes nothing returns nothing
local integer i
local effect e
local location l
set l = GetUnitLoc(GetTriggerUnit())
set e = AddSpecialEffectLocBJ( l, udg_NagaConstruction_DeathPath )
call DestroyEffectBJ( e )
call RemoveLocation(l)
set e = null
set l = null
endfunction
//===========================================================================
function InitTrig_Naga_Death takes nothing returns nothing
set gg_trg_Naga_Death = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Naga_Death, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Naga_Death, Condition( function Trig_Naga_Death_Conditions ) )
call TriggerAddAction( gg_trg_Naga_Death, function Trig_Naga_Death_Actions )
endfunction
function Trig_Crocodilian_Brood_Egg_Summon_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_CB_Ability
endfunction
function Trig_Crocodilian_Brood_Egg_Summon_Actions takes nothing returns nothing
local location l
local location l2
local real time_offset
local integer missile_speed
local unit egg
local integer egg_level
local group g
local unit u
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetSpellTargetLoc()
set missile_speed = BlzGetAbilityIntegerField(BlzGetUnitAbility(GetTriggerUnit(), GetSpellAbilityId()), ABILITY_IF_MISSILE_SPEED)
set time_offset = DistanceBetweenPoints(l, l2) / R2I(missile_speed) - 0.1
set egg_level = GetUnitAbilityLevelSwapped(udg_CB_Ability, GetTriggerUnit())
call PolledWait(time_offset)
set egg = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_CB_CrocodileEgg, l2, bj_UNIT_FACING)
call UnitApplyTimedLifeBJ( udg_CB_EggDuration, 'B00X', egg )
call SetUnitAnimation( egg, "birth" )
call QueueUnitAnimationBJ( egg, "stand" )
call BlzSetUnitMaxHP( egg, 100 * egg_level + 200 )
call SetUnitLifePercentBJ( egg, 100 )
call SetUnitAbilityLevelSwapped( udg_CB_CrocodileEggAbility, egg, egg_level )
set g = GetUnitsInRangeOfLocAll(udg_CB_TauntRange, l2)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsPlayerEnemy(GetOwningPlayer(u), GetOwningPlayer(egg)) and GetUnitTypeId(u) != udg_ShadowDagger_DamageDummy then
call UnitWakeUpBJ( u )
call IssueTargetOrderBJ( u, "attack", egg )
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
set g = null
set egg = null
endfunction
//===========================================================================
function InitTrig_Crocodilian_Brood_Egg_Summon takes nothing returns nothing
set gg_trg_Crocodilian_Brood_Egg_Summon = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Crocodilian_Brood_Egg_Summon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Crocodilian_Brood_Egg_Summon, Condition( function Trig_Crocodilian_Brood_Egg_Summon_Conditions ) )
call TriggerAddAction( gg_trg_Crocodilian_Brood_Egg_Summon, function Trig_Crocodilian_Brood_Egg_Summon_Actions )
endfunction
function Trig_Crocodile_Brood_Egg_Death_Conditions takes nothing returns boolean
// return GetUnitTypeId(GetTriggerUnit()) == udg_CB_CrocodileEgg and GetKillingUnitBJ() == null
return GetUnitTypeId(GetTriggerUnit()) == udg_CB_CrocodileEgg
endfunction
function Trig_Crocodile_Brood_Egg_Death_Actions takes nothing returns nothing
local location l
local unit crocodile
local integer egg_level
set l = GetUnitLoc(GetTriggerUnit())
set egg_level = GetUnitAbilityLevelSwapped(udg_CB_CrocodileEggAbility, GetTriggerUnit())
set crocodile = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_CB_Crocodiles[egg_level-1], l, 30)
call UnitApplyTimedLifeBJ( udg_CB_CrocodileDuration, 'BTLF', crocodile )
call SetUnitAnimation( crocodile, "birth" )
call QueueUnitAnimationBJ( crocodile, "stand" )
call SetUnitExplodedBJ( crocodile, true )
call UnitAddTypeBJ( UNIT_TYPE_SUMMONED, crocodile )
set crocodile = CreateUnitAtLoc(GetOwningPlayer(GetTriggerUnit()), udg_CB_Crocodiles[egg_level-1], l, -30)
call UnitApplyTimedLifeBJ( udg_CB_CrocodileDuration, 'BTLF', crocodile )
call SetUnitAnimation( crocodile, "birth" )
call QueueUnitAnimationBJ( crocodile, "stand" )
call SetUnitExplodedBJ( crocodile, true )
call UnitAddTypeBJ( UNIT_TYPE_SUMMONED, crocodile )
call RemoveLocation(l)
set l = null
set crocodile = null
endfunction
//===========================================================================
function InitTrig_Crocodile_Brood_Egg_Death takes nothing returns nothing
set gg_trg_Crocodile_Brood_Egg_Death = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Crocodile_Brood_Egg_Death, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_Crocodile_Brood_Egg_Death, Condition( function Trig_Crocodile_Brood_Egg_Death_Conditions ) )
call TriggerAddAction( gg_trg_Crocodile_Brood_Egg_Death, function Trig_Crocodile_Brood_Egg_Death_Actions )
endfunction
function LaunchTremorOftheDeepImpact takes unit u returns nothing
// local location l
local unit dummy
local timer t
local effect e
local integer level
set level = LoadIntegerBJ(udg_Skill_TOTD_AllocLevel, GetHandleIdBJ(u), udg_SkillHT)
call CastSpellNoTarget(u, udg_TOTD_DummyAbility, udg_TOTD_DummyOrder, level)
set e = AddSpecialEffectTargetUnitBJ( "origin", u, udg_TOTD_VisualEffectPath )
set t = LoadTimerHandleBJ(udg_Skill_TOTD_AllocTimer, GetHandleIdBJ(u), udg_SkillHT)
if t == null then
set t = CreateTimer()
call SaveTimerHandleBJ(t, udg_Skill_TOTD_AllocTimer, GetHandleIdBJ(u), udg_SkillHT)
call SaveUnitHandleBJ(u, udg_Skill_TOTD_AllocCaster, GetHandleIdBJ(t), udg_SkillHT)
call TriggerRegisterTimerExpireEventBJ( gg_trg_TOTD_Expiration, t )
endif
call StartTimerBJ( t, false, udg_TOTD_Frequency )
// call RemoveLocation(l)
call DestroyEffect(e)
set t = null
set dummy = null
// set l = null
set e = null
endfunction
function Trig_TOTD_Cast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == udg_TOTD_SourceAbility
endfunction
function Trig_TOTD_Cast_Actions takes nothing returns nothing
call SaveIntegerBJ(GetUnitAbilityLevelSwapped(udg_TOTD_SourceAbility, GetTriggerUnit()), udg_Skill_TOTD_AllocLevel, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call LaunchTremorOftheDeepImpact(GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_TOTD_Cast takes nothing returns nothing
set gg_trg_TOTD_Cast = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_TOTD_Cast, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_TOTD_Cast, Condition( function Trig_TOTD_Cast_Conditions ) )
call TriggerAddAction( gg_trg_TOTD_Cast, function Trig_TOTD_Cast_Actions )
endfunction
function Trig_TOTD_Expiration_Actions takes nothing returns nothing
local unit u
local timer t
local integer level
set t = GetExpiredTimer()
set u = LoadUnitHandleBJ(udg_Skill_TOTD_AllocCaster, GetHandleIdBJ(t), udg_SkillHT)
if u != null and IsUnitAliveBJ(u) and UnitHasBuffBJ(u, udg_TOTD_SourceBuff) then
call LaunchTremorOftheDeepImpact(u)
set u = null
set t = null
return
endif
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_SkillHT)
call PauseTimer( t )
call DestroyTimer( t )
set t = null
set u = null
endfunction
//===========================================================================
function InitTrig_TOTD_Expiration takes nothing returns nothing
set gg_trg_TOTD_Expiration = CreateTrigger( )
call TriggerAddAction( gg_trg_TOTD_Expiration, function Trig_TOTD_Expiration_Actions )
endfunction
// Explanation:
// For this effect the substracted armor needs to be "real" and not "integer"
// The only way to do that is to use the Devotion Aura ability
// The problem is that whenever the level of the Aura changes, there is a delay of 2 seconds (even if we remove the ability/disable the ability)
// The only workaround is to work with the level 1 value of the Aura (removing and adding the Ability without changing its level will work instantly)
// Therefore there is the udg_CorrosiveBite_SkillTargDeciOn ability based on the Devotion Aura that adds +0.5 armor to the unit and grants a buff
// and there is the udg_CorrosiveBite_SkillTargDeciOff ability which doesn't add any armor but allows to maintain the buff active.
// Finally there is the udg_CorrosiveBite_SkillTarget ability that decreases the armor by steps of 0 or 1 and that is instantaneous
// Nota bene: the udg_CorrosiveBite_BuffMarker is here to know when to increase the level of udg_CorrosiveBite_SkillTarget
function Trig_Corrosive_Bite_Effect_Conditions takes nothing returns boolean
// return GetUnitAbilityLevelSwapped(udg_CorrosiveBite_SkillSource, GetEventDamageSource()) > 0 and UnitHasBuffBJ(GetTriggerUnit(), udg_CorrosiveBite_BuffMarker) and not IsUnitIllusionBJ(GetEventDamageSource())
local boolean success = GetUnitAbilityLevelSwapped(udg_CorrosiveBite_SkillSource, GetEventDamageSource()) > 0
set success = success and BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL
set success = success and GetTriggerUnit() == LoadUnitHandleBJ(udg_Skill_Attack_IndexTarget, GetHandleIdBJ(GetEventDamageSource()), udg_SkillHT)
set success = success and not IsUnitIllusionBJ(GetEventDamageSource())
set success = success and not IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE)
return success
endfunction
function Trig_Corrosive_Bite_Effect_Actions takes nothing returns nothing
local real armor_reduction
local real max_armor_reduction
local integer target_ability_level
local integer source_ability_level
local integer new_target_ability_level
local timer t
set t = LoadTimerHandleBJ(udg_Skill_CB_AllocTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if t == null then
set t = CreateTimer()
call SaveTimerHandleBJ(t, udg_Skill_CB_AllocTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_CB_AllocTarget, GetHandleIdBJ(t), udg_SkillHT)
call TriggerRegisterTimerExpireEventBJ( gg_trg_Corrosive_Bite_Expiration, t )
endif
// getting armor reduction
set target_ability_level = GetUnitAbilityLevelSwapped(udg_CorrosiveBite_SkillTarget, GetTriggerUnit())
if (target_ability_level == 0) then
set armor_reduction = 0
else
set armor_reduction = -I2R(BlzGetAbilityIntegerLevelField( BlzGetUnitAbility(GetTriggerUnit(),udg_CorrosiveBite_SkillTarget), ABILITY_ILF_DEFENSE_BONUS_IDEF, target_ability_level-1 ))
endif
if (GetUnitAbilityLevelSwapped(udg_CorrosiveBite_SkillTargDeciOn, GetTriggerUnit()) > 0) then
set armor_reduction = armor_reduction - 0.5
endif
// making sure armor reduction is not too high
set source_ability_level = GetUnitAbilityLevelSwapped(udg_CorrosiveBite_SkillSource, GetEventDamageSource())
set max_armor_reduction = 2.5 * I2R(source_ability_level)
if (max_armor_reduction <= armor_reduction) then
call StartTimerBJ( t, false, udg_CorrosiveBite_Duration )
set t = null
return
endif
// updating armor reduction
set armor_reduction = armor_reduction + source_ability_level * 0.5
if armor_reduction > max_armor_reduction then
set armor_reduction = max_armor_reduction
endif
// resetting buff and abilities
call UnitRemoveBuffBJ( udg_CorrosiveBite_Buff, GetTriggerUnit() )
call UnitRemoveAbilityBJ( udg_CorrosiveBite_SkillTargDeciOn, GetTriggerUnit() )
call UnitRemoveAbilityBJ( udg_CorrosiveBite_SkillTargDeciOff, GetTriggerUnit() )
set new_target_ability_level = MathRound(armor_reduction)
if ( I2R(new_target_ability_level) != armor_reduction ) then
call UnitAddAbilityBJ( udg_CorrosiveBite_SkillTargDeciOn, GetTriggerUnit() )
call BlzUnitHideAbility( GetTriggerUnit(), udg_CorrosiveBite_SkillTargDeciOn, true )
else
call UnitAddAbilityBJ( udg_CorrosiveBite_SkillTargDeciOff, GetTriggerUnit() )
call BlzUnitHideAbility( GetTriggerUnit(), udg_CorrosiveBite_SkillTargDeciOff, true )
endif
call UnitAddAbilityBJ( udg_CorrosiveBite_SkillTarget, GetTriggerUnit() )
call SetUnitAbilityLevelSwapped( udg_CorrosiveBite_SkillTarget, GetTriggerUnit(), new_target_ability_level )
call StartTimerBJ( t, false, udg_CorrosiveBite_Duration )
set t = null
endfunction
//===========================================================================
function InitTrig_Corrosive_Bite_Effect takes nothing returns nothing
set gg_trg_Corrosive_Bite_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Corrosive_Bite_Effect, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Corrosive_Bite_Effect, Condition( function Trig_Corrosive_Bite_Effect_Conditions ) )
call TriggerAddAction( gg_trg_Corrosive_Bite_Effect, function Trig_Corrosive_Bite_Effect_Actions )
endfunction
function Trig_Corrosive_Bite_Expiration_Actions takes nothing returns nothing
local unit u
local timer t
set t = GetExpiredTimer()
set u = LoadUnitHandleBJ(udg_Skill_CB_AllocTarget, GetHandleIdBJ(t), udg_SkillHT)
call UnitRemoveAbilityBJ( udg_CorrosiveBite_SkillTargDeciOn, u )
call UnitRemoveAbilityBJ( udg_CorrosiveBite_SkillTargDeciOff, u )
call UnitRemoveAbilityBJ( udg_CorrosiveBite_SkillTarget, u )
call UnitRemoveBuffBJ( udg_CorrosiveBite_Buff, u )
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_SkillHT)
call PauseTimer( t )
call DestroyTimer( t )
set t = null
set u = null
endfunction
//===========================================================================
function InitTrig_Corrosive_Bite_Expiration takes nothing returns nothing
set gg_trg_Corrosive_Bite_Expiration = CreateTrigger( )
call TriggerAddAction( gg_trg_Corrosive_Bite_Expiration, function Trig_Corrosive_Bite_Expiration_Actions )
endfunction
function CreateWaterAura takes location l, real range returns nothing
local unit u
set u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), udg_WaterAura_Dummy, l, 0.00)
call SaveRealBJ(range, udg_Dict_NW_AllocRange, GetHandleIdBJ(u), udg_DictHT )
call GroupAddUnitSimple( u, udg_WaterAura_DummyGroup )
set u = null
endfunction
function CreateWaterBlockAt takes integer x, integer y, boolean add_wave, real angle returns nothing
local location l
local effect water_block
local effect bubble
local effect wave
set water_block = LoadEffectHandleBJ(x, y, udg_WaterHT)
if (water_block == null ) then
set l = Location(I2R(x), I2R(y))
set water_block = AddSpecialEffectLocBJ( l, udg_Water_ModelPath )
call BlzSetSpecialEffectScale( water_block, udg_Water_Size * 0.025 )
call BlzSetSpecialEffectZ( water_block, GetLocationZ(l) + udg_Water_OffsetHeight )
call SaveEffectHandleBJ(water_block, x, y, udg_WaterHT )
if GetRandomReal(0, 100) <= 15 then
set bubble = AddSpecialEffectLocBJ( l, udg_Water_ModelPathBubbles )
call BlzSetSpecialEffectZ( bubble, GetLocationZ(l) + 20 )
endif
// if add_wave and GetRandomReal(0, 100) <= 30 then
if add_wave then
set wave = AddSpecialEffectLocBJ( l, udg_Water_ModelPathWaves )
call BlzSetSpecialEffectZ( wave, GetLocationZ(l) + 20 )
call BlzSetSpecialEffectYaw( wave, angle * 3.1416 / 180)
call BlzSetSpecialEffectTimeScale( wave, GetRandomReal(0.35, 0.5) )
call BlzSetSpecialEffectScale( wave, GetRandomReal(0.6, 0.8) )
call SaveEffectHandleBJ(wave, udg_Skill_Water_IndexBorderWave, GetHandleIdBJ(water_block), udg_SkillHT)
endif
call RemoveLocation(l)
else
set wave = LoadEffectHandleBJ(udg_Skill_Water_IndexBorderWave, GetHandleIdBJ(water_block), udg_SkillHT)
if wave != null then
call DestroyEffect(wave)
endif
endif
set l = null
set water_block = null
set wave = null
set bubble = null
endfunction
function CreateWaterHole takes location l, integer iterations, real aura_range returns nothing
local integer x
local integer y
local integer i
local integer j
local boolean b
local integer range
local boolean skip_edges = false
local boolean add_wave
local real wave_angle
set x = udg_Water_Size * R2I( GetLocationX(l) / I2R(udg_Water_Size) )
set y = udg_Water_Size * R2I( GetLocationY(l) / I2R(udg_Water_Size) )
call CreateWaterAura(l, aura_range)
set i = 0 - iterations
loop
exitwhen i > iterations
set range = R2I(SquareRoot(iterations*iterations -i*i))
if range > 1 then
if i == 0 and skip_edges then
set range = range - 1
endif
set j = 0 - range
loop
exitwhen j > range
set add_wave = ((j == range-2 or j == 2-range) and (ModuloInteger(i, 3) == 0) or (i == 1-iterations or i == iterations-1))
if add_wave then
set wave_angle = AcosBJ( I2R(i) / iterations)
if j >=0 then
set wave_angle = wave_angle
else
set wave_angle = - wave_angle
endif
else
set wave_angle = 0
endif
call CreateWaterBlockAt(x + i*udg_Water_Size, y + j*udg_Water_Size, add_wave, wave_angle)
set j = j + 1
endloop
else
set skip_edges = true
endif
set i = i + 1
endloop
call TerrainDeformationRippleBJ( 1, false, l, aura_range, aura_range, 32, 2.00, 512.00 )
endfunction
function CreateSmallWaterHole takes location l returns nothing
call CreateWaterHole(l, udg_Water_IterationsS, udg_Water_AuraRangeS)
endfunction
function CreateLargeWaterHole takes location l returns nothing
call CreateWaterHole(l, udg_Water_IterationsL, udg_Water_AuraRangeL)
endfunction
function PropagateWaterAroundUnit takes unit u returns nothing
local location l
set l = GetUnitLoc(u)
if GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityS, u) > 0 then
call CreateSmallWaterHole(l)
else
if GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityL, u) > 0 then
call CreateLargeWaterHole(l)
endif
endif
call RemoveLocation(l)
set l = null
endfunction
function UnitHasCloakOfShadow takes unit u returns boolean
return UnitHasItemOfTypeBJ(u, 'clsd') and IsUnitType(u, UNIT_TYPE_HERO)
endfunction
function MoveUnitIfNoOrder takes unit u returns nothing
local location l
local location l2
local string previous_order = LoadStringBJ(udg_Skill_Order_IndexStringOrder, GetHandleIdBJ(u), udg_SkillHT)
if OrderId2StringBJ(GetUnitCurrentOrder(u)) == "" and previous_order != "harvest" and previous_order != "resumeharvesting" then
// call BJDebugMsg(GetUnitName(u) + " you want free invis mother fucker ?")
set l = GetUnitLoc(u)
set l2 = PolarProjectionBJ(l, 1, GetUnitFacing(u))
call IssuePointOrderLocBJ( u, "move", l2)
call RemoveLocation(l)
call RemoveLocation(l2)
endif
set l = null
set l2 = null
endfunction
function WaterAuraRemoveEffect takes unit u returns nothing
call UnitRemoveAbilityBJ( udg_WaterDisguise_InvisAbility, u )
// call UnitRemoveAbilityBJ( udg_WaterDisguise_PenaltyAbility1, u )
// call UnitRemoveAbilityBJ( udg_WaterDisguise_PenaltyAbility2, u )
call AddUnitAnimationPropertiesBJ( false, "swim", u )
if LoadBooleanBJ(udg_Skill_Frenzy_IndexAbilityOff, GetHandleIdBJ(u), udg_SkillHT ) then
call BlzUnitDisableAbility( u, udg_Frenzy_Ability, false, false )
call SaveBooleanBJ(false, udg_Skill_Frenzy_IndexAbilityOff, GetHandleIdBJ(u), udg_SkillHT )
endif
endfunction
function WaterAuraRemoveActiveAbility takes unit u returns nothing
if OrderId2StringBJ(GetUnitCurrentOrder(u)) == udg_WaterDisguise_Order or OrderId2StringBJ(GetUnitCurrentOrder(u)) == "" then
call IssueImmediateOrderBJ( u, "stop") // removing ability while being ambushed makes the unit bug and lose auto attack (a click makes it behave like move)
endif
call UnitRemoveAbilityBJ( udg_WaterDisguise_Ability, u )
endfunction
function Trig_Buildings_Actions takes nothing returns nothing
call PropagateWaterAroundUnit(GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_Buildings takes nothing returns nothing
set gg_trg_Buildings = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Buildings, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_Buildings, function Trig_Buildings_Actions )
endfunction
function Trig_Water_Disguise_end_Conditions takes nothing returns boolean
local boolean b = GetIssuedOrderIdBJ() != String2OrderIdBJ(udg_WaterDisguise_Order)
set b = b and LoadStringBJ(udg_Skill_Order_IndexStringOrder, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT) != udg_WaterDisguise_Order // we dont want it to break if the hero learns an ability
set b = b and GetUnitAbilityLevelSwapped(udg_WaterDisguise_InvisAbility, GetTriggerUnit()) > 0
return b
endfunction
function Trig_Water_Disguise_end_Actions takes nothing returns nothing
local location l
local location l2
call WaterAuraRemoveEffect(GetTriggerUnit())
if ( GetIssuedOrderIdBJ() == String2OrderIdBJ("stop") or GetIssuedOrderIdBJ() == String2OrderIdBJ("holdposition") ) then
set l = GetUnitLoc(GetTriggerUnit())
set l2 = PolarProjectionBJ(l, 10.00, GetUnitFacing(GetTriggerUnit()))
call IssuePointOrderLocBJ( GetTriggerUnit(), "move", l2 )
call IssueImmediateOrderBJ( GetTriggerUnit(), "holdposition" )
call RemoveLocation(l)
call RemoveLocation(l2)
endif
set l = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_Water_Disguise_end takes nothing returns nothing
set gg_trg_Water_Disguise_end = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Disguise_end, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Disguise_end, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Disguise_end, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_Water_Disguise_end, Condition( function Trig_Water_Disguise_end_Conditions ) )
call TriggerAddAction( gg_trg_Water_Disguise_end, function Trig_Water_Disguise_end_Actions )
endfunction
function GiveWaterAuraBonusAndCheckOrder takes nothing returns nothing
// call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetEnumUnit()) + " is splashing around" )
if UnitHasCloakOfShadow(GetEnumUnit()) then // we dont add the ability
// call UnitRemoveAbilityBJ( udg_WaterDisguise_Ability, GetEnumUnit() )
call WaterAuraRemoveActiveAbility(GetEnumUnit())
else
// a little bug when if the unit stops at the very edge of the water, it will be given the invis ability
// right when it has no current order which will make it invis right away
if GetUnitAbilityLevelSwapped(udg_WaterDisguise_Ability, GetEnumUnit()) == 0 then
call MoveUnitIfNoOrder(GetEnumUnit())
endif
call UnitAddAbilityBJ( udg_WaterDisguise_Ability, GetEnumUnit() )
endif
call UnitRemoveAbilityBJ( udg_WaterDisguise_AbilityOff, GetEnumUnit() )
if GetUnitAbilityLevelSwapped(udg_WaterDisguise_InvisAbility, GetEnumUnit()) > 0 then
// should not be necessary as when a unit is given an order that is not ambush, the invisibility is removed
// however some orders do not proc, such as dropping or selling an item. Thus we add a check here
if OrderId2StringBJ(GetUnitCurrentOrder(GetEnumUnit())) != udg_WaterDisguise_Order and OrderId2StringBJ(GetUnitCurrentOrder(GetEnumUnit())) != "" then
call WaterAuraRemoveEffect(GetEnumUnit())
elseif not UnitHasBuffBJ(GetEnumUnit(), udg_Parasite_Buff) then
call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) + udg_WaterAura_Regen ) )
endif
endif
endfunction
function Trig_Water_Aura_Refresh_Actions takes nothing returns nothing
local group dummy_group = CreateGroup()
local group units_in_range_group
local group units_to_reset_group = CreateGroup()
local unit dummy
local unit target
local real dummy_range
local location l
call GroupAddGroup( udg_WaterAura_DummyGroup, dummy_group ) // copy of udg_WaterAura_DummyGroup
call GroupAddGroup( udg_Water_AuraTargetGroup, units_to_reset_group ) // copy of udg_WaterAura_DummyGroup
call GroupClear( udg_Water_AuraTargetGroup )
// retrieving targets
loop
set dummy = FirstOfGroup(dummy_group)
exitwhen dummy == null
set dummy_range = LoadRealBJ(udg_Dict_NW_AllocRange, GetHandleIdBJ(dummy), udg_DictHT )
set l = GetUnitLoc(dummy)
set units_in_range_group = GetUnitsInRangeOfLocAll(dummy_range, l)
call RemoveLocation(l)
loop
set target = FirstOfGroup(units_in_range_group)
exitwhen target == null
if GetUnitAbilityLevelSwapped(udg_WaterDisguise_EligibleAbility, target) > 0 then
call GroupAddUnitSimple( target, udg_Water_AuraTargetGroup )
call GroupRemoveUnit( units_to_reset_group, target )
endif
call GroupRemoveUnit(units_in_range_group, target)
endloop
call DestroyGroup(units_in_range_group)
call GroupRemoveUnit(dummy_group, dummy)
endloop
// giving targets bonus
call ForGroup(udg_Water_AuraTargetGroup, function GiveWaterAuraBonusAndCheckOrder)
// removing bonus from out of range units
loop
set target = FirstOfGroup(units_to_reset_group)
exitwhen target == null
// call DisplayTextToForce( GetPlayersAll(), GetUnitName(target) + " is out of the water:" + OrderId2StringBJ(GetUnitCurrentOrder(target)))
// call UnitRemoveAbilityBJ( udg_WaterDisguise_PenaltyAbility1, target )
// call UnitRemoveAbilityBJ( udg_WaterDisguise_PenaltyAbility2, target )
// call UnitRemoveAbilityBJ( udg_WaterDisguise_Ability, target )
// call UnitRemoveAbilityBJ( udg_WaterDisguise_InvisAbility, target )
call WaterAuraRemoveActiveAbility(target)
call WaterAuraRemoveEffect(target)
if GetUnitAbilityLevelSwapped(udg_WaterDisguise_InvisAbility, target) > 0 or OrderId2StringBJ(GetUnitCurrentOrder(target)) == "" then // otherwise it breaks the harvest animation
call WaterAuraRemoveEffect(target)
endif
if not (UnitHasCloakOfShadow(target)) then
call UnitAddAbilityBJ( udg_WaterDisguise_AbilityOff, target )
// if at this very moment the unit has no order, it means it tried to ambush right out of water range. So we need to move it
call MoveUnitIfNoOrder(target)
endif
call GroupRemoveUnit(units_to_reset_group, target)
endloop
// destroying variables
call DestroyGroup(units_to_reset_group)
call DestroyGroup(dummy_group)
set l = null
set units_to_reset_group = null
set units_in_range_group = null
set dummy_group = null
set dummy = null
set target = null
endfunction
//===========================================================================
function InitTrig_Water_Aura_Refresh takes nothing returns nothing
set gg_trg_Water_Aura_Refresh = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Water_Aura_Refresh, 0.50 )
call TriggerAddAction( gg_trg_Water_Aura_Refresh, function Trig_Water_Aura_Refresh_Actions )
endfunction
function Trig_Water_Disguise_Training_Actions takes nothing returns nothing
local location l
if GetUnitRallyUnit(GetTriggerUnit()) != null then
call IssueTargetOrderBJ( GetTrainedUnit(), "smart", GetUnitRallyUnit(GetTriggerUnit()) )
else
if GetUnitRallyDestructable(GetTriggerUnit()) != null then
call IssueTargetDestructableOrder( GetTrainedUnit(), "smart", GetUnitRallyDestructable(GetTriggerUnit()) )
else
set l = GetUnitRallyPoint(GetTriggerUnit())
call IssuePointOrderLocBJ( GetTrainedUnit(), "smart", l)
call RemoveLocation(l)
set l = null
endif
endif
endfunction
//===========================================================================
function InitTrig_Water_Disguise_Training takes nothing returns nothing
set gg_trg_Water_Disguise_Training = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Disguise_Training, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddAction( gg_trg_Water_Disguise_Training, function Trig_Water_Disguise_Training_Actions )
endfunction
function Trig_Water_Disguise_Revival_Actions takes nothing returns nothing
local location l
local unit building = LoadUnitHandleBJ(udg_Skill_Revival_IndexBuilding, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT )
if building == null then
return
endif
if GetUnitRallyUnit(building) != null then
call IssueTargetOrderBJ( GetRevivingUnit(), "smart", GetUnitRallyUnit(building) )
else
if GetUnitRallyDestructable(building) != null then
call IssueTargetDestructableOrder( GetRevivingUnit(), "smart", GetUnitRallyDestructable(building) )
else
set l = GetUnitRallyPoint(building)
call IssuePointOrderLocBJ( GetRevivingUnit(), "smart", l)
call RemoveLocation(l)
set l = null
endif
endif
endfunction
//===========================================================================
function InitTrig_Water_Disguise_Revival takes nothing returns nothing
set gg_trg_Water_Disguise_Revival = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Disguise_Revival, EVENT_PLAYER_HERO_REVIVE_FINISH )
call TriggerAddAction( gg_trg_Water_Disguise_Revival, function Trig_Water_Disguise_Revival_Actions )
endfunction
function CrushingBlowTurnOff takes unit u returns nothing
local effect e = LoadEffectHandleBJ(udg_Skill_CrushingBlow_IndexEffect, GetHandleIdBJ(u), udg_SkillHT)
if e != null then
call DestroyEffect(e)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(u), udg_Skill_CrushingBlow_IndexEffect)
endif
call SaveBooleanBJ(false, udg_Skill_CrushingBlow_IndexOff, GetHandleIdBJ(u), udg_SkillHT)
call SaveRealBJ(0, udg_Skill_CrushingBlow_IndexBonus, GetHandleIdBJ(u), udg_SkillHT)
call RemoveSavedHandle( udg_SkillHT, GetHandleIdBJ(u), udg_Skill_CrushingBlow_IndexTarget)
set e = null
endfunction
function CrushingBlowClearData takes unit u returns nothing
local timer t
local trigger tr
call CrushingBlowTurnOff(u)
set t = LoadTimerHandleBJ(udg_Skill_CrushingBlow_IndexTimer, GetHandleIdBJ(u), udg_SkillHT)
if t != null then
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_SkillHT)
call PauseTimer(t)
call DestroyTimer(t)
endif
set tr = LoadTriggerHandleBJ(udg_Skill_CrushingBlow_IndexTriggr, GetHandleIdBJ(u), udg_SkillHT)
if tr != null then
call DestroyTrigger(tr)
endif
set t = null
set tr = null
endfunction
function CrushingBlow_Expiration_Actions takes nothing returns nothing
local unit u = LoadUnitHandleBJ(udg_Skill_CrushingBlow_IndexCaster, GetHandleIdBJ(GetExpiredTimer()), udg_SkillHT)
if u != null then
call CrushingBlowTurnOff(u)
endif
set u = null
endfunction
function Trig_Crushing_Blow_Effect_Conditions takes nothing returns boolean
if not(BlzGetEventDamageType() == DAMAGE_TYPE_NORMAL) then
return false
endif
if GetUnitAbilityLevelSwapped(udg_CrushingBlow_AbilityEviscerate, GetEventDamageSource()) > 0 then
return true
endif
if GetUnitAbilityLevelSwapped(udg_CrushingBlow_Ability, GetEventDamageSource()) == 0 then
return false
endif
if GetPlayerTechCountSimple(udg_CrushingBlow_Research, GetOwningPlayer(GetEventDamageSource())) == 0 then
return false
endif
if IsUnitIllusionBJ(GetEventDamageSource()) then
return false
endif
return true
endfunction
function Trig_Crushing_Blow_Effect_Actions takes nothing returns nothing
local timer t
local trigger tr
local real bonus
local effect e
local unit u
local unit target
local boolean off
set u = GetEventDamageSource()
set off = LoadBooleanBJ(udg_Skill_CrushingBlow_IndexOff, GetHandleIdBJ(u), udg_SkillHT)
if off then // when we add bonus damage, we have to shut the trigger or it will get into an infinite loop
// call BJDebugMsg("nice extra " + R2S(GetEventDamage()))
call SaveBooleanBJ(false, udg_Skill_CrushingBlow_IndexOff, GetHandleIdBJ(u), udg_SkillHT)
set u = null
return
endif
set target = LoadUnitHandleBJ(udg_Skill_CrushingBlow_IndexTarget, GetHandleIdBJ(u), udg_SkillHT)
// if target != null and target != LoadUnitHandleBJ(udg_Skill_Attack_IndexTarget, GetHandleIdBJ(u), udg_SkillHT)
if target != null and target != GetTriggerUnit() then
call CrushingBlowTurnOff(u)
endif
set target = GetTriggerUnit()
call SaveUnitHandleBJ(GetTriggerUnit(), udg_Skill_CrushingBlow_IndexTarget, GetHandleIdBJ(u), udg_SkillHT)
if IsUnitType(target, UNIT_TYPE_STRUCTURE) or IsUnitAlly(target, GetOwningPlayer(u)) then
call CrushingBlowTurnOff(u)
set u = null
set target = null
return
endif
set t = LoadTimerHandleBJ(udg_Skill_CrushingBlow_IndexTimer, GetHandleIdBJ(u), udg_SkillHT)
set bonus = LoadRealBJ(udg_Skill_CrushingBlow_IndexBonus, GetHandleIdBJ(u), udg_SkillHT)
set e = LoadEffectHandleBJ(udg_Skill_CrushingBlow_IndexEffect, GetHandleIdBJ(u), udg_SkillHT)
if t == null then
set t = CreateTimer()
set tr = CreateTrigger( )
call TriggerRegisterTimerExpireEventBJ( tr, t )
call TriggerAddAction( tr, function CrushingBlow_Expiration_Actions )
call SaveUnitHandleBJ(u, udg_Skill_CrushingBlow_IndexCaster, GetHandleIdBJ(t), udg_SkillHT)
call SaveTimerHandleBJ(t, udg_Skill_CrushingBlow_IndexTimer, GetHandleIdBJ(u), udg_SkillHT)
call SaveTriggerHandleBJ(tr, udg_Skill_CrushingBlow_IndexTriggr, GetHandleIdBJ(u), udg_SkillHT)
endif
call StartTimerBJ( t, false, udg_CrushingBlow_TimerDuration )
if ( bonus > 0 ) then
call SaveBooleanBJ(true, udg_Skill_CrushingBlow_IndexOff, GetHandleIdBJ(u), udg_SkillHT)
call UnitDamageTargetBJ( u, GetTriggerUnit(), bonus, BlzGetEventAttackType(), BlzGetEventDamageType() )
call AddSpecialEffectTargetUnitBJ( "overhead", target, udg_CrushingBlow_EffectPath )
call DestroyEffect(GetLastCreatedEffectBJ())
endif
if e == null then
set e = AddSpecialEffectTargetUnitBJ( "weapon", GetEventDamageSource(), udg_CrushingBlow_WeaponPath )
call SaveEffectHandleBJ(e, udg_Skill_CrushingBlow_IndexEffect, GetHandleIdBJ(u), udg_SkillHT)
endif
set bonus = bonus + udg_CrushingBlow_BonusDamage
if ( bonus > udg_CrushingBlow_BonusMax ) then
set bonus = udg_CrushingBlow_BonusMax
call BlzPlaySpecialEffect( e, ANIM_TYPE_WALK )
else
if ( bonus > 10 ) then
call BlzPlaySpecialEffect( e, ANIM_TYPE_SLEEP )
endif
endif
call SaveRealBJ(bonus, udg_Skill_CrushingBlow_IndexBonus, GetHandleIdBJ(u), udg_SkillHT)
set t = null
set tr = null
set e = null
set u = null
set target = null
endfunction
//===========================================================================
function InitTrig_Crushing_Blow_Effect takes nothing returns nothing
set gg_trg_Crushing_Blow_Effect = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Crushing_Blow_Effect, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_Crushing_Blow_Effect, Condition( function Trig_Crushing_Blow_Effect_Conditions ) )
call TriggerAddAction( gg_trg_Crushing_Blow_Effect, function Trig_Crushing_Blow_Effect_Actions )
endfunction
function RemoveHydraHeads takes unit hydra, boolean display_unmorph, boolean display_head_death_animation returns nothing
local unit u
local effect e
local location l
call GroupRemoveUnit(udg_HydraGrowth_AlternateGroup, hydra)
call AddUnitAnimationPropertiesBJ( false, "gold", hydra )
call WaterAuraRemoveEffect(hydra)
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitR, GetHandleIdBJ(hydra), udg_HydraGrowthHT)
if not (u == null) then
if display_head_death_animation then
call KillUnit(u)
else
call RemoveUnit(u)
endif
call SaveUnitHandleBJ(null, udg_HydraGrowth_AllocUnitR, GetHandleIdBJ(hydra), udg_HydraGrowthHT )
endif
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitL, GetHandleIdBJ(hydra), udg_HydraGrowthHT)
if not (u == null) then
if display_head_death_animation then
call KillUnit(u)
else
call RemoveUnit(u)
endif
call SaveUnitHandleBJ(null, udg_HydraGrowth_AllocUnitL, GetHandleIdBJ(hydra), udg_HydraGrowthHT )
endif
call FlushChildHashtableBJ( GetHandleIdBJ(hydra), udg_HydraGrowthHT)
if display_unmorph then
call SPv2PlaySoundOnUnit( udg_HydraGrowth_SoundUnmorphPath, hydra )
set l = GetUnitLoc(hydra)
set e = AddSpecialEffectLocBJ( l, udg_HydraGrowth_UnmorphEffectPath )
call DestroyEffect(e)
call RemoveLocation(l)
call GroupAddUnitSimple( hydra, udg_HydraGrowth_UnmorphGroup )
call EnableTrigger(gg_trg_Hydra_Check_Unmorph)
endif
set e = null
set u = null
set l = null
endfunction
function Trig_Hydra_Head_Creation_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == udg_HydraGrowth_Ability )
endfunction
function CreateHead takes unit hydra, location l, string side returns unit
local unit u
local integer unit_type
local integer unit_memory_index
local integer timer_memory_index
if side == "right" then
set unit_type = udg_HydraGrowth_DummyR
set unit_memory_index = udg_HydraGrowth_AllocUnitR
set timer_memory_index = udg_HydraGrowth_AllocTimerR
else
set unit_type = udg_HydraGrowth_DummyL
set unit_memory_index = udg_HydraGrowth_AllocUnitL
set timer_memory_index = udg_HydraGrowth_AllocTimerL
endif
set u = CreateUnitAtLoc(GetOwningPlayer(hydra), unit_type, l, bj_UNIT_FACING)
call UnitRemoveAbilityBJ('Amov', u)
call UnitAddAbilityBJ( 'Amrf', u )
call SetUnitFlyHeightBJ( u , 60.00, 0.00 ) // cannot be done through editor because would require 'flying' movement type which messes up with terrain
call SaveUnitHandleBJ(u, unit_memory_index, GetHandleIdBJ(hydra), udg_HydraGrowthHT )
call SaveUnitHandleBJ(hydra, udg_HydraGrowth_AllocCaster, GetHandleIdBJ(u), udg_HydraGrowthHT )
call SaveStringBJ(side, udg_HydraGrowth_AllocDummyType, GetHandleIdBJ(u), udg_HydraGrowthHT )
call SaveRealBJ(-udg_HydraGrowth_InactivityDelay, timer_memory_index, GetHandleIdBJ(hydra), udg_HydraGrowthHT)
call SaveBooleanBJ(false, udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
if side == "right" then
call SetUnitAnimation( u, "birth gold" )
call QueueUnitAnimationBJ( u, "stand gold" )
else
call SetUnitAnimation( u, "birth" )
call QueueUnitAnimationBJ( u, "stand" )
endif
call PauseUnit(u, true)
// little bug where the stand animation is played before the birth animation which makes the heads glitch. Therefore we hide them at first
call SetUnitVertexColorBJ( u, 100, 100, 100, 100 )
return u
endfunction
function Trig_Hydra_Head_Creation_Actions takes nothing returns nothing
local location l
local unit headr
local unit headl
call RemoveHydraHeads(GetTriggerUnit(), false, false)
call AddUnitAnimationPropertiesBJ( true, "gold", GetTriggerUnit() )
set l = GetUnitLoc(GetTriggerUnit())
call SPv2PlaySoundAtPointWithVolume( udg_HydraGrowth_SoundMorphPath, 70, l )
call CastSpellOnUnitAtUnitPos(GetTriggerUnit(), udg_HydraGrowth_TempStunAbility, udg_HydraGrowth_TempStunOrder, 1, GetTriggerUnit())
call PolledWait( 0.2 )
set headr = CreateHead(GetTriggerUnit(), l, "right")
set headl = CreateHead(GetTriggerUnit(), l, "left")
call SaveRealBJ(GetUnitX(GetTriggerUnit()), udg_HydraGrowth_AllocHydraX, GetHandleIdBJ(GetTriggerUnit()), udg_HydraGrowthHT )
call SaveRealBJ(GetUnitY(GetTriggerUnit()), udg_HydraGrowth_AllocHydraY, GetHandleIdBJ(GetTriggerUnit()), udg_HydraGrowthHT )
call SaveRealBJ(0, udg_HydraGrowth_IndexElapsedTime, GetHandleIdBJ(GetTriggerUnit()), udg_HydraGrowthHT )
call RemoveLocation(l)
set l = null
call GroupAddUnitSimple( GetTriggerUnit(), udg_HydraGrowth_AlternateGroup )
call EnableTrigger(gg_trg_Hydra_Head_Repositionning)
// We display the heads once we are sure the animation glitch is not visible anymore
call TriggerSleepAction( 0.1 )
call SetUnitVertexColorBJ( headr, 100, 100, 100, 0 )
call SetUnitVertexColorBJ( headl, 100, 100, 100, 0 )
set headr = null
set headl = null
endfunction
//===========================================================================
function InitTrig_Hydra_Head_Creation takes nothing returns nothing
set gg_trg_Hydra_Head_Creation = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hydra_Head_Creation, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Hydra_Head_Creation, Condition( function Trig_Hydra_Head_Creation_Conditions ) )
call TriggerAddAction( gg_trg_Hydra_Head_Creation, function Trig_Hydra_Head_Creation_Actions )
endfunction
function Trig_Hydra_Head_Attack_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) == udg_HydraGrowth_DummyR or GetUnitTypeId(GetAttacker()) == udg_HydraGrowth_DummyL
endfunction
function Trig_Hydra_Head_Attack_Actions takes nothing returns nothing
local unit hydra
local string dummy_type
local integer hydra_id
local real time_left
local unit u
local location l
local location l2
set hydra = LoadUnitHandleBJ(udg_HydraGrowth_AllocCaster, GetHandleIdBJ(GetAttacker()), udg_HydraGrowthHT)
if hydra == null then
return
endif
set hydra_id = GetHandleIdBJ(hydra)
set dummy_type = LoadStringBJ(udg_HydraGrowth_AllocDummyType, GetHandleIdBJ(GetAttacker()), udg_HydraGrowthHT)
if (dummy_type == "right") then
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitR, hydra_id, udg_HydraGrowthHT)
call SaveRealBJ(udg_HydraGrowth_AttackDelay, udg_HydraGrowth_AllocTimerR, hydra_id, udg_HydraGrowthHT)
else
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitL, hydra_id, udg_HydraGrowthHT)
call SaveRealBJ(udg_HydraGrowth_AttackDelay, udg_HydraGrowth_AllocTimerL, hydra_id, udg_HydraGrowthHT)
endif
set l = GetUnitLoc(hydra)
set l2 = GetUnitLoc(GetAttackedUnitBJ())
call SetUnitFacingTimed( u, AngleBetweenPoints(l, l2), 0.00 )
call RemoveLocation(l)
call RemoveLocation(l2)
call PolledWait( udg_HydraGrowth_AttackDelay + 0.1 )
if (dummy_type == "right") then
set time_left = LoadRealBJ(udg_HydraGrowth_AllocTimerR, hydra_id, udg_HydraGrowthHT)
else
set time_left = LoadRealBJ(udg_HydraGrowth_AllocTimerL, hydra_id, udg_HydraGrowthHT)
endif
if (time_left <= 0) then
call SetUnitFacingTimed( u, GetUnitFacing(hydra), 0.00 )
endif
set hydra = null
set u = null
set l = null
set l2 = null
endfunction
//===========================================================================
function InitTrig_Hydra_Head_Attack takes nothing returns nothing
set gg_trg_Hydra_Head_Attack = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hydra_Head_Attack, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Hydra_Head_Attack, Condition( function Trig_Hydra_Head_Attack_Conditions ) )
call TriggerAddAction( gg_trg_Hydra_Head_Attack, function Trig_Hydra_Head_Attack_Actions )
endfunction
function UpdrateHydraDummy takes unit u, unit hydra, real head_offset_x, real head_offset_y, real animation_offsetx, real animation_offsety , boolean moving, integer timer_alloc, real elapsed_time, real moving_coeff, boolean is_idle, string head_side returns nothing
local real attack_timer
local real hydra_angle
local real head_angle
local real relative_angle
local boolean tagon
local boolean attack_allowed
set tagon = LoadBooleanBJ(udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
set hydra_angle = GetUnitFacing(hydra)
set head_angle = GetUnitFacing(u)
set relative_angle = ModuloReal(head_angle - hydra_angle, 360)
set head_offset_y = head_offset_y - 30*moving_coeff
set head_offset_x = head_offset_x - 30*moving_coeff
call SetUnitX(u, GetUnitX(hydra) + animation_offsetx - head_offset_x*CosBJ(hydra_angle + 90) - head_offset_y*CosBJ(hydra_angle))
call SetUnitY(u, GetUnitY(hydra) + animation_offsety - head_offset_x*SinBJ(hydra_angle + 90) - head_offset_y*SinBJ(hydra_angle))
if elapsed_time > udg_HydraGrowth_MorphDelay then
if head_side == "left" then
if relative_angle <= 90 or relative_angle > 225 then
if tagon then
call AddUnitAnimationPropertiesBJ( false, "gold", u )
call SaveBooleanBJ(false, udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
endif
else
if not tagon then
call AddUnitAnimationPropertiesBJ( true, "gold", u )
call SaveBooleanBJ(true, udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
endif
endif
else
if head_side == "right" then
if relative_angle <= 40 or relative_angle > 220 then
if not tagon then
call AddUnitAnimationPropertiesBJ( true, "gold", u )
call SaveBooleanBJ(true, udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
endif
else
if tagon then
call AddUnitAnimationPropertiesBJ( false, "gold", u )
call SaveBooleanBJ(false, udg_HydraGrowth_IndexAnimTagOn, GetHandleIdBJ(u), udg_HydraGrowthHT )
endif
endif
endif
endif
endif
set attack_allowed = false
// is idle means the hydra is caught in a specific animation where the heads are within the model.
// Therefore the unit heads must be hidden
if is_idle then
call UnitRemoveAbilityBJ(udg_HydraGrowth_AttachmentAbilityL, u)
call UnitRemoveAbilityBJ(udg_HydraGrowth_AttachmentAbilityR, u)
call SetUnitVertexColorBJ( u, 100, 100, 100, 100 )
else
if elapsed_time > udg_HydraGrowth_MorphDelay then
if head_side == "left" then
call UnitAddAbilityBJ(udg_HydraGrowth_AttachmentAbilityL, u)
else
call UnitAddAbilityBJ(udg_HydraGrowth_AttachmentAbilityR, u)
endif
endif
if UnitHasBuffBJ(hydra, 'Bply') or UnitHasBuffBJ(hydra, 'BOhx') then // hex or poly
call SetUnitVertexColorBJ( u, 100, 100, 100, 100 )
else
if UnitHasBuffBJ(hydra, 'BHbn') then // bannish
call SetUnitVertexColorBJ( u, 70.00, 100, 70.00, 50.00 )
else
if elapsed_time > 0.1 then // since the heads are not 100% visible right at creation (check Hydra Head Creation)
call SetUnitVertexColorBJ( u, 100, 100, 100, 0 )
endif
set attack_allowed = true
endif
endif
endif
if UnitHasBuffBJ(hydra, 'Binv') and not is_idle then // invis
call UnitAddAbilityBJ('Apiv', u)
set attack_allowed = false
else
call UnitRemoveAbilityBJ('Apiv', u)
endif
if attack_allowed and not udg_HydraGrowth_AllowAttackAndMove and moving then
set attack_allowed = false
endif
set attack_timer = LoadRealBJ(timer_alloc, GetHandleIdBJ(hydra), udg_HydraGrowthHT)
if not attack_allowed then
set attack_timer = -udg_HydraGrowth_InactivityDelay
call UnitAddAbilityBJ('Abun', u) // prevent unit from attacking
else
set attack_timer = attack_timer - 0.01
call UnitRemoveAbilityBJ('Abun', u) // remove attacking restriction
endif
if attack_timer <= -udg_HydraGrowth_InactivityDelay then
set attack_timer = -udg_HydraGrowth_InactivityDelay
call BlzSetUnitFacingEx( u, hydra_angle )
endif
if elapsed_time > udg_HydraGrowth_MorphDelay then
call PauseUnit(u, false)
if attack_timer <= -udg_HydraGrowth_InactivityDelay and moving then
call SetUnitTimeScalePercent( u, 300 )
else
call SetUnitTimeScalePercent( u, 100 )
endif
endif
call SaveRealBJ(attack_timer, timer_alloc, GetHandleIdBJ(hydra), udg_HydraGrowthHT)
endfunction
function UpdateHydraPosition takes nothing returns nothing
local real head_offset_x
local real head_offset_y
local real animation_offsetx
local real animation_offsety
local real elapsed_time
local unit u
local unit hydra
local real previous_x
local real previous_y
local integer hydra_id
local boolean moving
local real moving_coeff
local boolean is_idle
local boolean is_hydra_alive
set hydra = GetEnumUnit()
set hydra_id = GetHandleIdBJ(hydra)
set is_hydra_alive = IsUnitAliveBJ(hydra)
if not (UnitHasBuffBJ(hydra, udg_HydraGrowth_Buff)) or not is_hydra_alive then
call RemoveHydraHeads(hydra, is_hydra_alive, false)
set hydra = null
return
endif
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitR, hydra_id, udg_HydraGrowthHT)
if u == null then
call RemoveHydraHeads(hydra, false, false)
set hydra = null
return
endif
// when the hydra is stuck in some sort of animation like cyclone or impale, we play the gold animation so that the heads stay attached to the body
set is_idle = LoadBooleanBJ(udg_HydraGrowth_IndexIdle, hydra_id, udg_HydraGrowthHT)
if UnitHasBuffBJ(hydra, 'Bcyc') or UnitHasBuffBJ(hydra, 'Bcy2') or UnitHasBuffBJ(hydra, 'BUim') or UnitHasBuffBJ(hydra, udg_Kraken_Buff) or GetUnitAbilityLevelSwapped(udg_WaterDisguise_InvisAbility, hydra) > 0 or IsUnitLoadedBJ(hydra) then
if not is_idle then
call AddUnitAnimationPropertiesBJ( false, "gold", hydra )
set is_idle = true
call SaveBooleanBJ(true, udg_HydraGrowth_IndexIdle, hydra_id, udg_HydraGrowthHT)
endif
else
if is_idle then
call AddUnitAnimationPropertiesBJ( true, "gold", hydra )
set is_idle = false
call SaveBooleanBJ(false, udg_HydraGrowth_IndexIdle, hydra_id, udg_HydraGrowthHT)
endif
endif
set elapsed_time = LoadRealBJ(udg_HydraGrowth_IndexElapsedTime, hydra_id, udg_HydraGrowthHT) + 0.01
call SaveRealBJ(elapsed_time, udg_HydraGrowth_IndexElapsedTime, hydra_id, udg_HydraGrowthHT)
set previous_x = LoadRealBJ(udg_HydraGrowth_AllocHydraX, hydra_id, udg_HydraGrowthHT)
set previous_y = LoadRealBJ(udg_HydraGrowth_AllocHydraY, hydra_id, udg_HydraGrowthHT)
set animation_offsetx = GetUnitX(hydra) - previous_x
set animation_offsety = GetUnitY(hydra) - previous_y
set moving = not (animation_offsetx == 0 and animation_offsety == 0)
set moving_coeff = LoadRealBJ(udg_HydraGrowth_IndexMovingCoeff, hydra_id, udg_HydraGrowthHT )
if moving then
set moving_coeff = moving_coeff + 0.05
else
set moving_coeff = moving_coeff - 0.05
endif
set moving_coeff = RMinBJ(RMaxBJ(0, moving_coeff), 1)
call SaveRealBJ(moving_coeff, udg_HydraGrowth_IndexMovingCoeff, hydra_id, udg_HydraGrowthHT )
set head_offset_x = 50
set head_offset_y = 10
call UpdrateHydraDummy(u, hydra, head_offset_x, head_offset_y, animation_offsetx, animation_offsety, moving, udg_HydraGrowth_AllocTimerR, elapsed_time, moving_coeff, is_idle, "right")
set u = LoadUnitHandleBJ(udg_HydraGrowth_AllocUnitL, hydra_id, udg_HydraGrowthHT)
set head_offset_x = 20
set head_offset_y = -20
call UpdrateHydraDummy(u, hydra, head_offset_x, head_offset_y, animation_offsetx, animation_offsety, moving, udg_HydraGrowth_AllocTimerL, elapsed_time, moving_coeff, is_idle, "left")
call SaveRealBJ(GetUnitX(hydra), udg_HydraGrowth_AllocHydraX, hydra_id, udg_HydraGrowthHT )
call SaveRealBJ(GetUnitY(hydra), udg_HydraGrowth_AllocHydraY, hydra_id, udg_HydraGrowthHT )
set u = null
set hydra = null
endfunction
function Trig_Hydra_Head_Repositionning_Actions takes nothing returns nothing
call ForGroupBJ( udg_HydraGrowth_AlternateGroup, function UpdateHydraPosition )
if IsUnitGroupEmptyBJ(udg_HydraGrowth_AlternateGroup) then
call DisableTrigger(gg_trg_Hydra_Head_Repositionning)
endif
endfunction
//===========================================================================
function InitTrig_Hydra_Head_Repositionning takes nothing returns nothing
set gg_trg_Hydra_Head_Repositionning = CreateTrigger( )
call DisableTrigger(gg_trg_Hydra_Head_Repositionning)
call TriggerRegisterTimerEventPeriodic( gg_trg_Hydra_Head_Repositionning, 0.01 )
call TriggerAddAction( gg_trg_Hydra_Head_Repositionning, function Trig_Hydra_Head_Repositionning_Actions )
endfunction
function CheckHydraStatus takes nothing returns nothing
if GetUnitAbilityLevelSwapped(udg_HydraGrowth_AttachmentAbilityM, GetEnumUnit()) == 0 then
call WaterAuraRemoveEffect(GetEnumUnit())
call GroupRemoveUnit(udg_HydraGrowth_UnmorphGroup, GetEnumUnit())
if not IsUnitInGroup(GetEnumUnit(), udg_Water_AuraTargetGroup) then
call UnitAddAbilityBJ( udg_WaterDisguise_AbilityOff, GetEnumUnit() )
endif
endif
endfunction
function Trig_Hydra_Check_Unmorph_Actions takes nothing returns nothing
call ForGroupBJ( udg_HydraGrowth_UnmorphGroup, function CheckHydraStatus )
if IsUnitGroupEmptyBJ(udg_HydraGrowth_UnmorphGroup) then
call DisableTrigger(gg_trg_Hydra_Check_Unmorph)
endif
endfunction
//===========================================================================
function InitTrig_Hydra_Check_Unmorph takes nothing returns nothing
set gg_trg_Hydra_Check_Unmorph = CreateTrigger( )
call DisableTrigger( gg_trg_Hydra_Check_Unmorph )
call TriggerRegisterTimerEventPeriodic( gg_trg_Hydra_Check_Unmorph, 0.50 )
call TriggerAddAction( gg_trg_Hydra_Check_Unmorph, function Trig_Hydra_Check_Unmorph_Actions )
endfunction
function RaceConditionPlayerHasChosenRace takes nothing returns boolean
return ( udg_Races_PlayersRace[GetConvertedPlayerId(GetFilterPlayer())] != -1 )
endfunction
function RaceChoiceEnd takes nothing returns nothing
call DialogDisplayBJ( false, udg_Races_WaitDialog, GetEnumPlayer() )
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER then
call StartMeleeAI( GetEnumPlayer(), udg_Races_AIPath[udg_Races_PlayersRace[GetConvertedPlayerId(GetEnumPlayer())]] )
endif
endfunction
function RaceDismissDialog takes nothing returns nothing
call DisableTrigger(gg_trg_Race_Dialog_Expiration )
call PauseTimer( udg_Races_ChoiceTimer )
call DestroyTimer( udg_Races_ChoiceTimer )
call TimerDialogDisplayBJ( false, udg_Races_ChoiceTimerWindow )
call DestroyTimerDialogBJ( udg_Races_ChoiceTimerWindow )
call ForForce( udg_PlayingPlayers, function RaceChoiceEnd )
call MeleeStartingAI( )
call MeleeInitVictoryDefeat( )
endfunction
function SetUpRaceForPlayer takes player p, integer race_index returns nothing
local location starting_location
local location mb_location
local location gm_location
local location wc_location
local location w_location
local real mb_gm_angle
local real w_angle
local unit gm
local unit mb
local force g
local integer i
set udg_Races_PlayersRace[GetConvertedPlayerId(p)] = race_index // player starts at 1
// get closest gold mine
set starting_location = GetPlayerStartLocationLoc(p)
set gm = GetClosestGoldMine(starting_location)
set gm_location = GetUnitLoc(gm)
set mb_gm_angle = AngleBetweenPoints(starting_location, gm_location)
if (race_index == udg_Races_IndexUndead) then
call BlightGoldMineForPlayer( gm, p )
endif
// place main building
set mb_location = PolarProjectionBJ(starting_location, udg_Races_MainBuildingOffset[race_index], mb_gm_angle)
set mb = CreateUnitAtLoc(p, udg_Races_MainBuilding[race_index], mb_location, bj_UNIT_FACING)
if (race_index == udg_Races_IndexNightElf) then
call IssueTargetOrderBJ( mb, "entangleinstant", gm )
endif
if (race_index == udg_Races_IndexNaga) then
call PropagateWaterAroundUnit(mb)
endif
if (race_index == udg_Races_IndexHuman) then
call UnitAddAbilityBJ('Amic', mb)
endif
// place workers of type 1
set wc_location = PolarProjectionBJ(gm_location, udg_Races_Worker1DistanceMine[race_index], 180+mb_gm_angle)
set i = 0
loop
exitwhen i >= udg_Races_TotalWorkers1[race_index]
set w_angle = 90 + i * (360 / udg_Races_TotalWorkers1[race_index])
set w_location = PolarProjectionBJ(wc_location, udg_Races_Worker1DistanceWorkers[race_index], w_angle)
call CreateUnitAtLoc(p, udg_Races_Worker1[race_index], w_location, -90)
call RemoveLocation(w_location)
set i = i + 1
endloop
// place workers of type 2
call RemoveLocation(wc_location)
set wc_location = PolarProjectionBJ(gm_location, udg_Races_Worker2DistanceMine[race_index], 180+mb_gm_angle)
set i = 0
loop
exitwhen i >= udg_Races_TotalWorkers2[race_index]
set w_angle = 90 + i * (360 / udg_Races_TotalWorkers2[race_index])
set w_location = PolarProjectionBJ(wc_location, 0, w_angle)
call CreateUnitAtLoc(p, udg_Races_Worker2[race_index], w_location, -90)
call RemoveLocation(w_location)
set i = i + 1
endloop
call RemoveLocation(starting_location)
call RemoveLocation(mb_location)
call RemoveLocation(gm_location)
call RemoveLocation(wc_location)
// musics
if GetLocalPlayer() == p then
call PlayThematicMusicBJ(udg_Races_Sound_MusicDummy)
call SetMapMusicRandomBJ(udg_Races_Sound_Musics[race_index])
endif
// UI
call UseCustomConsole(p, race_index)
// check other players
set g = GetPlayersMatching(Condition(function RaceConditionPlayerHasChosenRace))
if CountPlayersInForceBJ(g) == udg_TotalPlayingPlayers then
// call RaceDismissDialog()
endif
set starting_location = null
set mb_location = null
set gm_location = null
set wc_location = null
set w_location = null
set mb = null
set gm = null
set g = null
endfunction
function Trig_Race_Initialize_Races takes nothing returns nothing
set udg_Races_PlayersRace[GetConvertedPlayerId(GetEnumPlayer())] = -1
endfunction
function Trig_Race_Display_To_Players takes nothing returns nothing
if ( GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER ) then
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(GetEnumPlayer()) + " chose their race !" )
call SetUpRaceForPlayer(GetEnumPlayer(), GetRandomInt(0, 3))
else
call DialogDisplayBJ( true, udg_Races_ChoiceDialog, GetEnumPlayer() )
endif
endfunction
function Trig_Race_Dialog_Actions takes nothing returns nothing
local integer i
local button b
set i = 0
loop
exitwhen i >= udg_Races_TotalRaces
set b = DialogAddButtonBJ( udg_Races_ChoiceDialog, udg_Races_Name[i] )
call SaveIntegerBJ(i, udg_Skill_RacePicker_IndexButton, GetHandleIdBJ(b), udg_SkillHT)
set i = i + 1
endloop
set b = DialogAddButtonBJ( udg_Races_ChoiceDialog, "Random" )
call SaveIntegerBJ(-1, udg_Skill_RacePicker_IndexButton, GetHandleIdBJ(b), udg_SkillHT)
call DialogSetMessageBJ( udg_Races_ChoiceDialog, "Please pick a race" )
call DialogSetMessageBJ( udg_Races_WaitDialog, "Please wait for other players|n to pick their races ..." )
// we must separate the 2 because we need to set udg_Races_PlayersRace for everybody first
call ForForce( udg_PlayingPlayers, function Trig_Race_Initialize_Races )
call ForForce( udg_PlayingPlayers, function Trig_Race_Display_To_Players )
call StartTimerBJ( udg_Races_ChoiceTimer, false, 10.00 )
set udg_Races_ChoiceTimerWindow = CreateTimerDialogBJ( udg_Races_ChoiceTimer, "Pick your race" )
set b = null
endfunction
//===========================================================================
function InitTrig_Race_Dialog takes nothing returns nothing
set gg_trg_Race_Dialog = CreateTrigger( )
call TriggerAddAction( gg_trg_Race_Dialog, function Trig_Race_Dialog_Actions )
endfunction
function Trig_Race_Picking_Actions takes nothing returns nothing
local player p
local integer race_index
set p = GetTriggerPlayer()
set race_index = LoadIntegerBJ(udg_Skill_RacePicker_IndexButton, GetHandleIdBJ(GetClickedButtonBJ()), udg_SkillHT)
if race_index == -1 then
set race_index = GetRandomInt(0, udg_Races_TotalRaces-1)
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(GetTriggerPlayer()) + " has randomed their race !" )
else
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(GetTriggerPlayer()) + " chose their race !" )
endif
if not(bj_isSinglePlayer) then
call DialogDisplayBJ( true, udg_Races_WaitDialog, p )
endif
call SetUpRaceForPlayer(p, race_index)
set p = null
endfunction
//===========================================================================
function InitTrig_Race_Picking takes nothing returns nothing
set gg_trg_Race_Picking = CreateTrigger( )
call TriggerRegisterDialogEventBJ( gg_trg_Race_Picking, udg_Races_ChoiceDialog )
call TriggerAddAction( gg_trg_Race_Picking, function Trig_Race_Picking_Actions )
endfunction
function StartGame takes nothing returns nothing
call MeleeStartingAI( )
call MeleeInitVictoryDefeat( )
call CinematicFilterGenericBJ( 5.00, BLEND_MODE_BLEND, "UI\\RaceSelectionGameBeginLogo.blp", 100, 100, 100.00, 0.00, 100.00, 100.00, 100.00, 100.00 )
// call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUTIN, 5.00, "UI\\RaceSelectionGameBeginLogo.blp", 100.00, 100.00, 100.00, 0 )
endfunction
function SetUpRaceForPlayer takes player p, integer race_index returns nothing
local location starting_location
local location mb_location
local location gm_location
local location wc_location
local location w_location
local real mb_gm_angle
local real w_angle
local unit gm
local unit mb
local integer i
set udg_Races_PlayersRace[GetConvertedPlayerId(p)] = race_index // player starts at 1
// get closest gold mine
set starting_location = GetPlayerStartLocationLoc(p)
set gm = GetClosestGoldMine(starting_location)
set gm_location = GetUnitLoc(gm)
set mb_gm_angle = AngleBetweenPoints(starting_location, gm_location)
if (race_index == udg_Races_IndexUndead) then
call BlightGoldMineForPlayer( gm, p )
endif
// place main building
set mb_location = PolarProjectionBJ(starting_location, udg_Races_MainBuildingOffset[race_index], mb_gm_angle)
set mb = CreateUnitAtLoc(p, udg_Races_MainBuilding[race_index], mb_location, bj_UNIT_FACING)
if (race_index == udg_Races_IndexNightElf) then
call IssueTargetOrderBJ( mb, "entangleinstant", gm )
endif
if (race_index == udg_Races_IndexNaga) then
call PropagateWaterAroundUnit(mb)
endif
if (race_index == udg_Races_IndexHuman) then
call UnitAddAbilityBJ('Amic', mb)
endif
// place workers of type 1
set wc_location = PolarProjectionBJ(gm_location, udg_Races_Worker1DistanceMine[race_index], 180+mb_gm_angle)
set i = 0
loop
exitwhen i >= udg_Races_TotalWorkers1[race_index]
set w_angle = 90 + i * (360 / udg_Races_TotalWorkers1[race_index])
set w_location = PolarProjectionBJ(wc_location, udg_Races_Worker1DistanceWorkers[race_index], w_angle)
call CreateUnitAtLoc(p, udg_Races_Worker1[race_index], w_location, -90)
call RemoveLocation(w_location)
set i = i + 1
endloop
// place workers of type 2
call RemoveLocation(wc_location)
set wc_location = PolarProjectionBJ(gm_location, udg_Races_Worker2DistanceMine[race_index], 180+mb_gm_angle)
set i = 0
loop
exitwhen i >= udg_Races_TotalWorkers2[race_index]
set w_angle = 90 + i * (360 / udg_Races_TotalWorkers2[race_index])
set w_location = PolarProjectionBJ(wc_location, 0, w_angle)
call CreateUnitAtLoc(p, udg_Races_Worker2[race_index], w_location, -90)
call RemoveLocation(w_location)
set i = i + 1
endloop
call RemoveLocation(starting_location)
call RemoveLocation(mb_location)
call RemoveLocation(gm_location)
call RemoveLocation(wc_location)
// musics
if GetLocalPlayer() == p then
call PlayThematicMusicBJ(udg_Races_Sound_MusicDummy)
call SetMapMusicRandomBJ(udg_Races_Sound_Musics[race_index])
endif
// UI
call UseCustomConsole(p, race_index)
set starting_location = null
set mb_location = null
set gm_location = null
set wc_location = null
set w_location = null
set mb = null
set gm = null
endfunction
struct Interface3DElem
implement StructModule
real offset_x
real offset_y
real yaw
real pitch
real adjustable_roll // since the mathematics isn't rigorously correct, we can adjut the roll manually
real scale
boolean scale_by_distance
readonly string path
readonly effect effect
readonly timer timer
readonly player player
readonly static trigger refresh_trigger
static method refreshTimer takes nothing returns nothing
local location l
local real x1
local real y1
local real z1
local real x2
local real y2
local real z2
local real sintheta
local real costheta
local real sinphi
local real cosphi
local real distance
local real offset_x
local real offset_y
local real aoa
local thistype elem = Data2Struct(GetExpiredTimer())
if elem == null then
return
endif
set l = GetCameraTargetPositionLoc() // depends on local player
if GetLocalPlayer() == elem.player then
// set elem.yaw = elem.yaw + 0.05
// set elem.pitch = elem.pitch + 0.01
set x2 = GetLocationX(l)
set y2 = GetLocationY(l)
set z2 = 0
set distance = GetCameraField(CAMERA_FIELD_TARGET_DISTANCE)
set aoa = GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)
set sintheta = -SinBJ(180*GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)/bj_PI)
set costheta = -CosBJ(180*GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK)/bj_PI)
set sinphi = SinBJ(180*GetCameraField(CAMERA_FIELD_ROTATION)/bj_PI)
set cosphi = CosBJ(180*GetCameraField(CAMERA_FIELD_ROTATION)/bj_PI)
set x1 = x2 + distance*costheta*cosphi
set y1 = y2 + distance*costheta*sinphi
set z1 = z2 + distance*sintheta
call BlzSetSpecialEffectYaw( elem.effect, bj_PI + elem.yaw + GetCameraField(CAMERA_FIELD_ROTATION))
call BlzSetSpecialEffectPitch( elem.effect, aoa + elem.pitch + (-0.96*aoa + 6.04) * RAbsBJ(SinBJ(elem.yaw*180/bj_PI) ))
call BlzSetSpecialEffectRoll( elem.effect, elem.adjustable_roll - 0.5*SinBJ(elem.yaw*180/bj_PI) * ((aoa - 6.147) / (5.306 - 6.147)))
if elem.scale_by_distance then // in progress
// s = 1 -> 1
// s = 0.5 -> 4/3
// s = 1.5 ->
// set offset_y = elem.offset_y * ((1+elem.scale)*distance / 3000)
// set offset_x = elem.offset_x * ((1+elem.scale)*distance / 3000)
set offset_y = elem.offset_y * (4./3.) *(distance/1500)
set offset_x = elem.offset_x * (4./3.) * (distance/1500)
call BlzSetSpecialEffectScale( elem.effect, 1 )
call BlzSetSpecialEffectX(elem.effect, (elem.scale*elem.scale*x1 + x2)/(1 + elem.scale*elem.scale) + offset_y*sintheta*cosphi + offset_x*sinphi)
call BlzSetSpecialEffectY(elem.effect, (elem.scale*elem.scale*y1 + y2)/(1 + elem.scale*elem.scale) + offset_y*sintheta*sinphi - offset_x*cosphi)
call BlzSetSpecialEffectZ(elem.effect, (elem.scale*elem.scale*z1 + z2)/(1 + elem.scale*elem.scale) - offset_y*costheta - (distance / 1500) * (120*costheta + 67))
else
set offset_y = elem.offset_y * (distance / 1500)
set offset_x = elem.offset_x * (distance / 1500)
call BlzSetSpecialEffectScale( elem.effect, elem.scale * distance / 1500 )
call BlzSetSpecialEffectX(elem.effect, (x1+x2)/2 + offset_y*sintheta*cosphi + offset_x*sinphi)
call BlzSetSpecialEffectY(elem.effect, (y1+y2)/2 + offset_y*sintheta*sinphi - offset_x*cosphi)
call BlzSetSpecialEffectZ(elem.effect, (z1+z2)/2 - offset_y*costheta - (distance / 1500) * (120*costheta + 67))
endif
endif
call RemoveLocation(l)
set l = null
endmethod
// cannot be called directly. Needs a player
// yaw and pitch in degrees (yaw: -90 to 90, pitch: 0 to 90 for now)
private static method create takes string path, real offset_x, real offset_y, real scale, real yaw, real pitch returns thistype
local thistype elem = thistype.moduleAllocation()
local location l
set elem.offset_x = offset_x
set elem.offset_y = offset_y
set elem.yaw = yaw * (bj_PI / 180)
set elem.pitch = pitch * (bj_PI / 180)
set elem.adjustable_roll = 0
set elem.path = path
set elem.scale = scale
set elem.scale_by_distance = false
set l = Location(0, 0)
set elem.effect = AddSpecialEffectLocBJ( l, path )
// call BlzSpecialEffectAddSubAnimation( elem.effect, SUBANIM_TYPE_VICTORY )
call BlzPlaySpecialEffect( elem.effect, ANIM_TYPE_STAND )
set elem.timer = CreateTimer()
call elem.CreateAttributeIndex(elem.timer)
call StartTimerBJ( elem.timer, true, 0.05 )
call TriggerRegisterTimerExpireEventBJ( thistype.refresh_trigger, elem.timer )
call RemoveLocation(l)
set l = null
return elem
endmethod
static method createForPlayer takes player p, string path, real offset_x, real offset_y, real scale, real yaw, real pitch returns thistype
local thistype elem
if GetLocalPlayer() != p then
set path = ""
endif
set elem = thistype.create(path, offset_x, offset_y, scale, yaw, pitch)
set elem.player = p
return elem
endmethod
method destroy takes nothing returns nothing
call BlzSetSpecialEffectAlpha(this.effect, 0 )
call BlzSetSpecialEffectScale(this.effect, 0 )
call BlzSetSpecialEffectZ(this.effect, 5000)
call DestroyEffect(this.effect)
set this.effect = null
call CleanAttributeIndex(this.timer)
call PauseTimer(this.timer)
call DestroyTimer(this.timer)
set this.timer = null
set this.player = null
call this.deallocate()
endmethod
static method onInit takes nothing returns nothing
local string s
local Interface3DElem e
set thistype.refresh_trigger = CreateTrigger( )
call TriggerAddAction( thistype.refresh_trigger, function thistype.refreshTimer )
endmethod
endstruct
struct Interface3DShowcase
private Interface3DElem array blocks[40]
private integer total_blocks
private real offset_x = 0
private real offset_y = 0
private real scale = 1
private player player
static method newOrcShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "units\\orc\\Peon\\Peon.mdl", 145, 115, 0.22, -10, 20)
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 148, 125, 2, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "units\\orc\\Grunt\\Grunt.mdl", 170, 115, 0.22, 0, 20)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 178, 125, 2.7, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "units\\orc\\Headhunter\\Headhunter.mdl", 200, 115, 0.22, 0, 20)
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 205, 125, 2.5, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "units\\orc\\Catapult\\Catapult.mdl", 230, 115, 0.16, 0, 20)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 238, 128, 3, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "units\\orc\\KotoBeast\\KotoBeast.mdl", 110, 80, 0.22, -10, 20)
set elem.blocks[8].adjustable_roll = 0.1
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 115, 95, 3.7, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "units\\orc\\WolfRider\\WolfRider.mdl", 150, 80, 0.22, -10, 20)
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 157, 90, 2.7, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "units\\orc\\Tauren\\Tauren.mdl", 190, 80, 0.20, 0, 20)
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 197, 90, 3.5, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "units\\orc\\BatTroll\\BatTroll.mdl", 230, 85, 0.22, 0, 20)
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 235, 90, 2.5, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "units\\orc\\WyvernRider\\WyvernRider.mdl", 270, 95, 0.23, -10, 20)
set elem.blocks[16].adjustable_roll = 0.1
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 90, 2.3, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "units\\orc\\SpiritWalker\\SpiritWalker.mdl", 160, 42, 0.20, -10, 20)
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 165, 52, 2.7, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "units\\orc\\WitchDoctor\\WitchDoctor.mdl", 190, 42, 0.22, 0, 20)
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 52, 2.2, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "units\\orc\\Shaman\\Shaman.mdl", 220, 42, 0.22, 0, 20)
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 52, 2.5, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "units\\orc\\HeroFarSeer\\HeroFarSeer.mdl", 120, 5, 0.24, -10, 20)
set elem.blocks[24].adjustable_roll = 0.1
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 125, 10, 4, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "units\\orc\\HeroBladeMaster\\HeroBladeMaster.mdl", 165, 0, 0.25, 0, 20)
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 170, 10, 4, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "units\\orc\\HeroShadowHunter\\HeroShadowHunter.mdl", 215, 0, 0.25, 0, 20)
set elem.blocks[28].adjustable_roll = 0.1
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 220, 10, 4, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "units\\orc\\HeroTaurenChieftain\\HeroTaurenChieftain.mdl", 260, 0, 0.25, 0, 20)
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 270, 15, 4, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundOrc.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
static method newHumanShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "units\\human\\Peasant\\Peasant.mdl", 145, 115, 0.22, -10, 20)
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 150, 125, 2, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "units\\human\\Footman\\Footman.mdl", 175, 115, 0.22, 0, 20)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 180, 125, 2.5, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "units\\human\\Rifleman\\Rifleman.mdl", 205, 115, 0.22, 0, 20)
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 210, 125, 2.5, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "units\\human\\Knight\\Knight.mdl", 235, 115, 0.20, 0, 20)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 242, 125, 2.7, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "units\\human\\MortarTeam\\MortarTeam.mdl", 110, 80, 0.22, 0, 20)
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 110, 90, 2.5, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "units\\human\\WarWagon\\WarWagon.mdl", 150, 85, 0.20, -12, 20)
set elem.blocks[10].adjustable_roll = 0.1
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 155, 95, 3.5, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "units\\human\\Gyrocopter\\Gyrocopter.mdl", 190, 90, 0.22, -10, 20)
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 90, 3, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "units\\human\\GryphonRider\\GryphonRider.mdl", 230, 90, 0.22, 0, 20)
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 235, 90, 2.5, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "units\\human\\BloodElfDragonHawk\\BloodElfDragonHawk.mdl", 270, 90, 0.22, 0, 20)
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 90, 2.5, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "units\\human\\Sorceress\\Sorceress.mdl", 160, 40, 0.22, 0, 20)
set elem.blocks[18].adjustable_roll = 0.1
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 165, 50, 2.2, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "units\\human\\Priest\\Priest.mdl", 190, 43, 0.22, 0, 20)
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 53, 2.2, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "units\\human\\BloodElfSpellThief\\BloodElfSpellThief.mdl", 220, 40, 0.18, 0, 20)
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 50, 2.2, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "units\\human\\HeroArchMage\\HeroArchMage.mdl", 120, 3, 0.25, -10, 20)
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 130, 10, 3.5, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "units\\human\\HeroPaladin\\HeroPaladin.mdl", 167, 0, 0.25, 0, 20)
set elem.blocks[26].adjustable_roll = 0.06
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 172, 10, 3.5, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "units\\human\\HeroMountainKing\\HeroMountainKing.mdl", 212, 0, 0.25, 0, 20)
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 222, 10, 3.5, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "units\\human\\HeroBloodElf\\HeroBloodElf.mdl", 260, 0, 0.25, 0, 20)
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 265, 10, 3.5, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundHuman.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
static method newUndeadShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "units\\undead\\Acolyte\\Acolyte.mdl", 145, 115, 0.22, 0, 20)
set elem.blocks[0].adjustable_roll = 0.03
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 150, 125, 2, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "units\\undead\\Ghoul\\Ghoul.mdl", 175, 118, 0.20, 0, 20)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 180, 128, 2, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "units\\undead\\CryptFiend\\CryptFiend.mdl", 205, 118, 0.18, -10, 20)
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 210, 128, 2.5, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "units\\undead\\Gargoyle\\Gargoyle.mdl", 235, 125, 0.20, 0, 20)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 240, 125, 2, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "units\\undead\\MeatWagon\\MeatWagon.mdl", 110, 80, 0.22, -10, 20)
set elem.blocks[8].adjustable_roll = 0.05
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 115, 95, 3, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "units\\undead\\Abomination\\Abomination.mdl", 150, 80, 0.20, 0, 20)
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 155, 90, 3, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "units\\undead\\ObsidianStatue\\ObsidianStatue.mdl", 190, 75, 0.15, -10, 0)
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 90, 2.5, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "UI\\Showcase\\Destroyer.mdl", 230, 90, 0.16, 0, 20)
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 235, 90, 2.5, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "units\\undead\\FrostWyrm\\FrostWyrm.mdl", 270, 95, 0.22, 0, 20)
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 95, 3, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "units\\undead\\Necromancer\\Necromancer.mdl", 160, 43, 0.20, -10, 20)
set elem.blocks[18].adjustable_roll = 0.1
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 165, 55, 2.2, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "UI\\Showcase\\Banshee.mdl", 190, 47, 0.19, 0, 20)
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 55, 2.2, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "UI\\Showcase\\Shade.mdl", 220, 40, 0.18, 0, 20)
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 50, 2.2, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "units\\undead\\HeroDeathKnight\\HeroDeathKnight.mdl", 120, 0, 0.25, -15, 10)
set elem.blocks[24].adjustable_roll = 0.1
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 128, 10, 4, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "units\\undead\\HeroDreadLord\\HeroDreadLord.mdl", 165, 0, 0.25, 0, 20)
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 170, 10, 4, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "units\\undead\\HeroCryptLord\\HeroCryptLord.mdl", 215, 0, 0.23, -10, 20)
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 223, 15, 4, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "units\\undead\\HeroLich\\HeroLich.mdl", 260, 0, 0.25, 0, 20)
set elem.blocks[30].adjustable_roll = 0.1
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 268, 10, 3.5, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundUndead.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
static method newNightElfShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Wisp\\Wisp.mdl", 145, 115, 0.22, -10, 20)
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 150, 130, 1.7, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Archer\\Archer.mdl", 175, 115, 0.22, 0, 20)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 180, 125, 2, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Huntress\\Huntress.mdl", 205, 115, 0.22, 0, 20)
set elem.blocks[4].adjustable_roll = 0.1
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 210, 130, 2.5, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Ballista\\Ballista.mdl", 235, 118, 0.20, 0, 30)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 243, 128, 3, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "units\\nightelf\\MountainGiant\\MountainGiant.mdl", 110, 80, 0.18, 0, 20)
set elem.blocks[8].adjustable_roll = -0.04
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 115, 100, 4, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Dryad\\Dryad.mdl", 150, 80, 0.21, -10, 20)
set elem.blocks[10].adjustable_roll = 0.08
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 155, 95, 2.7, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Hippogryph\\Hippogryph.mdl", 190, 85, 0.20, -10, 20)
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 90, 2.3, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "units\\nightelf\\RiddenHippogryph\\RiddenHippogryph.mdl", 230, 85, 0.20, 0, 20)
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 235, 90, 2.5, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "units\\nightelf\\Chimaera\\Chimaera.mdl", 270, 93, 0.21, 0, 20)
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 93, 3, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "units\\nightelf\\FaerieDragon\\FaerieDragon.mdl", 160, 50, 0.24, 0, 20)
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 165, 50, 2.5, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "units\\nightelf\\DruidOfTheTalon\\DruidOfTheTalon.mdl", 190, 42, 0.21, 0, 20)
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 52, 2.5, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "units\\nightelf\\DruidOfTheClaw\\DruidOfTheClaw.mdl", 220, 42, 0.17, 0, 20)
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 52, 3, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "units\\nightelf\\HeroKeeperOfTheGrove\\HeroKeeperOfTheGrove.mdl", 120, 0, 0.25, -10, 20)
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 127, 15, 4, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "units\\nightelf\\HeroDemonHunter\\HeroDemonHunter.mdl", 165, 0, 0.25, 0, 20)
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 173, 15, 4, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "units\\nightelf\\HeroWarden\\HeroWarden.mdl", 215, 0, 0.25, 0, 20)
set elem.blocks[28].adjustable_roll = 0.1
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 10, 4, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "units\\nightelf\\HeroMoonPriestess\\HeroMoonPriestess.mdl", 260, 3, 0.25, 0, 20)
set elem.blocks[30].adjustable_roll = 0.1
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 270, 10, 4, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundNightElf.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
static method newNagaShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "units\\creeps\\MurgulSlave\\MurgulSlave.mdl", 145, 115, 0.21, -10, 20)
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 147, 125, 1.5, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "Units\\NagaMarauder.mdl", 175, 114, 0.175, -10, 20)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 180, 125, 2, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "Units\\Ophidian.mdl", 205, 115, 0.15, 0, 20)
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 210, 130, 2.5, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "Units\\Myrmidon.mdl", 235, 115, 0.175, 0, 30)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 243, 128, 3, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "Units\\Leviathan.mdl", 110, 85, 0.19, -10, 20)
set elem.blocks[8].adjustable_roll = 0.1
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 120, 100, 3.7, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "UI\\Showcase\\NagaBeastTamer.mdl", 150, 80, 0.16, 0, 20)
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 155, 90, 2.2, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "Units\\SiegeLizard.mdl", 190, 80, 0.18, -10, 10)
set elem.blocks[12].adjustable_roll = 0.05
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 90, 3, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "units\\naga\\WindSerpent\\WindSerpent.mdl", 230, 95, 0.12, -10, 20)
set elem.blocks[14].adjustable_roll = 0.1
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 235, 95, 2.2, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "Units\\Seadrake.mdl", 270, 85, 0.21, 0, 30)
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 95, 2.6, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "Units\\AbyssalSpirit.mdl", 160, 48, 0.25, -10, 20)
set elem.blocks[18].adjustable_roll = 0.1
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 165, 55, 1.7, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "Units\\NagaWarlock.mdl", 190, 42, 0.23, -10, 20)
set elem.blocks[20].adjustable_roll = 0.1
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 195, 55, 2, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "Units\\Naga\\NagaSiren\\NagaSiren.mdl", 220, 40, 0.19, 0, 20)
set elem.blocks[22].adjustable_roll = 0.2
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 55, 2.1, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "Units\\ReefLord.mdl", 115, 0, 0.26, -10, 10)
set elem.blocks[24].adjustable_roll = 0.1
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 122, 15, 4, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "Units\\NagaEmpress.mdl", 165, 0, 0.3, -10, 10)
set elem.blocks[26].adjustable_roll = 0.1
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 173, 15, 4, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "units\\naga\\HeroNagaSeawitch\\HeroNagaSeawitch.mdl", 215, 0, 0.25, 0, 20)
set elem.blocks[28].adjustable_roll = 0.1
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 225, 10, 4, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "Units\\ShoalCommander.mdl", 260, 0, 0.24, 0, 20)
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 270, 10, 4, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundNaga.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
static method newRandomShowcase takes player p returns thistype
local thistype elem = thistype.allocate()
set elem.player = p
set elem.blocks[0] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 145, 112, 0.4, 0, 0)
set elem.blocks[1] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 148, 130, 1.8, 0, 90)
set elem.blocks[2] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 175, 112, 0.4, 0, 0)
set elem.blocks[3] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 178, 130, 1.8, 0, 90)
set elem.blocks[4] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 205, 112, 0.4, 0, 0)
set elem.blocks[5] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 208, 130, 1.8, 0, 90)
set elem.blocks[6] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 235, 112, 0.4, 0, 0)
set elem.blocks[7] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 238, 130, 1.8, 0, 90)
set elem.blocks[8] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 110, 77, 0.4, 0, 0)
set elem.blocks[9] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 113, 95, 1.8, 0, 90)
set elem.blocks[10] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 150, 77, 0.4, 0, 0)
set elem.blocks[11] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 153, 95, 1.8, 0, 90)
set elem.blocks[12] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 190, 77, 0.4, 0, 0)
set elem.blocks[13] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 193, 95, 1.8, 0, 90)
set elem.blocks[14] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 230, 77, 0.4, 0, 0)
set elem.blocks[15] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 234, 95, 1.8, 0, 90)
set elem.blocks[16] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 270, 77, 0.4, 0, 0)
set elem.blocks[17] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 275, 95, 1.8, 0, 90)
set elem.blocks[18] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 160, 40, 0.4, 0, 0)
set elem.blocks[19] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 163, 58, 1.8, 0, 90)
set elem.blocks[20] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 190, 40, 0.4, 0, 0)
set elem.blocks[21] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 193, 58, 1.8, 0, 90)
set elem.blocks[22] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 220, 40, 0.4, 0, 0)
set elem.blocks[23] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 223, 58, 1.8, 0, 90)
set elem.blocks[24] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 130, 0, 0.4, 0, 0)
set elem.blocks[25] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 133, 18, 1.8, 0, 90)
set elem.blocks[26] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 170, 0, 0.4, 0, 0)
set elem.blocks[27] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 173, 18, 1.8, 0, 90)
set elem.blocks[28] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 210, 0, 0.4, 0, 0)
set elem.blocks[29] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 214, 18, 1.8, 0, 90)
set elem.blocks[30] = Interface3DElem.createForPlayer(p, "Objects\\RandomObject\\RandomObject.mdl", 250, 0, 0.4, 0, 0)
set elem.blocks[31] = Interface3DElem.createForPlayer(p, "UI\\ModelShade.mdl", 255, 18, 1.8, 0, 90)
set elem.blocks[32] = Interface3DElem.createForPlayer(p, "UI\\ShowCaseBackgroundRandom.mdl", 200, 0, 0.9, 0, 90)
set elem.total_blocks = 33
return elem
endmethod
method setOffset takes real x, real y returns nothing
local integer i = 0
loop
exitwhen i >= this.total_blocks
set this.blocks[i].offset_x = this.scale * (this.blocks[i].offset_x / this.scale - this.offset_x) + x
set this.blocks[i].offset_y = this.scale * (this.blocks[i].offset_y / this.scale- this.offset_y) + y
set this.blocks[i].scale = this.scale * (this.blocks[i].scale / this.scale)
set i = i + 1
endloop
set this.offset_x = x
set this.offset_y = y
endmethod
method setScale takes real s returns nothing
local integer i = 0
loop
exitwhen i >= this.total_blocks
set this.blocks[i].offset_x = s * (this.blocks[i].offset_x / this.scale - this.offset_x) + this.offset_x
set this.blocks[i].offset_y = s * (this.blocks[i].offset_y / this.scale- this.offset_y) + this.offset_y
set this.blocks[i].scale = s * (this.blocks[i].scale / this.scale)
set i = i + 1
endloop
set this.scale = s
endmethod
method playAnimation takes animtype at returns nothing
local integer i = 0
loop
exitwhen i >= this.total_blocks
call BlzPlaySpecialEffect( this.blocks[i].effect, at )
set i = i + 1
endloop
endmethod
method destroy takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= this.total_blocks
call this.blocks[i].destroy()
set this.blocks[i] = 0
set i = i + 1
endloop
set this.player = null
call this.deallocate()
endmethod
static method onInit takes nothing returns nothing
// local Interface3DShowcase sc
// set sc = newOrcShowcase()
// set sc = newHumanShowcase()
// set sc = newUndeadShowcase()
// set sc = newNightElfShowcase()
// call TriggerSleepAction(3)
// call sc.destroy()
endmethod
endstruct
scope RaceSelection
globals
private framehandle RS_BackgroundFrame = null
private framehandle RS_SelectedRaceBlock = null
private framehandle array RS_RaceBlock
private framehandle array RS_RaceSigilFrame
private framehandle array RS_TitleTextFrame
private framehandle array RS_Button
private framehandle RS_DescriptionTextBlock = null
private framehandle RS_DescriptionTextFrame = null
private framehandle RS_DescriptionFooterFrame = null
private framehandle RS_LogoFrame = null
private framehandle RS_HeaderTextFrame = null
private framehandle RS_TimerFrame = null
private framehandle RS_ValidationButton = null
private framehandle RS_HDSigilBlock = null
private framehandle RS_HDTitleBlock = null
private framehandle RS_HDTitleFrame = null
private real array RS_RaceBlock_TL_X[6]
private real array RS_RaceBlock_TL_Y[6]
private real array RS_RaceBlock_BR_X[6]
private real array RS_RaceBlock_BR_Y[6]
private string array RS_Race_Title[6]
private string array RS_Race_Description[6]
private string array RS_Race_Footer[6]
private string array RS_Race_Icon[6]
private string array RS_Race_IconHD[6]
private timer RS_SelectionTimer = null
private integer RS_TimeLeft = 30
private boolean RS_FrameBeingClosed = false
private string RS_SelectionSoundPath = "Sound\\Interface\\Rescue.flac"
private string RS_SelectionOtherSoundPath = "Sound\\Interface\\InGameChatWhat1.flac"
private string RS_TickSoundPath = "Sound\\Interface\\BattleNetTick.flac"
private string RS_BeginGameSoundPath = "Sound\\Interface\\NewTournament.flac"
private integer RS_ShowcaseOffsetX = 00 // 0 for test map, 10 for prod small map, 0 for prod big map
private integer RS_ShowcaseOffsetY = 50 // 0 for test map, 70 for prod small map, 50 for prod big map
private real RS_ShowcaseScale = 1.1 // 1 for test map, 1.1 for prod
private real RS_CameraDistance = 2100
private real RS_CameraAngleOfAttack = 304
private trigger RS_TriggerValidateRace = null
private trigger RS_TriggerManageUsers = null
private trigger RS_TriggerRefreshTimer = null
private trigger array RS_Trigger_Button
// 20 players, starts at 1
private Interface3DElem array RS_3DBackround[20]
private Interface3DShowcase array RS_ShowCase[20]
private fogmodifier array RS_VisibilityModifier[20]
private integer array RS_SelectedIndex[20]
private boolean array RS_RaceSelected[20]
endglobals
function RS_RefreshPlayerShowcaseFunc takes player p, integer race_id returns nothing
local integer player_id = GetConvertedPlayerId(p)
if RS_ShowCase[player_id] != null then
call RS_ShowCase[player_id].destroy()
endif
if race_id == 0 then
set RS_ShowCase[player_id] = Interface3DShowcase.newHumanShowcase(p)
elseif race_id == 1 then
set RS_ShowCase[player_id] = Interface3DShowcase.newOrcShowcase(p)
elseif race_id == 2 then
set RS_ShowCase[player_id] = Interface3DShowcase.newUndeadShowcase(p)
elseif race_id == 3 then
set RS_ShowCase[player_id] = Interface3DShowcase.newNightElfShowcase(p)
elseif race_id == 4 then
set RS_ShowCase[player_id] = Interface3DShowcase.newNagaShowcase(p)
elseif race_id == 5 then
set RS_ShowCase[player_id] = Interface3DShowcase.newRandomShowcase(p)
endif
call RS_ShowCase[player_id].setOffset(RS_ShowcaseOffsetX, RS_ShowcaseOffsetY)
call RS_ShowCase[player_id].setScale(RS_ShowcaseScale)
endfunction
function RS_CleanPlayerDataFunc takes nothing returns nothing
local integer player_id = GetConvertedPlayerId(GetEnumPlayer())
local location l
call RS_3DBackround[player_id].destroy()
call RS_ShowCase[player_id].destroy()
set l = GetPlayerStartLocationLoc(GetEnumPlayer())
call DestroyFogModifier(RS_VisibilityModifier[player_id])
set RS_VisibilityModifier[player_id] = null
call PanCameraToTimedForPlayer(GetEnumPlayer(), GetLocationX(l), GetLocationY(l), 0)
call RemoveLocation(l)
set l = null
endfunction
function RS_ValidateRaceForPlayerFunc takes player p, boolean active_validation returns nothing
local integer player_id = GetConvertedPlayerId(p)
local string soundpath = ""
local integer i
if RS_SelectedIndex[player_id] == -1 then
return
endif
if RS_RaceSelected[player_id] then
return
endif
set RS_RaceSelected[player_id] = true
// generating random race
if RS_SelectedIndex[player_id] == udg_Races_IndexRandom then
set RS_SelectedIndex[player_id] = GetRandomInt(0, udg_Races_TotalRaces-1)
if active_validation then
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(p) + " has randomed their race !" )
call RS_RefreshPlayerShowcaseFunc(p, RS_SelectedIndex[player_id])
else
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(p) + " has been given a random race !" )
endif
call RS_RefreshPlayerShowcaseFunc(p, RS_SelectedIndex[player_id])
else
call DisplayTextToForce( GetPlayersAll(), GetPlayerColoredName(p) + " has chosen their race !" )
endif
// updating frames for local player only
if GetLocalPlayer() == p then
set i = 0
loop
exitwhen i > udg_Races_TotalRaces
call BlzFrameSetVisible(RS_RaceBlock[i], false)
call BlzFrameSetVisible(RS_Button[i], false)
call BlzFrameSetVisible(RS_RaceSigilFrame[i], false)
set i = i + 1
endloop
call BlzFrameSetVisible(RS_SelectedRaceBlock, false)
call BlzFrameSetVisible(RS_ValidationButton, false)
call BlzFrameSetVisible(RS_HDSigilBlock, true)
call BlzFrameSetVisible(RS_HDTitleBlock, true)
call BlzFrameSetTexture(RS_HDSigilBlock, RS_Race_IconHD[RS_SelectedIndex[player_id]], 0, true)
call BlzFrameSetText(RS_HDTitleFrame, "|cffFFCC00"+RS_Race_Title[RS_SelectedIndex[player_id]]+"|r")
call BlzFrameSetText(RS_HeaderTextFrame, "|cffFFCC00Waiting for other players ...|r")
set soundpath = RS_SelectionSoundPath
// elseif active_validation then
else
set soundpath = RS_SelectionOtherSoundPath
endif
call PlaySound(soundpath)
call RS_ShowCase[player_id].playAnimation(ANIM_TYPE_WALK)
endfunction
function RS_SetComputerRaceFunc takes nothing returns nothing
local integer player_id = GetConvertedPlayerId(GetEnumPlayer())
set RS_SelectedIndex[player_id] = GetRandomInt(0, udg_Races_TotalRaces-2) // we do not allow custom races for computer for now
call RS_ValidateRaceForPlayerFunc(GetEnumPlayer(), true)
// since there is a triggersleepaction after the call of RS_SetComputerRaceFunc, it messes with the AI scripts so we should launch them before
call StartMeleeAI( GetEnumPlayer(), udg_Races_AIPath[RS_SelectedIndex[player_id]] )
endfunction
function RS_SetPlayerRaceFunc takes nothing returns nothing
local integer player_id = GetConvertedPlayerId(GetEnumPlayer())
call SetUpRaceForPlayer(GetEnumPlayer(), RS_SelectedIndex[player_id])
endfunction
function RS_CloseFrameFunc takes nothing returns nothing
set RS_TimeLeft = 1
set RS_FrameBeingClosed = true
call TriggerSleepAction(1.)
call ForForce( udg_ComputerPlayers, function RS_SetComputerRaceFunc )
call TriggerSleepAction(0.5)
call PlaySound(RS_BeginGameSoundPath)
call TriggerSleepAction(0.5)
call BlzFrameSetVisible(RS_BackgroundFrame, false)
call ForForce( udg_HumanPlayers, function RS_CleanPlayerDataFunc )
call ForForce( udg_PlayingPlayers, function RS_SetPlayerRaceFunc )
call PauseTimer(RS_SelectionTimer)
call DestroyTimer(RS_SelectionTimer)
set RS_SelectionTimer = null
call DestroyTrigger(RS_TriggerManageUsers)
set RS_TriggerManageUsers = null
call StartGame()
endfunction
function RS_ValidateRaceFunc takes nothing returns nothing
call BlzFrameSetEnable(RS_ValidationButton, false)
call BlzFrameSetEnable(RS_ValidationButton, true)
call RS_ValidateRaceForPlayerFunc(GetTriggerPlayer(), true)
endfunction
function RS_SelectRaceFunc takes integer ind returns nothing
local integer player_id = GetConvertedPlayerId(GetTriggerPlayer())
local integer previous_index = RS_SelectedIndex[player_id]
call BlzFrameSetEnable(RS_Button[ind], false)
call BlzFrameSetEnable(RS_Button[ind], true)
call RS_RefreshPlayerShowcaseFunc(GetTriggerPlayer(), ind)
set RS_SelectedIndex[player_id] = ind
if GetLocalPlayer() != GetTriggerPlayer() then
return
endif
call BlzFrameSetAbsPoint(RS_SelectedRaceBlock, FRAMEPOINT_TOPLEFT, RS_RaceBlock_TL_X[ind], RS_RaceBlock_TL_Y[ind])
call BlzFrameSetAbsPoint(RS_SelectedRaceBlock, FRAMEPOINT_BOTTOMRIGHT, RS_RaceBlock_BR_X[ind], RS_RaceBlock_BR_Y[ind])
call BlzFrameSetText(RS_DescriptionTextFrame, RS_Race_Description[ind])
call BlzFrameSetText(RS_DescriptionFooterFrame, RS_Race_Footer[ind])
call BlzFrameSetText(RS_TitleTextFrame[ind], RS_Race_Title[ind])
if previous_index != -1 then
call BlzFrameSetText(RS_TitleTextFrame[previous_index], "|cffFFCC00" + RS_Race_Title[previous_index] + "|r")
endif
endfunction
function RS_Button00Func takes nothing returns nothing
call RS_SelectRaceFunc(0)
endfunction
function RS_Button01Func takes nothing returns nothing
call RS_SelectRaceFunc(1)
endfunction
function RS_Button02Func takes nothing returns nothing
call RS_SelectRaceFunc(2)
endfunction
function RS_Button03Func takes nothing returns nothing
call RS_SelectRaceFunc(3)
endfunction
function RS_Button04Func takes nothing returns nothing
call RS_SelectRaceFunc(4)
endfunction
function RS_Button05Func takes nothing returns nothing
call RS_SelectRaceFunc(5)
endfunction
function RS_RefreshTimerFunc takes nothing returns nothing
local integer i
local string soundpath = ""
local player p
set RS_TimeLeft = RS_TimeLeft - 1
if RS_TimeLeft < 10 then
call BlzFrameSetText(RS_TimerFrame, "|cffFFCC0000:0" + I2S(RS_TimeLeft) + "|r")
else
call BlzFrameSetText(RS_TimerFrame, "|cffFFCC0000:" + I2S(RS_TimeLeft) + "|r")
endif
set i = 1
loop
exitwhen i >= 20
set p = Player(i-1) // start at 1
if RS_TimeLeft <= 5 and RS_TimeLeft > 0 and p == GetLocalPlayer() and not RS_RaceSelected[i] then
set soundpath = RS_TickSoundPath
endif
set i = i + 1
endloop
call PlaySound(soundpath)
set p = null
if RS_TimeLeft <= 0 then
call PauseTimer(RS_SelectionTimer)
call DestroyTimer(RS_SelectionTimer)
set RS_SelectionTimer = null
endif
endfunction
function RS_ManageUsersFunc takes nothing returns nothing
local location l
local integer i
local integer total_locked = 0
local player p
set i = 1
loop
exitwhen i >= 20
set p = Player(i-1) // start at 1
set l = GetPlayerStartLocationLoc(p)
if GetPlayerController(p) == MAP_CONTROL_USER and GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING then
call PanCameraToTimedForPlayer(p, GetLocationX(l), GetLocationY(l), 0) // point where you want to be
call SetCameraFieldForPlayer( p, CAMERA_FIELD_TARGET_DISTANCE, RS_CameraDistance, 0 )
call SetCameraFieldForPlayer( p, CAMERA_FIELD_ANGLE_OF_ATTACK, RS_CameraAngleOfAttack, 0 )
call PanCameraToTimedForPlayer(p, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF) // trick
if not RS_FrameBeingClosed then
if not RS_RaceSelected[i] then
set total_locked = total_locked + 1
endif
if RS_TimeLeft == 0 and not RS_RaceSelected[i] then
set RS_SelectedIndex[i] = udg_Races_IndexRandom
call RS_ValidateRaceForPlayerFunc(p, false)
endif
endif
endif
call RemoveLocation(l)
set i = i + 1
endloop
set l = null
set p = null
if total_locked == 0 and not RS_FrameBeingClosed then
call RS_CloseFrameFunc()
endif
endfunction
function RS_InitializePlayerDataFunc takes nothing returns nothing
local integer player_id = GetConvertedPlayerId(GetEnumPlayer())
set RS_SelectedIndex[player_id] = -1
set RS_RaceSelected[player_id] = false
if GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_USER then
set RS_3DBackround[player_id] = Interface3DElem.createForPlayer(GetEnumPlayer(), "UI\\ShowCaseDefault.mdl", 200 * RS_ShowcaseScale + RS_ShowcaseOffsetX, RS_ShowcaseOffsetY, RS_ShowcaseScale, 0, 90)
set RS_VisibilityModifier[player_id] = CreateFogModifierRectBJ( true, GetEnumPlayer(), FOG_OF_WAR_VISIBLE, RectFromCenterSizeBJ(GetPlayerStartLocationLoc(GetEnumPlayer()), 2000.00, 1200.00) )
endif
endfunction
public function Setup takes nothing returns nothing
local integer i
call ForForce( udg_PlayingPlayers, function RS_InitializePlayerDataFunc )
// call EnableSelect( false, false )
set RS_RaceBlock_TL_X[0] = 0.0522000
set RS_RaceBlock_TL_Y[0] = 0.508650
set RS_RaceBlock_BR_X[0] = 0.179430
set RS_RaceBlock_BR_Y[0] = 0.381130
set RS_Race_Icon[0] = "UI\\RaceSelectionHumanSigil.blp"
set RS_Race_IconHD[0] = "UI\\RaceSelectionHumanSigilHD.blp"
set RS_Race_Title[0] = "The Alliance"
set RS_Race_Description[0] = "The Human Alliance is a conglomeration of Humans, Elves, and Dwarves who devoted themselves to protect the world of Azeroth from cosmic invasions. Both knights and wizards fight side by side on the field of battle. Although the Alliance had once fallen apart, its valiant citizens have once again taken up arms against the enemies of humanity.\n\nThe Human Alliance employs both a strong military and powerful magics in the defense of its shining kingdoms. It has the most versatile army, with good ground and air troops, excellent siege capability, and powerful spellcasters."
set RS_Race_Footer[0] = "|cffFFCC00Unchanged from the original game.|r"
set RS_RaceBlock_TL_X[1] = 0.181120
set RS_RaceBlock_TL_Y[1] = 0.508650
set RS_RaceBlock_BR_X[1] = 0.308350
set RS_RaceBlock_BR_Y[1] = 0.381130
set RS_Race_Icon[1] = "UI\\RaceSelectionOrcSigil.blp"
set RS_Race_IconHD[1] = "UI\\RaceSelectionOrcSigilHD.blp"
set RS_Race_Title[1] = "The Horde"
set RS_Race_Description[1] = "The Orcs, who once cultivated a quiet Shamanistic society upon the world of Draenor, were corrupted by the chaos magics of the Burning Legion and formed into a voracious, unstoppable Horde, which was rallied later on by the powerful Taurens and vicious Trolls.\n\nThe Horde possesses the game's most powerful ground units. It has modest air and ranged capabilities, but its true strength lies in their brute strength and raw melee power. Even the magic of their spellcasters is designed to enhance their frontline troops."
set RS_Race_Footer[1] = "|cffFFCC00Unchanged from the original game.|r"
set RS_RaceBlock_TL_X[2] = 0.306670
set RS_RaceBlock_TL_Y[2] = 0.508650
set RS_RaceBlock_BR_X[2] = 0.433900
set RS_RaceBlock_BR_Y[2] = 0.381130
set RS_Race_Icon[2] = "UI\\RaceSelectionUndeadSigil.blp"
set RS_Race_IconHD[2] = "UI\\RaceSelectionUndeadSigilHD.blp"
set RS_Race_Title[2] = "The Scourge"
set RS_Race_Description[2] = "The horrifying Undead army consists of thousands of walking corpses, disembodied spirits, damned mortal men and insidious extra-dimensional entities. It was created by the Burning Legion for the sole purpose of sowing terror across the world in anticipation of the Legion's inevitable invasion.\n\nThe Undead are a well-balanced faction that can field enduring ground forces and powerful air units. Their spellcasters possess a variety of powerful magics, including the ability to raise fallen allies and foes alike into an army of walking dead."
set RS_Race_Footer[2] = "|cffFFCC00Unchanged from the original game.|r"
set RS_RaceBlock_TL_X[3] = 0.0522000
set RS_RaceBlock_TL_Y[3] = 0.380620
set RS_RaceBlock_BR_X[3] = 0.179430
set RS_RaceBlock_BR_Y[3] = 0.253100
set RS_Race_Icon[3] = "UI\\RaceSelectionNightElfSigil.blp"
set RS_Race_IconHD[3] = "UI\\RaceSelectionNightElfSigilHD.blp"
set RS_Race_Title[3] = "The Night Elves"
set RS_Race_Description[3] = "The reclusive Night Elves were the first race to awaken in Azeroth. Their reckless use of magic drew the Burning Legion into the world and led to a catastrophic war between the two titanic races. The Night Elves barely managed to banish the Legion from the world and ever since closed themselves off from the rest of the world and remained hidden.\n\nThe Night Elves are a mighty race that emphasizes mobility, ranged firepower, and spellcraft. They do not have the brute strength of other races, but their skills with bow and magic more than compensate for this deficiency."
set RS_Race_Footer[3] = "|cffFFCC00Unchanged from the original game.|r"
set RS_RaceBlock_TL_X[4] = 0.181120
set RS_RaceBlock_TL_Y[4] = 0.380620
set RS_RaceBlock_BR_X[4] = 0.308350
set RS_RaceBlock_BR_Y[4] = 0.253100
set RS_Race_Icon[4] = "UI\\RaceSelectionNagaSigil.blp"
set RS_Race_IconHD[4] = "UI\\RaceSelectionNagaSigilHD.blp"
set RS_Race_Title[4] = "The Naga"
set RS_Race_Description[4] = "The Naga are a mysterious and powerful race of serpentine beings with a tragic history rooted in betrayal. They were created after the Sundering when Queen Azshara tried to open a portal for the dark titan Sargeras, which shattered the world and plunged much of it beneath the ocean. Twisted by this underwater magic, the Highborne were reshaped into the Naga, cursed to live forever in the depths. \n\nThe Naga army is fairly balanced, with strong melee and powerful air units. Their spellcasters are versatile and can rescue their allies as well as doom their enemies."
set RS_Race_Footer[4] = "|cffFFCC00Brand new race !|r"
set RS_RaceBlock_TL_X[5] = 0.306670
set RS_RaceBlock_TL_Y[5] = 0.380620
set RS_RaceBlock_BR_X[5] = 0.433900
set RS_RaceBlock_BR_Y[5] = 0.253100
set RS_Race_Icon[5] = "UI\\RaceSelectionRandomSigil.blp"
set RS_Race_Title[5] = "Random"
set RS_Race_Description[5] = "Randomness is a concept we encounter every day, yet it’s one that seems to defy our instinct to find patterns, predict outcomes, and establish order. In essence, randomness is the occurrence of events or choices without a predictable pattern or purpose. This idea exists not just in the abstract but in the very fabric of nature and the universe itself.\n\nRandomness is an essential driver of diversity, creativity, and possibility. From the roll of dice to the complex arrangements of stars in the sky, it reveals itself in small and vast ways alike."
set RS_Race_Footer[5] = "|cffFFCC00You will be given a random race.|r"
// Picking phase blocks
set RS_BackgroundFrame = BlzCreateFrameByType("BACKDROP", "BACKDROP", BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0), "", 1)
call BlzFrameSetAbsPoint(RS_BackgroundFrame, FRAMEPOINT_TOPLEFT, 0.0158500, 0.563290)
call BlzFrameSetAbsPoint(RS_BackgroundFrame, FRAMEPOINT_BOTTOMRIGHT, 0.781910, 0.164570)
call BlzFrameSetTexture(RS_BackgroundFrame, "UI\\RaceSelectionBackground.blp", 0, true)
set i = 0
loop
exitwhen i > 5
set RS_RaceBlock[i] = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_BackgroundFrame, "", 1)
call BlzFrameSetAbsPoint(RS_RaceBlock[i], FRAMEPOINT_TOPLEFT, RS_RaceBlock_TL_X[i], RS_RaceBlock_TL_Y[i])
call BlzFrameSetAbsPoint(RS_RaceBlock[i], FRAMEPOINT_BOTTOMRIGHT, RS_RaceBlock_BR_X[i], RS_RaceBlock_BR_Y[i])
call BlzFrameSetTexture(RS_RaceBlock[i], "UI\\RaceSelectionButton.blp", 0, true)
set RS_TitleTextFrame[i] = BlzCreateFrameByType("TEXT", "name", RS_RaceBlock[i], "", 0)
call BlzFrameSetAbsPoint(RS_TitleTextFrame[i], FRAMEPOINT_TOPLEFT, RS_RaceBlock_TL_X[i] + 0.02477, RS_RaceBlock_TL_Y[i] - 0.08284)
call BlzFrameSetAbsPoint(RS_TitleTextFrame[i], FRAMEPOINT_BOTTOMRIGHT, RS_RaceBlock_BR_X[i] - 0.02337, RS_RaceBlock_BR_Y[i] + 0.02965)
call BlzFrameSetText(RS_TitleTextFrame[i], "|cffFFCC00" + RS_Race_Title[i] + "|r")
call BlzFrameSetEnable(RS_TitleTextFrame[i], false)
call BlzFrameSetScale(RS_TitleTextFrame[i], 1.00)
call BlzFrameSetTextAlignment(RS_TitleTextFrame[i], TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_MIDDLE)
set i = i + 1
endloop
set RS_SelectedRaceBlock = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_BackgroundFrame, "", 1)
call BlzFrameSetAbsPoint(RS_SelectedRaceBlock, FRAMEPOINT_TOPLEFT, 1, 1)
call BlzFrameSetAbsPoint(RS_SelectedRaceBlock, FRAMEPOINT_BOTTOMRIGHT, 1, 1)
call BlzFrameSetTexture(RS_SelectedRaceBlock, "UI\\RaceSelectionButtonSelected.blp", 0, true)
set RS_HDSigilBlock = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_BackgroundFrame, "", 1)
call BlzFrameSetAbsPoint(RS_HDSigilBlock, FRAMEPOINT_TOPLEFT, 0.134460, 0.51107)
call BlzFrameSetAbsPoint(RS_HDSigilBlock, FRAMEPOINT_BOTTOMRIGHT, 0.355880, 0.286730)
call BlzFrameSetVisible(RS_HDSigilBlock, false)
set RS_HDTitleBlock = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_BackgroundFrame, "", 1)
call BlzFrameSetAbsPoint(RS_HDTitleBlock, FRAMEPOINT_TOPLEFT, 0.157, 0.343)
call BlzFrameSetAbsPoint(RS_HDTitleBlock, FRAMEPOINT_BOTTOMRIGHT, 0.337, 0.253)
call BlzFrameSetTexture(RS_HDTitleBlock, "UI\\RaceSelectionTitleHD.blp", 0, true)
call BlzFrameSetVisible(RS_HDTitleBlock, false)
set RS_HDTitleFrame = BlzCreateFrameByType("TEXT", "name", RS_HDTitleBlock, "", 0)
call BlzFrameSetAbsPoint(RS_HDTitleFrame, FRAMEPOINT_TOPLEFT, 0.157, 0.343)
call BlzFrameSetAbsPoint(RS_HDTitleFrame, FRAMEPOINT_BOTTOMRIGHT, 0.337, 0.253)
call BlzFrameSetEnable(RS_HDTitleFrame, false)
call BlzFrameSetScale(RS_HDTitleFrame, 1.29)
call BlzFrameSetTextAlignment(RS_HDTitleFrame, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_CENTER)
set i = 0
loop
exitwhen i > 5
set RS_RaceSigilFrame[i] = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_SelectedRaceBlock, "", 1)
call BlzFrameSetAbsPoint(RS_RaceSigilFrame[i], FRAMEPOINT_TOPLEFT, RS_RaceBlock_TL_X[i] + 0.03171, RS_RaceBlock_TL_Y[i] - 0.01944)
call BlzFrameSetAbsPoint(RS_RaceSigilFrame[i], FRAMEPOINT_BOTTOMRIGHT, RS_RaceBlock_BR_X[i] - 0.0304, RS_RaceBlock_BR_Y[i] + 0.04296)
call BlzFrameSetTexture(RS_RaceSigilFrame[i], RS_Race_Icon[i], 0, true)
set RS_Button[i] = BlzCreateFrame("IconButtonTemplate", RS_RaceBlock[i], 0, 0)
call BlzFrameSetAbsPoint(RS_Button[i], FRAMEPOINT_TOPLEFT, RS_RaceBlock_TL_X[i] + 0.03171 + 0.001, RS_RaceBlock_TL_Y[i] - 0.01944 - 0.001)
call BlzFrameSetAbsPoint(RS_Button[i], FRAMEPOINT_BOTTOMRIGHT, RS_RaceBlock_BR_X[i] - 0.0304 - 0.002, RS_RaceBlock_BR_Y[i] + 0.04296 + 0.004)
set RS_Trigger_Button[i] = CreateTrigger()
call BlzTriggerRegisterFrameEvent(RS_Trigger_Button[i], RS_Button[i], FRAMEEVENT_CONTROL_CLICK)
set i = i + 1
endloop
call TriggerAddAction(RS_Trigger_Button[0], function RS_Button00Func)
call TriggerAddAction(RS_Trigger_Button[1], function RS_Button01Func)
call TriggerAddAction(RS_Trigger_Button[2], function RS_Button02Func)
call TriggerAddAction(RS_Trigger_Button[3], function RS_Button03Func)
call TriggerAddAction(RS_Trigger_Button[4], function RS_Button04Func)
call TriggerAddAction(RS_Trigger_Button[5], function RS_Button05Func)
set RS_ValidationButton = BlzCreateFrame("ScriptDialogButton", RS_BackgroundFrame, 0, 0)
call BlzFrameSetAbsPoint(RS_ValidationButton, FRAMEPOINT_TOPLEFT, 0.196160, 0.256530)
call BlzFrameSetAbsPoint(RS_ValidationButton, FRAMEPOINT_BOTTOMRIGHT, 0.296160, 0.223060)
call BlzFrameSetText(RS_ValidationButton, "|cffFCD20DI'm ready|r")
call BlzFrameSetScale(RS_ValidationButton, 1.00)
set RS_TriggerValidateRace = CreateTrigger()
call BlzTriggerRegisterFrameEvent(RS_TriggerValidateRace, RS_ValidationButton, FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(RS_TriggerValidateRace, function RS_ValidateRaceFunc)
set RS_TriggerManageUsers = CreateTrigger()
call TriggerRegisterTimerEventPeriodic( RS_TriggerManageUsers, 0.05 )
call TriggerAddAction( RS_TriggerManageUsers, function RS_ManageUsersFunc )
set RS_LogoFrame = BlzCreateFrameByType("BACKDROP", "BACKDROP", RS_BackgroundFrame, "", 1)
call BlzFrameSetAbsPoint(RS_LogoFrame, FRAMEPOINT_TOPLEFT, 0.325, 0.258)
call BlzFrameSetAbsPoint(RS_LogoFrame, FRAMEPOINT_BOTTOMRIGHT, 0.475, 0.108)
// call BlzFrameSetAbsPoint(RS_LogoFrame, FRAMEPOINT_TOPLEFT, 0.025, 0.60)
// call BlzFrameSetAbsPoint(RS_LogoFrame, FRAMEPOINT_BOTTOMRIGHT, 0.150, 0.485)
call BlzFrameSetTexture(RS_LogoFrame, "UI\\FKOA_logo.blp", 0, true)
set RS_HeaderTextFrame = BlzCreateFrameByType("TEXT", "name", RS_BackgroundFrame, "", 0)
call BlzFrameSetAbsPoint(RS_HeaderTextFrame, FRAMEPOINT_TOPLEFT, 0.246400, 0.54070)
call BlzFrameSetAbsPoint(RS_HeaderTextFrame, FRAMEPOINT_BOTTOMRIGHT, 0.556950, 0.52000)
call BlzFrameSetText(RS_HeaderTextFrame, "|cffFFCC00Pick up your race wisely|r")
call BlzFrameSetEnable(RS_HeaderTextFrame, false)
call BlzFrameSetScale(RS_HeaderTextFrame, 1.5)
call BlzFrameSetTextAlignment(RS_HeaderTextFrame, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_MIDDLE)
set RS_TimerFrame = BlzCreateFrameByType("TEXT", "name", RS_BackgroundFrame, "", 0)
call BlzFrameSetAbsPoint(RS_TimerFrame, FRAMEPOINT_TOPLEFT, 0.346400, 0.525070)
call BlzFrameSetAbsPoint(RS_TimerFrame, FRAMEPOINT_BOTTOMRIGHT, 0.456950, 0.505000)
call BlzFrameSetText(RS_TimerFrame, "|cffFFCC0000:" + I2S(RS_TimeLeft) + "|r")
call BlzFrameSetEnable(RS_TimerFrame, false)
call BlzFrameSetScale(RS_TimerFrame, 1.2)
call BlzFrameSetTextAlignment(RS_TimerFrame, TEXT_JUSTIFY_CENTER, TEXT_JUSTIFY_MIDDLE)
set RS_DescriptionTextBlock = BlzCreateFrame("CheckListBox", RS_BackgroundFrame, 0, 0)
call BlzFrameSetAbsPoint(RS_DescriptionTextBlock, FRAMEPOINT_TOPLEFT, 0.472960, 0.353430)
call BlzFrameSetAbsPoint(RS_DescriptionTextBlock, FRAMEPOINT_BOTTOMRIGHT, 0.703540, 0.220970)
set RS_DescriptionTextFrame = BlzCreateFrameByType("TEXT", "name", RS_DescriptionTextBlock, "", 0)
call BlzFrameSetAbsPoint(RS_DescriptionTextFrame, FRAMEPOINT_TOPLEFT, 0.484660, 0.341010)
call BlzFrameSetAbsPoint(RS_DescriptionTextFrame, FRAMEPOINT_BOTTOMRIGHT, 0.692960, 0.232490)
call BlzFrameSetEnable(RS_DescriptionTextFrame, false)
call BlzFrameSetScale(RS_DescriptionTextFrame, 0.858)
call BlzFrameSetTextAlignment(RS_DescriptionTextFrame, TEXT_JUSTIFY_TOP, TEXT_JUSTIFY_LEFT)
set RS_DescriptionFooterFrame = BlzCreateFrameByType("TEXT", "name", RS_DescriptionTextBlock, "", 0)
call BlzFrameSetAbsPoint(RS_DescriptionFooterFrame, FRAMEPOINT_TOPLEFT, 0.485210, 0.239320)
call BlzFrameSetAbsPoint(RS_DescriptionFooterFrame, FRAMEPOINT_BOTTOMRIGHT, 0.692400, 0.217060)
call BlzFrameSetEnable(RS_DescriptionFooterFrame, false)
call BlzFrameSetScale(RS_DescriptionFooterFrame, 0.858)
call BlzFrameSetTextAlignment(RS_DescriptionFooterFrame, TEXT_JUSTIFY_TOP, TEXT_JUSTIFY_LEFT)
set RS_SelectionTimer = CreateTimer()
set RS_TriggerRefreshTimer = CreateTrigger()
call TriggerRegisterTimerExpireEventBJ( RS_TriggerRefreshTimer, RS_SelectionTimer )
call TriggerAddAction( RS_TriggerRefreshTimer, function RS_RefreshTimerFunc )
call StartTimerBJ( RS_SelectionTimer, true, 1. )
endfunction
endscope
library FrameLoader initializer init_function
// in 1.31 and upto 1.32.9 PTR (when I wrote this). Frames are not correctly saved and loaded, breaking the game.
// This library runs all functions added to it with a 0s delay after the game was loaded.
// function FrameLoaderAdd takes code func returns nothing
// func runs when the game is loaded.
globals
private trigger eventTrigger = CreateTrigger()
private trigger actionTrigger = CreateTrigger()
private timer t = CreateTimer()
endglobals
function FrameLoaderAdd takes code func returns nothing
call TriggerAddAction(actionTrigger, func)
endfunction
private function timerAction takes nothing returns nothing
call TriggerExecute(actionTrigger)
endfunction
private function eventAction takes nothing returns nothing
call TimerStart(t, 0, false, function timerAction)
endfunction
private function init_function takes nothing returns nothing
call TriggerRegisterGameEvent(eventTrigger, EVENT_GAME_LOADED)
call TriggerAddAction(eventTrigger, function eventAction)
endfunction
endlibrary
library CustomConsoleUI initializer init_function requires optional FrameLoader
// CustomConsoleUI by Tasyen
// CustomConsoleUI allows to change the UI during the game, when setuped correctly. This excludes the mouse cursor and the UI sounds.
// In non reforged it can also not change the Idle worker Button nor the no inventory cover.
// How to setup this: First you have to make the default Console Textures be hidden that is done in Game Interface.
// Set ConsoleTexture01 to ConsoleTexture06 to UI\Widgets\EscMenu\Human\blank-background.blp
// The Day of Time clock has hardcoded textures therefore you need to swap it out. That also should be done in Gameinterface.
// TimeOfDayIndicator to the model included in this system.
// Now export and Import war3mapImported\CustomConsoleUI.toc & war3mapImported\CustomConsoleUI.fdf
// Finally you have to set the used textures into local data
globals
private framehandle idleWorkerButton
private framehandle idleWorkerButtonChild
private framehandle idleWorkerButtonOverlay
private framehandle idleWorkerButtonOverlayParent
private framehandle customInventoryCover
private framehandle customInventoryCoverParent
public string array data
public integer array dataCount
private integer dataPageSize = 11
private real ratio = 1
public boolean is_v2 = true
public real array x
public real array y
private constant boolean workerFace = true
endglobals
function AddCustomConsole takes integer index, string texture returns nothing
set dataCount[index] = dataCount[index] + 1
set data[index*dataPageSize + dataCount[index]] = texture
endfunction
function refreshFramesDimensions takes player p returns nothing
local framehandle f
local real factor
if GetLocalPlayer() != p then
return
endif
set f = BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 1) // to determine ratio
set ratio = (BlzFrameGetHeight(f) / 0.065) - 1.
set factor = 0.5*(ratio + 1)
set f = BlzGetFrameByName("CustomConsoleUI1B", 0)
call BlzFrameSetSize(f, 0.256*factor, 0.176*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMLEFT, 0.2 * (1 - ratio), 0)
set f = BlzGetFrameByName("CustomConsoleUI2B", 0)
call BlzFrameSetSize(f, 0.256*factor, 0.150*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMLEFT, 0.256*factor + 0.2 * (1 - ratio), 0)
set f = BlzGetFrameByName("CustomConsoleUI3B", 0)
call BlzFrameSetSize(f, 0.256*factor, 0.176*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMRIGHT, 0.768*factor + 0.2 * (1 - ratio), 0)
set f = BlzGetFrameByName("CustomConsoleUI4B", 0)
call BlzFrameSetSize(f, 0.032*factor, 0.176*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMRIGHT, 0.8*factor + 0.2 * (1 - ratio), 0)
set f = BlzGetFrameByName("CustomConsoleUI5B", 0)
call BlzFrameSetSize(f, 0.256*factor, 0.176*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMLEFT, 0.2 * (1 - ratio) - 0.256*factor, 0)
set f = BlzGetFrameByName("CustomConsoleUI6B", 0)
call BlzFrameSetSize(f, 0.256*factor, 0.176*factor)
call BlzFrameSetAbsPoint(f, FRAMEPOINT_BOTTOMRIGHT, 1.056*factor + 0.2 * (1 - ratio), 0)
endfunction
function UseCustomConsole takes player p, integer index returns nothing
local integer pageValue
if GetLocalPlayer() != p then
return
endif
set pageValue = index*dataPageSize
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI5T", 0), data[pageValue + 5], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI6T", 0), data[pageValue + 6], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI4T", 0), data[pageValue + 4], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI3T", 0), data[pageValue + 3], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2TL", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2TR", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI1T", 0), data[pageValue + 1], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI1B", 0), data[pageValue + 1], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI2B", 0), data[pageValue + 2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI3B", 0), data[pageValue + 3], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI4B", 0), data[pageValue + 4], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI5B", 0), data[pageValue + 5], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUI6B", 0), data[pageValue + 6], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("CustomConsoleUIClock", 0), data[pageValue + 7] ,0, true)
if GetLocalizedString("REFORGED") != "REFORGED" then
call BlzFrameSetTexture(BlzGetFrameByName("InventoryCoverTexture", 0), data[pageValue + 8] ,0, true)
static if workerFace then
call BlzFrameSetTexture(idleWorkerButtonOverlay, data[pageValue + 9], 0, false)
endif
else
call BlzFrameSetTexture(customInventoryCover, data[pageValue + 8] ,0, true)
endif
call BlzFrameSetPoint(BlzGetFrameByName("CustomConsoleUIClock", 0), FRAMEPOINT_TOP, BlzGetFrameByName("ConsoleUI", 0), FRAMEPOINT_TOP, x[index], y[index])
call refreshFramesDimensions(p)
endfunction
function CreateCustomConsole takes nothing returns nothing
call BlzLoadTOCFile( "UI\\CustomUI\\CustomConsoleUI.toc" )
call BlzCreateSimpleFrame( "CustomConsoleUI", BlzGetFrameByName("ConsoleUI", 0), 0)
call BlzFrameSetLevel(BlzGetFrameByName("CustomConsoleUI", 0), 0)
if GetLocalizedString("REFORGED") != "REFORGED" then
// Requires a native existing only in Reforged
static if workerFace then
if is_v2 then
set idleWorkerButton = BlzFrameGetChild(BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 1), 3)
else
set idleWorkerButton = BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 7)
endif
set idleWorkerButtonChild = BlzFrameGetChild(idleWorkerButton, 0)
set idleWorkerButtonOverlayParent = BlzCreateSimpleFrame( "SimpleTextureFrame", idleWorkerButton, 0 )
set idleWorkerButtonOverlay = BlzGetFrameByName("SimpleTextureFrameValue", 0)
call BlzFrameSetAllPoints(idleWorkerButtonOverlay, idleWorkerButton)
call BlzFrameSetLevel(idleWorkerButtonOverlayParent, 4)
endif
else
set customInventoryCoverParent = BlzCreateSimpleFrame( "SimpleTextureFrame", BlzGetFrameByName("ConsoleUI", 0), 0)
call BlzFrameSetLevel(customInventoryCoverParent, 4)
set customInventoryCover = BlzGetFrameByName("SimpleTextureFrameValue", 0)
call BlzFrameSetAbsPoint(customInventoryCover, FRAMEPOINT_BOTTOMRIGHT, 0.6, 0)
call BlzFrameSetAbsPoint(customInventoryCover, FRAMEPOINT_TOPLEFT, 0.6 - 0.128, 0.2558)
endif
// Preload
call BlzGetOriginFrame(ORIGIN_FRAME_ITEM_BUTTON, 0)
call BlzGetFrameByName("InventoryCoverTexture", 0)
call BlzGetFrameByName("CustomConsoleUIClock", 0)
call BlzGetFrameByName("CustomConsoleUI5T", 0)
call BlzGetFrameByName("CustomConsoleUI6T", 0)
call BlzGetFrameByName("CustomConsoleUI4T", 0)
call BlzGetFrameByName("CustomConsoleUI3T", 0)
call BlzGetFrameByName("CustomConsoleUI2TL", 0)
call BlzGetFrameByName("CustomConsoleUI2TR", 0)
call BlzGetFrameByName("CustomConsoleUI1T", 0)
call BlzGetFrameByName("CustomConsoleUI1B", 0)
call BlzGetFrameByName("CustomConsoleUI2B", 0)
call BlzGetFrameByName("CustomConsoleUI3B", 0)
call BlzGetFrameByName("CustomConsoleUI4B", 0)
call BlzGetFrameByName("CustomConsoleUI5B", 0)
call BlzGetFrameByName("CustomConsoleUI6B", 0)
if is_v2 then
call BlzFrameSetVisible(BlzFrameGetChild(BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 1), 0), false) // new borders
endif
endfunction
private function Init takes nothing returns nothing
call CreateCustomConsole()
call UseCustomConsole(GetLocalPlayer(), 0)
endfunction
private function at0s takes nothing returns nothing
call Init()
call DestroyTimer(GetExpiredTimer())
endfunction
private function update takes nothing returns nothing
// call BlzFrameSetVisible(idleWorkerButtonOverlayParent, BlzFrameIsVisible(idleWorkerButtonChild))
if BlzFrameIsVisible(idleWorkerButtonChild) then
call BlzFrameSetAlpha(idleWorkerButton, 255)
else
call BlzFrameSetAlpha(idleWorkerButton, 0)
endif
endfunction
private function checkRatio takes nothing returns nothing
local real current_ratio = (BlzFrameGetHeight(BlzFrameGetChild(BlzGetFrameByName("ConsoleUI", 0), 1)) / 0.065) - 1.
if ratio != current_ratio then
call refreshFramesDimensions(GetLocalPlayer())
endif
endfunction
private function init_function takes nothing returns nothing
local integer index = 0
call TriggerSleepAction(0.1)
set index = udg_Races_IndexHuman
call AddCustomConsole(index, "ui\\console\\human\\humanuitile01")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile02")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile03")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile04")
if is_v2 then
call AddCustomConsole(index, "ui\\console\\human\\humanuitile05overlay")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile06overlay")
else
call AddCustomConsole(index, "ui\\console\\human\\humanuitile05")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile06")
endif
call AddCustomConsole(index, "ui\\console\\human\\humanuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\human\\humanuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNPeasant")
// offset this mostly is used to fit to the glowing orbs showing the houers
set x[index] = 0.0009
set y[index] = 0.0
set index = udg_Races_IndexOrc
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile01")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile02")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile03")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile04")
if is_v2 then
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile05overlay")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile06overlay")
else
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile05")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile06")
endif
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\orc\\orcuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNPeon")
set x[index] = 0.0004
set y[index] = 0.0
set index = udg_Races_IndexUndead
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile01")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile02")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile03")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile04")
if is_v2 then
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile05overlay")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile06overlay")
else
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile05")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile06")
endif
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\undead\\undeaduitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNAcolyte")
set x[index] = 0.0009
set y[index] = 0.0
set index = udg_Races_IndexNightElf
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile01")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile02")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile03")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile04")
if is_v2 then
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile05overlay")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile06overlay")
else
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile05")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile06")
endif
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile-timeindicatorframe")
call AddCustomConsole(index, "ui\\console\\nightelf\\nightelfuitile-inventorycover")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNWisp")
set x[index] = 0.0009
set y[index] = 0.0
set index = udg_Races_IndexNaga
call AddCustomConsole(index, "UI\\Naga\\tile01.blp")
call AddCustomConsole(index, "UI\\Naga\\tile02.blp")
call AddCustomConsole(index, "UI\\Naga\\tile03.blp")
call AddCustomConsole(index, "UI\\Naga\\tile04.blp")
call AddCustomConsole(index, "UI\\Naga\\tile05.blp")
call AddCustomConsole(index, "UI\\Naga\\tile06.blp")
call AddCustomConsole(index, "UI\\Naga\\timeindicatorframe.blp")
call AddCustomConsole(index, "UI\\Naga\\inventorycover.blp")
call AddCustomConsole(index, "ReplaceableTextures\\CommandButtons\\BTNMurgalSlave")
set x[index] = 0.0000
set y[index] = 0.0
if workerFace then
call TimerStart(CreateTimer(), 0.02, true, function update)
endif
call TimerStart(CreateTimer(), 1, true, function checkRatio)
call TimerStart(CreateTimer(), 0, false, function at0s)
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function Init)
endif
endfunction
endlibrary
function Trig_Demo_Actions takes nothing returns nothing
if ( StringCase(GetEventPlayerChatString(), false) == "human" ) then
call UseCustomConsole(GetTriggerPlayer(), udg_Races_IndexHuman)
else
endif
if ( StringCase(GetEventPlayerChatString(), false) == "orc" ) then
call BJDebugMsg("hey")
call UseCustomConsole(GetTriggerPlayer(), udg_Races_IndexOrc)
else
endif
if ( StringCase(GetEventPlayerChatString(), false) == "undead" ) then
call UseCustomConsole(GetTriggerPlayer(), udg_Races_IndexUndead)
else
endif
if ( StringCase(GetEventPlayerChatString(), false) == "nightelf" ) then
call UseCustomConsole(GetTriggerPlayer(), udg_Races_IndexNightElf)
else
endif
if ( StringCase(GetEventPlayerChatString(), false) == "naga" ) then
call UseCustomConsole(GetTriggerPlayer(), udg_Races_IndexNaga)
else
endif
endfunction
//===========================================================================
function InitTrig_Demo takes nothing returns nothing
set gg_trg_Demo = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Demo, Player(0), "", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Demo, Player(1), "", false )
call TriggerAddAction( gg_trg_Demo, function Trig_Demo_Actions )
endfunction
function Trig_Race_Upgrades_Init_Func001A takes nothing returns nothing
if ( GetPlayerController(GetEnumPlayer()) == MAP_CONTROL_COMPUTER and GetPlayerSlotState(GetEnumPlayer()) == PLAYER_SLOT_STATE_PLAYING) then
return
endif
// Human
call SetPlayerUnitAvailableBJ( 'hkee', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'hcas', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'hgtw', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'hctw', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'hatw', false, GetEnumPlayer() )
call SaveIntegerBJ( 'hkee', 'R00I', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'hcas', 'R00M', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'hgtw', 'R00J', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'hctw', 'R00K', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'hatw', 'R00L', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
// Orc
call SetPlayerUnitAvailableBJ( 'ostr', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'ofrt', false, GetEnumPlayer() )
call SaveIntegerBJ( 'ostr', 'R00N', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'ofrt', 'R00O', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
// Night Elf
call SetPlayerUnitAvailableBJ( 'etoa', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'etoe', false, GetEnumPlayer() )
call SaveIntegerBJ( 'etoa', 'R00R', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'etoe', 'R00S', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
// Undead
call SetPlayerUnitAvailableBJ( 'unp1', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'unp2', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'uzg1', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'uzg2', false, GetEnumPlayer() )
call SaveIntegerBJ( 'unp1', 'R00P', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'unp2', 'R00Q', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'uzg1', 'R00V', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'uzg2', 'R00W', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
// Naga
call SetPlayerUnitAvailableBJ( 'h009', false, GetEnumPlayer() )
call SetPlayerUnitAvailableBJ( 'h00A', false, GetEnumPlayer() )
call SaveIntegerBJ( 'h009', 'R00T', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
call SaveIntegerBJ( 'h00A', 'R00U', udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
endfunction
function Trig_Race_Upgrades_Init_Actions takes nothing returns nothing
call ForForce( udg_PlayingPlayers, function Trig_Race_Upgrades_Init_Func001A )
endfunction
//===========================================================================
function InitTrig_Race_Upgrades_Init takes nothing returns nothing
set gg_trg_Race_Upgrades_Init = CreateTrigger( )
call TriggerAddAction( gg_trg_Race_Upgrades_Init, function Trig_Race_Upgrades_Init_Actions )
endfunction
function Trig_Race_Upgrades_Conversion_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) != udg_UnitData_DummyResearcher
endfunction
function Trig_Race_Upgrades_Conversion_Actions takes nothing returns nothing
local integer upgradeid = LoadIntegerBJ( GetResearched(), udg_Dict_Research_IndexUpgradeEq, udg_DictHT )
if upgradeid == 0 then
return
endif
// queue line is up to 7
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call IssueImmediateOrderById(GetTriggerUnit(), 851976 )
call SetPlayerUnitAvailableBJ( upgradeid, true, GetOwningPlayer(GetTriggerUnit()) )
call IssueTrainOrderByIdBJ( GetTriggerUnit(), upgradeid )
call SetPlayerUnitAvailableBJ( upgradeid, false, GetOwningPlayer(GetTriggerUnit()) )
endfunction
//===========================================================================
function InitTrig_Race_Upgrades_Conversion takes nothing returns nothing
set gg_trg_Race_Upgrades_Conversion = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Race_Upgrades_Conversion, EVENT_PLAYER_UNIT_RESEARCH_START )
call TriggerAddCondition( gg_trg_Race_Upgrades_Conversion, Condition( function Trig_Race_Upgrades_Conversion_Conditions ) )
call TriggerAddAction( gg_trg_Race_Upgrades_Conversion, function Trig_Race_Upgrades_Conversion_Actions )
endfunction
function ShopAnalyseItemIsSellable takes unit shop, integer item_type, player p, boolean play_extra_sounds, boolean force_buy returns nothing
local integer pid = GetConvertedPlayerId(p)
local integer current_gold = GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD)
local integer current_lumber = GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER)
local integer race_index = udg_Races_PlayersRace[pid]
local boolean buy_success
local integer target_max_slots
local unit target
local real range
local string sound_string = ""
if item_type == 0 then
return
endif
if play_extra_sounds then
if GetLocalPlayer() == p then
set sound_string = "Sound\\Interface\\MouseClick1.wav"
endif
call PlaySound(sound_string)
// call PlaySoundLocally(gg_snd_MouseClick1, p)
endif
if GetItemGoldCost(item_type) > current_gold then
call PlaySoundLocally(udg_Races_Sound_NoGold[race_index], p)
return
endif
if GetItemLumberCost(item_type) > current_lumber then
call PlaySoundLocally(udg_Races_Sound_NoLumber[race_index], p)
return
endif
if force_buy then
set buy_success = IssueNeutralImmediateOrderById(p, shop, item_type)
if buy_success then
return
endif
endif
set range = SBD_GetRangeByType(GetUnitTypeId(shop))
set target = LoadUnitHandleBJ(GetConvertedPlayerId(p), GetHandleIdBJ(shop), udg_SBD_HT)
if target == null or not SBD_IsUnitCandidateWithRange(shop, target, p, range) then
set target = SBD_RetrieveClosestTargetForPlayer(shop, p, range)
endif
if IsUnitType(target, UNIT_TYPE_HERO) then
set target_max_slots = 6
else
set target_max_slots = 2
endif
if target != null and UnitInventoryCount(target) >= target_max_slots then
call PlaySoundLocally(udg_Races_Sound_InventoryFull[race_index], p)
else
if play_extra_sounds then
if GetLocalPlayer() == p then
set sound_string = "Sound\\Interface\\Error.wav"
endif
call PlaySound(sound_string)
// call PlaySoundLocally(gg_snd_Error, p)
endif
endif
endfunction
function Trig_Race_Items_InitPlayerClicks takes nothing returns nothing
call TriggerRegisterPlayerMouseEventBJ( gg_trg_Race_Items_Click, GetEnumPlayer(), bj_MOUSEEVENTTYPE_UP )
endfunction
function Trig_Race_Items_Init_Actions takes nothing returns nothing
// Human
call SaveIntegerBJ( 'I009', 0, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00A', 1, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00B', 2, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00C', 4, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00D', 5, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00R', 7, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00F', 8, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ( 'I00E', 9, 'hvlt', udg_FBS_HT )
call SaveIntegerBJ('I009', 'hvlt', GetHandleIdBJ(OSKEY_R), udg_HotkeysHT )
call SaveIntegerBJ('I00A', 'hvlt', GetHandleIdBJ(OSKEY_C), udg_HotkeysHT )
call SaveIntegerBJ('I00B', 'hvlt', GetHandleIdBJ(OSKEY_E), udg_HotkeysHT )
call SaveIntegerBJ('I00C', 'hvlt', GetHandleIdBJ(OSKEY_P), udg_HotkeysHT )
call SaveIntegerBJ('I00D', 'hvlt', GetHandleIdBJ(OSKEY_M), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'hvlt', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I00R', 'hvlt', GetHandleIdBJ(OSKEY_V), udg_HotkeysHT )
call SaveIntegerBJ('I00E', 'hvlt', GetHandleIdBJ(OSKEY_N), udg_HotkeysHT )
call SaveIntegerBJ('I00F', 'hvlt', GetHandleIdBJ(OSKEY_F), udg_HotkeysHT )
// Orc
call SaveIntegerBJ( 'I007', 0, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00A', 1, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00O', 2, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00C', 4, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00D', 5, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00P', 8, 'ovln', udg_FBS_HT )
call SaveIntegerBJ( 'I00S', 9, 'ovln', udg_FBS_HT )
call SaveIntegerBJ('I007', 'ovln', GetHandleIdBJ(OSKEY_H), udg_HotkeysHT )
call SaveIntegerBJ('I00A', 'ovln', GetHandleIdBJ(OSKEY_C), udg_HotkeysHT )
call SaveIntegerBJ('I00O', 'ovln', GetHandleIdBJ(OSKEY_S), udg_HotkeysHT )
call SaveIntegerBJ('I00C', 'ovln', GetHandleIdBJ(OSKEY_P), udg_HotkeysHT )
call SaveIntegerBJ('I00D', 'ovln', GetHandleIdBJ(OSKEY_M), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'ovln', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I00P', 'ovln', GetHandleIdBJ(OSKEY_G), udg_HotkeysHT )
call SaveIntegerBJ('I00S', 'ovln', GetHandleIdBJ(OSKEY_L), udg_HotkeysHT )
// Night Elf
call SaveIntegerBJ( 'I00G', 0, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00A', 1, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00T', 3, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00C', 4, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00D', 5, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00V', 7, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00X', 8, 'eden', udg_FBS_HT )
call SaveIntegerBJ( 'I00W', 9, 'eden', udg_FBS_HT )
call SaveIntegerBJ('I00G', 'eden', GetHandleIdBJ(OSKEY_N), udg_HotkeysHT )
call SaveIntegerBJ('I00A', 'eden', GetHandleIdBJ(OSKEY_C), udg_HotkeysHT )
call SaveIntegerBJ('I00T', 'eden', GetHandleIdBJ(OSKEY_D), udg_HotkeysHT )
call SaveIntegerBJ('I00C', 'eden', GetHandleIdBJ(OSKEY_P), udg_HotkeysHT )
call SaveIntegerBJ('I00D', 'eden', GetHandleIdBJ(OSKEY_M), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'eden', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I00V', 'eden', GetHandleIdBJ(OSKEY_E), udg_HotkeysHT )
call SaveIntegerBJ('I00X', 'eden', GetHandleIdBJ(OSKEY_A), udg_HotkeysHT )
call SaveIntegerBJ('I00W', 'eden', GetHandleIdBJ(OSKEY_V), udg_HotkeysHT )
// Undead
call SaveIntegerBJ( 'I00K', 0, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00J', 1, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00L', 2, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00T', 3, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00C', 4, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00D', 5, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00U', 8, 'utom', udg_FBS_HT )
call SaveIntegerBJ( 'I00M', 9, 'utom', udg_FBS_HT )
call SaveIntegerBJ('I00K', 'utom', GetHandleIdBJ(OSKEY_R), udg_HotkeysHT )
call SaveIntegerBJ('I00J', 'utom', GetHandleIdBJ(OSKEY_A), udg_HotkeysHT )
call SaveIntegerBJ('I00L', 'utom', GetHandleIdBJ(OSKEY_K), udg_HotkeysHT )
call SaveIntegerBJ('I00T', 'utom', GetHandleIdBJ(OSKEY_D), udg_HotkeysHT )
call SaveIntegerBJ('I00C', 'utom', GetHandleIdBJ(OSKEY_P), udg_HotkeysHT )
call SaveIntegerBJ('I00D', 'utom', GetHandleIdBJ(OSKEY_M), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'utom', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I00U', 'utom', GetHandleIdBJ(OSKEY_B), udg_HotkeysHT )
call SaveIntegerBJ('I00M', 'utom', GetHandleIdBJ(OSKEY_H), udg_HotkeysHT )
// Naga
call SaveIntegerBJ( 'I002', 0, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I00A', 1, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I001', 2, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I00C', 4, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I00D', 5, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I006', 7, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I004', 8, 'h000', udg_FBS_HT )
call SaveIntegerBJ( 'I005', 9, 'h000', udg_FBS_HT )
call SaveIntegerBJ('I002', 'h000', GetHandleIdBJ(OSKEY_Q), udg_HotkeysHT )
call SaveIntegerBJ('I00A', 'h000', GetHandleIdBJ(OSKEY_C), udg_HotkeysHT )
call SaveIntegerBJ('I001', 'h000', GetHandleIdBJ(OSKEY_E), udg_HotkeysHT )
call SaveIntegerBJ('I00C', 'h000', GetHandleIdBJ(OSKEY_P), udg_HotkeysHT )
call SaveIntegerBJ('I00D', 'h000', GetHandleIdBJ(OSKEY_M), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'h000', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I006', 'h000', GetHandleIdBJ(OSKEY_F), udg_HotkeysHT )
call SaveIntegerBJ('I004', 'h000', GetHandleIdBJ(OSKEY_Z), udg_HotkeysHT )
call SaveIntegerBJ('I005', 'h000', GetHandleIdBJ(OSKEY_X), udg_HotkeysHT )
// Neutral
call SaveIntegerBJ( 'I010', 0, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00Z', 1, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I011', 2, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00T', 3, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00N', 4, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00H', 5, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I008', 6, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00Y', 7, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00Q', 8, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00M', 9, 'ngme', udg_FBS_HT )
call SaveIntegerBJ( 'I00I', 10, 'ngme', udg_FBS_HT )
call SaveIntegerBJ('I010', 'ngme', GetHandleIdBJ(OSKEY_S), udg_HotkeysHT )
call SaveIntegerBJ('I00Z', 'ngme', GetHandleIdBJ(OSKEY_V), udg_HotkeysHT )
call SaveIntegerBJ('I011', 'ngme', GetHandleIdBJ(OSKEY_C), udg_HotkeysHT )
call SaveIntegerBJ('I00T', 'ngme', GetHandleIdBJ(OSKEY_D), udg_HotkeysHT )
call SaveIntegerBJ('I00N', 'ngme', GetHandleIdBJ(OSKEY_R), udg_HotkeysHT )
call SaveIntegerBJ('I00H', 'ngme', GetHandleIdBJ(OSKEY_I), udg_HotkeysHT )
call SaveIntegerBJ('I008', 'ngme', GetHandleIdBJ(OSKEY_T), udg_HotkeysHT )
call SaveIntegerBJ('I00Y', 'ngme', GetHandleIdBJ(OSKEY_E), udg_HotkeysHT )
call SaveIntegerBJ('I00Q', 'ngme', GetHandleIdBJ(OSKEY_O), udg_HotkeysHT )
call SaveIntegerBJ('I00M', 'ngme', GetHandleIdBJ(OSKEY_H), udg_HotkeysHT )
call SaveIntegerBJ('I00I', 'ngme', GetHandleIdBJ(OSKEY_N), udg_HotkeysHT )
set udg_Hotkeys_Triggers[udg_Hotkeys_TotalTriggers] = gg_trg_Race_Items_Hotkey
set udg_Hotkeys_TotalTriggers = udg_Hotkeys_TotalTriggers + 1
call ForForce( udg_PlayingPlayers, function Trig_Race_Items_InitPlayerClicks )
endfunction
//===========================================================================
function InitTrig_Race_Items_Init takes nothing returns nothing
set gg_trg_Race_Items_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Race_Items_Init, 0 )
call TriggerAddAction( gg_trg_Race_Items_Init, function Trig_Race_Items_Init_Actions )
endfunction
function Trig_Race_Items_Click_Conditions takes nothing returns boolean
return udg_FBS_HoveredObjectId[GetConvertedPlayerId(GetTriggerPlayer())] != 0
endfunction
function Trig_Race_Items_Click_Actions takes nothing returns nothing
local integer item_type = udg_FBS_HoveredObjectId[GetConvertedPlayerId(GetTriggerPlayer())]
local unit shop = udg_FBS_SelectedUnit[GetConvertedPlayerId(GetTriggerPlayer())]
call ShopAnalyseItemIsSellable(shop, item_type, GetTriggerPlayer(), false, false)
set shop = null
endfunction
//===========================================================================
function InitTrig_Race_Items_Click takes nothing returns nothing
set gg_trg_Race_Items_Click = CreateTrigger( )
call TriggerAddAction( gg_trg_Race_Items_Click, function Trig_Race_Items_Click_Actions )
call TriggerAddCondition( gg_trg_Race_Items_Click, function Trig_Race_Items_Click_Conditions )
endfunction
function Trig_Race_Items_Hotkey_Conditions takes nothing returns boolean
local boolean success = udg_FBS_SelectedUnit[GetConvertedPlayerId(GetTriggerPlayer())] != null
set success = success and not LoadBooleanBJ(udg_Skill_Building_IndexProgress, GetHandleIdBJ(udg_FBS_SelectedUnit[GetConvertedPlayerId(GetTriggerPlayer())]), udg_SkillHT)
return success
endfunction
function Trig_Race_Items_Hotkey_Actions takes nothing returns nothing
local unit shop = udg_FBS_SelectedUnit[GetConvertedPlayerId(GetTriggerPlayer())]
local integer item_type = LoadIntegerBJ(GetUnitTypeId(shop), GetHandleIdBJ(BlzGetTriggerPlayerKey()), udg_HotkeysHT )
call ShopAnalyseItemIsSellable(shop, item_type, GetTriggerPlayer(), true, true)
set shop = null
endfunction
//===========================================================================
function InitTrig_Race_Items_Hotkey takes nothing returns nothing
set gg_trg_Race_Items_Hotkey = CreateTrigger( )
call TriggerAddCondition( gg_trg_Race_Items_Hotkey, Condition( function Trig_Race_Items_Hotkey_Conditions ) )
call TriggerAddAction( gg_trg_Race_Items_Hotkey, function Trig_Race_Items_Hotkey_Actions )
endfunction
function Trig_RS_Hero_Death_Conditions takes nothing returns boolean
return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO)
endfunction
function Trig_RS_Hero_Death_Actions takes nothing returns nothing
local string s = ""
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(GetLocalPlayer())]
if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
set s = udg_Races_Sound_SelfHeroDeath[player_race]
else
if IsUnitAlly(GetTriggerUnit(), GetLocalPlayer()) then
set s = udg_Races_Sound_AllyHeroDeath[udg_Races_PlayersRace[GetConvertedPlayerId(GetLocalPlayer())]]
endif
endif
call TriggerSleepAction( BlzGetUnitRealField(GetTriggerUnit(), UNIT_RF_DEATH_TIME) )
call PlaySound(s)
endfunction
//===========================================================================
function InitTrig_RS_Hero_Death takes nothing returns nothing
set gg_trg_RS_Hero_Death = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Hero_Death, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_RS_Hero_Death, Condition( function Trig_RS_Hero_Death_Conditions ) )
call TriggerAddAction( gg_trg_RS_Hero_Death, function Trig_RS_Hero_Death_Actions )
endfunction
function Trig_RS_Building_Complete_Actions takes nothing returns nothing
local string s = ""
if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
set s = udg_Races_Sound_BuildingComplete[udg_Races_PlayersRace[GetConvertedPlayerId(GetTriggerPlayer())]]
endif
call PlaySound(s)
endfunction
//===========================================================================
function InitTrig_RS_Building_Complete takes nothing returns nothing
set gg_trg_RS_Building_Complete = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Building_Complete, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_RS_Building_Complete, function Trig_RS_Building_Complete_Actions )
endfunction
function Trig_RS_Research_Complete_Actions takes nothing returns nothing
local string s = ""
if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
set s = udg_Races_Sound_ResearchComplete[udg_Races_PlayersRace[GetConvertedPlayerId(GetTriggerPlayer())]]
endif
call PlaySound(s)
endfunction
//===========================================================================
function InitTrig_RS_Research_Complete takes nothing returns nothing
set gg_trg_RS_Research_Complete = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Research_Complete, EVENT_PLAYER_UNIT_RESEARCH_FINISH )
call TriggerAddAction( gg_trg_RS_Research_Complete, function Trig_RS_Research_Complete_Actions )
endfunction
function Trig_RS_Upgrade_Complete_Actions takes nothing returns nothing
local string s = ""
if GetOwningPlayer(GetTriggerUnit()) == GetLocalPlayer() then
set s = udg_Races_Sound_UpgradeComplete[udg_Races_PlayersRace[GetConvertedPlayerId(GetTriggerPlayer())]]
endif
call PlaySound(s)
endfunction
//===========================================================================
function InitTrig_RS_Upgrade_Complete takes nothing returns nothing
set gg_trg_RS_Upgrade_Complete = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Upgrade_Complete, EVENT_PLAYER_UNIT_UPGRADE_FINISH )
call TriggerAddAction( gg_trg_RS_Upgrade_Complete, function Trig_RS_Upgrade_Complete_Actions )
endfunction
function Trig_GetClickActionBuildings takes nothing returns nothing
local player p = udg_LastInteractionPlayer
local integer object_code = LoadIntegerBJ(GetHandleIdBJ(GetTriggeringTrigger()), udg_Dict_Command_IndexCode, udg_DictHT)
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(p)]
local integer gold_cost = GetUnitGoldCost(object_code)
local integer lumber_cost = GetUnitWoodCost(object_code)
// call BJDebugMsg("building clicked")
if p != GetLocalPlayer() then
set p = null
return
endif
if gold_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) then
call PlaySoundBJ( udg_Races_Sound_NoGold[player_race] )
set p = null
return
endif
if lumber_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) then
call PlaySoundBJ( udg_Races_Sound_NoLumber[player_race] )
set p = null
return
endif
set p = null
endfunction
function Trig_GetClickActionResearches takes nothing returns nothing
local player p = udg_LastInteractionPlayer
local integer object_code = LoadIntegerBJ(GetHandleIdBJ(GetTriggeringTrigger()), udg_Dict_Command_IndexCode, udg_DictHT)
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(p)]
local real gold_cost = GetResearchGoldCost(object_code, p)
local real lumber_cost = GetResearchLumberCost(object_code, p)
if p != GetLocalPlayer() then
return
endif
if gold_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) then
call PlaySoundBJ( udg_Races_Sound_NoGold[player_race] )
set p = null
return
endif
if lumber_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) then
call PlaySoundBJ( udg_Races_Sound_NoLumber[player_race] )
set p = null
return
endif
set p = null
endfunction
function Trig_GetClickActionHeroes takes nothing returns nothing
local player p = udg_LastInteractionPlayer
local integer object_code = LoadIntegerBJ(GetHandleIdBJ(GetTriggeringTrigger()), udg_Dict_Command_IndexCode, udg_DictHT)
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(p)]
local integer current_food = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_USED)
local integer max_food = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_CAP)
local integer food_cost = GetUnitFoodCost(object_code)
local integer total_trained = LoadIntegerBJ(udg_Skill_Building_IndexTrainTotal, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if p != GetLocalPlayer() then
return
endif
if GetPlayerState(p, PLAYER_STATE_RESOURCE_HERO_TOKENS) != bj_MELEE_STARTING_HERO_TOKENS then
if 400 > GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) then
call PlaySoundBJ( udg_Races_Sound_NoGold[player_race] )
set p = null
return
endif
if 100 > GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) then
call PlaySoundBJ( udg_Races_Sound_NoLumber[player_race] )
set p = null
return
endif
endif
if food_cost != 0 and food_cost > max_food - current_food and total_trained == 0 then
call PlaySoundBJ( udg_Races_Sound_NoFood[player_race] )
set p = null
return
endif
set p = null
endfunction
function Trig_GetClickActionUnits takes nothing returns nothing
local player p = udg_LastInteractionPlayer
local integer object_code = LoadIntegerBJ(GetHandleIdBJ(GetTriggeringTrigger()), udg_Dict_Command_IndexCode, udg_DictHT)
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(p)]
local integer current_food = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_USED)
local integer max_food = GetPlayerState(p, PLAYER_STATE_RESOURCE_FOOD_CAP)
local integer gold_cost = GetUnitGoldCost(object_code)
local integer lumber_cost = GetUnitWoodCost(object_code)
local integer food_cost = 0
local integer total_trained = LoadIntegerBJ(udg_Skill_Building_IndexTrainTotal, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if not IsUnitIdType(object_code, UNIT_TYPE_STRUCTURE) then
set food_cost = GetUnitFoodCost(object_code)
endif
if p != GetLocalPlayer() then
return
endif
if gold_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) then
call PlaySoundBJ( udg_Races_Sound_NoGold[player_race] )
set p = null
return
endif
if lumber_cost > GetPlayerState(p, PLAYER_STATE_RESOURCE_LUMBER) then
call PlaySoundBJ( udg_Races_Sound_NoLumber[player_race] )
set p = null
return
endif
if food_cost != 0 and food_cost > max_food - current_food and total_trained == 0 then
call PlaySoundBJ( udg_Races_Sound_NoFood[player_race] )
set p = null
return
endif
set p = null
endfunction
function Trig_GetClickActionReveal takes nothing returns nothing
local player p = udg_LastInteractionPlayer
local integer player_race = udg_Races_PlayersRace[GetConvertedPlayerId(p)]
if p != GetLocalPlayer() then
set p = null
return
endif
if 50 > GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) then
call PlaySoundBJ( udg_Races_Sound_NoGold[player_race] )
set p = null
return
endif
endfunction
function Trig_RS_Resources_Actions takes nothing returns nothing
local string buildings
local string units
local string heroes
local string upgrades
local string researches
local string s
local integer object_code
local trigger t
local integer i
local integer max
// humans
set buildings = "htow,hhou,hbar,hbla,hwtw,halt,harm,hars,hlum,hgra,hvlt"
set units = "hpea,hfoo,hrif,hkni,hgyr,hmtm,hmtt,hrtt,hmpr,hsor,hspt,hgry,hdhw"
set heroes = "Hblm,Hamg,Hmkg,Hpal"
set researches = "Rhpm,Rhde,Rhan,Rhri,Rhac,Rhlh,Rhme,Rhar,Rhla,Rhra,Rhgb,Rhfl,Rhrt,Rhfc,Rhfs,Rhhb,Rhcd"
set researches = researches + ",R00I,R00M,R00J,R00K,R00L" // upgrades
// set upgrades = "hkee,hcas,hgtw,hctw,hatw"
// orc
set buildings = buildings + ",ogre,otrb,orbr,obar,ofor,oalt,obea,osld,otto,owtw,ovln"
set units = units + ",opeo,ogru,ohun,otbk,ocat,otau,ospm,oshm,odoc,orai,okod,owyv,otbr"
set heroes = heroes + ",Obla,Ofar,Otch,Oshd"
set researches = researches + ",Ropg,Ropm,Robs,Rotr,Robk,Robf,Rome,Roar,Rora,Rosp,Rorb,Rows,Rowt,Rowd,Rost,Roen,Rovs,Rwdm,Rolf"
set researches = researches + ",R00N,R00O" // upgrades
// night elves
set buildings = buildings + ",etol,emow,edos,eaom,eate,eaow,eaoe,edob,etrp,eden"
set units = units + ",ewsp,earc,esen,ebal,edry,edoc,emtg,ehip,edot,efdr,echm"
set heroes = heroes + ",Edem,Ekee,Emoo,Ewar"
set researches = researches + ",Renb,Repm,Reib,Remk,Resc,Remg,Repb,Resi,Redc,Rers,Rehs,Reeb,Redt,Reec,Resm,Rema,Resw,Rerh,Reuv,Rews,Recb"
set researches = researches + ",R00R,R00S" // upgrades
// undead
set buildings = buildings + ",unpl,uzig,usep,ugrv,uaod,utod,uslh,ubon,usap,ugol,utom"
set units = units + ",uaco,ugho,ucry,ugar,umtw,uabo,uobs,unec,uban,ufro"
set heroes = heroes + ",Udea,Ulic,Udre,Ucrl"
set researches = researches + ",Rupm,Ruwb,Rugf,Rusf,Rubu,Ruac,Rume,Ruar,Rura,Rucr,Rupc,Rusp,Ruex,Rune,Ruba,Rusm,Rufb"
set researches = researches + ",R00P,R00Q,R00V,R00W" // upgrades
// naga
set buildings = buildings + ",o002,o001,n006,n005,n004,h001,n002,n000,h000,o000"
set units = units + ",n001,n00C,h002,e005,n00D,h008,h00C,e003,u000,e002,n00G,n00A,n00B"
set heroes = heroes + ",E007,H004,H003,N003"
set researches = researches + ",R00B,R005,R001,R003,R002,R007,R00A,R00F,R009,R008,R00E,R00C,R00D,R00G,R004,R006"
set researches = researches + ",R00T,R00U" // upgrades
set max = StringLength(buildings)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(buildings, i, i+3)
set object_code = S2ObjectId(s)
set t = CreateTrigger( )
call TriggerRegisterBuildCommandEventBJ( t, object_code )
call TriggerAddAction( t, function Trig_GetClickActionBuildings )
call SaveIntegerBJ(object_code, GetHandleIdBJ(t), udg_Dict_Command_IndexCode, udg_DictHT)
set i = i + 5
endloop
set max = StringLength(units)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(units, i, i+3)
set object_code = S2ObjectId(s)
set t = CreateTrigger( )
call TriggerRegisterUpgradeCommandEventBJ( t, object_code )
call TriggerAddAction( t, function Trig_GetClickActionUnits )
call SaveIntegerBJ(object_code, GetHandleIdBJ(t), udg_Dict_Command_IndexCode, udg_DictHT)
set i = i + 5
endloop
set max = StringLength(heroes)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(heroes, i, i+3)
set object_code = S2ObjectId(s)
set t = CreateTrigger( )
call TriggerRegisterUpgradeCommandEventBJ( t, object_code )
call TriggerAddAction( t, function Trig_GetClickActionHeroes )
call SaveIntegerBJ(object_code, GetHandleIdBJ(t), udg_Dict_Command_IndexCode, udg_DictHT)
set i = i + 5
endloop
set max = StringLength(researches)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(researches, i, i+3)
set object_code = S2ObjectId(s)
// call BJDebugMsg(s + "!")
set t = CreateTrigger( )
call TriggerRegisterUpgradeCommandEventBJ( t, object_code )
call TriggerAddAction( t, function Trig_GetClickActionResearches )
call SaveIntegerBJ(object_code, GetHandleIdBJ(t), udg_Dict_Command_IndexCode, udg_DictHT)
set i = i + 5
endloop
// reveal ability
set t = CreateTrigger( )
call TriggerRegisterCommandEvent( t, 'Andt', "neutraldetectaoe" )
call TriggerAddAction( t, function Trig_GetClickActionReveal )
set t = null
endfunction
//===========================================================================
function InitTrig_RS_Resources takes nothing returns nothing
set gg_trg_RS_Resources = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_RS_Resources, 0.00 )
call TriggerAddAction( gg_trg_RS_Resources, function Trig_RS_Resources_Actions )
endfunction
function Trig_RS_Construction_2_Conditions takes nothing returns boolean
return LoadBooleanBJ(udg_Skill_Building_IndexProgress, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT) and GetUnitTypeId(GetTriggerUnit()) != 'egol'
endfunction
function Trig_RS_Construction_2_Actions takes nothing returns nothing
local real current_unit_timer
local real elapsed_unit_time
local string s = ""
if GetTriggerPlayer() != GetLocalPlayer() then
// return
else
if GetTriggerPlayer() != GetOwningPlayer(GetTriggerUnit()) and not(GetPlayerAlliance(GetOwningPlayer(GetTriggerUnit()), GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL)) then
// return
else
set current_unit_timer = LoadRealBJ(GetConvertedPlayerId(GetLocalPlayer()), GetHandleIdBJ(GetTriggerUnit()), udg_RSConstructionAsyncHT)
set elapsed_unit_time = udg_GlobalTime - current_unit_timer
if elapsed_unit_time < 4 and current_unit_timer != 0 then
// return // too early to play sound
else
if GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityL, GetTriggerUnit()) > 0 or GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityS, GetTriggerUnit()) > 0 then
set s = "Buildings\\Naga\\SpawningGrounds\\SpawningGroundsWhat1.flac"
else
if GetUnitRace(GetTriggerUnit()) == RACE_HUMAN then
set s = "Sound\\Buildings\\Shared\\BuildingConstruction.flac"
else
if GetUnitRace(GetTriggerUnit()) == RACE_ORC then
set s = "Sound\\Buildings\\Orc\\OrcBuildingBirthWhat1.flac"
else
if GetUnitRace(GetTriggerUnit()) == RACE_NIGHTELF then
set s = "Sound\\Buildings\\NightElf\\NightElfBuildingLoop.flac"
else
if GetUnitRace(GetTriggerUnit()) == RACE_UNDEAD then
set s = "Sound\\Buildings\\Undead\\UndeadBuildingBirthWhat1.flac"
endif
endif
endif
endif
endif
endif
endif
endif
if s != "" then
call BlzSendSyncData("UpdateRSConstructionTimer", I2S(GetHandleIdBJ(GetTriggerUnit())))
// call SaveRealBJ(udg_GlobalTime, udg_Skill_Building_SoundTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
endif
call SPv2PlaySoundOnUnit(s, GetTriggerUnit())
endfunction
//===========================================================================
function InitTrig_RS_Construction_2 takes nothing returns nothing
set gg_trg_RS_Construction_2 = CreateTrigger( )
call TriggerAddCondition( gg_trg_RS_Construction_2, Condition( function Trig_RS_Construction_2_Conditions ) )
call TriggerAddAction( gg_trg_RS_Construction_2, function Trig_RS_Construction_2_Actions )
endfunction
function Trig_RS_Construction_2_Copy_2_Conditions takes nothing returns boolean
return LoadBooleanBJ(udg_Skill_Building_IndexProgress, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT) and GetUnitTypeId(GetTriggerUnit()) != 'egol'
endfunction
function Trig_RS_Construction_2_Copy_2_Actions takes nothing returns nothing
local real elapsed_unit_time
local real current_unit_timer
if GetTriggerPlayer() != GetLocalPlayer() then
return
endif
if GetTriggerPlayer() != GetOwningPlayer(GetTriggerUnit()) and not(GetPlayerAlliance(GetOwningPlayer(GetTriggerUnit()), GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL)) then
return
endif
set current_unit_timer = LoadRealBJ(udg_Skill_Building_SoundTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
set elapsed_unit_time = udg_GlobalTime - current_unit_timer
if elapsed_unit_time < 4 and current_unit_timer != 0 then
return // too early to play sound
endif
call SaveRealBJ(udg_GlobalTime, udg_Skill_Building_SoundTimer, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
if GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityL, GetTriggerUnit()) > 0 or GetUnitAbilityLevelSwapped(udg_Water_ExpansionAbilityS, GetTriggerUnit()) > 0 then
// call SPv2PlaySoundOnUnit("Doodads\\Northrend\\Water\\Battleship\\BattleShipDeath1.flac", GetTriggerUnit())
call SPv2PlaySoundOnUnit("Buildings\\Naga\\SpawningGrounds\\SpawningGroundsWhat1.flac", GetTriggerUnit())
// call SPv2PlaySoundOnUnit("war3mapImported\\NagaBuildingLoop1.flac", GetTriggerUnit())
return
endif
if GetUnitRace(GetTriggerUnit()) == RACE_HUMAN then
call SPv2PlaySoundOnUnit("Sound\\Buildings\\Shared\\BuildingConstruction.flac", GetTriggerUnit())
return
endif
if GetUnitRace(GetTriggerUnit()) == RACE_ORC then
call SPv2PlaySoundOnUnit("Sound\\Buildings\\Orc\\OrcBuildingBirthWhat1.flac", GetTriggerUnit())
return
endif
if GetUnitRace(GetTriggerUnit()) == RACE_NIGHTELF then
call SPv2PlaySoundOnUnit("Sound\\Buildings\\NightElf\\NightElfBuildingLoop.flac", GetTriggerUnit())
return
endif
if GetUnitRace(GetTriggerUnit()) == RACE_UNDEAD then
call SPv2PlaySoundOnUnit("Sound\\Buildings\\Undead\\UndeadBuildingBirthWhat1.flac", GetTriggerUnit())
return
endif
endfunction
//===========================================================================
function InitTrig_RS_Construction_2_Copy_2 takes nothing returns nothing
set gg_trg_RS_Construction_2_Copy_2 = CreateTrigger( )
call TriggerRegisterPlayerSelectionEventBJ( gg_trg_RS_Construction_2_Copy_2, Player(0), true )
call TriggerAddCondition( gg_trg_RS_Construction_2_Copy_2, Condition( function Trig_RS_Construction_2_Copy_2_Conditions ) )
call TriggerAddAction( gg_trg_RS_Construction_2_Copy_2, function Trig_RS_Construction_2_Copy_2_Actions )
endfunction
function Trig_RS_Construction_Timer_Sync_Actions takes nothing returns nothing
// call BJDebugMsg(GetPlayerColoredName(GetTriggerPlayer()) + " has updated construction timer HT: " + BlzGetTriggerSyncData())
call SaveRealBJ(udg_GlobalTime, GetConvertedPlayerId(GetTriggerPlayer()), S2I(BlzGetTriggerSyncData()), udg_RSConstructionAsyncHT)
endfunction
//===========================================================================
function InitTrig_RS_Construction_Timer_Sync takes nothing returns nothing
set gg_trg_RS_Construction_Timer_Sync = CreateTrigger( )
call TriggerAddAction( gg_trg_RS_Construction_Timer_Sync, function Trig_RS_Construction_Timer_Sync_Actions )
endfunction
function Trig_RS_GoldMine_Collapse_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'ngol'
endfunction
function Trig_RS_GoldMine_Collapse_Actions takes nothing returns nothing
local player p
set p = LoadPlayerHandleBJ(udg_Skill_GoldMine_IndexOwner, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
// call BJDebugMsg("Owner of dying mine is " + GetPlayerName(p))
call PlaySoundLocally(udg_Races_Sound_GoldMineEmpty[udg_Races_PlayersRace[GetConvertedPlayerId(p)]], p)
call CustomPingOnUnit(p, GetTriggerUnit(), 255, 204, 0, false)
set p = null
endfunction
//===========================================================================
function InitTrig_RS_GoldMine_Collapse takes nothing returns nothing
set gg_trg_RS_GoldMine_Collapse = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_GoldMine_Collapse, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_RS_GoldMine_Collapse, Condition( function Trig_RS_GoldMine_Collapse_Conditions ) )
call TriggerAddAction( gg_trg_RS_GoldMine_Collapse, function Trig_RS_GoldMine_Collapse_Actions )
endfunction
function Trig_RS_GoldMine_Collapse_NE_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'egol' and GetResourceAmount(GetTriggerUnit()) == 0
endfunction
function Trig_RS_GoldMine_Collapse_NE_Actions takes nothing returns nothing
call PlaySoundLocally(udg_Races_Sound_GoldMineEmpty[udg_Races_PlayersRace[GetConvertedPlayerId(GetLocalPlayer())]], GetOwningPlayer(GetTriggerUnit()))
call CustomPingOnUnit(GetOwningPlayer(GetTriggerUnit()), GetTriggerUnit(), 255, 204, 0, false)
endfunction
//===========================================================================
function InitTrig_RS_GoldMine_Collapse_NE takes nothing returns nothing
set gg_trg_RS_GoldMine_Collapse_NE = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_GoldMine_Collapse_NE, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_RS_GoldMine_Collapse_NE, Condition( function Trig_RS_GoldMine_Collapse_NE_Conditions ) )
call TriggerAddAction( gg_trg_RS_GoldMine_Collapse_NE, function Trig_RS_GoldMine_Collapse_NE_Actions )
endfunction
function Trig_RS_GoldMine_Warning_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'ngol' and GetIssuedOrderIdBJ() == String2OrderIdBJ("stop")
endfunction
function Trig_RS_GoldMine_Warning_Actions takes nothing returns nothing
local player p
set p = LoadPlayerHandleBJ(udg_Skill_GoldMine_IndexOwner, GetHandleIdBJ(GetTriggerUnit()), udg_SkillHT)
// call BJDebugMsg("Owner of warning mine is " + GetPlayerName(p))
call PlaySoundLocally(udg_Races_Sound_GoldMineLow[udg_Races_PlayersRace[GetConvertedPlayerId(p)]], p)
call CustomPingOnUnit(p, GetTriggerUnit(), 255, 204, 0, false)
set p = null
endfunction
//===========================================================================
function InitTrig_RS_GoldMine_Warning takes nothing returns nothing
set gg_trg_RS_GoldMine_Warning = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_GoldMine_Warning, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_RS_GoldMine_Warning, Condition( function Trig_RS_GoldMine_Warning_Conditions ) )
call TriggerAddAction( gg_trg_RS_GoldMine_Warning, function Trig_RS_GoldMine_Warning_Actions )
endfunction
function Trig_RS_GoldMine_Warning_Special_Conditions takes nothing returns boolean
return (GetUnitTypeId(GetTriggerUnit()) == 'egol' or GetUnitTypeId(GetTriggerUnit()) == 'ugol') and GetIssuedOrderIdBJ() == String2OrderIdBJ("stop")
endfunction
function Trig_RS_GoldMine_Warning_Special_Actions takes nothing returns nothing
call PlaySoundLocally(udg_Races_Sound_GoldMineLow[udg_Races_PlayersRace[GetConvertedPlayerId(GetLocalPlayer())]], GetOwningPlayer(GetTriggerUnit()))
call CustomPingOnUnit(GetOwningPlayer(GetTriggerUnit()), GetTriggerUnit(), 255, 204, 0, false)
endfunction
//===========================================================================
function InitTrig_RS_GoldMine_Warning_Special takes nothing returns nothing
set gg_trg_RS_GoldMine_Warning_Special = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_GoldMine_Warning_Special, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( gg_trg_RS_GoldMine_Warning_Special, Condition( function Trig_RS_GoldMine_Warning_Special_Conditions ) )
call TriggerAddAction( gg_trg_RS_GoldMine_Warning_Special, function Trig_RS_GoldMine_Warning_Special_Actions )
endfunction
function Trig_RS_Attack_Conditions takes nothing returns boolean
return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetEventDamageSource()))
endfunction
function Trig_RS_Attack_Actions takes nothing returns nothing
local real elapsed_unit_time
local real elapsed_sound_time
local real current_unit_timer
local real current_sound_timer
local integer sound_id
local sound snd
local integer x
local integer y
local integer player_race
local location l
local location l2
local real distance
set l = GetUnitLoc(GetTriggerUnit())
set l2 = GetUnitLoc(GetEventDamageSource())
set distance = DistanceBetweenPoints(l2, l)
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
if not IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetLocalPlayer()) then
return
endif
if distance > udg_RS_Attack_ProcRange then
return
endif
if isUnitInCameraDefaultRange(GetTriggerUnit()) then
call BlzSendSyncData("UpdateRSAttackHT", I2S(GetHandleIdBJ(GetTriggerUnit())))
return
endif
set current_unit_timer = LoadRealBJ(GetConvertedPlayerId(GetLocalPlayer()), GetHandleIdBJ(GetTriggerUnit()), udg_RSAttackAsyncHT)
set elapsed_unit_time = udg_GlobalTime - current_unit_timer
if elapsed_unit_time < udg_RS_Attack_SoundInterval and current_unit_timer != 0 then
return // too early to play sound
endif
set player_race = udg_Races_PlayersRace[GetConvertedPlayerId(GetLocalPlayer())]
if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then
set sound_id = udg_RS_Attack_IdSelfBuildingTimer
set snd = udg_Races_Sound_SelfBuildingAttack[player_race]
else
set sound_id = udg_RS_Attack_IdSelfUnitTimer
set snd = udg_Races_Sound_SelfUnitAttack[player_race]
endif
else
if IsUnitType(GetTriggerUnit(), UNIT_TYPE_STRUCTURE) then
set sound_id = udg_RS_Attack_IdAllyBuildingTimer
set snd = udg_Races_Sound_AllyBuildingAttack[player_race]
else
if not (GetPlayerAlliance(GetOwningPlayer(GetTriggerUnit()), GetLocalPlayer(), ALLIANCE_SHARED_ADVANCED_CONTROL)) then
return // no sound if its the unit of an ally and unit not fully shared is off
endif
set sound_id = udg_RS_Attack_IdAllyUnitTimer
set snd = udg_Races_Sound_AllyUnitAttack[player_race]
endif
endif
set current_sound_timer = LoadRealBJ(GetConvertedPlayerId(GetLocalPlayer()), sound_id, udg_RSAttackAsyncHT)
set elapsed_sound_time = udg_GlobalTime - current_sound_timer
if elapsed_sound_time >= udg_RS_Attack_SoundInterval or current_sound_timer == 0 then
call PlaySoundIfUnplayed(snd)
call BlzSendSyncData("UpdateRSAttackHT", I2S(sound_id))
set x = R2I(GetUnitX(GetTriggerUnit()))
set y = R2I(GetUnitY(GetTriggerUnit()))
if GetPlayerName(GetLocalPlayer()) == "Pierziz" then
call BJDebugMsg(GetUnitName(GetTriggerUnit()) + " is being damaged " + R2S(GetEventDamage()) + " by " + GetUnitName(GetEventDamageSource()))
endif
call BlzSendSyncData("UpdateRSAttackCamera", I2S(x) + ";" + I2S(y))
endif
set snd = null
endfunction
//===========================================================================
function InitTrig_RS_Attack takes nothing returns nothing
set gg_trg_RS_Attack = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Attack, EVENT_PLAYER_UNIT_DAMAGED )
call TriggerAddCondition( gg_trg_RS_Attack, Condition( function Trig_RS_Attack_Conditions ) )
call TriggerAddAction( gg_trg_RS_Attack, function Trig_RS_Attack_Actions )
endfunction
function Trig_RS_Attack_HT_Sync_Actions takes nothing returns nothing
// call BJDebugMsg(GetPlayerColoredName(GetTriggerPlayer()) + " has updated attack sound HT: " + BlzGetTriggerSyncData())
call SaveRealBJ(udg_GlobalTime, GetConvertedPlayerId(GetTriggerPlayer()), S2I(BlzGetTriggerSyncData()), udg_RSAttackAsyncHT)
endfunction
//===========================================================================
function InitTrig_RS_Attack_HT_Sync takes nothing returns nothing
set gg_trg_RS_Attack_HT_Sync = CreateTrigger( )
call TriggerAddAction( gg_trg_RS_Attack_HT_Sync, function Trig_RS_Attack_HT_Sync_Actions )
endfunction
function Trig_RS_Attack_Camera_Sync_Actions takes nothing returns nothing
local string s
local string c
local integer max
local integer i
local integer cursor
local string array words
local location l
local force f
set s = BlzGetTriggerSyncData()
set max = StringLength(s)
set i = 0
set cursor = 0
set words[0] = ""
loop
exitwhen i >= max
set c = SubStringBJ(s, i+1, i+1)
if c == ";" then
set cursor = cursor + 1
set words[cursor] = ""
else
set words[cursor] = words[cursor] + c
endif
set i = i + 1
endloop
// call BJDebugMsg(GetPlayerColoredName(GetTriggerPlayer()) + " has sent camera coordinates : " + words[0] + ";" + words[1])
set l = Location(S2R(words[0]), S2R(words[1]))
set f = GetForceOfPlayer(GetTriggerPlayer())
call SetCameraQuickPositionLocForPlayer( GetLocalPlayer(), l )
// call PingMinimapLocForForceEx( f, l, 1, bj_MINIMAPPINGSTYLE_ATTACK, 100, 100, 100 )
call CustomPingAt(GetTriggerPlayer(), l, 255, 0, 0, true)
call DestroyForce(f)
call RemoveLocation(l)
set l = null
set f = null
endfunction
//===========================================================================
function InitTrig_RS_Attack_Camera_Sync takes nothing returns nothing
set gg_trg_RS_Attack_Camera_Sync = CreateTrigger( )
call TriggerAddAction( gg_trg_RS_Attack_Camera_Sync, function Trig_RS_Attack_Camera_Sync_Actions )
endfunction
function Trig_Test_Improved_Alliance_Actions takes nothing returns nothing
call SetPlayerAllianceBJ( Player(4), ALLIANCE_SHARED_ADVANCED_CONTROL, true, Player(0) )
return
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_HELP_REQUEST) then
call BJDebugMsg("ALLIANCE_HELP_REQUEST: On")
else
call BJDebugMsg("ALLIANCE_HELP_REQUEST: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_PASSIVE) then
call BJDebugMsg("ALLIANCE_PASSIVE: On")
else
call BJDebugMsg("ALLIANCE_PASSIVE: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_SHARED_VISION) then
call BJDebugMsg("ALLIANCE_SHARED_VISION: On")
else
call BJDebugMsg("ALLIANCE_SHARED_VISION: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_SHARED_CONTROL) then
call BJDebugMsg("ALLIANCE_SHARED_CONTROL: On")
else
call BJDebugMsg("ALLIANCE_SHARED_CONTROL: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_SHARED_ADVANCED_CONTROL) then
call BJDebugMsg("ALLIANCE_SHARED_ADVANCED_CONTROL: On")
else
call BJDebugMsg("ALLIANCE_SHARED_ADVANCED_CONTROL: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_SHARED_XP) then
call BJDebugMsg("ALLIANCE_SHARED_XP: On")
else
call BJDebugMsg("ALLIANCE_SHARED_XP: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_SHARED_SPELLS) then
call BJDebugMsg("ALLIANCE_SHARED_SPELLS: On")
else
call BJDebugMsg("ALLIANCE_SHARED_SPELLS: Off")
endif
if GetPlayerAlliance(Player(0), Player(4), ALLIANCE_HELP_RESPONSE) then
call BJDebugMsg("ALLIANCE_HELP_RESPONSE: On")
else
call BJDebugMsg("ALLIANCE_HELP_RESPONSE: Off")
endif
endfunction
//===========================================================================
function InitTrig_Test_Improved_Alliance takes nothing returns nothing
set gg_trg_Test_Improved_Alliance = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Test_Improved_Alliance, Player(0), "ally", true )
call TriggerAddAction( gg_trg_Test_Improved_Alliance, function Trig_Test_Improved_Alliance_Actions )
endfunction
function Trig_RS_Units_Shoal_Commander_Actions takes nothing returns nothing
local unit u
local string s = ""
if GetUnitTypeId(GetTrainedUnit()) == 'H004' then
set u = GetTrainedUnit()
else
if GetUnitTypeId(GetRevivingUnit()) == 'H004' then
set u = GetRevivingUnit()
else
return
endif
endif
if GetLocalPlayer() == GetOwningPlayer(u) then
set s = udg_RS_Units_SC_Ready
endif
call PlaySound(s)
set u = null
endfunction
//===========================================================================
function InitTrig_RS_Units_Shoal_Commander takes nothing returns nothing
set gg_trg_RS_Units_Shoal_Commander = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Units_Shoal_Commander, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Units_Shoal_Commander, EVENT_PLAYER_HERO_REVIVE_FINISH )
call TriggerAddAction( gg_trg_RS_Units_Shoal_Commander, function Trig_RS_Units_Shoal_Commander_Actions )
endfunction
function Trig_RS_Units_Ophidians_Actions takes nothing returns nothing
local unit u
local string s = ""
if GetUnitTypeId(GetTrainedUnit()) == 'n00A' then
set u = GetTrainedUnit()
else
return
endif
if GetLocalPlayer() == GetOwningPlayer(u) then
set s = udg_RS_Units_Ophidian_Ready
endif
call PlaySound(s)
set u = null
endfunction
//===========================================================================
function InitTrig_RS_Units_Ophidians takes nothing returns nothing
set gg_trg_RS_Units_Ophidians = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Units_Ophidians, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddAction( gg_trg_RS_Units_Ophidians, function Trig_RS_Units_Ophidians_Actions )
endfunction
function Trig_RS_Units_Marauders_Actions takes nothing returns nothing
local unit u
local string s = ""
if GetUnitTypeId(GetTrainedUnit()) == 'n00G' then
set u = GetTrainedUnit()
else
return
endif
if GetLocalPlayer() == GetOwningPlayer(u) then
set s = udg_RS_Units_Marauder_Ready
endif
call PlaySound(s)
set u = null
endfunction
//===========================================================================
function InitTrig_RS_Units_Marauders takes nothing returns nothing
set gg_trg_RS_Units_Marauders = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RS_Units_Marauders, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddAction( gg_trg_RS_Units_Marauders, function Trig_RS_Units_Marauders_Actions )
endfunction
function Trig_Display_Memory_Update takes nothing returns nothing
local location l = Location(0, 0)
local integer max_increment = 0
local integer increment = 0
local string game_seconds = I2S(R2I(ModuloReal(udg_GlobalTime, 60)))
local string game_mins = I2S(R2I(udg_GlobalTime / 60))
local string s
set increment = GetHandleId(l) - 0x100000 - udg_CurrentMemory
set udg_CurrentMemory = udg_CurrentMemory + increment
set max_increment = GetHandleId(l) - 0x100000 - udg_MemoryMax
if max_increment > 0 then
set udg_MemoryMax = udg_MemoryMax + max_increment
else
set max_increment = 0
endif
if StringLength(game_seconds) <= 1 then
set game_seconds = "0" + game_seconds
endif
if StringLength(game_mins) <= 1 then
set game_mins = "0" + game_mins
endif
set s = "Memory max: |cffffcc00"+I2S(udg_MemoryMax)+"|r|n"
set s = s + "Current memory: |cffffcc00"+I2S(udg_CurrentMemory)+"|r|n"
set s = s + "Increment Max per second: |cffffcc00"+I2S(max_increment)+"|r|n"
set s = s + "Increment per second: |cffffcc00"+I2S(increment)+"|r|n"
set s = s + "Game time: |cffffcc00"+game_mins+":"+game_seconds+"|r|n"
call BlzFrameSetText(udg_DebugFrame, s)
call RemoveLocation(l)
set l = null
endfunction
function Trig_Display_Memory_Actions takes nothing returns nothing
local timer t = CreateTimer()
local trigger tr = CreateTrigger()
call TriggerRegisterTimerExpireEventBJ( tr, t )
call TriggerAddAction( tr, function Trig_Display_Memory_Update )
set udg_DebugFrame = BlzCreateFrameByType("TEXT", "DebugFrame", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
call BlzFrameSetAbsPoint(udg_DebugFrame , FRAMEPOINT_TOPRIGHT, 0.8, 0.57)
call BlzFrameSetScale(udg_DebugFrame, 1)
call StartTimerBJ( t, true, 1.00 )
endfunction
//===========================================================================
function InitTrig_Display_Memory takes nothing returns nothing
set gg_trg_Display_Memory = CreateTrigger( )
call TriggerAddAction( gg_trg_Display_Memory, function Trig_Display_Memory_Actions )
call TriggerRegisterTimerEventSingle( gg_trg_Display_Memory, 1 )
endfunction
function Trig_Debug_Unit_Order_Actions takes nothing returns nothing
local unit u = FirstOfGroup(udg_FBS_SelectedGroup[GetConvertedPlayerId(GetTriggerPlayer())])
call DisplayTextToForce( GetPlayersAll(), ( OrderId2StringBJ(GetUnitCurrentOrder(u)) + ( " - " + LoadStringBJ(udg_Skill_Order_IndexStringOrder, GetHandleIdBJ(u), udg_SkillHT) ) ) )
endfunction
//===========================================================================
function InitTrig_Debug_Unit_Order takes nothing returns nothing
set gg_trg_Debug_Unit_Order = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Debug_Unit_Order , Player(0), "de", true )
call TriggerAddAction( gg_trg_Debug_Unit_Order, function Trig_Debug_Unit_Order_Actions )
endfunction
function Trig_Animation_Debugger_Actions takes nothing returns nothing
local string unitids
local integer max
local location l
local string s
local integer unit_id
local unit u
local integer i
set l = GetRectCenter(GetPlayableMapRect())
set unitids = "hpea,hfoo,hrif,hkni,hgyr,hmtm,hmtt,hrtt,hmpr,hsor,hspt,hgry,hdhw,Hblm,Hamg,Hmkg,Hpal" // human
set unitids = unitids + ",opeo,ogru,ohun,otbk,ocat,otau,ospm,oshm,odoc,orai,okod,owyv,otbr,Obla,Ofar,Otch,Oshd" // orc
set unitids = unitids + ",ewsp,earc,esen,ebal,edry,edoc,emtg,ehip,edot,efdr,echm,Edem,Ekee,Emoo,Ewar" // elf
set unitids = unitids + ",uaco,ugho,ucry,ugar,umtw,uabo,uobs,unec,uban,ufro,Udea,Ulic,Udre,Ucrl" // undead
set unitids = unitids + ",n001,n00C,h002,e005,n00D,h008,h00C,e003,u000,e002,n00G,n00A,n00B,E007,H004,H003,N003" // naga
set max = StringLength(unitids)
set i = 1
loop
exitwhen i + 3 > max
set s = SubStringBJ(unitids, i, i+3)
set unit_id = S2ObjectId(s)
set u = CreateUnitAtLoc(Player(PLAYER_NEUTRAL_PASSIVE), unit_id, l, bj_UNIT_FACING )
call RemoveUnit( u )
set i = i + 5
endloop
call RemoveLocation(l)
set l = null
set u = null
endfunction
//===========================================================================
function InitTrig_Animation_Debugger takes nothing returns nothing
set gg_trg_Animation_Debugger = CreateTrigger( )
call TriggerAddAction( gg_trg_Animation_Debugger, function Trig_Animation_Debugger_Actions )
endfunction