scope CoverofDarkness
/*_______________________________________________________________
| Author: Kruemel-Monster
| Version: 1.0
| Requirements:
| -BonusMod (Earth-Fury)
| -GroupUtils (Rising_Dusk)
| Description:
| -Disables the shared sight for all enemys Players
| -Decrease the sightrange of all enemy Units
| Tooltip:
| Turns the day into such a deep night, that all enemys
| get a defective sight. So every foe can only fight alone.
|
| Some Bugs:
| -It could malfunctions if you cange the Alliance while on Effect
| -Every unit could attack with autoattack over her sightrange ( so they attack you even if they dont see you )
| This is not rightly tested, i only saw this effect on neutral creeps as they having 0 sightrange
|
| How to import:
| 1. Copy the BonusMod trigger, GroupUtils trigger and this trigger into your map
| Info: 2 -> 5. is only if you dont have the Bonus Mod abilities
| 2. Search inside the BonusMod trigger for :
| -> runtextmacro BonusMod_BeginBonuses("false") <- line 225
| Replace the false into a true
| -> runtextmacro BonusMod_BeginBonuses("true")
| 3. Save the map, close the map and reopen the map
| 4. Now you should have like 80 Abilities in you Object Editor
| 5. if that is true, you can change the line again into false
| -> runtextmacro BonusMod_BeginBonuses("false")
| 6. Copy the ability Cover of Darkness into your map
| 7. Search inside this trigger for the global TESTMODE and set it to false
|_________________________________________________________________
*/ // Ye ye i know my Descitption sucks ;D
globals
private constant boolean TESTMODE = true
// It would be lame if your units are not under the effect of the Spell
// The TESTMODE allows you to affect only allies
// TESTMODE = true ::: You and your allies are affected
// TESTMODE = false ::: Your enemys are affected
private constant integer ABIL_ID = 'A000'
// The Base Ability Id
private constant integer SIGHT_MALUS = -575
// The Amount of Sightrange loose
// Be carful the Spell makes a night so all units have a night sight range
// And the normal night sight range is 800
private constant string CASTER_SFX = "Abilities\\Spells\\Other\\HowlOfTerror\\HowlCaster.mdl"
// The Effect on the Caster
endglobals
// It is important that the Spell Duration is equal to the Duration of the Ability
private constant function GetSpellDuration takes integer level returns real
return ((level*2.)+5)
endfunction
// CODE STARTS : READ AND CHANGE AT OWN RISK
globals
private constant real TIME_OUT = 0.1
endglobals
private struct Spell
real Time
unit Caster
integer Level
static Spell array Active
static integer Count = 0
static timer Timer = CreateTimer()
static trigger Trigger = CreateTrigger()
static force Force = CreateForce()
static force Force2 = CreateForce()
static integer array Multi
static player CurPlayer
static boolean flag_add
method release takes integer number returns nothing
set Count = Count - 1
set Active[number] = Active[Count]
call destroy()
endmethod
static method EnumForce_change takes nothing returns boolean
local integer pId = GetPlayerId(CurPlayer)
if CurPlayer != GetFilterPlayer() then // This is some funny Bug, if you Disable the Shared Visison to your self all units wont see anything ;)
if flag_add then
set Multi[pId] = Multi[pId] - 1
if Multi[pId] == 0 then
call SetPlayerAlliance(CurPlayer,GetFilterPlayer(),ALLIANCE_SHARED_VISION,flag_add)
call SetPlayerAlliance(GetFilterPlayer(),CurPlayer,ALLIANCE_SHARED_VISION,flag_add)
endif
else
set Multi[pId] = Multi[pId] + 1
call SetPlayerAlliance(CurPlayer,GetFilterPlayer(),ALLIANCE_SHARED_VISION,flag_add)
call SetPlayerAlliance(GetFilterPlayer(),CurPlayer,ALLIANCE_SHARED_VISION,flag_add)
endif
endif
return false
endmethod
static method EnumGroup_change takes nothing returns boolean
if not(flag_add) then
call SetUnitBonus(GetFilterUnit(),BONUS_SIGHT_RANGE,SIGHT_MALUS)
else
if Multi[GetPlayerId(CurPlayer)] == 0 then
call SetUnitBonus(GetFilterUnit(),BONUS_SIGHT_RANGE,0)
endif
endif
return false
endmethod
static method EnumForce_enemys takes nothing returns boolean
set CurPlayer = GetFilterPlayer()
call ForceEnumAllies(Force2,CurPlayer,function Spell.EnumForce_change)
call ForceClear(Force2)
call GroupEnumUnitsOfPlayer(ENUM_GROUP,CurPlayer,function Spell.EnumGroup_change)
call GroupClear(ENUM_GROUP)
return false
endmethod
static method onloop takes nothing returns nothing
local Spell this
local integer index = 0
loop
exitwhen index >= Count
set this = Active[index]
set Time = Time + TIME_OUT
if Time >= GetSpellDuration(Level) then
set flag_add = true
static if TESTMODE then
call ForceEnumAllies(Force,GetOwningPlayer(Caster),function Spell.EnumForce_enemys)
set CurPlayer = Player(12)
call GroupEnumUnitsOfPlayer(ENUM_GROUP,Player(12),function Spell.EnumGroup_change)
call GroupClear(ENUM_GROUP)
else
call ForceEnumEnemies(Force,GetOwningPlayer(Caster),function Spell.EnumForce_enemys)
set CurPlayer = Player(12)
call GroupEnumUnitsOfPlayer(ENUM_GROUP,Player(12),function Spell.EnumGroup_change)
call GroupClear(ENUM_GROUP)
endif
call ForceClear(Force)
set Caster = null
call release(index)
else
set index = index + 1
endif
endloop
if Count == 0 then
call PauseTimer(Timer)
endif
endmethod
static method create takes nothing returns Spell
local Spell this
if GetSpellAbilityId() == ABIL_ID then
set this = allocate()
set Active[Count] = this
set Count = Count + 1
set Time = 0
set flag_add = false
set Caster = GetTriggerUnit()
set Level = GetUnitAbilityLevel(Caster,ABIL_ID)
call DestroyEffect(AddSpecialEffectTarget(CASTER_SFX,Caster,"origin"))
static if TESTMODE then
call ForceEnumAllies(Force,GetOwningPlayer(Caster),function Spell.EnumForce_enemys)
set CurPlayer = Player(12)
call GroupEnumUnitsOfPlayer(ENUM_GROUP,Player(12),function Spell.EnumGroup_change)
call GroupClear(ENUM_GROUP)
else
call ForceEnumEnemies(Force,GetOwningPlayer(Caster),function Spell.EnumForce_enemys)
set CurPlayer = Player(12)
call GroupEnumUnitsOfPlayer(ENUM_GROUP,Player(12),function Spell.EnumGroup_change)
call GroupClear(ENUM_GROUP)
endif
call ForceClear(Force)
if Count == 1 then
call TimerStart(Timer,TIME_OUT,true,function Spell.onloop)
endif
endif
return this
endmethod
static method onInit takes nothing returns nothing
call TriggerRegisterAnyUnitEventBJ(Trigger,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(Trigger,function Spell.create)
endmethod
endstruct
endscope