gref
New Member
- Reaction score
- 33
Rain Of Footmen
MUI: Yes.
Leakless: Yes.
Lagless: Yes.
JESP: Yes.
Jass/GUI: Jass
Screenshot:
Description:
Channeled: Footmen fall from the sky and explode, dealing damage.
Inspired by: http://www.thehelper.net/forums/showthread.php?t=80226
Made in Jass
How to Implement:
MUI: Yes.
Leakless: Yes.
Lagless: Yes.
JESP: Yes.
Jass/GUI: Jass
Screenshot:
Description:
Channeled: Footmen fall from the sky and explode, dealing damage.
Inspired by: http://www.thehelper.net/forums/showthread.php?t=80226
Made in Jass
JASS:
//===============================>
// Rain of Footmen by gref.
//===============================>
scope RainOfFootmen
// Follows JESP
//===========================>
//Constants
//===========================>
globals
private constant integer AbilCode = 039;A000039; //Name of triggering ability
private constant integer UnitCode = 039;h000039; //Name of unit used for footman
private constant real maxheight = 1200.0 //maximum height
private constant real minheight = 1000.0 //minimum height
private constant real range = 400.0 //range from center. ie 400 = 800 aoe.
private constant real damagerange = 130.0 //range a unit has to be in to be hit by a footman's damage
private constant real damagefactor = 50.0 //damage per level
private constant real damagebase = 50.0 //constant damage
private constant real footmenpersecond = 10 //number of footmen per second.
endglobals
//===========================>
//Data Types
//===========================>
struct FootmenStruct
real x
real y
integer level
unit caster
static method create takes unit caster, real x, real y, integer level returns FootmenStruct
local FootmenStruct f = FootmenStruct.allocate()
set f.level = level
set f.x = x
set f.y = y
set f.caster = caster
return f
endmethod
endstruct
struct TimerStruct
timer t
method onDestroy takes nothing returns nothing
local FootmenStruct f = GetAttachedInt(.t, "FootmenStruct")
call FootmenStruct.destroy(f)
call CleanAttachedVars(.t)
call PauseTimer(.t)
call DestroyTimer(.t)
endmethod
static method create takes nothing returns TimerStruct
local TimerStruct ts = TimerStruct.allocate()
set ts.t = CreateTimer()
return ts
endmethod
endstruct
//===========================>
// Functions
//===========================>
private function DamageFilter takes nothing returns boolean
return (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0) and not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
endfunction
private function TimerTick takes nothing returns nothing
local timer t = GetExpiredTimer()
local FootmenStruct f = GetAttachedInt(t, "FootmenStruct")
local real angle = GetRandomReal(0, 6.28318)
local real distance = GetRandomReal(0, range)
local real x = f.x + distance*Cos(angle)
local real y = f.y + distance*Sin(angle)
local real tangle = GetRandomReal(0, 6.28318)
local real tdistance = GetRandomReal(0, 200)
local real tx = x + tdistance*Cos(tangle)
local real ty = y + tdistance*Sin(tangle)
local unit d = CreateUnit(GetOwningPlayer(f.caster), UnitCode, x, y, GetRandomReal(0, 360))
local real height = GetRandomReal(minheight, maxheight)
local real timedlife = height/(1500)
call AttachInt(d, "FootmanLevel", f.level)
call UnitApplyTimedLife(d, 039;BTLF039;, timedlife)
call IssuePointOrder(d, "move", tx, ty)
call UnitAddAbility(d, 039;Arav039;)
call UnitRemoveAbility(d, 039;Arav039;)
call SetUnitFlyHeight(d, height, 0)
call SetUnitFlyHeight(d, 0, (height/timedlife))
set d = null
set t = null
endfunction
private function RainOfFootmen_Actions takes nothing returns nothing
local TimerStruct ts
local FootmenStruct f
local unit u
local group g
local integer level
local real x
local real y
local player owner
if(GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT) then //Footman cast
if(GetSpellAbilityId() == AbilCode) then
set ts = TimerStruct.create()
set f = FootmenStruct.create(GetTriggerUnit(), GetLocationX(GetSpellTargetLoc()), GetLocationY(GetSpellTargetLoc()), GetUnitAbilityLevel(GetTriggerUnit(), AbilCode))
call AttachInt(GetTriggerUnit(), "TimerStruct", ts)
call AttachInt(ts.t, "FootmenStruct", f)
call TimerStart(ts.t, 1/footmenpersecond, true, function TimerTick)
endif
elseif(GetTriggerEventId() == EVENT_PLAYER_UNIT_DEATH) then //Footman dies
if (GetUnitTypeId(GetTriggerUnit()) == UnitCode) then
set g = CreateGroup()
set level = GetAttachedInt(GetTriggerUnit(), "FootmanLevel")
set x = GetUnitX(GetTriggerUnit())
set y = GetUnitY(GetTriggerUnit())
set owner = GetOwningPlayer(GetTriggerUnit())
call CleanAttachedVars(GetTriggerUnit())
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl", x, y))
call GroupEnumUnitsInRange(g, x, y, damagerange, Condition(function DamageFilter))
loop
set u = FirstOfGroup(g)
exitwhen u == null
if(IsUnitEnemy(u, owner) == true) then
call UnitDamageTarget(GetTriggerUnit(), u, damagebase+damagefactor*level, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
endif
else //stopped cast.
if(GetSpellAbilityId() == AbilCode) then
set ts = GetAttachedInt(GetTriggerUnit(), "TimerStruct")
call TimerStruct.destroy(ts)
call CleanAttachedVars(GetTriggerUnit())
endif
endif
set u = null
set owner = null
set g = null
endfunction
//===========================================================================
function InitTrig_RainOfFootmen takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( t, function RainOfFootmen_Actions )
call Preload("Objects\\Spawnmodels\\Human\\HumanLargeDeathExplode\\HumanLargeDeathExplode.mdl")
set t = null
endfunction
endscope
How to Implement:
Spell Requirements:
1. A vJass preprocessor (If you don't have one you can download one from wc3campaigns.net)
How to implement this in your map:
1. Copy the CSCache and RainOfFootmen triggers to your map. (If you have CSCache, don't worry about it)
2. Copy the unit called Footman in the object editor.
3. Copy the ability called Rain Of Footmen in the object editor.
4. Make sure that the constants in the RainOfFootmen trigger match the ability and unit.
1. A vJass preprocessor (If you don't have one you can download one from wc3campaigns.net)
How to implement this in your map:
1. Copy the CSCache and RainOfFootmen triggers to your map. (If you have CSCache, don't worry about it)
2. Copy the unit called Footman in the object editor.
3. Copy the ability called Rain Of Footmen in the object editor.
4. Make sure that the constants in the RainOfFootmen trigger match the ability and unit.