- Joined
- Mar 10, 2009
- Messages
- 5,016
MUIDummyCasters
- You may find the GUI version of this in >>> [thread=235236]MUI DummyCaster[GUI] [/thread]
- Creates only 1 dummy for instant spells like firebolt, carrion swarm, banish, etc
- Supports channel spells by creating another dummy to channel the spell like flamestrike, starfall, blizzard, etc
- You may control the point where the dummy is created and cast to a target or location where you can see the projectile is traveling
v4.4a
- Fixed a bug when checking the unit type if spell is finished.
v4.4
- LUA object merger removed
- Struct API's replaed by functions
- RegisterPlayerPlayerUnit requirement removed
- Readable functions
- Preloading dummy added
v4.3
- Fixed a very large bug that everytime the spell ends, ALL casters will be Player(15)
- Lua object name changed from 'dumy' to 'xcvb' and has a warning message inside the code only
v4.2
- Changed to struct syntax
- Added LUA object creator for dummy
- Added a fail safe cast in case the target is not targetable
- Codes and varibales reduced
v4.1
- Added ForGroup looper instead of Timer
v4.0
- Removed TimerUtils and IsUnitChanneling
- Added Hashtable to save the ability of the dummy then remove it
- Added END CAST code
v3.0a
- Fixed unithandle leak
- API explanations added
- Bugs if the MDCCastToPoint and MDCCastToTarget is unreachable.
- Bugs when checking the unit type if spell is finished (fixed).
Intro
Code
Demo
Changelogs
Bugs
- You may find the GUI version of this in >>> [thread=235236]MUI DummyCaster[GUI] [/thread]
- Creates only 1 dummy for instant spells like firebolt, carrion swarm, banish, etc
- Supports channel spells by creating another dummy to channel the spell like flamestrike, starfall, blizzard, etc
- You may control the point where the dummy is created and cast to a target or location where you can see the projectile is traveling
JASS:
library MUIDummyCasters /* v4.4a */ initializer Init /*
*************************************************************************************
*
* by mckill2009
*
*************************************************************************************
*
* Creates only 1 dummy for instant spells like firebolt, carrion swarm, banish, etc
* Supports channel spells by creating another dummy to channel the spell like flamestrike, starfall, blizzard, etc
* You may control the point where the dummy is created and cast to a target or location where you can see the projectile is traveling
*
*************************************************************************************
*
* Credits
*
* Bribe
* -----------------------
* For info about the 'Amov' ability remove
*
* Nesthaurus
* -----------------------
* For his Comment header
*
*************************************************************************************
*
* */ uses /*
*
* */ Table /* [url]http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/[/url]
*
************************************************************************************
*
* Installation
* - Copy ALL that is in the "MUIDummyCasters" folder to your map.
* - Copy the Table library to your map.
* - Replace the rawID of the DUMMY_CASTER if needed, you may view it via pressing CTRL+D in the object editor.
*
************************************************************************************
*
* GLOBALS
*
*/
globals
/*
* Change the DUMMY_CASTER raw code if needed
*/
private constant integer DUMMY_CASTER = 'h000'
/*
* Constant globals, never touch these!
*/
private Table c
private constant player OWNER = Player(15)
private group DummyTake = CreateGroup()
private unit Dummy = null
/*
* TEST is for testing duh!, set to true to display how many
* dummies are created, set to false to disable it
*/
private constant boolean TEST = true
private integer DummyCount = 0
endglobals
/*
************************************************************************************
*
* Functions
*
* function MDCCast takes player owningPlayer, real xDummy, real yDummy, integer abilityID, integer orderID, integer level returns nothing
* function MDCCastToPoint takes player owningPlayer, real xDummy, real yDummy, real xTarget, real yTarget, integer abilityID, integer orderID, integer level returns nothing
* function MDCCastToTarget takes player owningPlayer, unit target, real xDummy, real yDummy, integer abilityID, integer orderID, integer level returns nothing
*
* Function Parameter Description
* player owningPlayer
* - the owner of the casting unit
*
* unit target (unit)
* - the spelltarget, used only by MDCCastToTarget
*
* real xDummy and yDummy
* - the point/coordinate where the dummy will be placed
*
* real xTarget and yTarget
* - the point/coordinate where the dummy cast the spell
* - used only by MDCCastToPoint
*
* integer abilityID
* - the raw code of of the ability being cast by the dummt caster
*
* integer orderID
* - the orderID of the abilityID
*
* integer level
* - the level of the abilityID
*
*
*/
//! textmacro ISSUE takes order
local unit dum = GetDummyUnit()
call UnitAddAbility(dum, abilityID)
call SetUnitAbilityLevel(dum, abilityID, level)
call SetUnitOwner(dum, owningPlayer, false)
call SetUnitX(dum, xDummy)
call SetUnitY(dum, yDummy)
call Issue$order$
set c[GetHandleId(dum)] = abilityID
/*
* This is just a fail safe, in case the target is invulnerable, invisible or cannot be casted
*/
if GetUnitCurrentOrder(dum)==0 then
call RefreshDummyUnit(dum)
endif
set dum = null
//! endtextmacro
private function RefreshDummyUnit takes unit d returns nothing
call SetUnitOwner(d, OWNER, false)
call UnitRemoveAbility(d, c[GetHandleId(d)])
call GroupAddUnit(DummyTake, d)
endfunction
private function GetDummyUnit takes nothing returns unit
if FirstOfGroup(DummyTake)==null then
set Dummy = CreateUnit(OWNER, DUMMY_CASTER, 0, 0, 0)
call UnitRemoveAbility(Dummy,'Amov')
static if TEST then
set DummyCount = DummyCount + 1
call BJDebugMsg("Dummies Created = "+I2S(DummyCount))
endif
else
/*
* if group is not empty then it will pick the first dummy in the group
* I've used this above indexing to be.....different XD...
*/
set Dummy = FirstOfGroup(DummyTake)
call GroupRemoveUnit(DummyTake, Dummy)
endif
return Dummy
endfunction
private function CastEnd takes nothing returns boolean
/*
* Checks the caster if he belongs in this system instead of
* checking the unit type (which bugs)
*/
if c.has(GetHandleId(GetTriggerUnit())) then
call RefreshDummyUnit(GetTriggerUnit())
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
/*
* Preloading only to avoid first time lag
*/
local unit u = CreateUnit(OWNER, DUMMY_CASTER, 0, 0, 0)
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TriggerAddCondition(t, Condition(function CastEnd))
set c = Table.create()
call KillUnit(u)
call RemoveUnit(u)
set t = null
set u = null
endfunction
/*
* This the main core system, 3 API you may use
*/
function MDCCast takes player owningPlayer, real xDummy, real yDummy, integer abilityID, integer orderID, integer level returns nothing
//! runtextmacro ISSUE("ImmediateOrderById(dum, orderID)")
endfunction
function MDCCastToPoint takes player owningPlayer, real xDummy, real yDummy, real xTarget, real yTarget, integer abilityID, integer orderID, integer level returns nothing
//! runtextmacro ISSUE("PointOrderById(dum, orderID, xTarget, yTarget)")
endfunction
function MDCCastToTarget takes player owningPlayer, unit target, real xDummy, real yDummy, integer abilityID, integer orderID, integer level returns nothing
//! runtextmacro ISSUE("TargetOrderById(dum, orderID, target)")
endfunction
endlibrary
-
MDCCast
-
Events
- Time - Every 0.10 seconds of game time
- Conditions
-
Actions
- Custom script: set udg_a = udg_a + 1.04
- Custom script: call MDCCast(Player(1), 0+300*Cos(udg_a), 0+300*Sin(udg_a), 'AHtc', 852096, 1)
-
Events
-
MDCCastToPoint CHANNEL
-
Events
- Time - Every 1.00 seconds of game time
- Conditions
-
Actions
- Custom script: set bj_wantDestroyGroup=true
-
Unit Group - Pick every unit in (Units within 2000.00 of loc1 matching ((Unit-type of (Matching unit)) Equal to Peasant)) and do (Actions)
-
Loop - Actions
- Custom script: call MDCCastToPoint(Player(0), 0,0, GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()), 'ACfs', 852488, 1)
-
Loop - Actions
-
Events
JASS:
scope LTest initializer init
private function Actions takes nothing returns nothing
local player p = Player(0)
local unit target
local group g = CreateGroup()
call GroupEnumUnitsInRange(g, 0,0, 2500, null)
loop
set target=FirstOfGroup(g)
exitwhen target==null
if IsUnitEnemy(target,p)then
call MDCCastToTarget(p, target, 0,0,'ACfb',852231,1)
endif
call GroupRemoveUnit(g,target)
endloop
call DestroyGroup(g)
set g = null
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 1.00, true)
call TriggerAddAction(t, function Actions)
set t = null
endfunction
endscope
v4.4a
- Fixed a bug when checking the unit type if spell is finished.
v4.4
- LUA object merger removed
- Struct API's replaed by functions
- RegisterPlayerPlayerUnit requirement removed
- Readable functions
- Preloading dummy added
v4.3
- Fixed a very large bug that everytime the spell ends, ALL casters will be Player(15)
- Lua object name changed from 'dumy' to 'xcvb' and has a warning message inside the code only
v4.2
- Changed to struct syntax
- Added LUA object creator for dummy
- Added a fail safe cast in case the target is not targetable
- Codes and varibales reduced
v4.1
- Added ForGroup looper instead of Timer
v4.0
- Removed TimerUtils and IsUnitChanneling
- Added Hashtable to save the ability of the dummy then remove it
- Added END CAST code
v3.0a
- Fixed unithandle leak
- API explanations added
- Bugs if the MDCCastToPoint and MDCCastToTarget is unreachable.
- Bugs when checking the unit type if spell is finished (fixed).
Attachments
Last edited: