- Joined
- Apr 30, 2011
- Messages
- 359
JASS:
//========================================================================================
//
// Widget Type
// -*- overcold_ice -*-
//
// -[*] Requirements:
// - JNGP
// - latest version of JassHelper
//
// -[*] Optional Requirements:
// - ObjectMerger script: LUA_GET_VAR_OBJECT [url]http://www.hiveworkshop.com/forums/jass-resources-412/snippet-lua_get_var_object-185944/[/url]
//
// For your additional WidgetType needs
// This system provides additional IsWidgetType checker functions, primarily ones
// that the natives haven't have. Included: IsWidgetBridge, IsWidgetTree, and
// IsWidgetWard. You can add more types, and they can be a dynamic one.
//
// -[*] Note:
// - Doesn't support player-related checks (enemy, ally, friend, etc)
//
// -[*] API:
//
// function IsWidget$TYPE$ takes widget w returns boolean
// returns true if widget(w) is targeted as $TYPE$
// this uses an ability to check the widget
//
// $TYPE$:
// - Bridge
// - Tree
// - Ward
//
// -[*] ObjectMerger Script
/*
//! externalblock extension=lua ObjectMerger $FILENAME$
//====================================================================================
// C A L I B R A T I O N S E C T I O N
//====================================================================================
// Level of the ability
// higher level will enable more detections
//! i local LEVEL = "3"
// Detections in a level
// you can have as many detections in a single level
// number inside those '[ ]' represents the ability level
//! i local DETECT = {}
//! i local DETECT [1] = "bridge"
//! i local DETECT [2] = "tree"
//! i local DETECT [3] = "ward"
//====================================================================================
//! runtextmacro LUA_FILE_HEADER()
//! i dofile("GetVarObject")
//! i local id = getvarobject("Afod", "abilities", "WIDGET_TYPE_CHECKER_ID", true)
//! i createobject("Afod", id)
//! i makechange(current, "abpx", "0")
//! i makechange(current, "abpy", "0")
//! i makechange(current, "aart", "ReplaceableTextures\\WorldEditUI\\DoodadPlaceholder.blp")
//! i makechange(current, "alig", "")
//! i makechange(current, "atat", "")
//! i makechange(current, "alev", LEVEL)
//! i makechange(current, "arac", "unknown")
//! i makechange(current, "ansf", "")
//! i makechange(current, "ahky", "")
//! i makechange(current, "anam", "Widget Type Checker")
//! i makechange(current, "Nfd1", "1", "0")
//! i makechange(current, "Nfd2", "1", "0")
//! i makechange(current, "Nfd3", "1", "0")
//! i makechange(current, "acdn", "1", "0")
//! i makechange(current, "atp1", "1", "")
//! i makechange(current, "aub1", "1", "")
//! i for i=1, LEVEL do
//! i makechange(current, "aran", i, "99999")
//! i makechange(current, "atar", i, DETECT [i])
//! i end
//! i updateobjects()
//! endexternalblock
*/
//========================================================================================
library WidgetType
//====================================================================================
// C A L I B R A T I O N S E C T I O N
//====================================================================================
globals
// your dummy unit's rawcode
private constant integer DUMMY_ID = 'dumy'
// widget checker ability's rawcode
private constant integer ABILITY_CHECKER_ID = 'wtcs'
// variables related to the ability's level
// and especially the functions itself
// (see textmacros at the bottom of this script)
private constant integer BRIDGE = 1
private constant integer TREE = 2
private constant integer WARD = 3
endglobals
//====================================================================================
globals
private unit dummy
endglobals
//====================================================================================
// A P I
//====================================================================================
//! textmacro WidgetType___MakeAPI takes NAME, VAR
function IsWidget$NAME$ takes widget w returns boolean
call SetUnitAbilityLevel(dummy, ABILITY_CHECKER_ID, $VAR$)
return IssueTargetOrder(dummy, "fingerofdeath", w) and IssueImmediateOrder(dummy, "stop")
endfunction
//! endtextmacro
// Results
// Name : IsWidget$xXXXXx$
// Variable Used : $xXXx$
//! runtextmacro WidgetType___MakeAPI("Bridge", "BRIDGE")
//! runtextmacro WidgetType___MakeAPI( "Tree", "TREE")
//! runtextmacro WidgetType___MakeAPI( "Ward", "WARD")
//====================================================================================
private module InitM
private static method onInit takes nothing returns nothing
set dummy = CreateUnit(Player(15), DUMMY_ID, 0, 0, 0)
call UnitAddAbility(dummy, ABILITY_CHECKER_ID)
endmethod
endmodule
private struct InitS
implement InitM
endstruct
endlibrary
Attachments
Last edited: