- Joined
- Mar 10, 2009
- Messages
- 5,016
This s a simple one function that undetects un-engageable(non-attackable) units...
It's main purpose is for AI making...e.g. if an AI searches an enemy target, it will filter out non-attackable units,
thus not wasting time to lock to the unit that cannot be attacked...
Used by my AI systems:
EngageSystem
StrikeForce
v1.2
- Object ability Unholy Frenzy is replaced by Chain Lightning due to unwanted sound
v1.1
- I've decided to remove the LUA object since it's difficult for me to make a good instruction on how to import it
It's main purpose is for AI making...e.g. if an AI searches an enemy target, it will filter out non-attackable units,
thus not wasting time to lock to the unit that cannot be attacked...
Used by my AI systems:
EngageSystem
StrikeForce
JASS:
library IsUnitEngageable /* v1.2
************************************************************************************
* by mckill2009
************************************************************************************
*
* Installation:
* - Copy this script to your trigger editor via custom text
* - Copy the custom abilty from the object editor named 'IsUnitEngageable' to your map
* - Make sure you change also the rawID below (SPELL_ID) if you change the rawID of your imported ability
*
************************************************************************************
*
* function IsUnitEngageable takes unit u returns boolean
* Undetects units that is:
* - Invulnerable
* - Burrowed
* - Invisible
* - Ethereal
* - Have locust
*
************************************************************************************/
globals
/************************************************************************************
*
* Change the SPELL_ID according to the ability object named 'IsUnitEngageable'
*
*************************************************************************************/
private constant integer SPELL_ID = 'A000' //based on chain lightning
/************************************************************************************
*
* Never touch anything below this block
*
*************************************************************************************/
private constant integer DUMMY_ID = 'hmpr'
private unit DUMMY
endglobals
struct onInit
static method onInit takes nothing returns nothing
set DUMMY = CreateUnit(Player(15), DUMMY_ID, 0,0,0)
call UnitAddAbility(DUMMY, SPELL_ID)
call UnitAddAbility(DUMMY, 'Aloc')
call ShowUnit(DUMMY, false)
endmethod
endstruct
function IsUnitEngageable takes unit u returns boolean
call SetUnitPosition(DUMMY, GetUnitX(u), GetUnitY(u))
return IssueTargetOrderById(DUMMY, 852119, u) and not IsUnitType(u,UNIT_TYPE_ETHEREAL)
endfunction
endlibrary
JASS:
scope DEMO initializer init
globals
group grp = CreateGroup()
endglobals
function fil takes nothing returns boolean
call GroupAddUnit(grp,GetFilterUnit())
return false
endfunction
function grploop takes nothing returns nothing
local unit u = GetEnumUnit()
local texttag tag
if IsUnitEngageable(u) then
set tag = CreateTextTag()
call SetTextTagPosUnit(tag, u, 0)
call SetTextTagText(tag, GetUnitName(u), 0.025)
call SetTextTagPermanent(tag, false)
call SetTextTagVelocity(tag, 0.03, 0.03)
call SetTextTagLifespan(tag, 3)
call SetTextTagFadepoint(tag, 0.01)
endif
endfunction
function grplooper takes nothing returns nothing
call ForGroup(grp,function grploop)
endfunction
function init takes nothing returns nothing
call GroupEnumUnitsInRect(grp,bj_mapInitialPlayableArea,Filter(function fil))
call TimerStart(CreateTimer(),1.0,true,function grplooper)
endfunction
endscope
v1.2
- Object ability Unholy Frenzy is replaced by Chain Lightning due to unwanted sound
v1.1
- I've decided to remove the LUA object since it's difficult for me to make a good instruction on how to import it
Attachments
Last edited: