- Joined
- Jun 2, 2004
- Messages
- 849
But who cares about cheating in single player? It's doing no harm. If the player gets bored of your campaign they might actually continue it if they can just waltz through everything too, instead of plain giving up.
type rpgdialog extends agent
type rpgdialogbutton extends agent
type rpgdialogevent extends agent
type rpgdialogbuttontype extends handle
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_BUTTON
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_CHECK
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_TEXTFIELD
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_TEXTAREA
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_LABEL
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_RADIO
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_PROGRESS
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_ICON
constant rpgdialogbuttontype RPG_DIALOG_BUTTON_TYPE_MODEL_PORTRAIT
constant rpgdialogevent RPG_DIALOG_BUTTON_CLICKED
constant rpgdialogevent RPG_DIALOG_BUTTON_CHECKED
constant rpgdialogevent RPG_DIALOG_CLICKED
constant rpgdialogevent RPG_DIALOG_SHOWED
constant rpgdialogevent RPG_DIALOG_HIDE
native GetClickedButtonRPGDialog takes nothing returns rpgdialogbutton
native GetCheckedButtonRPGDialog takes nothing returns rpgdialogbutton
native GetClickedRPGDialog takes nothing returns rpgdialog
native GetCheckedRPGDialog takes nothing returns rpgdialog
native GetPlayerRPGDialog takes nothing returns player // Player which clicked the dialog
native TriggerRegisterRPGDialogEvent takes trigger whichTrigger, rpgdialog whichRPGDialog, rpgdialogevent eventId returns event
//native TriggerRegisterRPGDialogEvent takes trigger whichTrigger, rpgdialog whichRPGDialog returns event
//native TriggerRegisterRPGDialogButtonEvent takes trigger whichTrigger, rpgdialogbutton whichRPGDialogButton returns event
native RPGDialogCreate takes integer x, integer y, integer width, integer height returns rpgdialog
native RPGDialogResize takes rpgdialog whichRPGDialog, width, integer height returns nothing
native RPGDialogReposition takes rpgdialog whichRPGDialog, integer x, integer y returns nothing
native RPGDialogFolding takes rpgdialog whichRPGDialog, player whichPlayer, boolean onFolding returns nothing
native RPGDialogMinimize takes rpgdialog whichRPGDialog, player whichPlayer, boolean onMinimize returns nothing
native RPGDialogScrollStyle takes rpgdialog whichRPGDialog, boolean onEnabled returns nothing
native RPGDialogDisplay takes rpgdialog whichRPGDialog, player whichPlayer, boolean onShow returns nothing
native RPGDialogButtonDisplay takes rpgdialogbutton whichRPGDialogButton, player whichPlayer, boolean onShow returns nothing
native RPGDialogDestroy takes rpgdialog whichRPGDialog returns nothing
native RPGDialogSetTitle takes rpgdialog whichRPGDialog, string Text returns nothing
native RPGDialogButtonSetGraphic takes rpgdialogbutton whichRPGDialogButton, string icoOrModelPath returns nothing // RPG_DIALOG_BUTTON_TYPE_BUTTON, RPG_DIALOG_BUTTON_TYPE_ICON, RPG_DIALOG_BUTTON_TYPE_MODEL_PORTRAIT
native RPGDialogButtonRelease takes rpgdialogbutton whichRPGDialogButton returns nothing
native RPGDialogAddButton takes rpgdialog whichRPGDialog, rpgdialogbuttontype rpgbuttonType, integer x, integer y, integer width, integer height returns rpgdialogbutton
native RPGDialogButtonChangeValueString takes rpgdialogbutton whichRPGDialogButton, string changeText returns nothing
native RPGDialogButtonChangeValueBoolean takes rpgdialogbutton whichRPGDialogButton, boolean changeBool returns nothing
native RPGDialogButtonChangeValueInt takes rpgdialogbutton whichRPGDialogButton, integer changeInt returns nothing
native RPGDialogClear takes rpgdialog whichRPGDialog returns nothing
native RPGDialogSetTitleColor takes rpgdialog whichRPGDialog, integer red, integer green, integer blue, integer alpha returns nothing
native RPGDialogSetButtonColor takes rpgdialog whichRPGDialog, integer red, integer green, integer blue, integer alpha returns nothing // Colored progress bar, oh yeah!
native GetUnitRangeAttack takes unit whichUnit, integer attackIndex returns integer(real)
native SetUnitRangeAttack takes unit whichUnit, integer attackIndex, integer(real) newRange returns nothing
#13 #8 or "?" or {49}
native Char takes integer index returns char
native CharId takes char whichChar returns integer
native MultibyteCharSubStr takes string source, integer start, integer end, integer bytes returns char
native IsUnicodeMode takes nothing returns boolean
native DLLBlizzardInclude takes string dllPath returns integer //Only dll signed by the blizzard.
native IncludeJassFile takes string jassFile returns integer //Random jass scipt file ".j", ".ai"
GetTriggerPlayer()
currently returns the owner of unit. Having something like this would be nice:// I'm terrible at giving names to functions
constant native GetAlliedTriggerPlayer takes nothing returns player
// This function should probably work with almost all "playerunitevent" events, and also with
// the following "unitevents" - This is perhaps redundant since "playerunitevent" has the equivalent
// for every "unitevent" mentioned below:
EVENT_UNIT_SELL
EVENT_UNIT_SELL_ITEM
EVENT_UNIT_SPELL_CHANNEL
EVENT_UNIT_SPELL_CAST
EVENT_UNIT_SPELL_EFFECT
EVENT_UNIT_SPELL_FINISH
EVENT_UNIT_SPELL_ENDCAST
EVENT_UNIT_PAWN_ITEM
Probably would be better named something like that GetIssuingPlayer or GetOrderingPlayer. Definitely a good suggestion though.I'd like to see a simple function that I've seen people asking for, which is a getter that returns the real player that issued an order to an allied unit. For example, we sometimes share control with another player, and that player might want to use an ability, or give orders to that unit. The nativeGetTriggerPlayer()
currently returns the owner of unit. Having something like this would be nice:
JASS:// I'm terrible at giving names to functions constant native GetAlliedTriggerPlayer takes nothing returns player // This function should probably work with almost all "playerunitevent" events, and also with // the following "unitevents" - This is perhaps redundant since "playerunitevent" has the equivalent // for every "unitevent" mentioned below: EVENT_UNIT_SELL EVENT_UNIT_SELL_ITEM EVENT_UNIT_SPELL_CHANNEL EVENT_UNIT_SPELL_CAST EVENT_UNIT_SPELL_EFFECT EVENT_UNIT_SPELL_FINISH EVENT_UNIT_SPELL_ENDCAST EVENT_UNIT_PAWN_ITEM
I believe this function is simply hidden, because I remember seeing a similar one on Memory Hack (patch 1.26).
// Unit
native GetUnitBonusDamage takes unit u returns integer
// Returns bonus damage of a unit.
native SetUnitBonusDamage takes unit u, integer newDmg returns nothing
// Sets the bonus damage of a unit.
// Ability and Units
constant native GetEventManaCost takes nothing returns nothing
// I recommend usage in the EVENT_UNIT_SPELL_EFFECT or EVENT_PLAYER_UNIT_SPELL_EFFECT
native SetEventManaCost takes real newMana returns nothing
// A setter of the manacost, just like the new SetEventDamage native.
constant native GetEventRawDamage takes nothing returns real
// Used in EVENT_UNIT_DAMAGED events
// Just another name for unreduced damage, (before any possible reductions).
// More of a suggested name for a similar native than a new native in itself.
native SetUnitTypeAbilityCooldown takes unittype unitId, integer abilType, integer level, real cooldown returns boolean
// This is the suggested successor for the buggy SetUnitAbilityCooldown native. Only changes the ability cooldown
// of a specific unit type at a requested level. If successful, return true.
native UnitGetAbility takes unit u, integer abilId returns ability
// This is to make use of the type ability.
native GetAbilityCooldown takes ability abil returns real
// returns the individual ability's cooldown. Does not create a new one, though!
native GetAbilityLevelCooldown takes ability abil, integer level returns real
// returns the individual ability's cooldown at a specified level.
native SetAbilityCooldown takes ability abil, real newCool returns nothing
// sets the individual ability's cooldown.
native SetAbilityLevelCooldown takes ability abil, integer level, real newCool returns nothing
// sets the individual ability's cooldown at a specified level.
native SetUnitAbilityCooldown takes unit u, integer abilId, real newCool returns nothing
// Should be made a wrapper to SetAbilityCooldown
native SetUnitAbilityLevelCooldown takes unit u, integer abilId, integer level, real newCool returns nothing
// Should be made a wrapper to SetAbilityLevelCooldown
native GetUnitAttachX takes unit u, string attachmentPoint returns real
// Returns the abscissa.
native GetUnitAttachY takes unit u, string attachmentPoint returns real
// Returns the ordinate.
native GetUnitAttachZ takes unit u, string attachmentPoint returns real
// Returns the height of the attachment point.
native ConvertAbilityState takes integer i returns abilitystate
// A native for the ability states...
constant abilitystate ABILITY_STATE_SILENCE
// The state which determines the silence counter
constant abilitystate ABILITY_STATE_HIDDEN
// The state which determines the hide icon counter
constant abilitystate ABILITY_STATE_PERMANENT
// The state which determines the permanent counter
// Can be useful in making the permanent abilities temporary and stuff...
constant abilitystate ABILITY_STATE_DISABLED
// The sum of the silence and hide icon counters.
constant abilitystate ABILITY_STATE_CHARGED
// The charge counter of an ability. Can be seen in the Sentinel spell (Scout with trees).
native GetAbilityState takes ability abil, abilitystate abilState returns integer
// Returns certain things about the ability.
native SetAbilityState takes ability abil, abilitystate abilState, integer newValue returns nothing
if abilState == ABILITY_STATE_DISABLED or abilState == ABILITY_STATE_CHARGED then
return
endif
// Sets the ability state of a certain ability.
native AbilityPauseCooldown takes ability abil, boolean pause returns boolean
if not (GetAbilityCooldown(abil) != 0.) then
// You can resolve the epsilon in the double equal symbol operator
return false
endif
// Pauses the cooldown of an ability, making for some interesting interactions...
return true
native SetAbilityCooldownRemaining takes ability abil, real newAmount returns boolean
if newAmount < 0 then
return false
endif
// Sets the remaining cooldown of an ability.
native AbilityAddCounter takes ability abil returns boolean
if GetAbilityState(abil, ABILITY_STATE_CHARGED) == 0 then
return true
endif
return false
native AbilityRemoveCounter takes ability abil returns boolean
// An antithesis to the native AbilityAddCounter with an inverse boolean statement
native AbilitySetCounter takes ability abil, integer amount returns boolean
// Checks if the ability has a counter, and modifies the amount. Setting it to 0 or less defaults it to 1.
native AbilityGetCounter takes ability abil returns integer
// Returns the value of the charge counter.
// Timer stuff
native SetTimerRemaining takes timer t, real newTime returns nothing
// Sets the remaining time. If negative, execute the handler code immediately.
type ability
would make sense when working with specific abilities overall Yes, using the
type ability
would make sense when working with specific abilities overall.
There is still type buff, over that can be make a few operations and manipulations.
native GetBuffLevel takes buff whichBuff returns integer
native GetBuffAtUnit takes integer buffCode returns buff
native SetBuffLevel takes buff whichBuff, integer level returns nothing
native DecBuffLevel takes buff whichBuff returns integer
native IncBuffLevel takes buff whichBuff returns integer
native ApplyBuffTime takes buff whichBuff, real time returns nothing // Disables permanent status at buff
native RemoveBuffTime takes buff whichBuff returns nothing // Not enables permanent status at buff, just eternal buff, which may dispelled
native GetBuffTimer takes buff whichBuff returns timer
native GetBuffTimeRemaining takes buff whichBuff returns real
native SetBuffPermanent takes buff whichBuff returns nothing // Can't be dispelled, ignores magic immune, however may be deleted by triggers function.
native UnsetBuffPermanent takes buff whichBuff returns nothing // Can be dispelled, doesn't ignores magic immune.
native AddBuff takes integer buffCode, unit target returns buff
native RemoveBuff takes buff whichBuff returns buff
native SetEventManaCost takes real newMana returns nothing
constant native GetEventManaCost takes nothing returns nothing
native UnitGetAbility takes unit u, integer abilId returns ability
native AbilitySetCounter takes ability abil, integer amount returns boolean//and derivatives
native SetAbilityCooldown takes ability abil, integer level, real newCool returns nothing
// sets the individual ability's cooldown at a specified level.
native GetEventDamage takes nothing returns real
and native SetEventDamage takes real r returns nothing
for EVENT_UNIT_DAMAGED events?vJASS:native GetBuffLevel takes buff whichBuff returns integer native GetBuffAtUnit takes integer buffCode returns buff native SetBuffLevel takes buff whichBuff, integer level returns nothing native DecBuffLevel takes buff whichBuff returns integer native IncBuffLevel takes buff whichBuff returns integer native ApplyBuffTime takes buff whichBuff, real time returns nothing // Disables permanent status at buff native RemoveBuffTime takes buff whichBuff returns nothing // Not enables permanent status at buff, just eternal buff, which may dispelled native GetBuffTimer takes buff whichBuff returns timer native GetBuffTimeRemaining takes buff whichBuff returns real native SetBuffPermanent takes buff whichBuff returns nothing // Can't be dispelled, ignores magic immune, however may be deleted by triggers function. native UnsetBuffPermanent takes buff whichBuff returns nothing // Can be dispelled, doesn't ignores magic immune. native AddBuff takes integer buffCode, unit target returns buff native RemoveBuff takes buff whichBuff returns buff
native GetUnitBuff takes unit whichUnit, integer buffId returns buff
// A function for getting a certain buff. Does not create a new buff handle.
native GetBuffLevel takes buff whichBuff returns integer
// Seems okay here...
native GetUnitFromBuff takes buff whichBuff returns unit
// A function for returning the unit who has that buff...
native SetUnitBuffLevel takes unit whichUnit, buff whichBuff, integer level returns nothing
// The setter function for level
native DecBuffLevel takes buff whichBuff returns nothing
native IncBuffLevel takes buff whichBuff returns nothing
native SetBuffLevel takes buff whichBuff, integer level returns nothing
native BuffApplyTimedLife takes buff whichBuff, real newTime returns nothing
// Can also be made a resetter for when a buff is set to expire. If newTime is less than or equal to 0,
// the buff is removed on the next tick (0-second timer)
native BuffAlterTimedLife takes buff whichBuff, boolean pause returns nothing
if pause then
// Pauses the timer for the duration of the buff..
else
// Removes the buff on next tick.
endif
// native BuffGetTimer takes buff whichBuff returns timer
// There would be no need for a timer handle here, since it only handles the timed life of the buff.
// However, it can be made an internal function, where the existence of an internal timer will deter
// mine permanence. If it exists, the buff is not permanent.
native IsBuffPermanent takes buff whichBuff returns boolean
// As stated above, if an internal timer exists, the buff is not permanent.
native BuffGetRemaining takes buff whichBuff returns real
// If permanent, the result should be 0. Else it returns the remaining duration of the timer.
native SetBuffPermanent takes buff whichBuff, boolean permanent returns nothing
// Should be reduced to one function...
native UnitAddBuff takes unit whichUnit, integer buffId returns boolean
// If a buff already exists, it will just return false
// More natives and constants
native IsBuffPositive takes buff whichBuff returns boolean
// Returns true if a buff is beneficial (e.g. cast by an ally, or a beneficial dummy spell cast by enemy)
native SetBuffPositive takes buff whichBuff, boolean flag returns boolean
// A corresponding setter to the positive buff effect.
native GetBuffTooltip takes buff whichBuff returns string
native GetBuffTooltipEx takes buff whichBuff returns string
native GetBuffTooltipLength takes buff whichBuff returns integer
native GetBuffName takes buff whichBuff returns string
native SetBuffTooltip takes buff whichBuff, string newText returns nothing // Sets main tooltip
native SetBuffTooltipEx takes buff whichBuff, string newText returns nothing // Sets extra info
native SetBuffTooltipLength takes buff whichBuff, integer newLength returns nothing // Sets the total length of description of buff.
native SetBuffName takes buff whichBuff, string newName returns nothing // Sets the name of the buff.
Some event handlers
constant unitevent EVENT_UNIT_BUFF_APPLY
constant unitevent EVENT_UNIT_BUFF_DISPEL
constant playerunitevent EVENT_PLAYER_UNIT_BUFF_APPLY
constant playerunitevent EVENT_PLAYER_UNIT_BUFF_DISPEL
native BuffGetEventFlag takes nothing returns boolean
// Returns true if the buff triggered the playerunitevents through normal means. Otherwise
// return false.
constant native GetTriggerBuff takes nothing returns buff
// Gets the buff that triggered events EVENT_PLAYER_UNIT_BUFF_APPLY and EVENT_PLAYER_UNIT_BUFF_DISPEL
constant native BuffExpired takes nothing returns boolean
// As an event response native to EVENT_PLAYER_UNIT_BUFF_DISPEL. The buff is still in the unit
// but is about to be removed.
// If true, the buff was dispelled through normal means. Otherwise, it was just forcefully dispelled.
// Removing the buffs through triggers will trigger the EVENT_PLAYER_UNIT_BUFF_DISPEL event.
// Result on existing natives
native UnitRemoveBuffs takes unit whichUnit, boolean positive returns nothing
// Will trigger the unitevents and playerunitevents ....
native UnitRemoveBuffsEx takes unit whichUnit, boolean positive, boolean extraFlags ... returns nothing
// Will trigger the unitevents and playerunitevents ....
bj_functions:
function UnitBuffSetRemaining takes unit whichUnit, integer buffId, real newTime returns nothing
call BuffApplyTimedLife(GetUnitBuff(whichUnit, buffId), newTime)
function IsBuffNegative takes buff whichBuff returns boolean
return not IsBuffPositive(whichBuff)
No. Currently, those functions don't work at all with it; They return 0.00, and you can't even move a special effect attached to a unit.Is it possible to get xyz from the Effect that been set by SetSpecialEffectTarget?
I mean is there a chance to make something like axes been throw to ground and the model gone from your hand in term of playing smooth animation.
Please comment this.vJASS:native UnitGetAbility takes unit u, integer abilId returns ability native AbilitySetCounter takes ability abil, integer amount returns boolean//and derivatives
Blizzard adding both functions would be awesome. However, working with SetEventManaCost would be way better and faster for that purpose as you don't even need to care about tracking which ability has been cast. On the other hand, for SetAbilityManacost you'd have to use other functions which enumerates all abilities a unit has - like a Unit Group, then modify abilities individually. At last, the map maker has also to make sure they're not gonna mess up abilities mana cost for the rest of a game.But SetAbilityManacost fits a lot better for the same purpose (It visually represents an actual manacost)
native UnitGetAbility takes unit whichUnit, integer abilId returns ability
// This simply behaves as a getter for a certain ability handle if said ability exists.
// It is to be made an actual getter, in that it will NOT allocate more handles when called multiple times.
native AbilitySetCounter takes ability ability, integer newCount returns nothing
// Examine the Sentinel spell of the huntress.
// It has a visual counter representing the amount of charges in the spell.
// The native adds that counter to a specific ability of a unit, which makes for some interesting applications.
unitevent EVENT_UNIT_EVADE
I agree, but something is missing or so it seems to me. Your variant is better than my variant. May be is Show\Hide for Buff or something else?Those would be very useful functions. However, I would like to introduce some revisions:
// From local data into public data by sync to players.
type file extends handle
type fileoption extends file
type filedatatype extends file
fileoption FILE_OPTION_READ_ONLY
fileoption FILE_OPTION_WRITE_ONLY
fileoption FILE_OPTION_READ_AND_WRITE
fileoption FILE_OPTION_REWRITE
fileoption FILE_OPTION_APPEND
filedatatype FILE_DATA_STRING
filedatatype FILE_DATA_INTEGER
filedatatype FILE_DATA_BOOLEAN
filedatatype FILE_DATA_REAL
native SynFileOpen takes player wplayer, fileoption fopt, string fpath returns file
native SynFileClose takes file wfile returns boolean
native IsFileExist takes file wfile returns boolean
native SynFileRead takes file wfile, filedatatype wtype returns boolean
native SynBinFileRead takes file wfile, filedatatype wtype, integer pos returns boolean
native GetSynFileInteger takes nothing returns integer
native GetSynFileString takes nothing returns string
native GetSynFileReal takes nothing returns real
native GetSynFileBoolean takes nothing returns boolean
native SynFileWriteInt takes file wfile, filedatatype wtype, integer datawrite returns boolean
native SynFileWriteBool takes file wfile, filedatatype wtype, boolean datawrite returns boolean
native SynFileWriteStr takes file wfile, filedatatype wtype, string datawrite returns boolean
native SynFileWriteReal takes file wfile, filedatatype wtype, real datawrite returns boolean
native SynBinFileWriteInt takes file wfile, filedatatype wtype, integer pos, integer datawrite returns boolean
native SynBinFileWriteBool takes file wfile, filedatatype wtype, integer pos, boolean datawrite returns boolean
native SynBinFileWriteStr takes file wfile, filedatatype wtype, integer pos, string datawrite returns boolean
native SynBinFileWriteReal takes file wfile, filedatatype wtype, integer pos, real datawrite returns boolean
Here ya go:Would someone mind culling through this thread and creating an updated feature list?
Here ya go:
Updated Feature List
- New neutral Tavern Hero
Huh, that's a lot shorter than I thought. Weird.
![]()
/*
//NEW FEATURES
LIBRARIES & SCOPES
http://www.wc3c.net/vexorian/jasshelpermanual.html#lib
GLOBALS BLOCK
The ability to declare global variable directly in code. This tremendously facilitates installation of new system without the need for a separate 'variable creator' trigger.
http://www.wc3c.net/vexorian/jasshelpermanual.html#gdf
STRUCTS
http://www.wc3c.net/vexorian/jasshelpermanual.html#stru
2D ARRAYS
http://www.wc3c.net/vexorian/jasshelpermanual.html#twodarray
//NEW NATIVES
Dynamically Change Fields At Runtime: the following is just a list of commonly requested
properties that map-makers would enjoy having access to via triggers:
- Get and set a unit’s ability/item cooldown time
- Get and set attack damage, armor, attack range, attack speed, attack index, backswing, etc.
- Get and set object editor fields at runtime, e.g. a unit’s model, a unit’s attack missile, set tooltips
for units/abilities/items, set icons, etc.
- Set a unit’s facing, pitch, and roll instantly (setting a unit’s facing currently has turn-speed delay)
- Better control over a unit’s portrait
- Set a unit’s maximum hit points and mana points++
- Get a unit’s damage type
- ‘Attack released event’ - an event that fires when an attack is released i.e. released projectile
Some example are provided below, but in order of importance, 'getters' come before 'setters'. (eg: GetUnitGoldCost() is more important that SetUnitGoldCost(),
though having both would be tremendously helpful in a lot of circumstances)
*/
//Fixes
native EnableOcclusion takes boolean flag returns nothing //Possibly in reference to occlusion being broken in general? Details lacking.
native TriggerRegisterUnitStateEvent takes trigger whichTrigger, unit whichUnit, unitstate whichState, limitop opcode, real limitval returns event
//EQUAL is broken? Details lacking.
native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing
native UnitRemoveBuffs takes unit whichUnit, boolean positive returns nothing
// Will trigger the unitevents and playerunitevents ....
// Not really needs fix, but will trigger the appropriate events.
native UnitRemoveBuffsEx takes unit whichUnit, boolean positive, boolean extraFlags ... returns nothing
// Will trigger the unitevents and playerunitevents ....
// Not really needs fix, but will trigger the appropriate events.
native UnitRemoveAbility takes unit u, integer abilId returns boolean
// Can be made so that when the abilId is a buff, the native will instead call DestroyBuff(GetUnitBuff(u, abilId))
//The main tooltip of the added unit will always ignore color tags so the text will always appear to be white. Color tags should be parsed the same as all unit tooltips.
/*
With each of call of this function, the minimap is modified in a bugged way :
The positions of units and the fog of war are modified to fit to the new camera bound but not the terrain, nor the destructables.
The minimap is compressed (vertically) according to the current camera's rotation. With a rotation of 90°, there is no compression. With a rotation of 227.40, the minimap is fully compressed. Between 227.5 and 312.6, the game crashes.
Moreover, the camera bounds will also be adjusted according to the rotation of the current camera. The camera bounds created will be a rectangle going trough the 4 points given and whose sides will be parallel to the camera.
*/
native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing
/*
Destroy all bound triggeraction objects.
Currently it only destroys all bound events, triggercondition and the trigger itself leaving all triggeraction objects to leak unless explicitly destroyed before.
Also destroy all currently scheduled trigger threads from that trigger.
Currently destroying a trigger with scheduled trigger threads can cause handle stack corruption which has a high chance to cause Warcraft III to crash.
*/
native DestroyTrigger takes trigger whichTrigger returns nothing
function SmartCameraPanBJ takes player whichPlayer,location loc,real duration returns nothing
//This BJ function is currently not net safe. Details explained: https://www.hiveworkshop.com/threads/fixing-smartcamerapanbj-desync.243334/
constant native GetEventDamage takes nothing returns real //Return the amount of life damage taken through an imperfect mana shield. Currently returns 0 or negative only even if the unit takes life damage through the shield.
//Change suggestions
native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
//Change it so that displaying text to a player with unique x and y does not move any other messages.
//NEW TYPES
type file extends handle
type fileoption extends file
type filedatatype extends file
type proxy extends unit
//REWORKED TYPES
type ability extends handle
type buff extends handle
//NEW CONSTANTS
constant abilitystate ABILITY_STATE_SILENCE // The state which determines the silence counter
constant abilitystate ABILITY_STATE_HIDDEN // The state which determines the hide icon counter
constant abilitystate ABILITY_STATE_PERMANENT // The state which determines the permanent counter
// Can be useful in making the permanent abilities temporary and stuff...
constant abilitystate ABILITY_STATE_DISABLED // The sum of the silence and hide icon counters.
constant abilitystate ABILITY_STATE_CHARGED // The charge counter of an ability. Can be seen in the Sentinel spell (Scout with trees).
constant destructableevent DESTRUCTIBLE_DEATH //Triggers when a destructible dies. I put this here to standardise the way destructible events work.
constant destructableevent DESTRUCTIBLE_COMBAT //Triggers when a destructible takes damage from a combat source. Ignores tree-harvesting.
constant destructableevent DESTRUCTIBLE_HARVESTED //Triggers when a destructible takes damage from a tree-harvest ability. Ignores combat damage.
// Either one of these events should run before DESTRUCTIBLE_DAMAGED, for differentiation purposes in DESTRUCTIBLE_DAMAGED
constant destructableevent DESTRUCTIBLE_DAMAGED //Triggers when a destructible takes any damage at all.
constant minimapevent PING //Trigger on a minimap ping
constant minimapevent MINIMAP_BUTTON_PRESSED //Triggers when one of the associated minimap buttons have been pressed.
constant mouseevent MOUSE_CLICK //Triggers on any mouse click. Conditions determine what mouse button that was (eg left click, right click, side clicks (aka mouse 4, mouse 5), etc)
constant mouseevent MOUSE_RELEASE //Triggers when a mouse click is released. Again conditions determine what button was released.
constant mouseevent MOUSE_MOVE //Triggers when the mouse begins to move.
constant mouseevent MOUSE_WHEEL_ANY //Triggers when the mouse wheel scrolls up or down
constant mouseevent MOUSE_WHEEL_UP //Triggers when the mouse wheel scrolls up
constant mouseevent MOUSE_WHEEL_DOWN //Triggers when the mouse wheel scrolls down
constant unitstate UNIT_STATE_LIFE_REGEN //Unit current life regeneration. Compatible with GetUnitState and SetUnitState.
constant unitstate UNIT_STATE_MANA_REGEN //Unit current mana regeneration. Compatible with GetUnitState and SetUnitState.
constant unitevent EVENT_UNIT_DAMAGE_POINT //Same as above, but a unitevent instead.
constant unitevent EVENT_UNIT_MOVES //Fires when a unit moves.
constant unitevent EVENT_UNIT_IDLES //Similarly to how worker icons appear at the bottom-left corner of the screen when idling, this event detects when ANY unit is idling.
constant unitevent EVENT_UNIT_ENTERS_COMBAT //What it says on the tin - this event fires when a unit enters combat. Will be useful for in/out of combat regeneration, for example.
constant unitevent EVENT_UNIT_EXITS_COMBAT //What it says on the tin - this event fires when a unit leaves combat. Will be useful for in/out of combat regeneration, for example.
constant unitevent EVENT_UNIT_EVADE //The event triggers when a unit evades an attack using an evade ability (Evasion, Drunken Brawler, etc).
constant unitevent EVENT_UNIT_REMOVED //The event triggers the instant before the unit is removed from the game. Units get removed from the game by a variety of sources such as triggers, decaying or merging.
constant unitevent EVENT_UNIT_RESOURCE_RETURN //The event triggers when a unit returns a resource such as from gathering.
constant unitevent EVENT_UNIT_RESOURCE_HARVEST //The event triggers when a unit harvests a resource. This event means the amount the unit is carrying has changed.
constant unitevent EVENT_UNIT_BUFF_APPLY //The event triggers when a buff is applied to a unit. (i.e. The moment it exists on the unit.)
constant unitevent EVENT_UNIT_BUFF_DISPEL //The event triggers when a buff is about to be removed from a unit. (in the next tick).
constant playerunitevent EVENT_PLAYER_UNIT_BUFF_APPLY
constant playerunitevent EVENT_PLAYER_UNIT_BUFF_DISPEL
constant playerevent EVENT_PLAYER_ABILITY_PRESSED //The event triggers when a player presses an ability button and begins targeting. Requires netsync from the player so is not instant. Most spell event natives like trigger unit and spell ability id work in response to this event.
// These events would be very useful for most
constant playerunitevent EVENT_PLAYER_UNIT_DAMAGE_POINT //This triggers when a unit's attack is released - aka when a melee unit hits its target or a ranged unit launches a missile
constant playerunitevent EVENT_PLAYER_UNIT_DAMAGED //Same as EVENT_UNIT_DAMAGED except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_EVADE //Same as EVENT_UNIT_EVADE except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_REMOVED //Same as EVENT_UNIT_REMOVED except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_RETURN //Same as EVENT_UNIT_RESOURCE_RETURN except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_HARVEST //Same as EVENT_UNIT_RESOURCE_HARVEST except as a player unit event.
constant movementtype MOVEMENT_TYPE_NONE //Used by natives below.
constant movementtype MOVEMENT_TYPE_FOOT //Used by natives below.
constant movementtype MOVEMENT_TYPE_HORSE //Used by natives below.
constant movementtype MOVEMENT_TYPE_FLY //Used by natives below.
constant movementtype MOVEMENT_TYPE_HOVER //Used by natives below.
constant movementtype MOVEMENT_TYPE_FLOAT //Used by natives below.
constant movementtype MOVEMENT_TYPE_AMPHIBIOUS //Used by natives below.
constant armortype ARMOR_TYPE_SMALL //Used by natives below.
constant armortype ARMOR_TYPE_MEDIUM //Used by natives below.
constant armortype ARMOR_TYPE_LARGE //Used by natives below.
constant armortype ARMOR_TYPE_FORTIFIED //Used by natives below.
constant armortype ARMOR_TYPE_NORMAL //Used by natives below.
constant armortype ARMOR_TYPE_HERO //Used by natives below.
constant armortype ARMOR_TYPE_DIVINE //Used by natives below.
constant armortype ARMOR_TYPE_UNARMORED //Used by natives below.
constant armortype ARMOR_TYPE_UNKNOWN //Invalid armor type. Has been observed randomly in game, likely as the result of a non fatal memory corruption error to the armor type field.
constant herostat HERO_STAT_STR //Used by natives below.
constant herostat HERO_STAT_AGI //Used by natives below.
constant herostat HERO_STAT_INT //Used by natives below.
constant mousebutton MOUSE_BUTTON_LEFT //Used by natives below.
constant mousebutton MOUSE_BUTTON_RIGHT //Used by natives below.
constant mousebutton MOUSE_BUTTON_MIDDLE //Used by natives below.
constant catalog CATALOG_UNIT //Used by natives below.
constant catalog CATALOG_ITEM //Used by natives below.
constant catalog CATALOG_ABILITY //Used by natives below.
constant catalog CATALOG_BUFF //Used by natives below.
constant catalog CATALOG_UPGRADE //Used by natives below.
constant catalog CATALOG_DOODAD //Used by natives below.
constant catalog CATALOG_DESTRUCTABLE //Used by natives below.
constant resourcetype RESOURCE_GOLD //Used by natives below.
constant resourcetype RESOURCE_LUMBER //Used by natives below.
// IO types
constant fileoption FILE_OPTION_READ_ONLY
constant fileoption FILE_OPTION_WRITE_ONLY
constant fileoption FILE_OPTION_READ_AND_WRITE
constant fileoption FILE_OPTION_REWRITE
constant fileoption FILE_OPTION_APPEND
constant filedatatype FILE_DATA_STRING
constant filedatatype FILE_DATA_INTEGER
constant filedatatype FILE_DATA_BOOLEAN
constant filedatatype FILE_DATA_REAL
// Functions and natives
// Most information for the natives can be implied. However, there is much to
// elaborate further upon.
native SynFileOpen takes player wplayer, fileoption fopt, string fpath returns file
native SynFileClose takes file wfile returns boolean
native IsFileExist takes file wfile returns boolean
native SynFileRead takes file wfile, filedatatype wtype returns boolean
native SynBinFileRead takes file wfile, filedatatype wtype, integer pos returns boolean
native GetSynFileInteger takes nothing returns integer
native GetSynFileString takes nothing returns string
native GetSynFileReal takes nothing returns real
native GetSynFileBoolean takes nothing returns boolean
native SynFileWriteInt takes file wfile, filedatatype wtype, integer datawrite returns boolean
native SynFileWriteBool takes file wfile, filedatatype wtype, boolean datawrite returns boolean
native SynFileWriteStr takes file wfile, filedatatype wtype, string datawrite returns boolean
native SynFileWriteReal takes file wfile, filedatatype wtype, real datawrite returns boolean
native SynBinFileWriteInt takes file wfile, filedatatype wtype, integer pos, integer datawrite returns boolean
native SynBinFileWriteBool takes file wfile, filedatatype wtype, integer pos, boolean datawrite returns boolean
native SynBinFileWriteStr takes file wfile, filedatatype wtype, integer pos, string datawrite returns boolean
native SynBinFileWriteReal takes file wfile, filedatatype wtype, integer pos, real datawrite returns boolean
//Player natives
constant function GetOrderingPlayer takes nothing returns player
// This function should probably work with almost all "playerunitevent" events, and also with
// the following "unitevents" - This is perhaps redundant since "playerunitevent" has the equivalent
// for every "unitevent" mentioned above
//Terrain
function GetWaterZ takes real x, real y returns real //returns the water level (shallow or deep) since currently GetLocationZ() ignores water level.
function GetCliffZ takes real x, real y returns real //related to this https://www.hiveworkshop.com/threads/calculating-a-flying-units-flyheight.270925/
//Special Effects
native AddSpecialEffectEffect takes string modelName, effect targetEffect, string attachPointName returns effect
//Create a special effect attached to another special effect.
native SetSpecialEffectEffect takes effect fx, effect targetEffect, string attachPointName returns nothing
//Moves a special effect to the target special effect.
native SetSpecialEffectX takes effect fx, real x returns nothing //Moves a special effect relative to the map x axis.
native SetSpecialEffectY takes effect fx, real y returns nothing //Moves a special effect relative to the map y axis.
native SetSpecialEffectZ takes effect fx, real z returns nothing //Moves a special effect relative to the map z axis.
function SetSpecialEffectLoc takes effect fx, location where returns nothing //Moves a special effect to the location.
function SetSpecialEffectTarget takes effect fx, widget targetWidget, string attachPointName returns nothing
//Moves a special effect to the target.
native GetLocalSpecialEffectX takes effect fx returns real //Returns the map relative x coordinate of where the effect is positioned. Not net safe for target effects.
native GetLocalSpecialEffectY takes effect fx returns real //Returns the map relative y coordinate of where the effect is positioned. Not net safe for target effects.
native GetLocalSpecialEffectZ takes effect fx returns real //Returns the map relative z coordinate of where the effect is positioned. Not net safe for target effects.
native SetSpecialEffectScale takes effect fx, real x, real y, real z returns nothing //Scales a special effect the same way one can scale destructables.
native SetSpecialEffectRoll takes effect fx, real angle returns nothing //Set the roll angle of a special effect.
native SetSpecialEffectPitch takes effect fx, real angle returns nothing //Set the pitch angle of a special effect.
native SetSpecialEffectFacing takes effect fx, real angle returns nothing //Sets the XY facing angle of a special effect.
native SetSpecialEffectColor takes effect fx, playercolor color returns nothing //Alters the team color used by a special effect.
//Unit Functions
/*
List of useful unit functions. Some are often requested.
*/
function GetUnitIconPath takes unit u returns string //Returns the command card icon path of a unit.
function GetUnitTypeIconPath takes integer unitId returns string //Returns the command card icon path of a unit type.
function SetUnitIconPath takes unit u, string path returns nothing //Changes the command card icon path of a unit.
function GetUnitModelPath takes unit u returns string //Returns the model path of a unit.
function GetUnitTypeModelPath takes integer unitId returns string //Returns the model path of a unit type.
function SetUnitModelPath takes unit u, string path returns nothing //Changes the model path of a unit.
native SetUnitName takes unit u, string name returns nothing //Changes the unit type name of a unit to the specified string.
// Needs fix - no behavior defined
native SetHeroName takes unit u, string name returns nothing //Changes the hero name of a hero unit to the specified name. Does nothing to non hero units.
// Needs fix - no behavior defined
function SetUnitLevel takes unit u, integer newLevel returns nothing //Set the unit level of a non hero unit to the specified level. Does nothing to heroes.
function SetUnitMaxSpeed takes unit u, real r returns nothing //Does maximum and minimum unit speed even do anything? If so, the ability to modify those would be welcome. Units could be made to accelerate and decelerate like in Sc2.
function GetUnitMaxSpeed takes unit u, nothing returns real
function SetUnitMinSpeed takes unit u, real r returns nothing
function GetUnitMinSpeed takes unit u, nothing returns real
function GetUnitRangeAttack takes unit whichUnit, integer attackIndex returns real
function SetUnitRangeAttack takes unit whichUnit, integer attackIndex, real newRange returns nothing
function GetUnitAttackTime takes unit u, integer index returns real //Returns the cooldown time of a particular attack index (0 or 1) of a unit, with attack speed modifiers (eg: Glove of Haste, Cripple) factored in.
function SetUnitAttackTime takes unit u, integer index, real amount returns nothing //Set the base cooldown time of a particular attack index of a unit, reapplying all attack speed modifiers as appropiate.
function ModifyUnitAttackTime takes unit u, integer index, real fraction returns nothing //Applies fraction attack speed modifier to a particular attack index of a unit, being treated the same as other attack speed modifiers including limits.
function GetUnitAttackDamageMin takes unit u, integer index returns integer //Returns the minimum attack damage of a particular attack index of a unit, with damage modifiers (eg: Command Aura, Claws of Attack +16) factored in.
function GetUnitAttackDamageMax takes unit u, integer index returns integer //Returns the maximum attack damage of a particular attack index of a unit, with damage modifiers factored in.
function SetUnitAttackDamageMin takes unit u, integer index, integer min returns nothing //Changes the base minimum attack damage of a particular attack index of a unit to an exact value, reapplying all damage modifiers as appropiate. Will override bonuses from upgrades.
function SetUnitAttackDamageMax takes unit u, integer index, integer max returns nothing //Changes the base maximum attack damage of a particular attack index of a unit to an exact value, reapplying all damage modifiers as appropiate. Will override bonuses from upgrades.
function ModifyUnitAttackDamage takes unit u, integer index, integer amount returns nothing //Applies damage modifier to a particular attack index of a unit, being treated the same as other damage modifiers.
function SetUnitMovementType takes unit u, movementtype movementType returns nothing //Changes the movement type of a unit to the specified movement type.
native GetUnitMovementType takes unit u returns movementtype //Get the movement type of a unit.
function SetUnitVisionType takes unit u, boolean flying //Changes the vision mechanics of a unit to either be ground (can be occluded by terrain) or flying (absolute).
function SetItemStock takes unit u, integer itemId, integer stock returns nothing //Set the stock of an item id in a shop to the specified number. Maximum stock count is respected and if full cooldown progress will be lost.
function SetItemStockMax takes unit u, integer itemId, integer stock returns nothing //Set the maximum stock permitted of an item id in a shop to the specified number. Maximum stock count is respected and if below current stock cooldown and stock items will be lost.
function GetItemStock takes unit u, integer itemId returns integer //Get the stock available of an item id in a shop.
function GetItemStockMax takes unit u, integer itemId returns integer //Get the maximum stock permitted of an item id in a shop.
function GetLocalUnitZ takes unit u returns real //Get the exact map relative z coordinate of the unit origin. This is the visual height of the unit in the game world. Not net safe.
function GetUnitCollisionSize takes unit returns real //Seturns the collision size of a unit. The returned value factors in collision size limits so might be smaller than in the object editor.
function SetUnitFacingInstant takes unit u, real facingAngle returns nothing //Similar to SetUnitFacing but with angle change being instant with turn rate and orientation interpolation being ignored. Angle is in degrees.
function SetUnitFacingInstantRad takes unit u, real facingAngle returns nothing //Same as SetUnitFacingInstant except angle is in radians.
function SetUnitFacingRad takes unit whichUnit, real facingAngle returns nothing //Same as SetUnitFacing except angle is in radians.
function GetUnitAttackCooldownRemaining takes unit u returns real //Returns the remaining time in game seconds of the currently occuring attack cooldown. Returns 0.0 if attack is not on cooldown.
function SetUnitAttackCooldown takes unit u, real duration returns nothing //Sets the current attack cooldown time to a different value, potentially overriding/ignoring backswing point. Set to zero to cause the next attack to occur instantly. Can start attack cooldown.
function GetUnitDamageType takes unit u, integer index returns attacktype
function SetUnitDamageType takes unit u, integer index, attacktype newDamageType returns nothing
//function UnitAttackTarget takes unit whichUnit, widget target, real amount, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
//Similar to UnitDamageTarget but does so with the source's attack modifiers like Orb Effects, Critical Strike, Bash, Lifesteal, etc.
function UnitDamageTargetEx takes unit whichUnit, widget target, real amount, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
//Inherits the behavior of UnitAttackTarget
//function UnitAttackArea takes unit whichUnit, real radius, real x, real y, real amount, attacktype attackType, damagetype damageType, weapontype weaponType, boolexpr filterFunc returns boolean
//Just like UnitAttackTarget(), but this takes a boolexpr argument at the end to filter out unwanted victims. This is helpful in the case of area attacks with chance modifiers like bash.
function UnitDamageAreaEx takes unit whichUnit, real radius, real x, real y, real amount, attacktype attackType, damagetype damageType, weapontype weaponType, filterfunc filterFunc returns boolean
//Inherits the behavior of UnitAttackArea
native UnitInterruptAttack takes unit u returns nothing //Stops the current attack from occuring and triggers attack cooldown for the intended attack index. Call is only valid during backswing time or for trigger unit in response to EVENT_UNIT_ATTACKED and EVENT_PLAYER_UNIT_ATTACKED events.
native GetUnitArmorType takes unit u returns armortype //Returns the armor type of a unit.
native SetUnitArmorType takes unit u, armortype armorType returns nothing //Sets the armor type of a unit.
native GetUnitArmor takes unit u, boolean includeBonuses returns real //Returns the armor value of a unit. If includeBonuses is true then include all armor modifiers (eg: Devotion Aura, Faerie Fire).
native SetUnitArmor takes unit u, real amount returns nothing //Changes the base armor value of a unit, reapplying all armor modifiers as appropiate.
function ModifyUnitArmor takes unit u, real amount returns nothing //Applies armor modifier to a unit, being treated the same as all other armor modifiers.
function UnitDisableMovement takes unit u, boolean flag returns nothing //toggles a unit's movement on or off. Currently feasible with SetUnitPropWindow to zero, but restoring requires radians but GetUnitDefaultPropWindow returns degrees. Not a big issue, but it's hidden information.
function UnitDisableTurning takes unit u, boolean flag returns nothing //toggles a unit's ability to turn on or off.
function UnitDisableControl takes unit u boolean flag returns nothing //toggles whether a unit responds to player commands on or off. Can still respond to trigger commands.
function UnitFullDisable takes unit u, boolean flag returns nothing //toggles whether a unit responds to ANY commands on or off. Similar to being stunned, but will not 'unstun' until UnitFullDisable is set to false.
function UnitDisableAttack takes unit u, boolean flag returns nothing //Turns off one of the two attack indices. Currently feasible by adding Cargo Hold ability to the unit, but it disables both indices.
function UnitDisableSelection takes unit u, boolean flag returns nothing //Same as giving Locust ability to a unit (Aloc), but can be enabled/disabled without any buggy side effects.
function IsUnitSelectable takes unit u returns boolean //returns true or false on whether a unit can be selected or not. Eg would return false on a unit with Locust ability (Aloc).
function IsUnitInvulnerable takes unit u returns boolean //returns whether a unit is invulnerable or not
native UnitCancelTimedLife takes unit u returns nothing //Cancels a previously applied UnitApplyTimedLife or automatic expiration timer of a summoned unit.
// Needs fix - Unintended behavior.
function UnitApplyTimer takes unit u, integer buffId, real timeout returns timer //Applies a non-fatal timer to a unit that shows the time ticking down like with a spell like Avatar or Metamorphosis. When the timer expires, a TimerRegisterExpireEvent fires.
function UnitDisableItems takes unit u, boolean flag, boolean passive returns nothing //Toggles whether a unit can use items. Item passive effects are optionally able to be turned on or off.
function UnitDisableItem takes unit u, item iObj returns boolean //Disables a specific item if that item is in the inventory of the unit.
function GetLocalTargetAttachmentX takes widget who, string attachmentname returns real //Get the map relative x coordinate of the specified attachment site. Not net safe.
function GetLocalTargetAttachmentY takes widget who, string attachmentname returns real //Get the map relative y coordinate of the specified attachment site. Not net safe.
function GetLocalTargetAttachmentZ takes widget who, string attachmentname returns real //Get the map relative z coordinate of the specified attachment site. Not net safe.
function UnitHideAbility takes unit u, integer abilityId, boolean flag returns nothing //Shows or hide an ability command card button for the unit. Does not disable the ability itself.
function UnitDisableAbility takes unit u, integer abilityId, boolean flag returns nothing //Enables or disables an abilty for the unit. Will also disable passives.
function GetUnitAbilityCooldownTimeout takes unit u, integer abilityId returns real //Returns the cooldown time for an ability if the unit were to use it.
function GetUnitAbilityCooldownRemaining takes unit u, integer abilityId returns real //Returns the remaining cooldown time of an ability on a unit.
function SetUnitAbilityCooldown takes unit u, integer abilityId, real timeout, real remaining returns nothing
//Modifies the current cooldown progress of an ability for a unit. Timeout will clamp remaining for logical reasons. Set timeout or remaining to zero to instantly complete cooldown.
function GetUnitAbilityManaCost takes unit u, integer abilityId returns integer //Returns the potential mana cost of an ability for a unit.
function IsUnitAbilityOnCooldown takes unit u, integer abilityId returns boolean //Returns true if an ability is on cooldown for a unit.
function UnitChangeUnitId takes unit u, integer unitid returns nothing //Changes the unit type ID of a unit. Results are the same as unit a morph ability except without needing an ability.
function ReviveUnit takes unit u returns nothing //Revives a dead unit at the position of its corpse. Mechanically the same as the unit being effected by Paladin's Resurrection ability.
//Should affect all units, not those that leave a corpse
function GroupEnumCorpsesInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing
//Convenience function to enum all corpses in range of a position.
function GroupEnumCorpsesInRangeloc takes group g, location whichLocation, real radius, boolexpr filter returns nothing
//Same as above but with location parameter.
function GetUnitGoldCost takes integer unitid returns integer //AI native copied to normal JASS for convince.
function GetUnitWoodCost takes integer unitid returns integer //AI native copied to normal JASS for convince.
function IsUnitMoving takes unit u returns boolean //Returns true if a unit is trying to move. The unit might not actually be moving if it is waiting for the pathfinder to attend to it.
function IsUnitIdle takes unit u returns boolean //Returns true if a unit is not moving, is not attacking, is not casting and is not using an item.
function IsUnitInCombat takes unit u returns boolean //Returns true if a unit has recently attacked or been attacked. Possibly tied into the forces under attack mechanics?
/*
Object Editor - Ability
*/
//Recent changes made, the Obj prefix makes a bit more sense.
function GetObjAbilityManaCost takes integer abilityId, integer level returns integer //Returns the ability cost of an ability.
function SetObjAbilityManaCost takes integer abilityId, integer level, integer newcost returns integer
function GetObjAbilityCooldown takes integer abilityId, integer level returns real //Returns the cooldown time of an ability.
function SetObjAbilityCooldown takes integer abilityId, integer level, integer newcool returns integer
/*
NB: Abilities are reference from a global cache, so it stands to reason that a native that modifies independent of a unit will change that ability globally. While this is a nice
tool to have, it would be even nicer to have the capability to modify them individually. However, this could hike up the performance cost of the game itself since every unit in the
game will have its own personal version of that ability.
*/
function GetUnitAbilityManaCost takes unit u, integer abilityId, integer level returns integer
function SetUnitAbilityManaCost takes unit u, integer abilityId, integer level, integer newcost returns integer
function GetUnitAbilityCooldown takes unit u, integer abilityId, integer level returns real
function SetUnitAbilityCooldown takes unit u, integer abilityId, integer level, integer newcool returns integer
function GetHeroPrimaryStat takes unit u returns herostat //Returns the integer code for the attribute that is set as primary. Eg if the unit is a Paladin, it returns the id for Strength.
function GetHeroPrimaryStatById takes integer unitid returns herostat //Same as above but references the object editor value instead of an actual unit.
function SetHeroPrimaryStat takes unit u, herostat stat returns integer //Allows the game to individual modify which attribute of the hero becomes its primary. Damage modifier from primary hero stat has to be reapplied.
function GetHeroStat takes herostat whichStat, unit whichHero, boolean includeBonuses returns integer
//Mechanically same as the GetHeroStatBJ function except takes the new native herostat constants.
function SetHeroStatEx takes unit whichHero, herostat whichStat, integer value, boolean permanent returns nothing
//Mechanically similar to the SetHeroStat function except takes the new native herostat constants and can set permanence.
//Existing natives should be reworked to call this new native. (not ideal, though)
function GetUnitBonusDamage takes unit u returns integer // Returns bonus damage of a unit.
function SetUnitBonusDamage takes unit u, integer newDmg returns nothing // Sets the bonus damage of a unit.
function GetBuilderUnit takes unit building returns unit //Returns the unit that constructed a building/unit. In the case of buildings this should be the unit that converted the foundation into a unit.
function GetUnitBuildProgress takes unit u returns real //Returns the fraction (percent / 100) completion of a building/unit in progress. If the unit has no progress (already built) returns 1.0.
function SetUnitBuildProgress takes unit u, real fraction returns nothing //Modifies the fraction completion of a building/unit in progress. A fraction of 1.0 causes the unit to be instantly completed. Does nothing to a unit that is complete.
function GetUnitTrainProgress takes unit factory returns real //Returns the fraction completion of a unit that is being trained. Returns 1.0 if no unit is being trained.
function SetUnitTrainProgress takes unit factory, real fraction returns nothing //Modifies the fraction completion of a unit that is currently being trained. A fraction of 1.0 causes the unit to be instantly trained. Does nothing to a factory that is not training anything.
function GetTrainingQueueSize takes unit factory returns integer //Returns the number of queued training orders.
function GetMaxTrainingQueueSize takes unit factory returns integer //Returns the maximum number of queued training orders a factory allows.
function CancelTraining takes unit factory, integer slot returns boolean //Cancels a train order from the training queue of a building determined by slot number (eg 0 - 6). Returns true if a unit was actually canceled.
function ClearTrainingQueue takes unit factory returns boolean //Equivelant to calling CancelTraining on all occupied training slots of a building. Returns true if at least 1 training order was canceled.
function GetItemAbilityCooldownRemaining takes item whichItem returns real //Returns the remaining cooldown time on a used item.
function GetItemAbilityCooldownTimeoutById takes integer itemId returns real //Returns the default timeout cooldown of an item type.
function SetItemAbilityCooldown takes item whichItem, real timeout, real remaining returns real
//Sets the remaining cooldown time of an item to a specific value. Timeout will clamp remaining for logical reasons and might be ignored for unowned items. Set timeout or remaining to zero to instantly complete cooldown.
function EnableItem takes item whichItem, boolean flag returns nothing //Enables/Disables an item. Items that are disabled provide no modifiers and cannot be used.
function GetUnitBuildTime takes integer unitid returns integer //AI native ported to standard JASS.
function GetHeroBuildTime takes integer unitid, player whichPlayer returns integer //Returns the train time in seconds for a player to make the specified hero type. Factors in train time increases with sequential heroes in melee.
function GetHeroReviveTime takes unit whichUnit returns integer //Returns the revive time in seconds for a player to revive the specified hero if it were dead.
//Damage Event Extensions
function GetEventDamageAttackType takes nothing returns attacktype //In response to a damage event returns the attacktype (Spell, Hero, Chaos, etc) of the damage.
function GetEventDamageDamageType takes nothing returns damagetype //In response to a damage event returns the damagetype (unkown, magic, normal, enhanced, etc) of the damage.
function GetEventDamageAbilityId takes nothing returns integer //In response to a damage event returns the ability ID that caused the damage. This ability can be a damage spell (Flame Strike, Storm Bolt, etc) or an attack modifier ability (Cold Arrow, orb of fire, etc). Normal attack damage returns some safe default value such as 0.
//function GetEventDamageUnmodified takes nothing returns real //In response to a damage event returns the damage dealt to the unit before any modifications (armor, attacktype reduction, etc) were applied.
function GetEventRawDamage takes nothing returns real //Same as GetEventDamageUnmodified, but shorter in name
//function GetEventDamageMana takes nothing returns real //In response to a damage event returns the mana lost due to an active mana shield.
function GetEventManaCost takes nothing returns real //Should deprecate GetEventDamageMana due to it obtaining the manacost.
//Spell Effect Extensions
// function GetEventManaCost takes nothing returns real //Described above
function SetEventManaCost takes real newMana returns nothing //Sets the mana cost of the ability cast or when unit is damaged.
//Resource Event Extensions
function GetEventResourceType takes nothing returns resourcetype //The resource type the event responded to. For example RESOURCE_LUMBER when a wisp unit gathers lumber.
function GetEventResourceAmount takes nothing returns integer //The resource amount the event responded to. For example 10 when a Haunted Gold Mine extracts 10 gold.
//UI Functions
function ShowUI takes boolean flag returns nothing //True/false arguments would show/hide the UI. That includes disabling the black borders at the top and bottom of the screen.
function ShowManaBar takes boolean flag returns nothing //Turns mana bar display over units on or off. Whether they display depends on the player's Gameplay options but this can overwrite that for a session.
function SetPlayerHPBarColor takes player p, real red, real green, real blue returns nothing //Changes the health bar color of units belonging to a particular player.
function SetPlayerMPBarColor takes player p, real red, real green, real blue returns nothing //Changes the mana bar color of units belonging to a particular player.
function CreateBar takes real red, real green, real blue, real alpha returns bar //'New' object type. Creates a bar (like the health bars above units) and colours them according to the values used. Eg recreating Protoss shields.
function AttachBarTarget takes bar whichBar, widget target, real z returns nothing //Attaches a bar to a unit, destructable, item etc with the option to move it up and down the z axis.
function GetBarX takes bar whichBar returns real //Returns the x coordinate of a bar.
function GetBarY takes bar whichBar returns real //Returns the y coordinate of a bar.
function GetBarZ takes bar whichBar returns real //Returns the z coordinate of a bar.
function SetBarPos takes bar, real x, real y, real heightOffset returns nothing //Manually repoisitions a bar to map relative coordinates like floating texts.
function DisplayScreenMessage takes string s, real x, real y, real timeout returns nothing //This displays a text message for a period but with respect to normalised X / Y value of the screen. Can overlap other text messages. An invalid timeout will automatically compute a timeout based on message length.
function GetLocalDisplayResolutionHorizontal takes nothing returns real //Returns the horizontal resolution in pixels being used to display Warcraft III for the local client. Not net safe.
function GetLocalDisplayResolutionVertical takes nothing returns real //Returns the vertical resolution in pixels being used to display Warcraft III for the local client. Not net safe.
//Minimap Functions
function GetPingX takes ping whichPing returns real //returns the corresponding map relative x coordinate of a ping.
function GetPingY takes ping whichPing returns real //returns the corresponding map relative y coordinate of a ping.
function TriggerRegisterPlayerPingEvent takes trigger whichTrigger, player whichPlayer returns event
//New event that fires the trigger when the specified player sends a ping. Both GetTriggerPlayer and GetTriggerPing are valid with this event.
function GetTriggerPing takes nothing returns ping //In response to a player ping event returns the ping object that triggered the event.
//Mouse input functions
function GetLocalCursorTargetX takes nothing returns real //Returns the map relative x coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function GetLocalCursorTargetY takes nothing returns real //Returns the map relative y coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function GetLocalCursorTargetZ takes nothing returns real //Returns the map relative z coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function SetLocalCursorX takes real x returns nothing //Set the local client cursor position to the specified screen space normalised x coordinate.
function SetLocalCursorY takes real y returns nothing //Set the local client cursor position to the specified screen space normalised y coordinate.
function IsLocalCursorOverUI takes nothing returns boolean //Returns true if the cursor is currently not targeting the map. Not net safe.
function IsLocalMouseButtonPressed takes mousebutton mouseButton returns boolean //Returns true or false depending on which mouse button is being held down. Will be useful for click-and-drag functions. Not net safe.
function TriggerRegisterPlayerMouseEvent takes whichTrigger, player whichPlayer, mouseevent mouseEvent returns event
//Mouse click/drag/release events. All mouse events go here. See constants. Attaching this event causes periodic mouse sync traffic from the player.
function GetTriggerMouseEvent takes nothing returns mouseevent //In response to player mouse event returns which mouseevent triggered the trigger.
function GetTriggerMouseX takes nothing returns real //In response to player mouse event returns the screen space normalised x coordinate the event occurred at. Is net safe.
function GetTriggerMouseY takes nothing returns real //In response to player mouse event returns the screen space normalised y coordinate the event occurred at. Is net safe.
function GetTriggerMouseMapX takes nothing returns real //In response to player mouse event returns the map relative x coordinate the event occurred at. Return value non 0.0 only if the mouse event targeted the map. Is net safe.
function GetTriggerMouseMapY takes nothing returns real //In response to player mouse event returns the map relative y coordinate the event occurred at. Return value non 0.0 only if the mouse event targeted the map. Is net safe.
function GetTriggerMouseMapZ takes nothing returns real //In response to player mouse event returns the map relative z coordinate the event occurred at. Return value non 0.0 only if the mouse event targeted the map. Is net safe.
//Keyboard
function TriggerRegisterPlayerKeyboardEvent takes trigger whichTrigger, player whichPlayer, keyboardbutton hotkey, boolean state returns event
//Fires when the corresponding key is pressed by the player. The keyboardbutton constants are not mentioned but should cover most common keyboard buttons. If state is true then fires when key is pressed, otherwise fires when key is released. Attaching this event causes keyboard button sync traffic from the player.
function GetTriggerKeyboardButton takes nothing returns keyboardbutton //In response to player keyboard event returns which button caused the event.
function GetTriggerKeyboardState takes nothing returns boolean //In response to player keyboard event returns the state that caused the event. True if it was pressed, false if released.
function GetLocalKeyboardButtonState takes keyboardbutton whichButton returns boolean //Returns true if the local client has the specified keyboard button (eg arrow keys) depressed or false if released. Not net safe.
//Destructable
function IsDestructableTree takes destructable d returns boolean //Returns true if a destructable can be used as a tree. Otherwise false.
function TriggerRegisterDestructibleEvent takes trigger whichTrigger, destructable d, destructableevent whichEvent returns event
//Like TriggerRegisterUnitEvent. Some of the important event constants are listed but others might also exist.
function TriggerRegisterAnyDestructibleEvent takes trigger whichTrigger, destructableevent whichEvent returns event
//Like TriggerRegisterDestructibleEvent except applies to all destructables on the map, even ones yet to be created.
//Trackables
function SetTrackablePos takes trackable t, real x, real y returns nothing //Moves a trackable to the specified map realative coordinate.
function SetTrackableZ takes trackable t, real z returns nothing //Sets the map realative z coordinate of the trackable. This disables automatic Z positioning.
function SetTrackableZOffset takes trackable t, real zOffset returns nothing //Sets the Z offset of a trackable. This is realitive to the Z it is automatically positioned at. This enables automatic Z positioning.
function GetTrackableX takes trackable t returns real //Returns the map relative x coordinate of the trackable.
function GetTrackableY takes trackable t returns real //Returns the map relative y coordinate of the trackable.
function GetTrackableZ takes trackable t returns real //Returns the map relative z coordinate of the trackable if in map relative z mode. Returns the z offset if in automatic z mode.
function DestroyTrackable takes trackable t returns nothing //Trackables currently cannot be destroyed through triggers, so this native is needed for them to be useful.
//Uberspalts
function SetUbersplatPos takes ubersplat u, real x, real y returns nothing //Moves an ubersplat to a new map relative coordinate.
function SetUbersplatScale takes ubersplat u, real x, real y returns nothing //Allows the distortion of an ubersplat. This is applied to the ubersplat in its default orientation before it is rotated.
function SetUbersplatFacing takes ubersplat u, real angle returns nothing //Allows an ubersplat to be rotated. Useful for hazard markers or hit markers. Angle is in degrees.
function SetUbersplatFacingRad takes ubersplat u, real angle returns nothing //Same as SetUbersplatFacing except angle is in radians.
//Triggers
function EvaluateBoolexpr takes boolexpr func returns boolean //Simple function to evaluate a boolexpr in a single call. Currently one has to bind it to a trigger as a condition, evaluate the trigger and then destroy the trigger after evaluation. The way the boolexpr is executed should be similar to the current trigger approach.
//Benchmarking
/*
Whoever suggested these did not explain their purpose or what they are meant to do.
I am guessing they are meant to be client local performance counters for measuring performance of various scripts.
If this is the case then all calls made to these during multiplayer these should return default safe values that do nothing,
StopWatch natives can be used to clock or benchmark the performance
of certain snippets of code. They are intended to be used in single
player, not multiplayer, which explains the safe default values.
*/
function CreateStopWatch takes nothing returns stopwatch //Create a performance counter stop watch.
function StopWatchStart takes stopwatch returns nothing //Start the stop watch, causing it to record time progression. If it has been paused, resumes recording.
function GetStopWatchTime takes stopwatch returns real //Pause the stop watch and get the current elapsed stop watch time, which is the sum of all time it has been left running.
function StopWatchEnd takes stopwatch returns nothing //Destroy the stop watch freeing all resources it used.
function StopWatchPause takes stopwatch returns nothing //Pause the stop watch causing it to stop recording time progression. If trying to accuratly measure execution time of a piece of script this should be called between game frames to prevent the stop watch measuring the game loop time.
//Camera
function UnlockCameraRotation boolean flag returns nothing //True unlocks camera rotation with a mouse.
//Debugging
function DisplayErrorMsg takes string s, real duration returns nothing //Display the given error message string in the error message area. The message is also written out to an error log file.
function GetOPLimit takes nothing returns integer //Get the current remaining JASS thread operation limit. Due to how the JASS virtual machine works the returned value may be larger than the actual limit by the time it can be processed.
function SetOPLimit takes integer newlimit returns nothing //Changes the current JASS thread operation limit to the specified value. Due to how the JASS virtual machine works the actual limit may be slightly smaller than the specified amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
function ResetOPLimit takes nothing returns nothing //Resets the current JASS thread operation limit to the default operation limit of that thread, as if it was freshly created. Due to how the JASS virtual machine works the actual limit may be smaller than the default amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
//Ideally, this function will be called on map close.
//Code
type func extends code //Function type to be used with debugging natives. Possibly has special syntax requirements to prevent code exploit.
function TriggerRegisterJassOpLimitEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of the thread reaching its operation limit. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassDivideByZeroEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempted division by 0. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassNoBlockEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempting to block when blocking is not allowed (eg TriggerSleepAction in a condition function). Useful for detecting when a thread crash occurs.
function GetTriggerFunction takes nothing returns func //In response to all JASS thread crash events returns the function the crash occured at.
function GetEventJassError takes nothing returns string //In response to all JASS thread crash events returns a human readable string with as much information about the crash as possible. Intended to be printed out or logged to help map makers track down where/why a thread crash occured.
function GetHandleIdCount takes nothing returns integer //Returns the number of currently allocated handle ids. If this number is observed increasing as a game progresses there is likely an object leak of sorts.
function GetHandleIdFreeCount takes nothing returns integer //Returns the number of handle ids on the free handle id stack. If this number is very large then either the map has suffered from object count reduction over time or there was a step that required a large number of objects be created and destroyed.
//Dialog
function IsPlayerInDialog takes player p returns boolean //Returns true if the player currently has any dialog box visible to them. Might require net sync.
//Object Editor API
/*
Read only object editor API. Similar to StarCraft II catalog natives, hence the naming.
The field string would be the attribute key in the object editor, ie "regenHP" for the unit's base health regeneration.
Passing an invalid key (or one that would return an incorrect data type for the function) would return some sensible default (0, 0.0, null, etc).
*/
function GetUnitTypeAttributeInteger takes catalog whichCatalog, integer typeId, string field returns integer
function GetUnitTypeAttributeReal takes catalog whichCatalog, integer typeId, string field returns real
function GetUnitTypeAttributeString takes catalog whichCatalog, integer typeId, string field returns string
//Timer
/*
This is just a small adjustment, but an appreciable one.
*/
function SetTimerRemaining takes timer t, real newTime returns nothing
// Sets the remaining time. If negative, execute the handler code immediately.
//Custom UI
/*
Someone suggested the ability to customize the UI similar to StarCraft II where one can place custom UI elements anywhere on a clients screen.
They did not suggest an API to do this however.
Due to the complexity of such an API I would suggest looking at StarCraft II's implementation which allows the UI to be heavilly customized.
*/
//Ability type API
/*
This makes use of the ability type in jass, which is only ever useful in GUI.
Of course, the GUI will have to be reworked a bit to accommodate the proper
values.
*/
function ConvertAbilityState takes integer i returns abilitystate
// A native for the ability states...
function SetUnitTypeAbilityCooldown takes unittype unitId, integer abilType, integer level, real cooldown returns boolean
// This is the suggested name for the SetUnitAbilityCooldown native. Only changes the ability cooldown
// of a specific unit type at a requested level. If successful, return true. Failure can mean that the cooldown is
// the same or the ability doesn't exist on all units of the requested unitType.
function GetUnitAbility takes unit u, integer abilId returns ability
// This is to make use of the type ability.
function GetAbilityCooldown takes ability abil returns real
// returns the individual ability's cooldown. Does not create a new one, though!
function GetAbilityLevelCooldown takes ability abil, integer level returns real
// returns the individual ability's cooldown at a specified level.
function SetAbilityCooldown takes ability abil, real newCool returns nothing
// sets the individual ability's cooldown.
function SetAbilityLevelCooldown takes ability abil, integer level, real newCool returns nothing
// sets the individual ability's cooldown at a specified level.
function SetUnitAbilityCooldown takes unit u, integer abilId, real newCool returns nothing
// Should be made a wrapper to SetAbilityCooldown
function SetUnitAbilityLevelCooldown takes unit u, integer abilId, integer level, real newCool returns nothing
// Should be made a wrapper to SetAbilityLevelCooldown
function GetAbilityState takes ability abil, abilitystate abilState returns integer
// Returns certain things about the ability.
function SetAbilityState takes ability abil, abilitystate abilState, integer newValue returns nothing
if abilState == ABILITY_STATE_DISABLED or abilState == ABILITY_STATE_CHARGED then
return
endif
// Sets the ability state of a certain ability.
function IsAbilityCooldownPaused takes ability abil returns boolean
// Check if the cooldown is paused
function AbilityPauseCooldown takes ability abil, boolean pause returns boolean
if not (GetAbilityCooldown(abil) != 0.) then
// You can resolve the epsilon in the double equal symbol operator
return false
endif
// Pauses the cooldown of an ability, making for some interesting interactions...
return true
function SetAbilityCooldownRemaining takes ability abil, real newAmount returns boolean
// Sets the remaining cooldown of an ability.
// If negative, refreshes it immediately
// If zero, refreshes on a 0-second timer interval.
function IncAbilityCounter takes ability abil returns boolean
if GetAbilityState(abil, ABILITY_STATE_CHARGED) == 0 then
return false
endif
// Add a charge to the counter.
return true
function DecAbilityCounter takes ability abil returns boolean
// An antithesis to the native AbilityAddCounter with an inverse boolean statement
function GetAbilityCounter takes ability abil returns integer
// Returns the value of the charge counter.
function SetAbilityCounter takes ability abil, integer amount returns boolean
// Checks if the ability has a counter, and modifies the amount. Setting it to 0 or less defaults it to 1.
// Buffs
/*
This makes use of the buff type in jass, which is only ever useful in GUI.
Of course, the GUI will have to be reworked a bit to accommodate the proper
values.
*/
function GetUnitBuff takes unit whichUnit, integer buffId returns buff
// A function for getting a certain buff. Does not and should not create a new buff handle.
function GetBuffLevel takes buff whichBuff returns integer
// Sets the buff's level, which can properly be read by GetUnitAbilityLevel(unit, whichBuffId)
function GetUnitFromBuff takes buff whichBuff returns unit
// A function for returning the unit who has that buff...
function DestroyBuff takes buff whichBuff returns boolean
// Returns true if the buff exists.
// Otherwise, return false.
function SetBuffLevel takes buff whichBuff, integer level returns nothing
// The setter function for level
function DecBuffLevel takes buff whichBuff returns nothing // Decreases the level of the buff
function IncBuffLevel takes buff whichBuff returns nothing // Increases the level of the buff
function BuffApplyTimedLife takes buff whichBuff, real newTime returns nothing
// Can also be made a resetter for when a buff is set to expire. If newTime is less than or equal to 0,
// the buff is removed on the next tick (0-second timer)
function BuffPauseTimedLife takes buff whichBuff, boolean pause returns nothing
if pause then
// Pauses the timer for the duration of the buff..
else
// Removes the buff on next tick.
endif
// Internal function:
// function BuffGetTimer takes buff whichBuff returns timer
// There would be no need for a timer handle here, since it only handles the timed life of the buff.
// However, it can be made an internal function, where the existence of an internal timer will deter
// mine permanence. If it exists, the buff is not permanent.
function IsBuffPermanent takes buff whichBuff returns boolean
// As stated above, if an internal timer exists, the buff is not permanent.
function BuffGetRemaining takes buff whichBuff returns real
// Returns the remaining amount of time for the buff.
// Aura buffs, by default, are permanent.
// If permanent, the result should be 0. Else it returns the remaining duration of the timer.
// Following the convention of TypeGetRemaining
function SetBuffPermanent takes buff whichBuff, boolean permanent returns nothing
// Should be reduced to one function...
function UnitAddBuff takes unit whichUnit, integer buffId returns boolean
// If a buff already exists, it will just return false
// If it doesn't exist, the buff added will be considered a permanent buff.
// Based on the object data.
function IsBuffPositive takes buff whichBuff returns boolean
// Returns true if a buff is beneficial (e.g. cast by an ally, or a beneficial dummy spell cast by enemy)
// Otherwise, returns false.
function SetBuffPositive takes buff whichBuff, boolean flag returns boolean
// A corresponding setter to the positive buff effect.
function GetBuffTooltip takes buff whichBuff returns string
function GetBuffTooltipEx takes buff whichBuff returns string
function GetBuffTooltipLength takes buff whichBuff returns integer
function GetBuffName takes buff whichBuff returns string
function SetBuffTooltip takes buff whichBuff, string newText returns nothing // Sets main tooltip
function SetBuffTooltipEx takes buff whichBuff, string newText returns nothing // Sets extra info
function SetBuffTooltipLength takes buff whichBuff, integer newLength returns nothing // Sets the total length of description of buff.
function SetBuffName takes buff whichBuff, string newName returns nothing // Sets the name of the buff.
function BuffGetEventFlag takes nothing returns boolean
// Returns true if the buff triggered the playerunitevents through normal means. Otherwise,
// If the buff triggered the events through native functions, return false.
constant function GetTriggerBuff takes nothing returns buff
// Gets the buff that triggered events EVENT_PLAYER_UNIT_BUFF_APPLY and EVENT_PLAYER_UNIT_BUFF_DISPEL
constant function BuffExpired takes nothing returns boolean
// As an event response native to EVENT_PLAYER_UNIT_BUFF_DISPEL. The buff is still in the unit
// but is about to be removed.
// If true, the buff was dispelled through normal means. Otherwise, it was just forcefully dispelled.
// Removing the buffs through triggers will trigger the EVENT_PLAYER_UNIT_BUFF_DISPEL event.
//NOTES
/*
This list of suggested additions is meant as a way to streamline existing processes or change them entirely.
*/
//Proxies
/*
Proxies are essentially units - dummy casters to be exact, that are less performance-heavy. They have no collision, no model (though you may attach something to their "origin"), no
movement type, nothing. They only move through triggers (SetUnitX/Y) and can cast spells regardless of mana cost, tech requirement, cooldown. They can also cast an unlimited amount
of spells without any downtime so potentially only 1 proxy will ever be needed per map, or per player. One key aspect to proxies is that all actions they take is creditted to a source
unit, so this way if a proxy kills a unit using a spell, the game will register the source unit as having earned that kill. Depending on the allegiance of the source will determine
whether a target can be hit with a spell or not (eg: if the source is an ally of the target of the Proxy, the Proxy cannot cast Storm Bolt at the target).
NB: the Proxy type is affected by most of the relevant unit triggers, like SetUnitX/Y and RemoveUnit. It can be added to unit groups, etc.
*/
type proxy extends unit
function CreateAbilityProxy takes unit source, real x, real y, real z returns proxy //This is essentially a dummy of which all the actions it takes will be credited to the source.
function SetProxySource takes proxy dummy, unit source returns nothing //Modifies the source of the proxy.
//ApllySpellEffect
/*
This approach is an attempt to change the way modders apply spells to targets. Rather than using dummy units, what if spells - and their corresponding effect - could be cast directly on
a target unit/point? There are multiple ways in which we thought this could happen, but ultimately it's up to the people with the source code who will know how best to do this.
*/
Method 1
The ApplySpellEffect idea will look like spells can be cast at any point, anywhere. However, there's' the issue of auras, which means that those natives should probably return something other than a boolean (maybe a spelleffect type?)
function ApplySpellEffect takes player owner, real x, real y, integer abilcode returns nothing //returns false for spells that only affect the caster (eg. Storm Crow Form)
function ApplySpellEffectTarget takes player owner, unit target, integer abilcode returns boolean //returns null if the target is invalid (eg Spell immune, invulnerable, etc)
function ApplySpellEffectPoint takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, integer abilcode returns boolean //returns false on untargertable context (eg Inferno over water, Force of Nature with no trees)
function ApplySpellEffectChanneled takes player owner, real x, real y, real timeout, integer abilcode returns boolean //ends after the timer has expired. The timeout overrides the spell's internal duration.
function ApplySpellEffectTargetChanneled takes player owner, unit target, real timeout, integer abilcode returns boolean
function ApplySpellEffectPointChanneled takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, real timeout, integer abilcode returns boolean
Method 2
While the above could work, I suppose it's' hardly the most elegant solution to go around. User MindWorX suggested the atomic approach:
local leveldata data = CreateLevelData()
call SetLevelDataDuration(1.00)
call SetLevelDataDataA(RealData(10))
call SetLevelDataDataB(RealData(100))
call ApplyBuff(target, 'Ahea', data)
Method 3
Implement structs and have Struct-based triggers to use.
local leveldata data = CreateAbility()
set leveldata.Duration = 1.00
set leveldata.DataA = RealData(10)
//etc...
Kk. I see.It's better to have multiple lists because one person will never reflect the needs of all the community.
I am also working on a list![]()
It's better to have multiple lists because one person will never reflect the needs of all the community.
I am also working on a list![]()
// ENHANCEMENTS
Dr Super Good:
native DestroyTrigger takes trigger whichTrigger returns nothing
// * Destroy all bound triggeraction objects. Currently it only destroys all bound events, triggercondition and the trigger itself leaving all triggeraction objects to leak unless explicitly destroyed before.
// * Also destroy all currently scheduled trigger threads from that trigger. Currently destroying a trigger with scheduled trigger threads can cause handle stack corruption which has a high chance to cause Warcraft III to crash.
// * Strings should be automatically garbage collected or at least a native should exist that can be periodically called to help free up disused strings.
// * Pausing a periodic timer should not cause the timer to lose the periodic status.
// * Creating quests during map initialization should not cause a game crash.
// * Local handles declared with the local keyword should automatically cause the reference counter to be decremented at the end of a function just like local handles declared as function arguments.
// * Creating units should not cause a permanent memory leak.
native SetUnitFlyHeight takes unit u, real newHeight, real rate returns nothing //This should affect non-flying units or units with 0 (zero) movement speed.
native SetItemPosition takes item i, real x, real y, real z returns nothing //Allow to set item Z
native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing //The main tooltip of the added unit will always ignore color tags so the text will always appear to be white. Color tags should be parsed the same as all unit tooltips.
native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing //Change it so that displaying text to a player with unique x and y does not move any other messages.
native GetEventDamage takes boolean unresisted returns real //This is just another idea
native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing //With each of call of this function, the minimap is modified in a bugged way: The positions of units and the fog of war are modified to fit to the new camera bound but not the terrain, nor the destructables. The minimap is compressed (vertically) according to the current camera's rotation. With a rotation of 90°, there is no compression. With a rotation of 227.40, the minimap is fully compressed. Between 227.5 and 312.6, the game crashes. Moreover, the camera bounds will also be adjusted according to the rotation of the current camera. The camera bounds created will be a rectangle going trough the 4 points given and whose sides will be parallel to the camera.
native SmartCameraPanBJ takes player whichPlayer,location loc,real duration returns nothing //This BJ function is currently not net safe. Details explained: https://www.hiveworkshop.com/threads/fixing-smartcamerapanbj-desync.243334/
// * Camera view distance minimum value should be decreased from 100 to 1. This is required to get rid of ticks in first person camera
// GENERAL
// * Multidimensional arrays
function UnlockGameCamera takes player p, boolean flag, boolean invert returns nothing //Allows specified player to rotate the camera freely with the mouse. By default pins camera target, if flag, rotates camera eye
function GetCameraMapZ takes real x, real y returns real //Returns coordinate of the projection of specified point at invisible plane on which game camera moves.
function GetFlightMapZ takes real x, real y returns real //Returns coordinate of the projection of specified point at invisible plane on which flying units are moving.
function SetWidgetTexure takes widget whichWidget, string texturePath, integer replaceableId returns boolean
function GetWidgetTexure takes widget whichWidget returns string
function EvaluateBoolexpr takes boolexpr func returns boolean //Simple function to evaluate a boolexpr in a single call. Currently one has to bind it to a trigger as a condition, evaluate the trigger and then destroy the trigger after evaluation. The way the boolexpr is executed should be similar to the current trigger approach.
// EDITOR
// * Ability to rotate decorations in WorldEditor (pitch,yaw,roll) In other words - remove prehictoric restrictions.
// * Ability to draw custom path map (instead of spamming path blockers). Path blockers affects FPS significantly if are spammed at big amounts, especially with non-default camera angles.
// * Ability to specify texture path for most of objects
//RESOURCE EVENT EXTENSIONS
type resourcetype extends handle
constant playerevent EVENT_PLAYER_RESOURCE_COLLECTED
constant resourcetype RESOURCETYPE_LUMBER
constant resourcetype RESOURCETYPE_GOLD
function GetEventResourceType takes nothing returns resourcetype //The resource type the event responded to. For example RESOURCE_LUMBER when a wisp unit gathers lumber.
function GetEventResourceAmount takes nothing returns integer //The resource amount the event responded to. For example 10 when a Haunted Gold Mine extracts 10 gold.
// SPECIAL EFFECT API
function GetSpecialEffectScale takes effect whichEffect returns real
function GetSpecialEffectPitch takes effect whichEffect returns real
function GetSpecialEffectYaw takes effect whichEffect returns real
function GetSpecialEffectRoll takes effect whichEffect returns real
function GetSpecialEffectR takes effect whichEffect returns integer
function GetSpecialEffectG takes effect whichEffect returns integer
function GetSpecialEffectB takes effect whichEffect returns integer
function GetSpecialEffectA takes effect whichEffect returns integer
function GetSpecialEffectTimeScale takes effect whichEffect returns real
// DESTRUCTIBLE API
constant destructableevent EVENT_DESTRUCTIBLE_DEATH
constant destructableevent EVENT_DESTRUCTIBLE_COMBAT
constant destructableevent EVENT_DESTRUCTIBLE_HARVESTED
constant destructableevent EVENT_DESTRUCTIBLE_DAMAGED
function GetDestructableType takes destructable d returns integer
function TriggerRegisterDestructibleEvent takes trigger whichTrigger, destructable d, destructableevent whichEvent returns event
function TriggerRegisterAnyDestructibleEvent takes trigger whichTrigger, destructableevent whichEvent returns event
// TRACKABLE API
function SetTrackablePos takes trackable t, real x, real y returns nothing //Moves a trackable to the specified map realative coordinate.
function SetTrackableZ takes trackable t, real z returns nothing //Sets the map realative z coordinate of the trackable. This disables automatic Z positioning.
function SetTrackableZOffset takes trackable t, real zOffset returns nothing //Sets the Z offset of a trackable. This is realitive to the Z it is automatically positioned at. This enables automatic Z positioning.
function GetTrackableX takes trackable t returns real //Returns the map relative x coordinate of the trackable.
function GetTrackableY takes trackable t returns real //Returns the map relative y coordinate of the trackable.
function GetTrackableZ takes trackable t returns real //Returns the map relative z coordinate of the trackable if in map relative z mode. Returns the z offset if in automatic z mode.
function DestroyTrackable takes trackable t returns nothing //Trackables currently cannot be destroyed through triggers, so this native is needed for them to be useful.
// DIALOG API
function IsPlayerInDialog takes player p returns boolean //Returns true if the player currently has any dialog box visible to them. Might require net sync.
//========================================================================================================================================
// BUFF API
unitevent EVENT_UNIT_BUFF_APPLIED
unitevent EVENT_UNIT_BUFF_EXPIRED //Triggers when the buff expires or gets removed
function UnitApplyBuff takes unit u, integer rawcode, integer level returns nothing //Applies specified buff and pauses dissipation timer. StartBuffDissipation can be called later on to remove the paused state and to set the timeout
function UnitRemoveBuff takes unit u, integer rawcode returns nothing
function GetEventBuffApplied takes nothing returns integer //Returns buff rawcode
function GetEventBuffExpired takes nothing returns integer //Returns buff rawcode
function StartBuffDissipation takes unit u, integer rawcode, real timeout returns nothing //Starts dissipation timer or rewrites the dissipation timeout
function PauseBuffDissipation takes unit u, integer rawcode, boolean flag returns nothing //Pauses dissipation timer
function IsBuffDissipating takes unit u, integer rawcode returns boolean
function SetBuffPositive takes unit u, integer rawcode, boolean flag returns nothing //By default this parameter inherits buff type settings
function IsBuffPositive takes unit u, integer rawcode returns boolean
function SetBuffLevel takes unit u, integer rawcode, integer level returns nothing
function SetBuffTip takes unit u, integer rawcode, string tip returns nothing
function SetBuffUbertip takes unit u, integer rawcode, string tip returns nothing
function SetBuffArt takes unit u, integer rawcode, string path returns nothing
function GetTriggerBuff takes nothing returns integer
function GetBuffTimeout takes unit u, integer rawcode returns real
function GetBuffElapsed takes unit u, integer rawcode returns real
function GetBuffRemaining takes unit u, integer rawcode returns real
function GetBuffLevel takes unit u, integer rawcode returns integer //Actually this can be achieved with current methods, but one must use GetUnitAbilityLevel(buffRawcode) function which is not intuitive.
function GetBuffTip takes unit u, integer rawcode returns string
function GetBuffUbertip takes unit u, integer rawcode returns string
function GetBuffArt takes unit u, integer rawcode returns string
// APPLY ABILITY API
constant playerevent EVENT_PLAYER_ABILITY_PRESSED //The event triggers when a player presses an ability button and begins targeting. Requires netsync from the player so is not instant. Most spell event natives like trigger unit and spell ability id work in response to this event.
function GetPlayerAbilityPressed takes player returns integer
function UnitApplyAbilityAtPoint takes integer abilCode, unit caster, real x, real y, boolean cast returns nothing
function UnitApplyAbilityOnTarget takes integer abilCode, unit caster, widget target, boolean cast returns nothing
//Applies specified ability from target's name (even if target hasn't such ability) does not waste mana or goes in CD. Boolean defines if it's required to have this ability in order to be able to cast it (just like Issue Immediate/Target/Point/Etc Order but takes abilId as an argument). Non-targeted abilities can still be applied at specified location if cast flag is marked otherwise at caster's location.
// CUSTOM CONTROLS API
type playerkey extends handle
constant playerevent EVENT_PLAYER_INPUT //Basically any key (mouse or keyboard)
constant playerkey KEY_A
constant playerkey KEY_B
constant playerkey KEY_C
constant playerkey KEY_D
constant playerkey KEY_E
...
constant playerkey KEY_SPACE
constant playerkey KEY_SHIFT
...
constant playerkey KEY_MOUSE_LEFT
constant playerkey KEY_MOUSE_RIGHT
constant playerkey KEY_MOUSE_WHEEL_UP
constant playerkey KEY_MOUSE_WHEEL_DOWN
...
//ETC
function GetTriggerKey takes nothing returns playerkey //Returns pressed/released key in response to EVENT_PLAYER_INPUT playerevent. Returns values like those: key_A, key_B, key_SPACE, key_MOUSE_1..., key_MOUSE_1234, etc.
function GetPlayerKeyState takes player p, playerkey k returns boolean //Returns true if the key is pressed
// CUSTOM UI API
function GetPlayerMouseScreenX takes player p, returns real
function GetPlayerMouseScreenY takes player p, returns real
function GetPlayerDisplayResolutionHorizontal takes player p, returns real
function GetPlayerDisplayResolutionVertical takes player p, returns real
function HideUIForPlayer takes player p, boolean flag returns nothing //Hides default UI and makes it so that the game renders at whole screen. Does not hide the player cursor.
function HideCursorForPlayer takes player p, boolean flag returns nothing //Hides the cursor for player.
function AllowPlayerCursorFlicking takes player p, boolean on returns nothing //Enables/disables cursor flicking (change of color)
function SetPlayerCursorPosition takes player p, real x, real y returns nothing
function LockPlayerCursorPosition takes player p, boolean flag returns nothing
function SetPlayerCursorColor takes player p, integer r, integer g, integer b returns nothing //Sets a custom coloration for players cursor
function GetPlayerCursorR takes player p, returns integer
function GetPlayerCursorG takes player p, returns integer
function GetPlayerCursorB takes player p, returns integer
function SetPlayerCursorModel takes player p, string model returns nothing //Changes cursor’s model
function GetPlayerCursorModel takes player p, returns string
// Model
type uimodel extends handle
function CreateUIModel takes real x, real y, string path, string texture, integer layer returns uimodel
function DestroyUIModel takes uimodel u returns nothing
function ShowUIModel takes uimodel u, boolean flag returns nothing
function IsUIModelVisible takes uimodel returns boolean
function GetOverlappedUIModel takes real x, real, y returns uimodel //returns the uimodel at the top layer of specified position
function SetUIModelScale takes uimodel u, real s returns nothing
function SetUIModelPosition takes uimodel u, real x, real y returns nothing
function SetUIModelModel takes uimodel u, string path returns nothing
function SetUIModelTexture takes uimodel u, string path returns nothing
function SetUIModelLayer takes uimodel u, integer h returns nothing //Default UI should be on layer 0
function SetUIModelAnimation takes uimodel, string animation returns nothing
function SetUIModelAnimationSpeed takes uimodel, real speed returns nothing
function GetUIModelScale takes uimodel u returns real
function GetUIModelModel takes uimodel u returns string //Returns path
function GetUIModelTexture takes uimodel u returns string
function GetUIModelX takes uimodel u returns real
function GetUIModelY takes uimodel u returns real
function GetUIModelLayer takes uimodel u returns integer
// Text
type uitext extends handle
function CreateUIText takes real x, real y, string text, real textsize, integer layer returns uitext
function DestroyUIText takes uitext u returns nothing
function ShowUIText takes uitext u, boolean flag returns nothing
function IsUITextVisible takes uitext returns boolean
function SetUITextPosition takes uitext u, real x, real y returns nothing
function SetUITextText takes uitext u, string text returns nothing
function SetUITextSize takes uitext u, real t returns nothing
function SetUITextLayer takes uitext u, integer h returns nothing
function GetUITextText takes uitext u returns string
function GetUITextSize takes uitext u returns real
function GetUITextX takes uitext u returns real
function GetUITextY takes uitext u returns real
function GetUITextLayer takes uitext u returns integer
// Tooltip
type uitooltip extends handle // Tooltip is drawn over other layers
function CreateUITooltip takes real x, real y, real width, real heigth, string text returns uitooltip
function DestroyUITooltip takes uitooltip u returns nothing
function ShowUITooltip takes uitooltip u, boolean flag returns nothing
function IsUITooltipVisible takes uitext returns boolean
function SetUITooltipPosition takes uitooltip u, real x, real y returns nothing
function SetUITooltipWidth takes uitooltip u, real w returns nothing
function SetUITooltipHeight takes uitooltip u, real h returns nothing
function SetUITooltipText takes uitooltip u, string t returns nothing
function GetUITooltipX takes uitooltip u returns real
function GetUITooltipY takes uitooltip u returns real
function GetUITooltipWidth takes uitooltip u returns real
function GetUITooltipHeight takes uitooltip u returns real
function GetUITooltipText takes uitooltipu returns string
// ITEM API
function SetItemColor takes item i, integer r, integer g, integer b, real t returns nothing
function GetItemColorR takes item i returns integer // Red
function GetItemColorG takes item i returns integer
function GetItemColorB takes item i returns integer
function GetItemColorT takes item i returns real// Transparency
function GetItemZ takes item i returns real
function PauseItemAbilityCooldown takes item i, integer abilcode, boolean flag returns nothing
function IsItemAbilityCooldownPaused takes item i, integer abilcode returns boolean
function SetItemAbilityCooldown takes item i, integer abilcode, real cd returns nothing
function SetItemAbilityCooldownRemaining takes item i, integer abilcode, real cd returns nothing
function GetItemAbilityCooldown takes item i, integer abilcode returns real
function GetItemAbilityCooldownElapsed takes item i, integer abilcode returns real
function GetItemAbilityCooldownRemaining takes item i, integer abilcode returns real
function SetItemLevel takes item i, integer level returns nothing
function SetItemTooltip takes item whichItem, string tip returns nothing
function SetItemExtendedTooltip takes item whichItem, string tip returns nothing
function SetItemIconPath takes item whichItem, string path returns nothing
function GetItemIconPath takes item whichItem returns string
function SetItemModel takes item i, string path returns nothing
function GetItemModel takes item i returns string
// ABILITY API
// Setters
function SetAbilityCooldown takes integer abilCode, integer level, real cooldown returns nothing
function SetAbilityIcon takes integer abilCode, integer level, string path returns nothing
function SetAbilityManaCost takes integer abilCode, integer level, real manacost returns nothing
function SetAbilityOnIcon takes integer abilCode, string path returns nothing
function SetAbilityOnTooltip takes integer abilCode, integer level, string text returns nothing
function SetAbilityOnUberTooltip takes integer abilCode, integer level, string text returns nothing
function SetUnitAbilityCooldownRemaining takes unit u, integer abilId, real time returns nothing //May be higher than unit ability cooldown.
function SetUnitAbilityPosition takes unit u, integer abilCode, real x, real y returns nothing
function SeUnittAbilityOnPosition takes unit u, integer abilCode, real x, real y returns nothing
function SetUnitAbilityIcon takes unit u, integer abilCode, integer level, string path returns nothing
function SetUnitAbilityResearchTooltip takes unit u, integer abilCode, integer level, string text returns nothing
function SetUnitAbilityResearchExtendedTooltip takes unit u, integer abilCode, integer level, string text returns nothing
function SetUnitAbilityTooltip takes unit u, integer abilCode, integer level, string text returns nothing
function SetUnitAbilityExtendedTooltip takes unit u, integer abilCode, integer level, string text returns nothing
function SetUnitAbilityOnIcon takes unit u, integer abilCode, string path returns nothing
function SetUnitAbilityOnTooltip takes unit u, integer abilCode, integer level, string text returns nothing
function SetUnitAbilityOnUberTooltip takes unit u, integer abilCode, integer level, string text returns nothing
// Getters
GetUnitAbilityIcon takes unit u, integer abilCode, integer level returns string
GetUnitAbilityPosX takes unit u, integer abilCode returns integer
GetUnitAbilityPosY takes unit u, integer abilCode returns integer
GetUnitAbilityResearchTooltip takes unit u, integer abilCode, integer level returns string
GetUnitAbilityResearchExtendedTooltip takes unit u, integer abilCode, integer level returns string
GetUnitAbilityTooltip takes unit u, integer abilCode, integer level returns string
GetUnitAbilityExtendedTooltip takes unit u, integer abilCode, integer level returns string
GetUnitAbilityOnIcon takes unit u, integer abilCode returns string
GetUnitAbilityOnPosX takes unit u, integer abilCode returns integer
GetUnitAbilityOnPosY takes unit u, integer abilCode returns integer
GetUnitAbilityOnTooltip takes unit u, integer abilCode, integer level returns string
GetUnitAbilityOnUberTooltip takes unit u, integer abilCode, integer level returns string
// UNIT API
// Types
type movementtype extends handle
type targettype extends handle
type defensetype extends handle
type deathtype extends handle
type armortype extends handle
type shadowimage extends handle
type attribute extends handle
type attackindex extends handle
constant targettype TARGETTYPE_AIR
constant targettype TARGETTYPE_ALIVE
constant targettype TARGETTYPE_ALLIED
constant targettype TARGETTYPE_ANCIENT
constant targettype TARGETTYPE_DRIDGE
constant targettype TARGETTYPE_DEAD
constant targettype TARGETTYPE_DEBRIS
constant targettype TARGETTYPE_DECORATION
constant targettype TARGETTYPE_ENEMY
constant targettype TARGETTYPE_FRIEND
constant targettype TARGETTYPE_GROUND
constant targettype TARGETTYPE_HERO
constant targettype TARGETTYPE_INVULNERABLE
constant targettype TARGETTYPE_ITEM
constant targettype TARGETTYPE_MECHANICAL
constant targettype TARGETTYPE_NEUTRAL
constant targettype TARGETTYPE_NON_ANCIENT
constant targettype TARGETTYPE_NON_HERO
constant targettype TARGETTYPE_NON_SUICIDAL
constant targettype TARGETTYPE_NONE
constant targettype TARGETTYPE_NOT_SELF
constant targettype TARGETTYPE_ORGANIC
constant targettype TARGETTYPE_PLAYER_UNITS
constant targettype TARGETTYPE_SELF
constant targettype TARGETTYPE_STRUCTURE
constant targettype TARGETTYPE_SUICIDAL
constant targettype TARGETTYPE_TERRAIN
constant targettype TARGETTYPE_TREE
constant targettype TARGETTYPE_VUlNERABLE
constant targettype TARGETTYPE_WALL
constant targettype TARGETTYPE_WARD
constant armortype ARMORTYPE_ETHEREAL
constant armortype ARMORTYPE_FLESH
constant armortype ARMORTYPE_METAL
constant armortype ARMORTYPE_STONE
constant armortype ARMORTYPE_WOOD
constant defensetype DEFENSETYPE_NORMAL
constant defensetype DEFENSETYPE_SMALL
constant defensetype DEFENSETYPE_MEDIUM
constant defensetype DEFENSETYPE_LARGE
constant defensetype DEFENSETYPE_FORTIFIED
constant defensetype DEFENSETYPE_HERO
constant defensetype DEFENSETYPE_DIVINE
constant defensetype DEFENSETYPE_UNARMORED
constant deathtype CANT_RAISE_NO_DECAY
constant deathtype CAN_RAISE_NO_DECAY
constant deathtype CANT_RAISE_DOES_DECAY
constant deathtype CAN_RAISE_DOES_DECAY
constant shadowimage SHADOWIMAGE_NONE
constant shadowimage SHADOWIMAGE_FLYER
constant shadowimage SHADOWIMAGE_NORMAL
constant attribute ATTRIBUTE_STR
constant attribute ATTRIBUTE_AGI
constant attribute ATTRIBUTE_INT
constant attackindex ATTACK_INDEX_NONE
constant attackindex ATTACK_INDEX_FIRST
constant attackindex ATTACK_INDEX_SECOND
constant attackindex ATTACK_INDEX_NONE
constant movementtype MOVEMENT_TYPE_NONE
constant movementtype MOVEMENT_TYPE_FOOT
constant movementtype MOVEMENT_TYPE_HORSE
constant movementtype MOVEMENT_TYPE_FLY
constant movementtype MOVEMENT_TYPE_HOVER
constant movementtype MOVEMENT_TYPE_FLOAT
constant movementtype MOVEMENT_TYPE_AMPHIBIOUS
constant armortype ARMOR_TYPE_SMALL
constant armortype ARMOR_TYPE_MEDIUM
constant armortype ARMOR_TYPE_LARGE
constant armortype ARMOR_TYPE_FORTIFIED
constant armortype ARMOR_TYPE_NORMAL
constant armortype ARMOR_TYPE_HERO
constant armortype ARMOR_TYPE_DIVINE
constant armortype ARMOR_TYPE_UNARMORED //Used by natives below.
constant armortype ARMOR_TYPE_UNKNOWN //Invalid armor type. Has been observed randomly in game, likely as the result of a non fatal memory corruption error to the armor type field.
// Functions
function GetUnitBuildTime takes integer unitid returns integer //AI native ported to standard JASS.
function GetHeroBuildTime takes integer unitid, player whichPlayer returns integer //Returns the train time in seconds for a player to make the specified hero type. Factors in train time increases with sequential heroes in melee.
function GetHeroReviveTime takes unit whichUnit returns integer //Returns the revive time in seconds for a player to revive the specified hero if it were dead.
function GetBuilderUnit takes unit building returns unit //Returns the unit that constructed a building/unit. In the case of buildings this should be the unit that converted the foundation into a unit.
function GetUnitBuildProgress takes unit u returns real //Returns the fraction (percent / 100) completion of a building/unit in progress. If the unit has no progress (already built) returns 1.0.
function SetUnitBuildProgress takes unit u, real fraction returns nothing //Modifies the fraction completion of a building/unit in progress. A fraction of 1.0 causes the unit to be instantly completed. Does nothing to a unit that is complete.
function GetUnitTrainProgress takes unit factory returns real //Returns the fraction completion of a unit that is being trained. Returns 1.0 if no unit is being trained.
function SetUnitTrainProgress takes unit factory, real fraction returns nothing //Modifies the fraction completion of a unit that is currently being trained. A fraction of 1.0 causes the unit to be instantly trained. Does nothing to a factory that is not training anything.
function GetTrainingQueueSize takes unit factory returns integer //Returns the number of queued training orders.
function GetMaxTrainingQueueSize takes unit factory returns integer //Returns the maximum number of queued training orders a factory allows.
function CancelTraining takes unit factory, integer slot returns boolean //Cancels a train order from the training queue of a building determined by slot number (eg 0 - 6). Returns true if a unit was actually canceled.
function ClearTrainingQueue takes unit factory returns boolean //Equivelant to calling CancelTraining on all occupied training slots of a building. Returns true if at least 1 training order was canceled.
function SetUnitVisionType takes unit u, boolean flying //Changes the vision mechanics of a unit to either be ground (can be occluded by terrain) or flying (absolute).
function UnitCancelTimedLife takes unit u returns nothing //Cancels a previously applied UnitApplyTimedLife or automatic expiration timer of a summoned unit.
function UnitApplyTimer takes unit u, integer buffId, real timeout returns timer //Applies a non-fatal timer to a unit that shows the time ticking down like with a spell like Avatar or Metamorphosis. When the timer expires, a TimerRegisterExpireEvent fires.
function UnitDisableItems takes unit u, boolean flag, boolean passive returns nothing //Toggles whether a unit can use items. Item passive effects are optionally able to be turned on or off.
function ReviveUnit takes unit u returns nothing //Revives a dead unit at the position of its corpse. Mechanically the same as the unit being effected by Paladin's Resurrection ability.
function SetUnitSpeed takes unit u, real speed returns nothing
function GetUnitSpeed takes unit u returns real
function SetUnitTurnRate takes unit u, real tr returns nothing
function GetUnitTurnRate takes unit u returns real
function SetUnitMovementType takes unit u, movementtype type returns nothing
function GetUnitMovementType takes unit u, returns movementtype
function SetUnitFoodCost takes unit u, integer i returns nothing
function GetUnitFoodCost takes unit u returns integer
function SetUnitFoodProduced takes unit u, integer i returns nothing
function GetUnitFoodProduced takes unit u returns integer
function SetUnitLevel takes unit u, integer level returns nothing
//function GetUnitLevel takes unit u returns integer
function SetUnitFormationRank takes unit u integer rank returns nothing
function GetUnitFormationRank takes unit u returns integer
function SetUnitTransportSize takes unit u, integer size returns nothing
function GetUnitTransportSize takes unit u returns integer
function UnitShowMinimapIcon takes unit u, boolean show returns nothing
function IsUnitMinimapIconShown takes unit u returns boolean
function UnitAllowSelection takes unit u, boolean flag returns nothing
//function IsUnitSelectable takes unit u returns boolean
function UnitDisablePlayerControl takes unit u boolean flag returns nothing //toggles whether a unit responds to player commands on or off. Can still respond to trigger commands.
function IsPlayerUnitControlDisabled takes unit u returns boolean
function UnitDisableAIControl takes unit u boolean b returns nothing //Allow/disallow attack if there was no player command or running away while being attacked.
function IsUnitControlledByAI takes unit u returns boolean
function SetHeroPrimaryAttribute takes unit u, attribute a, boolean preserveStats returns nothing //preserveStats makes it so that such parameters as attack speed, armor, hp and mana remains the same, otherwise they should be recalculated
function GetHeroPrimaryAttribute takes unit u returns attribute
function SetUnitCollisionSize takes unit u, real size returns nothing
function SetUnitSoundSet takes unit u, string soundset returns nothing
function GetUnitSoundSet takes unit u returns string
function SetUnitMovementSound unit u, string sound returns nothing
function GetUnitMovementSound takes unit u returns string
function GetUnitBlendTime takes unit u returns real
function SetUnitCastBackswing takes unit u, real r returns nothing
function GetUnitCastBackswing takes unit u returns real
function SetUnitCastPoint takes unit u, real r returns nothing
function GetUnitCastPoint takes unit u returns real
function SetUnitRunSpeed takes unit u real speed returns nothing
function GetUnitRunSpeed takes unit u returns real
function SetUnitWalkSpeed takes unit u real speed returns nothing
function GetUnitWalkSpeed takes unit u returns real
function SetUnitDeathTime takes unit u, real t returns nothing
function GetUnitDeathTime takes unit u returns real
function AllowUnitWaterShadow takes unit u boolean flag returns nothing
function HaveUnitWaterShadow takes unit u returns boolean
function SetUnitIcon takes unit u, string icon returns nothing
function GetUnitIcon takes unit u returns string
function SetUnitIconScoreScreen takes unit u, string icon returns nothing
function GetUnitIconScoreScreen takes unit u returns string
function SetUnitMaximumRollAngle takes unit u, real r returns nothing
function GetUnitMaximumRollAngle unit u returns real
function SetUnitMaximumPitchAngle takes unit u, real p returns nothing
function GetUnitMaximumPitchAngle unit u returns real
function SetUnitModel takes unit u, real string returns nothing
function GetUnitModel takes unit u returns string
function SetUnitOccluderHeight takes unit u, real h returns nothing
function GetUnitOccluderHeight takes unit u returns real
function SetUnitOrientationInterpolation takes unit u, integer oi returns nothing
function GetUnitOrientationInterpolation takes unit u returns integer
function SetUnitProjectileImpactZSwimming takes unit u, real z returns nothing
function GetUnitProjectileImpactZSwimming takes unit u returns real
function SetUnitProjectileImpactZ takes unit u, real z returns nothing
function GetUnitProjectileImpactZ takes unit u returns real
function SetUnitProjectileLaunchX takes unit u, real z returns nothing
function GetUnitProjectileLaunchX takes unit u returns real
function SetUnitProjectileLaunchY takes unit u, real z returns nothing
function GetUnitProjectileLaunchY takes unit u returns real
function SetUnitProjectileLaunchZSwimming takes unit u, real z returns nothing
function GetUnitProjectileLaunchZSwimming takes unit u returns real
function SetUnitProjectileLaunchZ takes unit u, real z returns nothing
function GetUnitProjectileLaunchZ takes unit u returns real
function AllowUnilProjectileScaling takes unit u, boolean flag returns nothing
function IsUnitProjectileScalingAllowed takes unit u returns boolean
function SetUnitSelectionHeight takes unit u, real height returns nothing
function GetUnitSelectionHeight takes unit u returns real
function AllowUnitSelectionOnWater takes unit u boolean flag returns nothing
function IsUnitSelectionOnWaterAllowed takes unit u returns boolean
function SetUnitSelectionScale takes unit u, real size returns nothing
function GetUnitSelectionScale takes unit u returns real
function SetUnitShadowImage takes unit u, shadowimage si returns nothing
function GetUnitShadowImage takes unit u returns shadowimage
function SetUnitShadow takes unit u, real width, real height, centerX, centerY returns nothing
function GetUnitShadowWidth takes unit u returns real
function GetUnitShadowHeight takes unit u returns real
function GetUnitShadowCenterX takes unit u returns real
function GetUnitShadowCenterY takes unit u returns real
function SetUnitShadowTexture takes unit u, string path returns nothing
function GetUnitShadowTexture takes unit u returns string
function SetUnitSpecialart takes unit u, string path returns nothing
function GetUnitSpecialart takes unit u returns string
function SetUnitAttackAnimationBackswingPoint takes unit u, integer ai, real v returns nothing
function GetUnitAttackAnimationBackswingPoint takes unit u, integer ai, returns real
function SetUnitAttackAnimationDamagePoint takes unit u, integer ai, real v returns nothing
function GetUnitAttackAnimationDamagePoint takes unit u, integer ai, returns real
function SetUnitAttackAoEDamageFull takes unit u, integer ai, real AoE returns nothing
function GetUnitAttackAoEDamageFull takes unit u, integer ai, returns real
function SetUnitAttackAoEDamageMedium takes unit u, integer ai, real AoE returns nothing
function GetUnitAttackAoEDamageMedium takes unit u, integer ai, returns real
function SetUnitAttackAoEDamageSmall takes unit u, integer ai, real AoE returns nothing
function GetUnitAttackAoEDamageSmall takes unit u, integer ai, returns real
function SetUnitAttackAoETargetAllowed takes unit u, integer ai, targettype target, boolean allowed returns nothing
function GetUnitAttackAoETargetAllowed takes unit u, integer ai, targettype target returns boolean
function SetUnitAttackType takes unit u, integer ai, attacktype at returns nothing
function GetUnitAttackType takes unit u, integer ai returns attacktype
function SetUnitAttackDamageFactorMedium takes unit u, integer ai, real fm returns nothing
function GetUnitAttackDamageFactorMedium takes unit u, integer ai, returns real
function SetUnitAttackDamageFactorSmall takes unit u, integer ai, real fs returns nothing
function GetUnitAttackDamageFactorSmall takes unit u, integer ai, returns real
function SetUnitAttackDamageLossFactor takes unit u, integer ai, real lf returns nothing
function GetUnitAttackDamageLossFactor takes unit u, integer ai, returns real
function SetUnitAttackDamageSpillDistance takes unit u, integer ai, real distance returns nothing
function GetUnitAttackDamageSpillDistance takes unit u, integer ai, returns real
function SetUnitAttackDamageSpillRadius takes unit u, integer ai, real radius returns nothing
function GetUnitAttackDamageSpillRadius takes unit u, integer ai, returns real
function SetUnitAttackMaxTargets takes unit u, integer ai, integer amount returns nothing
function GetUnitAttackMaxTargets takes unit u, integer ai returns integer
function SetUnitAttackProjectileArc takes unit u, integer ai, real arc returns nothing
function GetUnitAttackProjectileArc takes unit u, integer ai returns real
function SetUnitAttackProjectile takes unit u, integer ai, string path returns nothing
function GetUnitAttackProjectile takes unit u, integer ai returns string
function SetUnilAttackProjectileHoming takes unit u, integer ai, boolean flag returns nothing
function IsUnitAttackProjectileHoming takes unit u, integer ai returns boolean
function SetUnitAttackProjectileSpeed takes unit u, integer ai, real speed returns nothing
function GetUnitAttackProjectileSpeed takes unit u, integer ai returns real
function SetUnitAttackRangeMotionBuffer takes unit u, integer ai, real range returns nothing
function GetUnitAttackRangeMotionBuffer takes unit u, integer ai returns real
function SetUnitAttackTargetAllowed takes unit u, integer ai, targettype type, boolean allowed returns nothing
function GetUnitAttackTargetAllowed takes unit u, integer ai, targettype type returns boolean
function SetUnitWeaponSound takes unit u, integer ai, string path returns nothing
function GetUnitWeaponSound takes unit u, integer ai, returns string
function SetUnitAttackIndex takes unit u, attackindex index returns nothing
function GetUnitAttackIndex takes unit u returns attackindex
function SetUnitDeathType takes unit u, deathtype dt returns nothing
function GetUnitDeathType takes unit u returns deathtype
function SetUnitDefenseBase takes unit u, real armor returns nothing
function GetUnitDefenseBase takes unit u returns real
function SetUnitArmorType takes unit u, armortype at returns nothing
function GetUnitArmorType takes unit u returns armortype
function SetUnitWeaponType takes unit u, integer ai, weapontype wt returns nothing
function GetUnitWeaponType takes unit u, integer ai, returns weapontype
function SetUnitDefenseType takes unit u, defensetype d returns nothing
function GetUnitDefenseType takes unit u returns defensetype
function SetUnitTargetType takes unit u, targettype target returns nothing
function GetUnitTargetType takes unit u returns targettype
function SetUnitAttackUpgradeBonus takes unit u, integer ai, integer amount returns nothing
function GetUnitAttackUpgradeBonus takes unit u, integer ai, returns integer
function SetUnitDefenseUpgradeBonus takes unit u, real newBonus returns nothing
function GetUnitDefenseUpgradeBonus takes unit u returns real
function SetUnitMinimumAttackRange takes unit u, real range returns nothing
function GetUnitMinimumAttackRange takes unit u returns real
function SetUnitAttackRange takes unit u, integer ai, real range returns nothing
function GetUnitAttackRange takes unit u, integer ai returns real
function SetUnitAcquisitionRange takes unit u, real r returns nothing
function GetUnitAcquisitionRange takes unit u returns real
function SetUnitCasterUpgradeArt takes unit u, string icon returns nothing
function GetUnitCasterUpgradeArt takes unit u returns string
function SetUnitCasterUpgradeName takes unit u, integer level, string name returns nothing
function GetUnitCasterUpgradeName takes unit u, integer level returns string
function SetUnitCasterUpgradeTip takes unit u, integer index, string name returns nothing
function GetUnitCasterUpgradeTip takes unit u, integer index, returns string
// TERRAIN API
function GetWaterLevelZ takes real x, real y returns real //Returns Z of water level at specified position
function IsPointPathable takes real x, real y, movementtype mt returns boolean
//========================================================================================================================================
// BENCHMARKING API
/*
Whoever suggested these did not explain their purpose or what they are meant to do.
I am guessing they are meant to be client local performance counters for measuring performance of various scripts.
If this is the case then all calls made to these during multiplayer these should return default safe values that do nothing.
*/
function CreateStopWatch takes nothing returns stopwatch //Create a performance counter stop watch.
function StopWatchStart takes stopwatch returns nothing //Start the stop watch, causing it to record time progression. If it has been paused, resumes recording.
function GetStopWatchTime takes stopwatch returns real //Pause the stop watch and get the current elapsed stop watch time, which is the sum of all time it has been left running.
function StopWatchEnd takes stopwatch returns nothing //Destroy the stop watch freeing all resources it used.
function StopWatchPause takes stopwatch returns nothing //Pause the stop watch causing it to stop recording time progression. If trying to accuratly measure execution time of a piece of script this should be called between game frames to prevent the stop watch measuring the game loop time.
// DEBUGGING API
type func extends code //Function type to be used with debugging natives. Possibly has special syntax requirements to prevent code exploit.
function DisplayErrorMsg takes string s, real duration returns nothing //Display the given error message string in the error message area. The message is also written out to an error log file.
function GetOPLimit takes nothing returns integer //Get the current remaining JASS thread operation limit. Due to how the JASS virtual machine works the returned value may be larger than the actual limit by the time it can be processed.
function SetOPLimit takes integer newlimit returns nothing //Changes the current JASS thread operation limit to the specified value. Due to how the JASS virtual machine works the actual limit may be slightly smaller than the specified amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
function ResetOPLimit takes nothing returns nothing //Resets the current JASS thread operation limit to the default operation limit of that thread, as if it was freshly created. Due to how the JASS virtual machine works the actual limit may be smaller than the default amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
function TriggerRegisterJassOpLimitEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of the thread reaching its operation limit. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassDivideByZeroEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempted division by 0. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassNoBlockEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempting to block when blocking is not allowed (eg TriggerSleepAction in a condition function). Useful for detecting when a thread crash occurs.
function GetTriggerFunction takes nothing returns func //In response to all JASS thread crash events returns the function the crash occured at.
function GetEventJassError takes nothing returns string //In response to all JASS thread crash events returns a human readable string with as much information about the crash as possible. Intended to be printed out or logged to help map makers track down where/why a thread crash occured.
function GetHandleIdCount takes nothing returns integer //Returns the number of currently allocated handle ids. If this number is observed increasing as a game progresses there is likely an object leak of sorts.
function GetHandleIdFreeCount takes nothing returns integer //Returns the number of handle ids on the free handle id stack. If this number is very large then either the map has suffered from object count reduction over time or there was a step that required a large number of objects be created and destroyed.
function GetSpecialEffectAttachX takes effect fx returns real //Get value from X axis of the attachment point.
function GetSpecialEffectAttachY takes effect fx returns real //Get value from Y axis of the attachment point.
function GetSpecialEffectAttachZ takes effect fx returns real //Get value from Z axis of the attachment point.
function GetSpecialEffectAttachYaw takes effect fx returns real //Get Yaw value from the special effect attachment.
function GetSpecialEffectAttachPitch takes effect fx returns real //Get Pitch value from the special effect attachment.
function GetSpecialEffectAttachRoll takes effect fx returns real //Get Roll value from the special effect attachment.
// Animation sequences
function GetAnimationTimeout takes string modelFile, string anim returns real
// This returns the duration of the sequence converted from key-frames to float-seconds.
function GetUnitAnimationTimeout takes unit u, string anim returns real
// A wrapper function for GetAnimationTimeout but for units.
return GetAnimationTimeout(GetUnitModelFile(u), anim)
function GetUnitCurrentAnimationTimeout takes unit u, string anim returns real
// A function that gets the animation timeout and adjusts to the time scale of the unit.
// For instance, if the time-scale of the unit is 2, then the duration is halved.
// However, for additional protection, a safe default value of 0 will be returned
// when the time scale is 0.
return GetAnimationTimeout(GetUnitModelFile(u), anim)/GetUnitTimeScale(u)
function GetDestructableAnimTimeout takes destructable d, string anim returns real
function GetDestructableCurrentAnimTimeout takes destructable d, string anim returns real
function GetItemAnimationTimeout takes item i, string anim returns real
function GetItemCurrentAnimationTimeout takes item i, string anim returns real
constant colorType BASIC_COLOR_RED = ConvertColorType(1)
constant colorType BASIC_COLOR_GREEN = ConvertColorType(2)
constant colorType BASIC_COLOR_BLUE = ConvertColorType(4)
constant colorType BASIC_COLOR_ALPHA = ConvertColorType(8)
function GetWidgetVertexColor takes widget w, colorType c returns real
// Returns the vertex coloring of a desired widget.
// In retrospect, the functions above could be replaced with
// just GetWidgetAnimationTimeout or something.
//===========================================================================
// NEW FEATURES
//===========================================================================
/*
LIBRARIES & SCOPES
http://www.wc3c.net/vexorian/jasshelpermanual.html#lib
GLOBALS BLOCK
The ability to declare global variable directly in code. This tremendously facilitates installation of new system without the need for a separate 'variable creator' trigger.
http://www.wc3c.net/vexorian/jasshelpermanual.html#gdf
STRUCTS
http://www.wc3c.net/vexorian/jasshelpermanual.html#stru
2D ARRAYS
http://www.wc3c.net/vexorian/jasshelpermanual.html#twodarray
CODE ARRAY
The abillity to declare code array.
ARRAY AS AN ARGUMENT
The ability to use arrays as an argument and the ability to return an array.
LOCAL DECLARATION
The ability to declare locals anywhere - not just at the top of the function.
MULTIPLE MULTIBOARDS / LEADERBOARDS
The abilty to have multiple multiboards or leaderboards on screen at the same time.
UNICODE SUPPORT
*/
//===========================================================================
// NON DIRECTLY CODE BASE NEW FEATURES
//===========================================================================
/*
HIDE TEXT TAGS OF NATIVE ABILITIES
The ability to hide (or modify) textags from some native abilities (Evade, Shadow Strike, Critical Strike and Mana Burn) with a flag in Object Editor.
CUSTOM ATTACK/ARMOR TYPES
The ability to add custom attack or armor types.
*/
//===========================================================================
// INCREASE LIMITS
//===========================================================================
/*
TextTags
- Currently 100 per local player
Regions
- Increase constant integer bj_MAX_DEST_IN_REGION_EVENTS = 64
Sound
- Max 4x playing a sound filepath at a time.
- Max 16 sounds in general at a time.
- There's a limit before a sound filepath can be played again (seems depend on client), around 0.1 seconds.
String
- The amount of text that you can put in a tooltip.
*/
//===========================================================================
// FIXES
//===========================================================================
//Strings should be automatically garbage collected or at least a native should exist that can be periodically called to help free up disused strings.
//Local handles declared with the local keyword should automatically cause the reference counter to be decremented at the end of a function just like local handles declared as function arguments.
native EnableOcclusion takes boolean flag returns nothing
//Occlusion has been a feature present in the first versions of Warcraft 3 but was broken after a patch.
//Details explained: https://www.hiveworkshop.com/threads/occlusion-isnt-working-properly.286926/
native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing
//The main tooltip of the added unit will always ignore color tags so the text will always appear to be white. Color tags should be parsed the same as all unit tooltips.
//The hotkey of the unit isn't working proprely to if it was added using this function.
native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing
/*With each of call of this function, the minimap is modified in a bugged way :
The positions of units and the fog of war are modified to fit to the new camera bound but not the terrain, nor the destructables.
The minimap is compressed (vertically) according to the current camera's rotation. With a rotation of 90°, there is no compression. With a rotation of 227.40, the minimap is fully compressed. Between 227.5 and 312.6, the game crashes.
Moreover, the camera bounds will also be adjusted according to the rotation of the current camera. The camera bounds created will be a rectangle going trough the 4 points given and whose sides will be parallel to the camera.*/
native DestroyTrigger takes trigger whichTrigger returns nothing
/* Destroy all bound triggeraction objects.
Currently it only destroys all bound events, triggercondition and the trigger itself leaving all triggeraction objects to leak unless explicitly destroyed before.
Also destroy all currently scheduled trigger threads from that trigger.
Currently destroying a trigger with scheduled trigger threads can cause handle stack corruption which has a high chance to cause Warcraft III to crash.*/
function SmartCameraPanBJ takes player whichPlayer,location loc,real duration returns nothing
//This BJ function is currently not net safe. Details explained: https://www.hiveworkshop.com/threads/fixing-smartcamerapanbj-desync.243334/
constant native GetEventDamage takes nothing returns real
//Return the amount of life damage taken through an imperfect mana shield. Currently returns 0 or negative only even if the unit takes life damage through the shield.
function GetRandomSubGroupEnum takes integer count, group sourceGroup returns group
//Not an even distribution. See http://www.hiveworkshop.com/forums/l-715/g-275344
native PauseTimer takes timer whichTimer returns nothing
//Pausing a periodic timer should not cause the timer to lose the periodic status.
native CreateQuest takes nothing returns quest
//Creating quests during map initialization should not cause a game crash.
native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
//Creating units should not cause a permanent memory leak
native UnitApplyTimedLife takes unit whichUnit, integer buffId, real duration returns nothing
//Only 'BTLF' will be accepted as a buffId, inputing anything else don't work.
native DestroyImage takes image whichImage returns nothing
//May crash the game if an invalid image is used (null, before the first image is created).
native SetImageRenderAlways takes image whichImage, boolean flag returns nothing
//Does not work. Use SetImageRenderAlways instead.
native PlayMusic takes string musicName returns nothing
//This native may cause a short lag spike as soon as the music starts. To circumvent this lag, stop the current music without fadeout before calling this function (`call StopMusic(false)`).
//PlayMusicEx has the same issue.
native CameraSetupApplyWithZ takes camerasetup whichSetup, real zDestOffset returns nothing
//If a player pauses the game after the camerasetup has been applied, the z-offset of the game camera will change to the z-offset of the camerasetup for that player.
native SetUnitScale takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing
//Only takes scaleX int account and uses scaleX for all three dimensions.
native AddHeroXP takes unit whichHero, integer xpToAdd, boolean showEyeCandy returns nothing
//Adding negative value to experience will decrease it by the stated value, but won't lower the level even if the experience value after deduction is lower than the lower bound of the experience required to get the stated level.
//If the value will become lower than zero, the experience won't be negative, instead of it it'll be equal to 4294967296+(supposed_negative_experience_value) which actually proves that WarCraft III uses unsigned int type for storing experience points.
native UnitDamagePoint takes unit whichUnit, real delay, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
//Has been known to cause crashes in battle.net
native AddResourceAmount takes unit whichUnit, integer amount returns nothing
/*If the value after adding negative amount will be less than zero, then it
will display negative resource amount, but if some peasant or peon will try to
gather resources from such a mine, he will bring back 0 gold and the mine will
be auto-destroyed.*/
constant native UnitId2String takes integer unitId returns string
//Always returns null after the game is loaded/if the game is a replay.
constant native AbilityId takes string abilityIdString returns integer
constant native AbilityId2String takes integer abilityId returns string
// Both not working correctly
native GroupEnumUnitsOfTypeCounted takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRectCounted takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
native GroupEnumUnitsInRangeOfLocCounted takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
//Causes irregular behavior when used with large numbers
native ResetUbersplat takes ubersplat whichSplat returns nothing
native FinishUbersplat takes ubersplat whichSplat returns nothing
native SetTerrainFog takes real a, real b, real c, real d, real e returns nothing
native AddSpellEffect takes string abilityString, effecttype t, real x, real y returns effect
native AddSpellEffectLoc takes string abilityString, effecttype t,location where returns effect
native GetAbilityEffect takes string abilityString, effecttype t, integer index returns string
native GetAbilitySound takes string abilityString, soundtype t returns string
//All do nothing.
native MultiboardSetRowCount takes multiboard lb, integer count returns nothing
/*It is only safe to change the row count by one. Use multiple calls for bigger values.
Details explained: http://www.hiveworkshop.com/forums/l-715/m-250775/
http://www.hiveworkshop.com/forums/t-269/w-234897/
*/
native GetLocalizedString takes string source returns string
//Cannot assign it to a constant variable as it will crash the game.
//constant string foo = GetLocalizedString("bar")
native SyncStoredString takes gamecache cache, string missionKey, string key returns nothing
//Doesn't work
native PauseUnit takes unit whichUnit, boolean flag returns nothing
/* This forces a unit to have a collision until it's unpaused.
Pausing a unit with a disabled collision will re-enable it for this unit.
Trying to disable the collision of a paused unit doesn't work.
This has been tested with the SetUnitPathing native and abilities that affect collision such as 'Aeth'*/
native UnitModifySkillPoints takes unit whichHero, integer skillPointDelta returns boolean
//Can only add as many points the Hero can use at the given moment. A vanilla hero level 1 can have only 10 points added to him per call
//Works as excepted with any negative value
native TimerGetRemaining takes timer whichTimer returns real
//This might not return the correct value if the timer was paused and restarted at one point.
//Details explained: http://www.wc3c.net/showthread.php?t=95756
native GetExpiredTimer takes nothing returns timer
//Might crash the game if called when there is no expired timer.
//Details explained: http://www.wc3c.net/showthread.php?t=84131
native SetSoundPitch takes sound soundHandle, real pitch returns nothing
//This native has very weird behaviour.
//Details explained: http://www.hiveworkshop.com/threads/setsoundpitch-weirdness.215743/#post-2145419
//For a non-bugged implementation: http://www.hiveworkshop.com/threads/snippet-rapidsound.258991/#post-2611724
native DisplayTimedTextFromPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
//Only the first "%s" will be replaced correctly. Following "%s" will be printed as garbage.
//Using formatters like "%i" will also print garbage and following "%s" wont work either.
constant native OrderId takes string orderIdString returns integer
//Do not use this in a global initialisation as it returns 0 there.
constant native OrderId2String takes integer orderId returns string
constant native UnitId2String takes integer unitId returns string
//Do not use this in a global initialisation as it returns null there.
constant native GetObjectName takes integer objectId returns string
//Do not use this in a global initialisation as it crashes the game there.
native LoadGame takes string saveFileName, boolean doScoreScreen returns nothing
/*The filename seems to have some limitations:
- No underscores in campaign names.
- Shorter file names for savegames.
- Probably no dots in savegames or campaign names.
For more info see http://www.hiveworkshop.com/threads/map-transition-does-not-work-when-loading-a-custom-savegame.286927/
*/
native GetWidgetLife takes widget w returns real
//The real is not exact? Details lacking.
native TriggerRegisterUnitStateEvent takes trigger whichTrigger, unit whichUnit, unitstate whichState, limitop opcode, real limitval returns event
//EQUAL is broken? Details lacking.
//===========================================================================
// CHANGES TO EXISTING NATIVES
//===========================================================================
native SetUnitState takes unit whichUnit,unitstate whichUnitState,real newVal returns nothing
//Add support for modifying both maximum and regeneration for life and mana. Currently only supports modifying current life.
native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
//Change it so that displaying text to a player with unique x and y does not move any other messages.
constant gameevent EVENT_GAME_TRACKABLE_HIT = ConvertGameEvent(7)
constant gameevent EVENT_GAME_TRACKABLE_TRACK = ConvertGameEvent(8)
//Make GetTriggerPlayer() Return the player that triggered the trackable event
//===========================================================================
// NEW NATIVES
//===========================================================================
//===========================================================================
// GAME
//===========================================================================
native EnableCheats takes boolean flag returns nothing
//Already exist but not usable (game.dll + 0x1C97E0 on 1.28.5).
//===========================================================================
// EVENTS
//===========================================================================
// > NEW EVENTS
constant unitevent EVENT_UNIT_REMOVED
//The event triggers the instant before the unit is removed from the game. Units get removed from the game by a variety of sources such as triggers, decaying or merging.
constant unitevent EVENT_UNIT_UNLOADED
//Triggers when unit is unloading
constant unitevent EVENT_UNIT_IDLES
//Similarly to how worker icons appear at the bottom-left corner of the screen when idling, this event detects when ANY unit is idling.
constant unitevent EVENT_UNIT_ENTERS_COMBAT
//What it says on the tin - this event fires when a unit enters combat. Will be useful for in/out of combat regeneration, for example.
constant unitevent EVENT_UNIT_EXITS_COMBAT
//What it says on the tin - this event fires when a unit leaves combat. Will be useful for in/out of combat regeneration, for example.
constant unitevent EVENT_UNIT_DAMAGE_RELEASE
//This triggers when a unit's attack is released, aka when a melee unit hits its target or a ranged unit launches a missile.
constant unitevent EVENT_UNIT_MOVES
//Fires when a unit moves.
constant unitevent EVENT_UNIT_EVADE
//The event triggers when a unit evades an attack using an evade ability (Evasion, Drunken Brawler, etc).
constant playerunitevent EVENT_PLAYER_UNIT_DAMAGE_RELEASE
//Same as EVENT_UNIT_DAMAGE_POINT except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_EVADE
//Same as EVENT_UNIT_EVADE except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_REMOVED
//Same as EVENT_UNIT_REMOVED except as a player unit event.
// > RESOURCES EVENT EXTENSION
constant unitevent EVENT_UNIT_RESOURCE_RETURN //The event triggers when a unit returns a resource such as from gathering.
constant unitevent EVENT_UNIT_RESOURCE_HARVEST //The event triggers when a unit harvests a resource. This event means the amount the unit is carrying has changed.
constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_RETURN //Same as EVENT_UNIT_RESOURCE_RETURN except as a player unit event.
constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_HARVEST //Same as EVENT_UNIT_RESOURCE_HARVEST except as a player unit event.
constant resourcetype RESOURCE_GOLD //Used by natives below.
constant resourcetype RESOURCE_LUMBER //Used by natives below.
function GetEventResourceType takes nothing returns resourcetype
//The resource type the event responded to. For example RESOURCE_LUMBER when a wisp unit gathers lumber.
function GetEventResourceAmount takes nothing returns integer
//The resource amount the event responded to. For example 10 when a Haunted Gold Mine extracts 10 gold.
// > DAMAGE EVENT EXTENSION
constant playerunitevent EVENT_PLAYER_UNIT_DAMAGED //Same as EVENT_UNIT_DAMAGED except as a player unit event.
function GetEventDamageAttackType takes nothing returns attacktype
//In response to a damage event returns the attacktype (Spell, Hero, Chaos, etc) of the damage.
function GetEventDamageDamageType takes nothing returns damagetype
//In response to a damage event returns the damagetype (unkown, magic, normal, enhanced, etc) of the damage.
function GetEventDamageAbilityId takes nothing returns integer
//In response to a damage event returns the ability ID that caused the damage. This ability can be a damage spell (Flame Strike, Storm Bolt, etc) or an attack modifier ability (Cold Arrow, orb of fire, etc). Normal attack damage returns some safe default value such as 0.
function GetEventDamageUnmodified takes nothing returns real
//In response to a damage event returns the damage dealt to the unit before any modifications (armor, attacktype reduction, etc) were applied.
function GetEventDamageMana takes nothing returns real
//In response to a damage event returns the mana lost due to an active mana shield.
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
native SetEventDamage takes real damage returns nothing
*/
//===========================================================================
// TRIGGER
//===========================================================================
function EvaluateBoolexpr takes boolexpr func returns boolean
//Simple function to evaluate a boolexpr in a single call. Currently one has to bind it to a trigger as a condition, evaluate the trigger and then destroy the trigger after evaluation. The way the boolexpr is executed should be similar to the current trigger approach.
//===========================================================================
// TIMER
//===========================================================================
function TimerSetRemaining takes timer t, real newTime returns nothing
//Set Remaining time would allow to enlarge/shorten a timer's duration.
//Or evoke its execution instantly
//without changing execution code nor repeat mode.
function TimerSetRepeat takes timer t, real repeatTime returns nothing
//change the repeatTime of an timer.
//will en/disable repeat mode, if needed.
//===========================================================================
// PLAYER
//===========================================================================
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
constant native DecPlayerTechResearched takes player whichPlayer, integer techid, integer levels returns nothing
*/
//===========================================================================
// FORCE
//===========================================================================
function FirstOfForce takes force f returns player
//same as FirstOfGroup, for player-groups.
//===========================================================================
// PATHING
//===========================================================================
function GetPathingCost takes real x1 real y1 real x2 real y2 returns int
// GetPathing returns the pathing cost between two points and returns -1 if it's unreachable.
//===========================================================================
// TERRAIN
//===========================================================================
function GetWaterZ takes real x, real y returns real
//returns the water level (shallow or deep) since currently GetLocationZ() ignores water level.
function GetCliffZ takes real x, real y returns real
//related to this https://www.hiveworkshop.com/threads/calculating-a-flying-units-flyheight.270925/
//===========================================================================
// UBERSPLAT
//===========================================================================
function SetUbersplatPos takes ubersplat u, real x, real y returns nothing
//Moves an ubersplat to a new map relative coordinate.
function SetUbersplatScale takes ubersplat u, real x, real y returns nothing
//Allows the distortion of an ubersplat. This is applied to the ubersplat in its default orientation before it is rotated.
function SetUbersplatFacing takes ubersplat u, real angle returns nothing
//Allows an ubersplat to be rotated. Useful for hazard markers or hit markers. Angle is in degrees.
function SetUbersplatFacingRad takes ubersplat u, real angle returns nothing
//Same as SetUbersplatFacing except angle is in radians.
//===========================================================================
// SPECIAL EFFECT
//===========================================================================
function AddSpecialEffectEffect takes string modelName, effect targetEffect, string attachPointName returns effect
//Create a special effect attached to another special effect.
function SetSpecialEffectEffect takes effect fx, effect targetEffect, string attachPointName returns nothing
//Moves a special effect to the target special effect.
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
native SetSpecialEffectX takes effect whichEffect, real x returns nothing
native SetSpecialEffectY takes effect whichEffect, real y returns nothing
native SetSpecialEffectZ takes effect whichEffect, real z returns nothing
native SetSpecialEffectPositionLoc takes effect whichEffect, location loc returns nothing
native GetLocalSpecialEffectX takes effect whichEffect returns real
native GetLocalSpecialEffectY takes effect whichEffect returns real
native GetLocalSpecialEffectZ takes effect whichEffect returns real
native SetSpecialEffectColorByPlayer takes effect whichEffect, player whichPlayer returns nothing
native SetSpecialEffectColor takes effect whichEffect, integer r, integer g, integer b returns nothing
native SetSpecialEffectAlpha takes effect whichEffect, integer alpha returns nothing
native SetSpecialEffectScale takes effect whichEffect, real scale returns nothing
native SetSpecialEffectPosition takes effect whichEffect, real x, real y, real z returns nothing
native SetSpecialEffectHeight takes effect whichEffect, real height returns nothing
native SetSpecialEffectTimeScale takes effect whichEffect, real timeScale returns nothing
native SetSpecialEffectTime takes effect whichEffect, real time returns nothing
native SetSpecialEffectOrientation takes effect whichEffect, real yaw, real pitch, real roll returns nothing
native SetSpecialEffectYaw takes effect whichEffect, real yaw returns nothing
native SetSpecialEffectPitch takes effect whichEffect, real pitch returns nothing
native SetSpecialEffectRoll takes effect whichEffect, real roll returns nothing
native PlaySpecialEffect takes effect whichEffect, integer anim returns nothing
native PlaySpecialEffectWithTimeScale takes effect whichEffect, integer anim, real timeScale returns nothing
*/
//===========================================================================
// LIGHTNING
//===========================================================================
native SetLightningScale takes lightning whichBolt, real scale returns nothing
//===========================================================================
// WEATHER EFFECT
//===========================================================================
function SetWeatherEffectHeight takes weathereffect whichEffect, real height returns nothing
function SetWeatherEffectScale takes weathereffect whichEffect, real scale returns nothing
function SetWeatherEffectColor takes weathereffect whichEffect, real r, real g, real b, real a returns nothing
function SetWeatherEffectSound takes weathereffect whichEffect, sound soundHandle returns nothing
//===========================================================================
// WIDGET
//===========================================================================
// > WIDGET VISUAL
function SetWidgetTexure takes widget whichWidget, string texturePath, integer replaceableId returns boolean
/*Models can have textures with a Replaceable ID instead of a texture path.
The most common use of this is for team color and hero glow (Replaceable ID 1 & 2).
While there are natives to set a units team color, that's about all that is natively supported.
The Mountain Giant's War Club ability will change any texture on the caster that uses "Replaceable ID 32" to the texture of the targeted destructable.
While this allows us to modify ID 32, it's not enough and has some overhead.
If we can allow the user to change any ID, then we can switch the texture of any part of the model dynamically.
Of course this requires models to use Replaceable ID's instead of texture paths, so many vanilla models won't have uses other than custom team colors.
Perhaps a complete API to modify model data would be better, however this would be the easiest to implement.
There is already an internal function capable of doing this. However it requires a destructable as one of the paramaters, but I think it should be fairly easy to find a way to not require one.
The way I do it is by using a dummy destructable object (not handle) and switching it's texture, but there is probably a better way.*/
function GetWidgetTexure takes widget whichWidget, replaceableId returns string
// > WIDGET ATTACHEMENT
function GetLocalTargetAttachmentX takes widget who, string attachmentname returns real
//Get the map relative x coordinate of the specified attachment site. Not net safe.
//for instance GetLocalTargetAttachmentX(unit,"hand") would return the projected X coordinate of the hand
function GetLocalTargetAttachmentY takes widget who, string attachmentname returns real
//Get the map relative y coordinate of the specified attachment site. Not net safe.
function GetLocalTargetAttachmentZ takes widget who, string attachmentname returns real
//Get the map relative z coordinate of the specified attachment site. Not net safe.
// > WIDGET EVENTS
function TriggerRegisterWidgetInRange takes trigger whichTrigger, widget whichWidget, real range, boolexpr filter returns event
// > WIDGET GROUP
type widgetgroup extends agent
//this would allow tot make groups of items and destructables
function CreateWidgetGroup takes nothing returns widgetgroup
function DestroyGroup takes widgetgroup whichGroup returns nothing
function GroupAddWidget takes widgetgroup whichGroup, widget wichWidget returns nothing
function GroupRemoveWidget takes widgetgroup whichGroup, widget wichWidget returns nothing
function GroupClear takes widgetgroup whichGroup returns nothing
function GroupEnumWidgetsOfType takes widgetgroup whichGroup, string widgetname, boolexpr filter returns nothing
function GroupEnumWidgetsOfTypeCounted takes widgetgroup whichGroup, string widgetname, boolexpr filter, integer countLimit returns nothing
function GroupEnumWidgetsInRect takes widgetgroup whichGroup, rect r, boolexpr filter returns nothing
function GroupEnumWidgetsInRectCounted takes widgetgroup whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
function GroupEnumWidgetsInRange takes widgetgroup whichGroup, real x, real y, real radius, boolexpr filter returns nothing
function GroupEnumWidgetsInRangeOfLoc takes widgetgroup whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
function GroupEnumWidgetsInRangeCounted takes widgetgroup whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
function GroupEnumWidgetsInRangeOfLocCounted takes widgetgroup whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
function ForGroup takes widgetgroup whichGroup, code callback returns nothing
function FirstOfGroup takes widgetgroup whichGroup returns widget
//native widgetgroup API update for widget widgetgroup
//===========================================================================
// DESTRUCTABLE
//===========================================================================
constant destructableevent DESTRUCTIBLE_DEATH //Triggers when a destructible dies. I put this here to standardise the way destructible events work.
constant destructableevent DESTRUCTIBLE_COMBAT //Triggers when a destructible takes damage from a combat source. Ignores tree-harvesting.
constant destructableevent DESTRUCTIBLE_HARVESTED //Triggers when a destructible takes damage from a tree-harvest ability. Ignores combat damage.
constant destructableevent DESTRUCTIBLE_DAMAGED //Triggers when a destructible takes any damage at all.
function IsDestructableTree takes destructable d returns boolean
//Returns true if a destructable can be used as a tree. Otherwise false.
function TriggerRegisterDestructibleEvent takes trigger whichTrigger, destructable d, destructableevent whichEvent returns event
//Like TriggerRegisterUnitEvent. Some of the important event constants are listed but others might also exist.
function TriggerRegisterAnyDestructibleEvent takes trigger whichTrigger, destructableevent whichEvent returns event
//Like TriggerRegisterDestructibleEvent except applies to all destructables on the map, even ones yet to be created.
//===========================================================================
// TRACKABLE
//===========================================================================
function SetTrackablePos takes trackable t, real x, real y returns nothing
//Moves a trackable to the specified map realative coordinate.
function SetTrackableZ takes trackable t, real z returns nothing
//Sets the map realative z coordinate of the trackable. This disables automatic Z positioning.
function SetTrackableZOffset takes trackable t, real zOffset returns nothing
//Sets the Z offset of a trackable. This is realitive to the Z it is automatically positioned at. This enables automatic Z positioning.
function GetTrackableX takes trackable t returns real
//Returns the map relative x coordinate of the trackable.
function GetTrackableY takes trackable t returns real
//Returns the map relative y coordinate of the trackable.
function GetTrackableZ takes trackable t returns real
//Returns the map relative z coordinate of the trackable if in map relative z mode. Returns the z offset if in automatic z mode.
function DestroyTrackable takes trackable t returns nothing
//Trackables currently cannot be destroyed through triggers, so this native is needed for them to be useful.
//===========================================================================
// UNIT
//===========================================================================
constant unitstate UNIT_STATE_LIFE_REGEN //Unit current life regeneration. Compatible with GetUnitState and SetUnitState.
constant unitstate UNIT_STATE_MANA_REGEN //Unit current mana regeneration. Compatible with GetUnitState and SetUnitState.
constant armortype ARMOR_TYPE_SMALL //Used by natives below.
constant armortype ARMOR_TYPE_MEDIUM //Used by natives below.
constant armortype ARMOR_TYPE_LARGE //Used by natives below.
constant armortype ARMOR_TYPE_FORTIFIED //Used by natives below.
constant armortype ARMOR_TYPE_NORMAL //Used by natives below.
constant armortype ARMOR_TYPE_HERO //Used by natives below.
constant armortype ARMOR_TYPE_DIVINE //Used by natives below.
constant armortype ARMOR_TYPE_UNARMORED //Used by natives below.
constant armortype ARMOR_TYPE_UNKNOWN //Invalid armor type. Has been observed randomly in game, likely as the result of a non fatal memory corruption error to the armor type field.
constant herostat HERO_STAT_STR //Used by natives below.
constant herostat HERO_STAT_AGI //Used by natives below.
constant herostat HERO_STAT_INT //Used by natives below.
constant movementtype MOVEMENT_TYPE_NONE //Used by natives below.
constant movementtype MOVEMENT_TYPE_FOOT //Used by natives below.
constant movementtype MOVEMENT_TYPE_HORSE //Used by natives below.
constant movementtype MOVEMENT_TYPE_FLY //Used by natives below.
constant movementtype MOVEMENT_TYPE_HOVER //Used by natives below.
constant movementtype MOVEMENT_TYPE_FLOAT //Used by natives below.
constant movementtype MOVEMENT_TYPE_AMPHIBIOUS //Used by natives below.
// > UNIT LEVEL
function SetUnitLevel takes unit u, integer newLevel returns nothing
//Set the unit level of a non hero unit to the specified level. Does nothing to heroes.
// > UNIT ABILITIES
function SetUnitAbilityCooldownRemaining takes unit u, integer abilityId, real remaining returns nothing
function IsUnitAbilityOnCooldown takes unit u, integer abilityId returns boolean
//Returns true if an ability is on cooldown for a unit.
// > UNIT VISUALS
function GetUnitIconPath takes unit u returns string
//Returns the command card icon path of a unit.
function GetUnitTypeIconPath takes integer unitId returns string
//Returns the command card icon path of a unit type.
function SetUnitIconPath takes unit u, string path returns nothing
//Changes the command card icon path of a unit.
function GetUnitModelPath takes unit u returns string
//Returns the model path of a unit.
function GetUnitTypeModelPath takes integer unitId returns string
//Returns the model path of a unit type.
function SetUnitModelPath takes unit u, string path returns nothing
//Changes the model path of a unit.
function ShowUnitLocalPlayer takes unit whichUnit, player pUnit, boolean show returns nothing
//Native Show Unit with GetLocalPlayer() work to hide a unit for a single player.
function SetUnitSelectionCircle takes unit u, image circle returns nothing
//Sets a selection circle image for a unit
function ResetUnitSelectionCircle takes unit u returns nothing
//Returns the original selection circle of the unit
function GetUnitShadow takes unit whichUnit returns image
// or at least this: function ShowUnitShadow takes unit whichUnit, boolean flag returns nothing
// > UNIT MOVEMENT
function SetUnitMovementType takes unit u, movementtype movementType returns nothing
//Changes the movement type of a unit to the specified movement type.
function GetUnitMovementType takes unit u returns movementtype
//Get the movement type of a unit.
function UnitDisableMovement takes unit u, boolean flag returns nothing
//toggles a unit's movement on or off. Currently feasible with SetUnitPropWindow to zero, but restoring requires radians but GetUnitDefaultPropWindow returns degrees. Not a big issue, but it's hidden information.
function UnitDisableTurning takes unit u, boolean flag returns nothing
//toggles a unit's ability to turn on or off.
function IsUnitMoving takes unit u returns boolean
//Returns true if a unit is trying to move. The unit might not actually be moving if it is waiting for the pathfinder to attend to it.
function IsUnitIdle takes unit u returns boolean
//Returns true if a unit is not moving, is not attacking, is not casting and is not using an item.
function SetUnitMaxSpeed takes unit u, real r returns nothing
function GetUnitMaxSpeed takes unit u, nothing returns real
function SetUnitMinSpeed takes unit u, real r returns nothing
function GetUnitMinSpeed takes unit u, nothing returns real
//Does maximum and minimum unit speed even do anything? If so, the ability to modify those would be welcome.
// > UNIT ATTACK
function SetUnitAttackCooldown takes unit u, real duration returns nothing
//Sets the current attack cooldown time to a different value, potentially overriding/ignoring backswing point. Set to zero to cause the next attack to occur instantly. Can start attack cooldown.
function GetUnitAttackCooldownRemaining takes unit u returns real
//Returns the remaining time in game seconds of the currently occuring attack cooldown. Returns 0.0 if attack is not on cooldown.
function UnitAttackTarget takes unit whichUnit, widget target, real amount, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
//Similar to UnitDamageTarget but does so with the source's attack modifiers like Orb Effects, Critical Strike, Bash, Lifesteal, etc.
function UnitAttackArea takes unit whichUnit, real radius, real x, real y, real amount, attacktype attackType, damagetype damageType, weapontype weaponType, boolexpr filterFunc returns boolean
//Just like UnitAttackTarget(), but this takes a boolexpr argument at the end to filter out unwanted victims. This is helpful in the case of area attacks with chance modifiers like bash.
function GetUnitAttackSpeedBonus takes unit u, returns real
//Returns the current attack speed bonus of a unit. For instance a hero with a glove of haste (+15% attack speed) would return 0.15
function ModifyUnitAttackSpeedBonus takes unit u, real fraction returns nothing
//Applies a bonus to the attack speed of a unit, being treated the same as other attack speed modifiers.
function IsUnitInCombat takes unit u returns boolean
//Returns true if a unit has recently attacked or been attacked. Possibly tied into the forces under attack mechanics?
// > UNIT POSITION
function SetUnitFacingInstant takes unit u, real facingAngle returns nothing
//Similar to SetUnitFacing but with angle change being instant with turn rate and orientation interpolation being ignored. Angle is in degrees.
function SetUnitFacingInstantRad takes unit u, real facingAngle returns nothing
//Same as SetUnitFacingInstant except angle is in radians.
function SetUnitFacingRad takes unit whichUnit, real facingAngle returns nothing
//Same as SetUnitFacing except angle is in radians.
// > UNIT ARMOR
function GetUnitArmorType takes unit u returns armortype
function SetUnitArmorType takes unit u, armortype armorType returns nothing
function GetUnitArmorBonus takes unit u returns real
//Returns the current armor bonus of a unit.
function ModifyUnitArmorBonus takes unit u, real amount returns nothing
//Applies armor modifier to a unit, being treated the same as all other armor modifiers.
// > UNIT COST
function GetUnitGoldCost takes integer unitid returns integer
//AI native copied to normal JASS for convince.
function GetUnitWoodCost takes integer unitid returns integer
//AI native copied to normal JASS for convince.
function SetUnitAbilityManaCost takes unit u, integer abilityId, integer level, integer newcost returns integer
// > UNITS CONTROL
function UnitDisableControl takes unit u boolean flag returns nothing
//toggles whether a unit responds to player commands on or off. Can still respond to trigger commands.
function UnitFullDisable takes unit u, boolean flag returns nothing
//toggles whether a unit responds to ANY commands on or off. Similar to being stunned, but will not 'unstun' until UnitFullDisable is set to false.
function UnitDisableAttack takes unit u, boolean flag returns nothing
//Turns off one of the two attack indices. Currently feasible by adding Cargo Hold ability to the unit, but it disables both indices.
function UnitDisableSelection takes unit u, boolean flag returns nothing
//Same as giving Locust ability to a unit (Aloc), but can be enabled/disabled without any buggy side effects.
function UnitApplyTimer takes unit u, integer buffId, real timeout returns timer
//Applies a non-fatal timer to a unit that shows the time ticking down like with a spell like Avatar or Metamorphosis. When the timer expires, a TimerRegisterExpireEvent fires.
function UnitDisableItems takes unit u, boolean flag, boolean passive returns nothing
//Toggles whether a unit can use items. Item passive effects are optionally able to be turned on or off.
function UnitChangeUnitId takes unit u, integer unitid returns nothing
//Changes the unit type ID of a unit. Results are the same as unit a morph ability except without needing an ability.
function ReviveUnit takes unit u returns nothing
//Revives a dead unit at the position of its corpse. Mechanically the same as the unit being effected by Paladin's Resurrection ability.
// > HEROES
function GetHeroPrimaryStat takes unit u returns herostat
//Returns the integer code for the attribute that is set as primary. Eg if the unit is a Paladin, it returns the id for Strength.
function GetHeroPrimaryStatById takes integer unitid returns herostat
//Same as above but references the object editor value instead of an actual unit.
function SetHeroPrimaryStat takes unit u, herostat stat returns integer
//Allows the game to individual modify which attribute of the hero becomes its primary. Damage modifier from primary hero stat has to be reapplied.
function GetHeroStat takes herostat whichStat, unit whichHero, boolean includeBonuses returns integer
//Mechanically same as the GetHeroStatBJ function except takes the new native herostat constants.
function SetHeroStatEx takes unit whichHero, herostat whichStat, integer value, boolean permanent returns nothing
//Mechanically similar to the SetHeroStat function except takes the new native herostat constants and can set permanence.
// > CONSTRUCTION & TRAINING
function GetUnitBuildTime takes integer unitid returns integer
//AI native ported to standard JASS.
function GetHeroBuildTime takes integer unitid, player whichPlayer returns integer
//Returns the train time in seconds for a player to make the specified hero type. Factors in train time increases with sequential heroes in melee.
function GetHeroReviveTime takes unit whichUnit returns integer
//Returns the revive time in seconds for a player to revive the specified hero if it were dead.
function GetBuilderUnit takes unit building returns unit
//Returns the unit that constructed a building/unit. In the case of buildings this should be the unit that converted the foundation into a unit.
function GetUnitBuildProgress takes unit u returns real
//Returns the fraction (percent / 100) completion of a building/unit in progress. If the unit has no progress (already built) returns 1.0.
function SetUnitBuildProgress takes unit u, real fraction returns nothing
//Modifies the fraction completion of a building/unit in progress. A fraction of 1.0 causes the unit to be instantly completed. Does nothing to a unit that is complete.
function GetUnitTrainProgress takes unit factory returns real
//Returns the fraction completion of a unit that is being trained. Returns 1.0 if no unit is being trained.
function SetUnitTrainProgress takes unit factory, real fraction returns nothing
//Modifies the fraction completion of a unit that is currently being trained. A fraction of 1.0 causes the unit to be instantly trained. Does nothing to a factory that is not training anything.
function GetTrainingQueueSize takes unit factory returns integer
//Returns the number of queued training orders.
function GetMaxTrainingQueueSize takes unit factory returns integer
//Returns the maximum number of queued training orders a factory allows.
function CancelTraining takes unit factory, integer slot returns boolean
//Cancels a train order from the training queue of a building determined by slot number (eg 0 - 6). Returns true if a unit was actually canceled.
function ClearTrainingQueue takes unit factory returns boolean
//Equivelant to calling CancelTraining on all occupied training slots of a building. Returns true if at least 1 training order was canceled.
// > UNIT MARKET
function SetItemStock takes unit u, integer itemId, integer stock returns nothing
//Set the stock of an item id in a shop to the specified number. Maximum stock count is respected and if full cooldown progress will be lost.
function SetItemStockMax takes unit u, integer itemId, integer stock returns nothing
//Set the maximum stock permitted of an item id in a shop to the specified number. Maximum stock count is respected and if below current stock cooldown and stock items will be lost.
function GetItemStock takes unit u, integer itemId returns integer
//Get the stock available of an item id in a shop.
function GetItemStockMax takes unit u, integer itemId returns integer
//Get the maximum stock permitted of an item id in a shop.
// > UNIT TECH
function UnitDisableTechBoni takes unit u, boolean flag returns nothing
//Allows/Disallows a unit benefiting from techs researched.
// > OTHER UNIT NATIVES
function SetUnitVisionType takes unit u, boolean flying returns nothing
//Changes the vision mechanics of a unit to either be ground (can be occluded by terrain) or flying (absolute).
function GroupEnumCorpsesInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing
//Convenience function to enum all corpses in range of a position.
function GroupEnumCorpsesInRangeloc takes group g, location whichLocation, real radius, boolexpr filter returns nothing
//Same as above but with location parameter.
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
native SetHeroName takes unit u, string name returns nothing
native DeleteHeroAbility takes unit whichUnit, integer abilCode returns nothing
native GetUnitMaxHP takes unit whichUnit returns integer
native SetUnitMaxHP takes unit whichUnit, integer hp returns nothing
native GetUnitMaxMana takes unit whichUnit returns integer
native SetUnitMaxMana takes unit whichUnit, integer mana returns nothing
native SetUnitName takes unit whichUnit, string name returns nothing
native SetUnitNameAll takes unit whichUnit, string name returns nothing
native GetUnitBaseDamage takes unit whichUnit, integer weaponIndex returns integer
native SetUnitBaseDamage takes unit whichUnit, integer baseDamage, integer weaponIndex returns nothing
native GetUnitDiceNumber takes unit whichUnit, integer weaponIndex returns integer
native SetUnitDiceNumber takes unit whichUnit, integer diceNumber, integer weaponIndex returns nothing
native GetUnitDiceSides takes unit whichUnit, integer weaponIndex returns integer
native SetUnitDiceSides takes unit whichUnit, integer diceSides, integer weaponIndex returns nothing
native GetUnitAttackCooldown takes unit whichUnit, integer weaponIndex returns real
native SetUnitAttackCooldown takes unit whichUnit, real cooldown, integer weaponIndex returns nothing
native GetUnitArmor takes unit whichUnit returns real
native SetUnitArmor takes unit whichUnit, real armorAmount returns nothing
native UnitHideAbility takes unit whichUnit, integer abilId, boolean flag returns nothing
native UnitDisableAbility takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing
native UnitCancelTimedLife takes unit whichUnit returns nothing
native IsUnitSelectable takes unit whichUnit returns boolean
native IsUnitInvulnerable takes unit whichUnit returns boolean
native UnitInterruptAttack takes unit whichUnit returns nothing
native GetUnitCollisionSize takes unit whichUnit returns real
native SetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level, real cooldown returns nothing
native GetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level returns real
native GetUnitAbilityCooldownRemaining takes unit whichUnit, integer abilId returns real
native EndUnitAbilityCooldown takes unit whichUnit, integer abilCode returns nothing
native GetUnitAbilityManaCost takes unit whichUnit, integer abilId, integer level returns integer
native GetLocalUnitZ takes unit whichUnit returns real
*/
//===========================================================================
// ABILITIES
//===========================================================================
constant playerevent EVENT_PLAYER_ABILITY_PRESSED
/*The event triggers when a player presses an ability button and begins targeting.
Requires netsync from the player so is not instant.
Most spell event natives like trigger unit and spell ability id work in response to this event.*/
function GetTriggerPlayerAbilityPressed takes player returns integer
function SetAbilityManaCost takes integer abilityId, integer level, integer newcost returns integer
function SetAbilityCooldown takes integer abilityId, integer level, integer newcool returns integer
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
native GetAbilityManaCost takes integer abilId, integer level returns integer
native GetAbilityCooldown takes integer abilId, integer level returns real
native SetAbilityTooltip takes integer abilCode, string tooltip, integer level returns nothing
native SetAbilityOnTooltip takes integer abilCode, string tooltip, integer level returns nothing
native SetAbilityExtendedTooltip takes integer abilCode, string ExtendedTooltip, integer level returns nothing
native SetAbilityOnExtendedTooltip takes integer abilCode, string ExtendedTooltip, integer level returns nothing
native SetAbilityResearchTooltip takes integer abilCode, string researchTooltip, integer level returns nothing
native SetAbilityResearchExtendedTooltip takes integer abilCode, string researchExtendedTooltip, integer level returns nothing
native GetAbilityTooltip takes integer abilCode, integer level returns string
native GetAbilityOnTooltip takes integer abilCode, integer level returns string
native GetAbilityExtendedTooltip takes integer abilCode, integer level returns string
native GetAbilityOnExtendedTooltip takes integer abilCode, integer level returns string
native GetAbilityResearchTooltip takes integer abilCode, integer level returns string
native GetAbilityResearchExtendedTooltip takes integer abilCode, integer level returns string
native SetAbilityIcon takes integer abilCode, string iconPath, integer level returns nothing
native GetAbilityIcon takes integer abilCode, integer level returns string
native SetAbilityOnIcon takes integer abilCode, string iconPath returns nothing
native GetAbilityOnIcon takes integer abilCode returns string
native GetAbilityPosX takes integer abilCode returns integer
native GetAbilityPosY takes integer abilCode returns integer
native SetAbilityPosX takes integer abilCode, integer x returns nothing
native SetAbilityPosY takes integer abilCode, integer y returns nothing
native GetAbilityOnPosX takes integer abilCode returns integer
native GetAbilityOnPosY takes integer abilCode returns integer
native SetAbilityOnPosX takes integer abilCode, integer x returns nothing
native SetAbilityOnPosY takes integer abilCode, integer y returns nothing
*/
//===========================================================================
// BUFF
//===========================================================================
unitevent EVENT_UNIT_BUFF_APPLIED
unitevent EVENT_UNIT_BUFF_EXPIRED
//Triggers when the buff expires or gets removed
function UnitApplyBuff takes unit u, integer rawcode, integer level returns nothing
//Applies specified buff and pauses dissipation timer. SetUnitBuffTimeout can be called later on to remove the paused state and to set the timeout
function UnitRemoveBuff takes unit u, integer rawcode returns nothing
function GetEventBuffApplied takes nothing returns integer
function GetEventBuffExpired takes nothing returns integer
//Returns buff rawcode
function SetUnitBuffTimeout takes unit u, integer rawcode, real timeout returns nothing /
//Starts dissipation timer
function SetUnitBuffPermanent takes unit u, integer rawcode, boolean flag returns nothing
//Pauses dissipation timer
function SetUnitBuffPositive takes unit u, integer rawcode, boolean flag returns nothing
// By default this parameter inherits buff type settings
function SetUnitBuffLevel takes unit u, integer rawcode, integer level returns nothing
function SetUnitBuffTip takes unit u, integer rawcode, string tip returns nothing
function SetUnitBuffUbertip takes unit u, integer rawcode, string tip returns nothing
function SetUnitBuffArt takes unit u, integer rawcode, string path returns nothing
function IsUnitBuffPermanent takes unit u, integer rawcode returns boolean
function IsUnitBuffPositive takes unit u, integer rawcode returns boolean
function GetTriggerBuff takes nothing returns integer
//Actually this can be achieved with current methods, but one must use GetUnitAbilityLevel(buffRawcode) function which is not intuitive.
function GetUnitBuffTimeout takes unit u, integer rawcode returns real
function GetUnitBuffElapsed takes unit u, integer rawcode returns real
function GetUnitBuffRemaining takes unit u, integer rawcode returns real
function GetUnitBuffLevel takes unit u, integer rawcode returns integer
function GetUnitBuffTip takes unit u, integer rawcode returns string
function GetUnitBuffUbertip takes unit u, integer rawcode returns string
function GetUnitBuffArt takes unit u, integer rawcode returns string
//===========================================================================
// ITEMS
//===========================================================================
function GetItemAbilityCooldownRemaining takes item whichItem returns real
//Returns the remaining cooldown time on a used item.
function GetItemAbilityCooldownTimeoutById takes integer itemId returns real
//Returns the default timeout cooldown of an item type.
function SetItemAbilityCooldown takes item whichItem, real timeout, real remaining returns real
//Sets the remaining cooldown time of an item to a specific value. Timeout will clamp remaining for logical reasons and might be ignored for unowned items. Set timeout or remaining to zero to instantly complete cooldown.
function EnableItem takes item whichItem, boolean flag returns nothing
//Enables/Disables an item. Items that are disabled provide no modifiers and cannot be used.
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
native SetItemName takes item whichItem, string name returns nothing
native SetItemDescription takes item whichItem, string name returns nothing
native GetItemDescription takes item whichItem returns string
native SetItemTooltip takes item whichItem, string name returns nothing
native GetItemTooltip takes item whichItem returns string
native SetItemExtendedTooltip takes item whichItem, string name returns nothing
native GetItemExtendedTooltip takes item whichItem returns string
native SetItemIconPath takes item whichItem, string name returns nothing
native GetItemIconPath takes item whichItem returns string
*/
//===========================================================================
// UI
//===========================================================================
constant minimapevent PING //Trigger on a minimap ping
constant minimapevent MINIMAP_BUTTON_PRESSED //Triggers when one of the associated minimap buttons have been pressed.
function ShowUI takes boolean flag returns nothing
//True/false arguments would show/hide the UI. That includes disabling the black borders at the top and bottom of the screen.
// > HP / MANA UI
function ShowManaBar takes boolean flag returns nothing
//Turns mana bar display over units on or off. Whether they display depends on the player's Gameplay options but this can overwrite that for a session.
function SetPlayerHPBarColor takes player p, real red, real green, real blue returns nothing
//Changes the health bar color of units belonging to a particular player.
function SetPlayerMPBarColor takes player p, real red, real green, real blue returns nothing
//Changes the mana bar color of units belonging to a particular player.
function SetPlayerHPTextColor takes player p, real red, real green, real blue returns nothing
//Changes the health text color under units portrait belonging to a particular player.
function SetPlayerMPTextColor takes player p, real red, real green, real blue returns nothing
//Changes the mana text color under units portrait belonging to a particular player.
// > BAR
function CreateBar takes real red, real green, real blue, real alpha returns bar
//'New' object type. Creates a bar (like the health bars above units) and colours them according to the values used. Eg recreating Protoss shields.
function AttachBarTarget takes bar whichBar, widget target, real z returns nothing
//Attaches a bar to a unit, destructable, item etc with the option to move it up and down the z axis.
function GetBarX takes bar whichBar returns real
//Returns the x coordinate of a bar.
function GetBarY takes bar whichBar returns real
//Returns the y coordinate of a bar.
function GetBarZ takes bar whichBar returns real
//Returns the z coordinate of a bar.
function SetBarPos takes bar, real x, real y, real heightOffset returns nothing
//Manually repoisitions a bar to map relative coordinates like floating texts.
// > SCREEN
function DisplayScreenMessage takes string s, real x, real y, real timeout returns nothing
//This displays a text message for a period but with respect to normalised X / Y value of the screen. Can overlap other text messages. An invalid timeout will automatically compute a timeout based on message length.
function GetLocalDisplayResolutionHorizontal takes nothing returns real
//Returns the horizontal resolution in pixels being used to display Warcraft III for the local client. Not net safe.
function GetLocalDisplayResolutionVertical takes nothing returns real
//Returns the vertical resolution in pixels being used to display Warcraft III for the local client. Not net safe.
// > MINIMAP
function GetPingX takes ping whichPing returns real
//returns the corresponding map relative x coordinate of a ping.
function GetPingY takes ping whichPing returns real
//returns the corresponding map relative y coordinate of a ping.
function TriggerRegisterPlayerPingEvent takes trigger whichTrigger, player whichPlayer returns event
//New event that fires the trigger when the specified player sends a ping. Both GetTriggerPlayer and GetTriggerPing are valid with this event.
function GetTriggerPing takes nothing returns ping
//In response to a player ping event returns the ping object that triggered the event.
//===========================================================================
// CUSTOM UI
//===========================================================================
/*
Someone suggested the ability to customize the UI similar to StarCraft II where one can place custom UI elements anywhere on a clients screen.
They did not suggest an API to do this however.
Due to the complexity of such an API I would suggest looking at StarCraft II's implementation which allows the UI to be heavilly customized.
*/
//===========================================================================
// MULTIBOARD
//===========================================================================
function SetMultiboardScreenPositionXY takes multiboard mb, real x, real y returns nothing
//This changes the position of a multiboard with respect to normalised X / Y value of the screen
//===========================================================================
// LEADERBOARD
//===========================================================================
function SetLeaderboardScreenPositionXY takes leaderboard lb, real x, real y returns nothing
//This changes the position of a leaderboard with respect to normalised X / Y value of the screen
//===========================================================================
// TEXTTAG
//===========================================================================
constant textagalignment TEXTTAG_CENTER
constant textagalignment TEXTTAG_RIGHT
constant textagalignment TEXTTAG_LEFT
function SetTexTagAlignment takes texttag tt, textagalignment alignment returns nothing
// left—the text is aligned along the left margin (default);
// right—the text is aligned along the right margin;
// centered—text is aligned to neither the left nor right margin; there is an even gap on each side of each line.
//===========================================================================
// DIALOG
//===========================================================================
function IsPlayerInDialog takes player p returns boolean
//Returns true if the player currently has any dialog box visible to them. Might require net sync.
//===========================================================================
// HARDWARE INPUT
//===========================================================================
constant mouseevent MOUSE_WHEEL_ANY //Triggers when the mouse wheel scrolls up or down
constant mouseevent MOUSE_WHEEL_UP //Triggers when the mouse wheel scrolls up
constant mouseevent MOUSE_WHEEL_DOWN //Triggers when the mouse wheel scrolls down
// > MOUSE
function GetLocalCursorTargetX takes nothing returns real
//Returns the map relative x coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function GetLocalCursorTargetY takes nothing returns real
//Returns the map relative y coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function GetLocalCursorTargetZ takes nothing returns real
//Returns the map relative z coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe.
function SetLocalCursorX takes real x returns nothing
//Set the local client cursor position to the specified screen space normalised x coordinate.
function SetLocalCursorY takes real y returns nothing
//Set the local client cursor position to the specified screen space normalised y coordinate.
function IsLocalCursorOverUI takes nothing returns boolean
//Returns true if the cursor is currently not targeting the map. Not net safe.
function IsLocalMouseButtonPressed takes mousebutton mouseButton returns boolean
//Returns true or false depending on which mouse button is being held down. Will be useful for click-and-drag functions. Not net safe.
function GetTriggerPlayerMouseEvent takes nothing returns mouseevent
//In response to player mouse event returns which mouseevent triggered the trigger.
function GetTriggerPlayerMouseScreenX takes nothing returns real
//In response to player mouse event returns the screen space normalised x coordinate the event occurred at. Is net safe.
function GetTriggerPlayerMouseScreenY takes nothing returns real
//In response to player mouse event returns the screen space normalised y coordinate the event occurred at. Is net safe.
function GetTriggerPlayerMouseY takes nothing returns real
//In response to player mouse event returns the map relative z coordinate the event occurred at. Return value non 0.0 only if the mouse event targeted the map. Is net safe.
// > KEYBOARD
function TriggerRegisterPlayerKeyboardEvent takes trigger whichTrigger, player whichPlayer, keyboardbutton hotkey, boolean state returns event
//Fires when the corresponding key is pressed by the player. The keyboardbutton constants are not mentioned but should cover most common keyboard buttons. If state is true then fires when key is pressed, otherwise fires when key is released. Attaching this event causes keyboard button sync traffic from the player.
function GetTriggerKeyboardButton takes nothing returns keyboardbutton
//In response to player keyboard event returns which button caused the event.
function GetTriggerKeyboardState takes nothing returns boolean
//In response to player keyboard event returns the state that caused the event. True if it was pressed, false if released.
function GetLocalKeyboardButtonState takes keyboardbutton whichButton returns boolean
//Returns true if the local client has the specified keyboard button (eg arrow keys) depressed or false if released. Not net safe.
// > ALREADY ADDED NATIVES IN 1.29 PTR
/*
constant mousebuttontype MOUSE_BUTTON_TYPE_LEFT = ConvertMouseButtonType(1)
constant mousebuttontype MOUSE_BUTTON_TYPE_MIDDLE = ConvertMouseButtonType(2)
constant mousebuttontype MOUSE_BUTTON_TYPE_RIGHT = ConvertMouseButtonType(3)
constant playerevent EVENT_PLAYER_MOUSE_DOWN = ConvertPlayerEvent(269)
constant playerevent EVENT_PLAYER_MOUSE_UP = ConvertPlayerEvent(270)
constant playerevent EVENT_PLAYER_MOUSE_MOVE = ConvertPlayerEvent(271)
native GetTriggerPlayerMouseX takes nothing returns real
native GetTriggerPlayerMouseY takes nothing returns real
native GetTriggerPlayerMousePosition takes nothing returns location
native GetTriggerPlayerMouseButton takes nothing returns mousebuttontype
*/
//===========================================================================
// AI
//===========================================================================
/*
One of the biggest problems with the AI is the very inflexible use of captain widgets.
Currently, captain widgets are a "middleman" in charge of orders given to the computer player.
The AI player moves, or teleports, the captain widget to a target location and the units assigned to the captain follow.
There are two captains: attack and defense, each with it's own problems.
The units assigned to the defense captain will stay still even when given an order to change location, until one of three cases:
aggroed,
player town under attack,
another unit is added to the defense captain.
But the bigger problem is with the attack captain: once a unit has been added to the attack captain, it cannot be removed manually.
If it is injured, and the attack group requires units with a higher health percentage, then the unit will be removed, but it cannot be done manually.
I have two ideas for solutions in mind, both in a way that should not break backwards compatibility and enhance the AI greatly:
1. Add an */Empty attack group /* native.
A simple native that will allow one to manually remove all units from the attack group.
That alone will not change existing scripts and will remove a lot of limitations.
2. Allow multiple captains. This one is a bit more radical change, but it will make the AI far better and more flexible.
The thing with captains is that you can only have one of each, but that is not to say that you can't create more.
In fact, you can use the */native CreateCaptains /* as many times as you want, and it will create new captains.
Also, it doesn't remove the old captains, as units assigned to them cannot be added to the new captains, and will continue following the old captain to the last target it received.
The problem here, is that referencing the captains is done by constant integers set in the common.ai file:
*/
constant integer ATTACK_CAPTAIN = 1
constant integer DEFENSE_CAPTAIN = 2
constant integer BOTH_CAPTAINS = 3
/*
Once you create new captains, these variables will reference the new captains instead of the old ones.
If you could allow users to reference older captains (for example allocating another 3 numbers for older captains for every time CreateCaptains is called), AI will be much more usable.
*/
//===========================================================================
// MISSILE
//===========================================================================
type missile extends agent //New variable type - missile
type missileevent extends eventid //New event type for missiles
constant unitevent EVENT_UNIT_MISSILE //Event of missile hitting a unit
constant missileevent EVENT_MISSILE_IMPACT //Even of missile reaching a point
function CreateMissileOnUnitToUnit takes unit target, unit source, real height, real speed, real arcangle, real scale, string modelpath returns missile //Creates a missile that moves from one point to another. Upon impact triggers EVENT_UNIT_MISSILE.
function CreateMissileOnPointToUnit takes unit source, unit target, real x, real y, real height, real speed, real arcangle, real scale, string modelpath returns missile //Like one above but from point to unit
function CreateMissileOnPointToPoint takes unit source, real x1, real y1, real x2, real y2, real height, real speed, real arcangle, real scale, string modelpath returns missile //Like ones above but from point to point. Upon impact triggers EVENT_MISSILE_IMPACT.
function SetMissileX takes missile m, real x returns nothing //Sets X coordinate of missile
function SetMissileY takes missile m, real y returns nothing //Sets Y coordinate of missile
function SetMissileHeight takes missile m, real height returns nothing //Sets height of missile
function SetMissileTargetPoint takes missile m, real x, real y returns nothing //Sets the target that missile will move at
function SetMissileTargetUnit takes missile m, unit u returns nothing //Missile will move to targeted unit
function SetMissileSourceUnit takes missile m, unit u returns nothing //Detects a unit that spawned missile
function SetMissileSpeed takes missile m, real speed returns nothing //Sets missile speed
function SetMissileScale takes missile m, real scale returns nothing //Sets missile size
function SetMissileArcAngle takes missile m, real angle returns nothing //Sets missile arcangle
function SetMissileModel takes missile m, string path returns nothing //Sets missile model
function GetEventMissile takes nothing returns missile //Returns a missile that reached its target
function GetMissileX takes missile m returns real //Returns current X of a missile
function GetMissileY takes missile m returns real //Returns current Y of a missile
function GetMissileHeight takes missile m returns real //Returns current height of a missile
function GetMissileSpeed takes missile m returns real //Returns current speed of a missile
function GetMissileScale takes missile m returns real //Returns current size of a missile
function GetMissileArcAngle takes missile m returns real //Returns current arcangle of a missile
function RemoveMissile takes missile m, boolean animation returns nothing //Deletes a missile. Flag animation depends if it will play death animation or not
//===========================================================================
// OBJECT EDITOR API
//===========================================================================
/*
Read only object editor API. Similar to StarCraft II catalog natives, hence the naming.
The field string would be the attribute key in the object editor, ie "regenHP" for the unit's base health regeneration.
Passing an invalid key (or one that would return an incorrect data type for the function) would return some sensible default (0, 0.0, null, etc).
*/
constant catalog CATALOG_UNIT //Used by natives below.
constant catalog CATALOG_ITEM //Used by natives below.
constant catalog CATALOG_ABILITY //Used by natives below.
constant catalog CATALOG_BUFF //Used by natives below.
constant catalog CATALOG_UPGRADE //Used by natives below.
constant catalog CATALOG_DOODAD //Used by natives below.
constant catalog CATALOG_DESTRUCTABLE //Used by natives below.
function GetUnitTypeAttributeInteger takes catalog whichCatalog, integer typeId, string field returns integer
function GetUnitTypeAttributeReal takes catalog whichCatalog, integer typeId, string field returns real
function GetUnitTypeAttributeString takes catalog whichCatalog, integer typeId, string field returns string
//===========================================================================
// BENCHMARKING
//===========================================================================
/*
Whoever suggested these did not explain their purpose or what they are meant to do.
I am guessing they are meant to be client local performance counters for measuring performance of various scripts.
If this is the case then all calls made to these during multiplayer these should return default safe values that do nothing.
*/
function CreateStopWatch takes nothing returns stopwatch
//Create a performance counter stop watch.
function StopWatchStart takes stopwatch returns nothing
//Start the stop watch, causing it to record time progression. If it has been paused, resumes recording.
function GetStopWatchTime takes stopwatch returns real
//Pause the stop watch and get the current elapsed stop watch time, which is the sum of all time it has been left running.
function StopWatchEnd takes stopwatch returns nothing
//Destroy the stop watch freeing all resources it used.
function StopWatchPause takes stopwatch returns nothing
//Pause the stop watch causing it to stop recording time progression. If trying to accuratly measure execution time of a piece of script this should be called between game frames to prevent the stop watch measuring the game loop time.
//===========================================================================
// DEBUG
//===========================================================================
function DisplayErrorMsg takes string s, real duration returns nothing
//Display the given error message string in the error message area. The message is also written out to an error log file.
function GetOPLimit takes nothing returns integer
//Get the current remaining JASS thread operation limit. Due to how the JASS virtual machine works the returned value may be larger than the actual limit by the time it can be processed.
function SetOPLimit takes integer newlimit returns nothing
//Changes the current JASS thread operation limit to the specified value. Due to how the JASS virtual machine works the actual limit may be slightly smaller than the specified amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
function ResetOPLimit takes nothing returns nothing
//Resets the current JASS thread operation limit to the default operation limit of that thread, as if it was freshly created. Due to how the JASS virtual machine works the actual limit may be smaller than the default amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit.
type func extends code
//Function type to be used with debugging natives. Possibly has special syntax requirements to prevent code exploit.
function TriggerRegisterJassOpLimitEvent takes trigger whichTrigger returns event
//Event fires in response to a JASS virtual machine thread crash as a result of the thread reaching its operation limit. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassDivideByZeroEvent takes trigger whichTrigger returns event
//Event fires in response to a JASS virtual machine thread crash as a result of attempted division by 0. Useful for detecting when a thread crash occurs.
function TriggerRegisterJassNoBlockEvent takes trigger whichTrigger returns event
//Event fires in response to a JASS virtual machine thread crash as a result of attempting to block when blocking is not allowed (eg TriggerSleepAction in a condition function). Useful for detecting when a thread crash occurs.
function GetTriggerFunction takes nothing returns func
//In response to all JASS thread crash events returns the function the crash occured at.
function GetEventJassError takes nothing returns string
//In response to all JASS thread crash events returns a human readable string with as much information about the crash as possible. Intended to be printed out or logged to help map makers track down where/why a thread crash occured.
function GetHandleIdCount takes nothing returns integer
//Returns the number of currently allocated handle ids. If this number is observed increasing as a game progresses there is likely an object leak of sorts.
function GetHandleIdFreeCount takes nothing returns integer
//Returns the number of handle ids on the free handle id stack. If this number is very large then either the map has suffered from object count reduction over time or there was a step that required a large number of objects be created and destroyed.
//===========================================================================
// BINARY DATA
//===========================================================================
// Each function is annotated with it's C++ equivalent
function BitwiseNot takes integer a returns integer
// ~a
function BitwiseAnd takes integer a, integer b returns integer
// a & b
function BitwiseOr takes integer a, integer b returns integer
// a | b
function BitwiseXor takes integer a, integer b returns integer
// a ^ b
function BitwiseShl takes integer a, integer b returns integer
// a << b
function BitwiseShr takes integer a, integer b returns integer
// a >> b
function Char2Byte takes string a returns integer
// Returns the byte value of the first character in the string, or -1 if string is empty
// Return value is guaranteed to be in the bound of [0, 256)
function Byte2Char takes integer a returns string
// Converts the byte into a single character corresponding to that character's value
// The argument should be in the bound of [0, 256), if it is not, the returned string should be null
//===========================================================================
// FILE I/O
//===========================================================================
constant integer FILEMODE_READ = 1
constant integer FILEMODE_WRITE = 2
constant integer FILEMODE_READWRITE = 3
type file extends handle
type directory extends handle
function FileExists takes string path returns boolean
function DirectoryExists takes string path returns boolean
function GetDirectory takes string path returns directory
// Returns an iterator to a directory's contents
// Returns null if path doesn't exist or isn't a directory
function ForDirectory takes directory dir, code callback returns nothing
function GetEnumPath takes nothing returns string
// Callback-style iteration
function PopDirectoryPath takes directory dir returns string
// Pops a single path from this directory object, allowing us to iterate it using a while loop
function OpenFile takes string path, integer mode returns file
// Opens a new file, creating it if necessary
// There should probably be a restriction on which extensions are allowed
// Good candidates are probably ".txt" and ".dat"
function OpenFile takes string path, integer mode, player owner returns file
// Opens a new file only for a certain player
// This is necessary to allow reading/writing locally, because creating a handle locally would desync, so
// we need to create it in shared code
// Reading/Writing for other players on this handle will have no effect, unless SyncFile has been called,
// then reading operations should become available
function SyncFile takes file f, player sender returns nothing
// (I'm not sure if this should be added or not) Tries to send the contents of an entire file from one players to the rest
// Calling this in a local block will read the whole file and start sending it to other players, allowing us to read the file
// synchronously in shared code without issues
function SyncFileWait takes file f returns nothing
// If this can be implemented, it'd be really neat
// Pauses the current thread until the file has finished syncing
function TriggerRegisterFileSync takes trigger t returns nothing
function GetSyncedFile takes nothing returns file
// Async events for syncing to signal when it's finished
function CloseFile takes file f returns nothing
// Flushes the changes and closes the file
function GetFileSize takes file f returns integer
function SetFileSeekPos takes file f, integer pos returns nothing
function GetFileSeekPos takes file f returns integer
function IsFileEOF takes file f returns boolean
// Checks whether the file has hit EOF
function FileReadString takes file f, integer max returns string
// Reads the contents of the file into a string, up to specified amount of characters
function FileWriteString takes file f, string s returns nothing
// Writes the contents of the string into the file as-is, without null-terminators
function FileWriteUInt8 takes file f, integer a returns nothing
function FileWriteUInt16 takes file f, integer a returns nothing
function FileWriteUInt32 takes file f, integer a returns nothing
function FileWriteInt8 takes file f, integer a returns nothing
function FileWriteInt16 takes file f, integer a returns nothing
function FileWriteInt32 takes file f, integer a returns nothing
// Natives for reading and writing bytes directly, rather than using a string
// Since WC3 runs only on little-endian platforms, these too should probably be little-endian
function FileReadUInt8 takes file f returns integer
function FileReadUInt16 takes file f returns integer
function FileReadUInt32 takes file f returns integer
function FileReadInt8 takes file f returns integer
function FileReadInt16 takes file f returns integer
function FileReadInt32 takes file f returns integer
// Natives for reading bytes directly
function FileWriteReal takes file f, real a returns nothing
function FileReadReal takes file f returns real
// Writing/Reading reals
//===========================================================================
// SYNCH
//===========================================================================
// > METHOD 1
function SyncHashtableParent takes hashtable ht returns nothing
// When called locally, will start syncing the contents of this hashtable to other players
function SyncHashtableChild takes hashtable ht, integer parentKey returns nothing
// Same as SyncHashtable, but only for a child hashtable
function SyncHashtableWait takes hashtable ht returns nothing
// Pauses the thread until the specified hashtable has finished syncing
function TriggerRegisterHashtableSync takes trigger t returns nothing
function GetSyncedHashtable takes nothing returns hashtable
// Events for hashtable syncs
// > METHOD 2
type bytes extends handle
function CreateBytes takes nothing returns bytes
function DestroyBytes takes bytes b returns nothing
function BytesWriteUInt8 takes bytes b, integer pos, integer a returns nothing
function BytesWriteUInt16 takes bytes b, integer pos, integer a returns nothing
function BytesWriteUInt32 takes bytes b, integer pos, integer a returns nothing
function BytesWriteInt8 takes bytes b, integer pos, integer a returns nothing
function BytesWriteInt16 takes bytes b, integer pos, integer a returns nothing
function BytesWriteInt32 takes bytes b, integer pos, integer a returns nothing
function BytesReadUInt8 takes bytes b, integer pos returns integer
function BytesReadUInt16 takes bytes b, integer pos returns integer
function BytesReadUInt32 takes bytes b, integer pos returns integer
function BytesReadInt8 takes bytes b, integer pos returns integer
function BytesReadInt16 takes bytes b, integer pos returns integer
function BytesReadInt32 takes bytes b, integer pos returns integer
function BytesWriteReal takes bytes b, integer pos, real r returns nothing
function BytesReadReal takes bytes b, integer pos returns nothing
function BytesWriteString takes bytes b, integer pos, string s returns nothing
function BytesReadString takes bytes b, integer pos, integer amount returns string
function GetBytesSize takes bytes b returns integer
// Get the amount of data in this buffer
function ReserveBytesCapacity takes bytes b, integer capacity returns nothing
// Reserve capacity for this buffer
function GetBytesCapacity takes bytes b returns bytes
// Get capacity for this buffer
function SyncBytes takes bytes b returns nothing
// Tries to sync the local contents of this bytes object to other players
function SyncBytesWait takes bytes b returns nothing
// Pauses the current thread until syncing has finished
function TriggerRegisterBytesSync takes trigger t returns nothing
function GetSyncedBytes takes nothing returns bytes
// Events
//===========================================================================
// STREAMLINING
//===========================================================================
/*
This list of suggested additions is meant as a way to streamline existing processes or change them entirely.
*/
//Proxies
/*
Proxies are essentially units - dummy casters to be exact, that are less performance-heavy. They have no collision, no model (though you may attach something to their "origin"), no
movement type, nothing. They only move through triggers (SetUnitX/Y) and can cast spells regardless of mana cost, tech requirement, cooldown. They can also cast an unlimited amount
of spells without any downtime so potentially only 1 proxy will ever be needed per map, or per player. One key aspect to proxies is that all actions they take is creditted to a source
unit, so this way if a proxy kills a unit using a spell, the game will register the source unit as having earned that kill. Depending on the allegiance of the source will determine
whether a target can be hit with a spell or not (eg: if the source is an ally of the target of the Proxy, the Proxy cannot cast Storm Bolt at the target).
NB: the Proxy type is affected by most of the relevant unit triggers, like SetUnitX/Y and RemoveUnit. It can be added to unit groups, etc.
*/
function CreateAbilityProxy takes unit source, real x, real y, real z returns proxy //This is essentially a dummy of which all the actions it takes will be credited to the source.
function SetProxySource takes proxy dummy, unit source returns nothing //Modifies the source of the proxy.
//ApllySpellEffect
/*
This approach is an attempt to change the way modders apply spells to targets. Rather than using dummy units, what if spells - and their corresponding effect - could be cast directly on
a target unit/point? There are multiple ways in which we thought this could happen, but ultimately it's up to the people with the source code who will know how best to do this.
*/
//Method 1
//The ApplySpellEffect idea will look like spells can be cast at any point, anywhere. However, there's the issue of auras, which means that those natives should probably return something other than a boolean (maybe a spelleffect type?)
function ApplySpellEffect takes player owner, real x, real y, integer abilcode returns nothing //returns false for spells that only affect the caster (eg. Storm Crow Form)
function ApplySpellEffectTarget takes player owner, unit target, integer abilcode returns boolean //returns null if the target is invalid (eg Spell immune, invulnerable, etc)
function ApplySpellEffectPoint takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, integer abilcode returns boolean //returns false on untargertable context (eg Inferno over water, Force of Nature with no trees)
function ApplySpellEffectChanneled takes player owner, real x, real y, real timeout, integer abilcode returns boolean //ends after the timer has expired. The timeout overrides the spell's internal duration.
function ApplySpellEffectTargetChanneled takes player owner, unit target, real timeout, integer abilcode returns boolean
function ApplySpellEffectPointChanneled takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, real timeout, integer abilcode returns boolean
//Method 2
//While the above could work, I suppose it's hardly the most elegant solution to go around. User MindWorX suggested the atomic approach:
local leveldata data = CreateLevelData()
call SetLevelDataDuration(1.00)
call SetLevelDataDataA(RealData(10))
call SetLevelDataDataB(RealData(100))
call ApplyBuff(target, 'Ahea', data)
//Method 3
//Implement structs and have Struct-based triggers to use.
local leveldata data = CreateAbility()
set leveldata.Duration = 1.00
set leveldata.DataA = RealData(10)
//etc...
//===========================================================================
//
//===========================================================================
I see you already incorperated my notes from jass.db. Here is a more recent list from the same query:Here is the list I have made.
Worked a few hours on it, hope it was worth it
JASS://=========================================================================== // NEW FEATURES //=========================================================================== /* LIBRARIES & SCOPES http://www.wc3c.net/vexorian/jasshelpermanual.html#lib GLOBALS BLOCK The ability to declare global variable directly in code. This tremendously facilitates installation of new system without the need for a separate 'variable creator' trigger. http://www.wc3c.net/vexorian/jasshelpermanual.html#gdf STRUCTS http://www.wc3c.net/vexorian/jasshelpermanual.html#stru 2D ARRAYS http://www.wc3c.net/vexorian/jasshelpermanual.html#twodarray CODE ARRAY The abillity to declare code array. ARRAY AS AN ARGUMENT The ability to use arrays as an argument and the ability to return an array. LOCAL DECLARATION The ability to declare locals anywhere - not just at the top of the function. MULTIPLE MULTIBOARDS / LEADERBOARDS The abilty to have multiple multiboards or leaderboards on screen at the same time. UNICODE SUPPORT */ //=========================================================================== // NON DIRECTLY CODE BASE NEW FEATURES //=========================================================================== /* HIDE TEXT TAGS OF NATIVE ABILITIES The ability to hide (or modify) textags from some native abilities (Evade, Shadow Strike, Critical Strike and Mana Burn) with a flag in Object Editor. CUSTOM ATTACK/ARMOR TYPES The ability to add custom attack or armor types. */ //=========================================================================== // INCREASE LIMITS //=========================================================================== /* TextTags - Currently 100 per local player Regions - Increase constant integer bj_MAX_DEST_IN_REGION_EVENTS = 64 Sound - Max 4x playing a sound filepath at a time. - Max 16 sounds in general at a time. - There's a limit before a sound filepath can be played again (seems depend on client), around 0.1 seconds. String - The amount of text that you can put in a tooltip. */ //=========================================================================== // FIXES //=========================================================================== //Strings should be automatically garbage collected or at least a native should exist that can be periodically called to help free up disused strings. //Local handles declared with the local keyword should automatically cause the reference counter to be decremented at the end of a function just like local handles declared as function arguments. native EnableOcclusion takes boolean flag returns nothing //Occlusion has been a feature present in the first versions of Warcraft 3 but was broken after a patch. //Details explained: https://www.hiveworkshop.com/threads/occlusion-isnt-working-properly.286926/ native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing //The main tooltip of the added unit will always ignore color tags so the text will always appear to be white. Color tags should be parsed the same as all unit tooltips. //The hotkey of the unit isn't working proprely to if it was added using this function. native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing /*With each of call of this function, the minimap is modified in a bugged way : The positions of units and the fog of war are modified to fit to the new camera bound but not the terrain, nor the destructables. The minimap is compressed (vertically) according to the current camera's rotation. With a rotation of 90°, there is no compression. With a rotation of 227.40, the minimap is fully compressed. Between 227.5 and 312.6, the game crashes. Moreover, the camera bounds will also be adjusted according to the rotation of the current camera. The camera bounds created will be a rectangle going trough the 4 points given and whose sides will be parallel to the camera.*/ native DestroyTrigger takes trigger whichTrigger returns nothing /* Destroy all bound triggeraction objects. Currently it only destroys all bound events, triggercondition and the trigger itself leaving all triggeraction objects to leak unless explicitly destroyed before. Also destroy all currently scheduled trigger threads from that trigger. Currently destroying a trigger with scheduled trigger threads can cause handle stack corruption which has a high chance to cause Warcraft III to crash.*/ function SmartCameraPanBJ takes player whichPlayer,location loc,real duration returns nothing //This BJ function is currently not net safe. Details explained: https://www.hiveworkshop.com/threads/fixing-smartcamerapanbj-desync.243334/ constant native GetEventDamage takes nothing returns real //Return the amount of life damage taken through an imperfect mana shield. Currently returns 0 or negative only even if the unit takes life damage through the shield. function GetRandomSubGroupEnum takes integer count, group sourceGroup returns group //Not an even distribution. See http://www.hiveworkshop.com/forums/l-715/g-275344 native PauseTimer takes timer whichTimer returns nothing //Pausing a periodic timer should not cause the timer to lose the periodic status. native CreateQuest takes nothing returns quest //Creating quests during map initialization should not cause a game crash. native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit //Creating units should not cause a permanent memory leak native UnitApplyTimedLife takes unit whichUnit, integer buffId, real duration returns nothing //Only 'BTLF' will be accepted as a buffId, inputing anything else don't work. native DestroyImage takes image whichImage returns nothing //May crash the game if an invalid image is used (null, before the first image is created). native SetImageRenderAlways takes image whichImage, boolean flag returns nothing //Does not work. Use SetImageRenderAlways instead. native PlayMusic takes string musicName returns nothing //This native may cause a short lag spike as soon as the music starts. To circumvent this lag, stop the current music without fadeout before calling this function (`call StopMusic(false)`). native CameraSetupApplyWithZ takes camerasetup whichSetup, real zDestOffset returns nothing //If a player pauses the game after the camerasetup has been applied, the z-offset of the game camera will change to the z-offset of the camerasetup for that player. native SetUnitScale takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing //Only takes scaleX int account and uses scaleX for all three dimensions. native AddHeroXP takes unit whichHero, integer xpToAdd, boolean showEyeCandy returns nothing //Adding negative value to experience will decrease it by the stated value, but won't lower the level even if the experience value after deduction is lower than the lower bound of the experience required to get the stated level. //If the value will become lower than zero, the experience won't be negative, instead of it it'll be equal to 4294967296+(supposed_negative_experience_value) which actually proves that WarCraft III uses unsigned int type for storing experience points. native UnitDamagePoint takes unit whichUnit, real delay, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean //Has been known to cause crashes in battle.net native AddResourceAmount takes unit whichUnit, integer amount returns nothing /*If the value after adding negative amount will be less than zero, then it will display negative resource amount, but if some peasant or peon will try to gather resources from such a mine, he will bring back 0 gold and the mine will be auto-destroyed.*/ constant native UnitId2String takes integer unitId returns string //Always returns null after the game is loaded/if the game is a replay. constant native AbilityId takes string abilityIdString returns integer constant native AbilityId2String takes integer abilityId returns string // Both not working correctly native GroupEnumUnitsOfTypeCounted takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing native GroupEnumUnitsInRectCounted takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing native GroupEnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing native GroupEnumUnitsInRangeOfLocCounted takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing //Causes irregular behavior when used with large numbers native ResetUbersplat takes ubersplat whichSplat returns nothing native FinishUbersplat takes ubersplat whichSplat returns nothing native SetTerrainFog takes real a, real b, real c, real d, real e returns nothing native AddSpellEffect takes string abilityString, effecttype t, real x, real y returns effect native AddSpellEffectLoc takes string abilityString, effecttype t,location where returns effect native GetAbilityEffect takes string abilityString, effecttype t, integer index returns string native GetAbilitySound takes string abilityString, soundtype t returns string //All do nothing. native MultiboardSetRowCount takes multiboard lb, integer count returns nothing /*It is only safe to change the row count by one. Use multiple calls for bigger values. Details explained: http://www.hiveworkshop.com/forums/l-715/m-250775/ http://www.hiveworkshop.com/forums/t-269/w-234897/ */ native GetLocalizedString takes string source returns string //Cannot assign it to a constant variable as it will crash the game. //constant string foo = GetLocalizedString("bar") native SyncStoredString takes gamecache cache, string missionKey, string key returns nothing //Doesn't work native PauseUnit takes unit whichUnit, boolean flag returns nothing /* This forces a unit to have a collision until it's unpaused. Pausing a unit with a disabled collision will re-enable it for this unit. Trying to disable the collision of a paused unit doesn't work. This has been tested with the SetUnitPathing native and abilities that affect collision such as 'Aeth'*/ native GetWidgetLife takes widget w returns real //The real is not exact? Details lacking. native TriggerRegisterUnitStateEvent takes trigger whichTrigger, unit whichUnit, unitstate whichState, limitop opcode, real limitval returns event //EQUAL is broken? Details lacking. //=========================================================================== // CHANGES TO EXISTING NATIVES //=========================================================================== native SetUnitState takes unit whichUnit,unitstate whichUnitState,real newVal returns nothing //Add support for modifying both maximum and regeneration for life and mana. Currently only supports modifying current life. native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing //Change it so that displaying text to a player with unique x and y does not move any other messages. constant gameevent EVENT_GAME_TRACKABLE_HIT = ConvertGameEvent(7) constant gameevent EVENT_GAME_TRACKABLE_TRACK = ConvertGameEvent(8) //Make GetTriggerPlayer() Return the player that triggered the trackable event //=========================================================================== // NEW NATIVES //=========================================================================== //=========================================================================== // GAME //=========================================================================== native EnableCheats takes boolean flag returns nothing //Already exist but not usable (game.dll + 0x1C97E0 on 1.28.5). //=========================================================================== // EVENTS //=========================================================================== // > NEW EVENTS constant unitevent EVENT_UNIT_REMOVED //The event triggers the instant before the unit is removed from the game. Units get removed from the game by a variety of sources such as triggers, decaying or merging. constant unitevent EVENT_UNIT_UNLOADED //Triggers when unit is unloading constant unitevent EVENT_UNIT_IDLES //Similarly to how worker icons appear at the bottom-left corner of the screen when idling, this event detects when ANY unit is idling. constant unitevent EVENT_UNIT_ENTERS_COMBAT //What it says on the tin - this event fires when a unit enters combat. Will be useful for in/out of combat regeneration, for example. constant unitevent EVENT_UNIT_EXITS_COMBAT //What it says on the tin - this event fires when a unit leaves combat. Will be useful for in/out of combat regeneration, for example. constant unitevent EVENT_UNIT_DAMAGE_RELEASE //This triggers when a unit's attack is released, aka when a melee unit hits its target or a ranged unit launches a missile. constant unitevent EVENT_UNIT_MOVES //Fires when a unit moves. constant unitevent EVENT_UNIT_EVADE //The event triggers when a unit evades an attack using an evade ability (Evasion, Drunken Brawler, etc). constant playerunitevent EVENT_PLAYER_UNIT_DAMAGE_RELEASE //Same as EVENT_UNIT_DAMAGE_POINT except as a player unit event. constant playerunitevent EVENT_PLAYER_UNIT_EVADE //Same as EVENT_UNIT_EVADE except as a player unit event. constant playerunitevent EVENT_PLAYER_UNIT_REMOVED //Same as EVENT_UNIT_REMOVED except as a player unit event. // > RESOURCES EVENT EXTENSION constant unitevent EVENT_UNIT_RESOURCE_RETURN //The event triggers when a unit returns a resource such as from gathering. constant unitevent EVENT_UNIT_RESOURCE_HARVEST //The event triggers when a unit harvests a resource. This event means the amount the unit is carrying has changed. constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_RETURN //Same as EVENT_UNIT_RESOURCE_RETURN except as a player unit event. constant playerunitevent EVENT_PLAYER_UNIT_RESOURCE_HARVEST //Same as EVENT_UNIT_RESOURCE_HARVEST except as a player unit event. constant resourcetype RESOURCE_GOLD //Used by natives below. constant resourcetype RESOURCE_LUMBER //Used by natives below. function GetEventResourceType takes nothing returns resourcetype //The resource type the event responded to. For example RESOURCE_LUMBER when a wisp unit gathers lumber. function GetEventResourceAmount takes nothing returns integer //The resource amount the event responded to. For example 10 when a Haunted Gold Mine extracts 10 gold. // > DAMAGE EVENT EXTENSION constant playerunitevent EVENT_PLAYER_UNIT_DAMAGED //Same as EVENT_UNIT_DAMAGED except as a player unit event. function GetEventDamageAttackType takes nothing returns attacktype //In response to a damage event returns the attacktype (Spell, Hero, Chaos, etc) of the damage. function GetEventDamageDamageType takes nothing returns damagetype //In response to a damage event returns the damagetype (unkown, magic, normal, enhanced, etc) of the damage. function GetEventDamageAbilityId takes nothing returns integer //In response to a damage event returns the ability ID that caused the damage. This ability can be a damage spell (Flame Strike, Storm Bolt, etc) or an attack modifier ability (Cold Arrow, orb of fire, etc). Normal attack damage returns some safe default value such as 0. function GetEventDamageUnmodified takes nothing returns real //In response to a damage event returns the damage dealt to the unit before any modifications (armor, attacktype reduction, etc) were applied. function GetEventDamageMana takes nothing returns real //In response to a damage event returns the mana lost due to an active mana shield. // > ALREADY ADDED NATIVES IN 1.29 PTR /* native SetEventDamage takes real damage returns nothing */ //=========================================================================== // TRIGGER //=========================================================================== function EvaluateBoolexpr takes boolexpr func returns boolean //Simple function to evaluate a boolexpr in a single call. Currently one has to bind it to a trigger as a condition, evaluate the trigger and then destroy the trigger after evaluation. The way the boolexpr is executed should be similar to the current trigger approach. //=========================================================================== // TIMER //=========================================================================== function TimerSetRemaining takes timer t, real newTime returns nothing //Set Remaining time would allow to enlarge/shorten a timer's duration. //Or evoke its execution instantly //without changing execution code nor repeat mode. function TimerSetRepeat takes timer t, real repeatTime returns nothing //change the repeatTime of an timer. //will en/disable repeat mode, if needed. //=========================================================================== // PLAYER //=========================================================================== // > ALREADY ADDED NATIVES IN 1.29 PTR /* constant native DecPlayerTechResearched takes player whichPlayer, integer techid, integer levels returns nothing */ //=========================================================================== // FORCE //=========================================================================== function FirstOfForce takes force f returns player //same as FirstOfGroup, for player-groups. //=========================================================================== // PATHING //=========================================================================== function GetPathingCost takes real x1 real y1 real x2 real y2 returns int // GetPathing returns the pathing cost between two points and returns -1 if it's unreachable. //=========================================================================== // TERRAIN //=========================================================================== function GetWaterZ takes real x, real y returns real //returns the water level (shallow or deep) since currently GetLocationZ() ignores water level. function GetCliffZ takes real x, real y returns real //related to this https://www.hiveworkshop.com/threads/calculating-a-flying-units-flyheight.270925/ //=========================================================================== // UBERSPLAT //=========================================================================== function SetUbersplatPos takes ubersplat u, real x, real y returns nothing //Moves an ubersplat to a new map relative coordinate. function SetUbersplatScale takes ubersplat u, real x, real y returns nothing //Allows the distortion of an ubersplat. This is applied to the ubersplat in its default orientation before it is rotated. function SetUbersplatFacing takes ubersplat u, real angle returns nothing //Allows an ubersplat to be rotated. Useful for hazard markers or hit markers. Angle is in degrees. function SetUbersplatFacingRad takes ubersplat u, real angle returns nothing //Same as SetUbersplatFacing except angle is in radians. //=========================================================================== // SPECIAL EFFECT //=========================================================================== function AddSpecialEffectEffect takes string modelName, effect targetEffect, string attachPointName returns effect //Create a special effect attached to another special effect. function SetSpecialEffectEffect takes effect fx, effect targetEffect, string attachPointName returns nothing //Moves a special effect to the target special effect. // > ALREADY ADDED NATIVES IN 1.29 PTR /* native SetSpecialEffectX takes effect whichEffect, real x returns nothing native SetSpecialEffectY takes effect whichEffect, real y returns nothing native SetSpecialEffectZ takes effect whichEffect, real z returns nothing native SetSpecialEffectPositionLoc takes effect whichEffect, location loc returns nothing native GetLocalSpecialEffectX takes effect whichEffect returns real native GetLocalSpecialEffectY takes effect whichEffect returns real native GetLocalSpecialEffectZ takes effect whichEffect returns real native SetSpecialEffectColorByPlayer takes effect whichEffect, player whichPlayer returns nothing native SetSpecialEffectColor takes effect whichEffect, integer r, integer g, integer b returns nothing native SetSpecialEffectAlpha takes effect whichEffect, integer alpha returns nothing native SetSpecialEffectScale takes effect whichEffect, real scale returns nothing native SetSpecialEffectPosition takes effect whichEffect, real x, real y, real z returns nothing native SetSpecialEffectHeight takes effect whichEffect, real height returns nothing native SetSpecialEffectTimeScale takes effect whichEffect, real timeScale returns nothing native SetSpecialEffectTime takes effect whichEffect, real time returns nothing native SetSpecialEffectOrientation takes effect whichEffect, real yaw, real pitch, real roll returns nothing native SetSpecialEffectYaw takes effect whichEffect, real yaw returns nothing native SetSpecialEffectPitch takes effect whichEffect, real pitch returns nothing native SetSpecialEffectRoll takes effect whichEffect, real roll returns nothing native PlaySpecialEffect takes effect whichEffect, integer anim returns nothing native PlaySpecialEffectWithTimeScale takes effect whichEffect, integer anim, real timeScale returns nothing */ //=========================================================================== // LIGHTNING //=========================================================================== native SetLightningScale takes lightning whichBolt, real scale returns nothing //=========================================================================== // WEATHER EFFECT //=========================================================================== function SetWeatherEffectHeight takes weathereffect whichEffect, real height returns nothing function SetWeatherEffectScale takes weathereffect whichEffect, real scale returns nothing function SetWeatherEffectColor takes weathereffect whichEffect, real r, real g, real b, real a returns nothing function SetWeatherEffectSound takes weathereffect whichEffect, sound soundHandle returns nothing //=========================================================================== // WIDGET //=========================================================================== // > WIDGET VISUAL function SetWidgetTexure takes widget whichWidget, string texturePath, integer replaceableId returns boolean /*Models can have textures with a Replaceable ID instead of a texture path. The most common use of this is for team color and hero glow (Replaceable ID 1 & 2). While there are natives to set a units team color, that's about all that is natively supported. The Mountain Giant's War Club ability will change any texture on the caster that uses "Replaceable ID 32" to the texture of the targeted destructable. While this allows us to modify ID 32, it's not enough and has some overhead. If we can allow the user to change any ID, then we can switch the texture of any part of the model dynamically. Of course this requires models to use Replaceable ID's instead of texture paths, so many vanilla models won't have uses other than custom team colors. Perhaps a complete API to modify model data would be better, however this would be the easiest to implement. There is already an internal function capable of doing this. However it requires a destructable as one of the paramaters, but I think it should be fairly easy to find a way to not require one. The way I do it is by using a dummy destructable object (not handle) and switching it's texture, but there is probably a better way.*/ function GetWidgetTexure takes widget whichWidget, replaceableId returns string // > WIDGET ATTACHEMENT function GetLocalTargetAttachmentX takes widget who, string attachmentname returns real //Get the map relative x coordinate of the specified attachment site. Not net safe. //for instance GetLocalTargetAttachmentX(unit,"hand") would return the projected X coordinate of the hand function GetLocalTargetAttachmentY takes widget who, string attachmentname returns real //Get the map relative y coordinate of the specified attachment site. Not net safe. function GetLocalTargetAttachmentZ takes widget who, string attachmentname returns real //Get the map relative z coordinate of the specified attachment site. Not net safe. // > WIDGET EVENTS function TriggerRegisterWidgetInRange takes trigger whichTrigger, widget whichWidget, real range, boolexpr filter returns event // > WIDGET GROUP type widgetgroup extends agent //this would allow tot make groups of items and destructables function CreateWidgetGroup takes nothing returns widgetgroup function DestroyGroup takes widgetgroup whichGroup returns nothing function GroupAddWidget takes widgetgroup whichGroup, widget wichWidget returns nothing function GroupRemoveWidget takes widgetgroup whichGroup, widget wichWidget returns nothing function GroupClear takes widgetgroup whichGroup returns nothing function GroupEnumWidgetsOfType takes widgetgroup whichGroup, string widgetname, boolexpr filter returns nothing function GroupEnumWidgetsOfTypeCounted takes widgetgroup whichGroup, string widgetname, boolexpr filter, integer countLimit returns nothing function GroupEnumWidgetsInRect takes widgetgroup whichGroup, rect r, boolexpr filter returns nothing function GroupEnumWidgetsInRectCounted takes widgetgroup whichGroup, rect r, boolexpr filter, integer countLimit returns nothing function GroupEnumWidgetsInRange takes widgetgroup whichGroup, real x, real y, real radius, boolexpr filter returns nothing function GroupEnumWidgetsInRangeOfLoc takes widgetgroup whichGroup, location whichLocation, real radius, boolexpr filter returns nothing function GroupEnumWidgetsInRangeCounted takes widgetgroup whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing function GroupEnumWidgetsInRangeOfLocCounted takes widgetgroup whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing function ForGroup takes widgetgroup whichGroup, code callback returns nothing function FirstOfGroup takes widgetgroup whichGroup returns widget //native widgetgroup API update for widget widgetgroup //=========================================================================== // DESTRUCTABLE //=========================================================================== constant destructableevent DESTRUCTIBLE_DEATH //Triggers when a destructible dies. I put this here to standardise the way destructible events work. constant destructableevent DESTRUCTIBLE_COMBAT //Triggers when a destructible takes damage from a combat source. Ignores tree-harvesting. constant destructableevent DESTRUCTIBLE_HARVESTED //Triggers when a destructible takes damage from a tree-harvest ability. Ignores combat damage. constant destructableevent DESTRUCTIBLE_DAMAGED //Triggers when a destructible takes any damage at all. function IsDestructableTree takes destructable d returns boolean //Returns true if a destructable can be used as a tree. Otherwise false. function TriggerRegisterDestructibleEvent takes trigger whichTrigger, destructable d, destructableevent whichEvent returns event //Like TriggerRegisterUnitEvent. Some of the important event constants are listed but others might also exist. function TriggerRegisterAnyDestructibleEvent takes trigger whichTrigger, destructableevent whichEvent returns event //Like TriggerRegisterDestructibleEvent except applies to all destructables on the map, even ones yet to be created. //=========================================================================== // TRACKABLE //=========================================================================== function SetTrackablePos takes trackable t, real x, real y returns nothing //Moves a trackable to the specified map realative coordinate. function SetTrackableZ takes trackable t, real z returns nothing //Sets the map realative z coordinate of the trackable. This disables automatic Z positioning. function SetTrackableZOffset takes trackable t, real zOffset returns nothing //Sets the Z offset of a trackable. This is realitive to the Z it is automatically positioned at. This enables automatic Z positioning. function GetTrackableX takes trackable t returns real //Returns the map relative x coordinate of the trackable. function GetTrackableY takes trackable t returns real //Returns the map relative y coordinate of the trackable. function GetTrackableZ takes trackable t returns real //Returns the map relative z coordinate of the trackable if in map relative z mode. Returns the z offset if in automatic z mode. function DestroyTrackable takes trackable t returns nothing //Trackables currently cannot be destroyed through triggers, so this native is needed for them to be useful. //=========================================================================== // UNIT //=========================================================================== constant unitstate UNIT_STATE_LIFE_REGEN //Unit current life regeneration. Compatible with GetUnitState and SetUnitState. constant unitstate UNIT_STATE_MANA_REGEN //Unit current mana regeneration. Compatible with GetUnitState and SetUnitState. constant armortype ARMOR_TYPE_SMALL //Used by natives below. constant armortype ARMOR_TYPE_MEDIUM //Used by natives below. constant armortype ARMOR_TYPE_LARGE //Used by natives below. constant armortype ARMOR_TYPE_FORTIFIED //Used by natives below. constant armortype ARMOR_TYPE_NORMAL //Used by natives below. constant armortype ARMOR_TYPE_HERO //Used by natives below. constant armortype ARMOR_TYPE_DIVINE //Used by natives below. constant armortype ARMOR_TYPE_UNARMORED //Used by natives below. constant armortype ARMOR_TYPE_UNKNOWN //Invalid armor type. Has been observed randomly in game, likely as the result of a non fatal memory corruption error to the armor type field. constant herostat HERO_STAT_STR //Used by natives below. constant herostat HERO_STAT_AGI //Used by natives below. constant herostat HERO_STAT_INT //Used by natives below. constant movementtype MOVEMENT_TYPE_NONE //Used by natives below. constant movementtype MOVEMENT_TYPE_FOOT //Used by natives below. constant movementtype MOVEMENT_TYPE_HORSE //Used by natives below. constant movementtype MOVEMENT_TYPE_FLY //Used by natives below. constant movementtype MOVEMENT_TYPE_HOVER //Used by natives below. constant movementtype MOVEMENT_TYPE_FLOAT //Used by natives below. constant movementtype MOVEMENT_TYPE_AMPHIBIOUS //Used by natives below. // > UNIT LEVEL function SetUnitLevel takes unit u, integer newLevel returns nothing //Set the unit level of a non hero unit to the specified level. Does nothing to heroes. // > UNIT ABILITIES function SetUnitAbilityCooldownRemaining takes unit u, integer abilityId, real remaining returns nothing function IsUnitAbilityOnCooldown takes unit u, integer abilityId returns boolean //Returns true if an ability is on cooldown for a unit. // > UNIT VISUALS function GetUnitIconPath takes unit u returns string //Returns the command card icon path of a unit. function GetUnitTypeIconPath takes integer unitId returns string //Returns the command card icon path of a unit type. function SetUnitIconPath takes unit u, string path returns nothing //Changes the command card icon path of a unit. function GetUnitModelPath takes unit u returns string //Returns the model path of a unit. function GetUnitTypeModelPath takes integer unitId returns string //Returns the model path of a unit type. function SetUnitModelPath takes unit u, string path returns nothing //Changes the model path of a unit. function ShowUnitLocalPlayer takes unit whichUnit, player pUnit, boolean show returns nothing //Native Show Unit with GetLocalPlayer() work to hide a unit for a single player. function SetUnitSelectionCircle takes unit u, image circle returns nothing //Sets a selection circle image for a unit function ResetUnitSelectionCircle takes unit u returns nothing //Returns the original selection circle of the unit function GetUnitShadow takes unit whichUnit returns image // or at least this: function ShowUnitShadow takes unit whichUnit, boolean flag returns nothing // > UNIT MOVEMENT function SetUnitMovementType takes unit u, movementtype movementType returns nothing //Changes the movement type of a unit to the specified movement type. function GetUnitMovementType takes unit u returns movementtype //Get the movement type of a unit. function UnitDisableMovement takes unit u, boolean flag returns nothing //toggles a unit's movement on or off. Currently feasible with SetUnitPropWindow to zero, but restoring requires radians but GetUnitDefaultPropWindow returns degrees. Not a big issue, but it's hidden information. function UnitDisableTurning takes unit u, boolean flag returns nothing //toggles a unit's ability to turn on or off. function IsUnitMoving takes unit u returns boolean //Returns true if a unit is trying to move. The unit might not actually be moving if it is waiting for the pathfinder to attend to it. function IsUnitIdle takes unit u returns boolean //Returns true if a unit is not moving, is not attacking, is not casting and is not using an item. function SetUnitMaxSpeed takes unit u, real r returns nothing function GetUnitMaxSpeed takes unit u, nothing returns real function SetUnitMinSpeed takes unit u, real r returns nothing function GetUnitMinSpeed takes unit u, nothing returns real //Does maximum and minimum unit speed even do anything? If so, the ability to modify those would be welcome. // > UNIT ATTACK function SetUnitAttackCooldown takes unit u, real duration returns nothing //Sets the current attack cooldown time to a different value, potentially overriding/ignoring backswing point. Set to zero to cause the next attack to occur instantly. Can start attack cooldown. function GetUnitAttackCooldownRemaining takes unit u returns real //Returns the remaining time in game seconds of the currently occuring attack cooldown. Returns 0.0 if attack is not on cooldown. function UnitAttackTarget takes unit whichUnit, widget target, real amount, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean //Similar to UnitDamageTarget but does so with the source's attack modifiers like Orb Effects, Critical Strike, Bash, Lifesteal, etc. function UnitAttackArea takes unit whichUnit, real radius, real x, real y, real amount, attacktype attackType, damagetype damageType, weapontype weaponType, boolexpr filterFunc returns boolean //Just like UnitAttackTarget(), but this takes a boolexpr argument at the end to filter out unwanted victims. This is helpful in the case of area attacks with chance modifiers like bash. function GetUnitAttackSpeedBonus takes unit u, returns real //Returns the current attack speed bonus of a unit. For instance a hero with a glove of haste (+15% attack speed) would return 0.15 function ModifyUnitAttackSpeedBonus takes unit u, real fraction returns nothing //Applies a bonus to the attack speed of a unit, being treated the same as other attack speed modifiers. function IsUnitInCombat takes unit u returns boolean //Returns true if a unit has recently attacked or been attacked. Possibly tied into the forces under attack mechanics? // > UNIT POSITION function SetUnitFacingInstant takes unit u, real facingAngle returns nothing //Similar to SetUnitFacing but with angle change being instant with turn rate and orientation interpolation being ignored. Angle is in degrees. function SetUnitFacingInstantRad takes unit u, real facingAngle returns nothing //Same as SetUnitFacingInstant except angle is in radians. function SetUnitFacingRad takes unit whichUnit, real facingAngle returns nothing //Same as SetUnitFacing except angle is in radians. // > UNIT ARMOR function GetUnitArmorType takes unit u returns armortype function SetUnitArmorType takes unit u, armortype armorType returns nothing function GetUnitArmorBonus takes unit u returns real //Returns the current armor bonus of a unit. function ModifyUnitArmorBonus takes unit u, real amount returns nothing //Applies armor modifier to a unit, being treated the same as all other armor modifiers. // > UNIT COST function GetUnitGoldCost takes integer unitid returns integer //AI native copied to normal JASS for convince. function GetUnitWoodCost takes integer unitid returns integer //AI native copied to normal JASS for convince. function SetUnitAbilityManaCost takes unit u, integer abilityId, integer level, integer newcost returns integer // > UNITS CONTROL function UnitDisableControl takes unit u boolean flag returns nothing //toggles whether a unit responds to player commands on or off. Can still respond to trigger commands. function UnitFullDisable takes unit u, boolean flag returns nothing //toggles whether a unit responds to ANY commands on or off. Similar to being stunned, but will not 'unstun' until UnitFullDisable is set to false. function UnitDisableAttack takes unit u, boolean flag returns nothing //Turns off one of the two attack indices. Currently feasible by adding Cargo Hold ability to the unit, but it disables both indices. function UnitDisableSelection takes unit u, boolean flag returns nothing //Same as giving Locust ability to a unit (Aloc), but can be enabled/disabled without any buggy side effects. function UnitApplyTimer takes unit u, integer buffId, real timeout returns timer //Applies a non-fatal timer to a unit that shows the time ticking down like with a spell like Avatar or Metamorphosis. When the timer expires, a TimerRegisterExpireEvent fires. function UnitDisableItems takes unit u, boolean flag, boolean passive returns nothing //Toggles whether a unit can use items. Item passive effects are optionally able to be turned on or off. function UnitChangeUnitId takes unit u, integer unitid returns nothing //Changes the unit type ID of a unit. Results are the same as unit a morph ability except without needing an ability. function ReviveUnit takes unit u returns nothing //Revives a dead unit at the position of its corpse. Mechanically the same as the unit being effected by Paladin's Resurrection ability. // > HEROES function GetHeroPrimaryStat takes unit u returns herostat //Returns the integer code for the attribute that is set as primary. Eg if the unit is a Paladin, it returns the id for Strength. function GetHeroPrimaryStatById takes integer unitid returns herostat //Same as above but references the object editor value instead of an actual unit. function SetHeroPrimaryStat takes unit u, herostat stat returns integer //Allows the game to individual modify which attribute of the hero becomes its primary. Damage modifier from primary hero stat has to be reapplied. function GetHeroStat takes herostat whichStat, unit whichHero, boolean includeBonuses returns integer //Mechanically same as the GetHeroStatBJ function except takes the new native herostat constants. function SetHeroStatEx takes unit whichHero, herostat whichStat, integer value, boolean permanent returns nothing //Mechanically similar to the SetHeroStat function except takes the new native herostat constants and can set permanence. // > CONSTRUCTION & TRAINING function GetUnitBuildTime takes integer unitid returns integer //AI native ported to standard JASS. function GetHeroBuildTime takes integer unitid, player whichPlayer returns integer //Returns the train time in seconds for a player to make the specified hero type. Factors in train time increases with sequential heroes in melee. function GetHeroReviveTime takes unit whichUnit returns integer //Returns the revive time in seconds for a player to revive the specified hero if it were dead. function GetBuilderUnit takes unit building returns unit //Returns the unit that constructed a building/unit. In the case of buildings this should be the unit that converted the foundation into a unit. function GetUnitBuildProgress takes unit u returns real //Returns the fraction (percent / 100) completion of a building/unit in progress. If the unit has no progress (already built) returns 1.0. function SetUnitBuildProgress takes unit u, real fraction returns nothing //Modifies the fraction completion of a building/unit in progress. A fraction of 1.0 causes the unit to be instantly completed. Does nothing to a unit that is complete. function GetUnitTrainProgress takes unit factory returns real //Returns the fraction completion of a unit that is being trained. Returns 1.0 if no unit is being trained. function SetUnitTrainProgress takes unit factory, real fraction returns nothing //Modifies the fraction completion of a unit that is currently being trained. A fraction of 1.0 causes the unit to be instantly trained. Does nothing to a factory that is not training anything. function GetTrainingQueueSize takes unit factory returns integer //Returns the number of queued training orders. function GetMaxTrainingQueueSize takes unit factory returns integer //Returns the maximum number of queued training orders a factory allows. function CancelTraining takes unit factory, integer slot returns boolean //Cancels a train order from the training queue of a building determined by slot number (eg 0 - 6). Returns true if a unit was actually canceled. function ClearTrainingQueue takes unit factory returns boolean //Equivelant to calling CancelTraining on all occupied training slots of a building. Returns true if at least 1 training order was canceled. // > UNIT MARKET function SetItemStock takes unit u, integer itemId, integer stock returns nothing //Set the stock of an item id in a shop to the specified number. Maximum stock count is respected and if full cooldown progress will be lost. function SetItemStockMax takes unit u, integer itemId, integer stock returns nothing //Set the maximum stock permitted of an item id in a shop to the specified number. Maximum stock count is respected and if below current stock cooldown and stock items will be lost. function GetItemStock takes unit u, integer itemId returns integer //Get the stock available of an item id in a shop. function GetItemStockMax takes unit u, integer itemId returns integer //Get the maximum stock permitted of an item id in a shop. // > UNIT TECH function UnitDisableTechBoni takes unit u, boolean flag returns nothing //Allows/Disallows a unit benefiting from techs researched. // > OTHER UNIT NATIVES function SetUnitVisionType takes unit u, boolean flying returns nothing //Changes the vision mechanics of a unit to either be ground (can be occluded by terrain) or flying (absolute). function GroupEnumCorpsesInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing //Convenience function to enum all corpses in range of a position. function GroupEnumCorpsesInRangeloc takes group g, location whichLocation, real radius, boolexpr filter returns nothing //Same as above but with location parameter. // > ALREADY ADDED NATIVES IN 1.29 PTR /* native SetHeroName takes unit u, string name returns nothing native DeleteHeroAbility takes unit whichUnit, integer abilCode returns nothing native GetUnitMaxHP takes unit whichUnit returns integer native SetUnitMaxHP takes unit whichUnit, integer hp returns nothing native GetUnitMaxMana takes unit whichUnit returns integer native SetUnitMaxMana takes unit whichUnit, integer mana returns nothing native SetUnitName takes unit whichUnit, string name returns nothing native SetUnitNameAll takes unit whichUnit, string name returns nothing native GetUnitBaseDamage takes unit whichUnit, integer weaponIndex returns integer native SetUnitBaseDamage takes unit whichUnit, integer baseDamage, integer weaponIndex returns nothing native GetUnitDiceNumber takes unit whichUnit, integer weaponIndex returns integer native SetUnitDiceNumber takes unit whichUnit, integer diceNumber, integer weaponIndex returns nothing native GetUnitDiceSides takes unit whichUnit, integer weaponIndex returns integer native SetUnitDiceSides takes unit whichUnit, integer diceSides, integer weaponIndex returns nothing native GetUnitAttackCooldown takes unit whichUnit, integer weaponIndex returns real native SetUnitAttackCooldown takes unit whichUnit, real cooldown, integer weaponIndex returns nothing native GetUnitArmor takes unit whichUnit returns real native SetUnitArmor takes unit whichUnit, real armorAmount returns nothing native UnitHideAbility takes unit whichUnit, integer abilId, boolean flag returns nothing native UnitDisableAbility takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing native UnitCancelTimedLife takes unit whichUnit returns nothing native IsUnitSelectable takes unit whichUnit returns boolean native IsUnitInvulnerable takes unit whichUnit returns boolean native UnitInterruptAttack takes unit whichUnit returns nothing native GetUnitCollisionSize takes unit whichUnit returns real native SetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level, real cooldown returns nothing native GetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level returns real native GetUnitAbilityCooldownRemaining takes unit whichUnit, integer abilId returns real native EndUnitAbilityCooldown takes unit whichUnit, integer abilCode returns nothing native GetUnitAbilityManaCost takes unit whichUnit, integer abilId, integer level returns integer native GetLocalUnitZ takes unit whichUnit returns real */ //=========================================================================== // ABILITIES //=========================================================================== constant playerevent EVENT_PLAYER_ABILITY_PRESSED /*The event triggers when a player presses an ability button and begins targeting. Requires netsync from the player so is not instant. Most spell event natives like trigger unit and spell ability id work in response to this event.*/ function GetTriggerPlayerAbilityPressed takes player returns integer function SetAbilityManaCost takes integer abilityId, integer level, integer newcost returns integer function SetAbilityCooldown takes integer abilityId, integer level, integer newcool returns integer // > ALREADY ADDED NATIVES IN 1.29 PTR /* native GetAbilityManaCost takes integer abilId, integer level returns integer native GetAbilityCooldown takes integer abilId, integer level returns real native SetAbilityTooltip takes integer abilCode, string tooltip, integer level returns nothing native SetAbilityOnTooltip takes integer abilCode, string tooltip, integer level returns nothing native SetAbilityExtendedTooltip takes integer abilCode, string ExtendedTooltip, integer level returns nothing native SetAbilityOnExtendedTooltip takes integer abilCode, string ExtendedTooltip, integer level returns nothing native SetAbilityResearchTooltip takes integer abilCode, string researchTooltip, integer level returns nothing native SetAbilityResearchExtendedTooltip takes integer abilCode, string researchExtendedTooltip, integer level returns nothing native GetAbilityTooltip takes integer abilCode, integer level returns string native GetAbilityOnTooltip takes integer abilCode, integer level returns string native GetAbilityExtendedTooltip takes integer abilCode, integer level returns string native GetAbilityOnExtendedTooltip takes integer abilCode, integer level returns string native GetAbilityResearchTooltip takes integer abilCode, integer level returns string native GetAbilityResearchExtendedTooltip takes integer abilCode, integer level returns string native SetAbilityIcon takes integer abilCode, string iconPath, integer level returns nothing native GetAbilityIcon takes integer abilCode, integer level returns string native SetAbilityOnIcon takes integer abilCode, string iconPath returns nothing native GetAbilityOnIcon takes integer abilCode returns string native GetAbilityPosX takes integer abilCode returns integer native GetAbilityPosY takes integer abilCode returns integer native SetAbilityPosX takes integer abilCode, integer x returns nothing native SetAbilityPosY takes integer abilCode, integer y returns nothing native GetAbilityOnPosX takes integer abilCode returns integer native GetAbilityOnPosY takes integer abilCode returns integer native SetAbilityOnPosX takes integer abilCode, integer x returns nothing native SetAbilityOnPosY takes integer abilCode, integer y returns nothing */ //=========================================================================== // BUFF //=========================================================================== unitevent EVENT_UNIT_BUFF_APPLIED unitevent EVENT_UNIT_BUFF_EXPIRED //Triggers when the buff expires or gets removed function UnitApplyBuff takes unit u, integer rawcode, integer level returns nothing //Applies specified buff and pauses dissipation timer. SetUnitBuffTimeout can be called later on to remove the paused state and to set the timeout function UnitRemoveBuff takes unit u, integer rawcode returns nothing function GetEventBuffApplied takes nothing returns integer function GetEventBuffExpired takes nothing returns integer //Returns buff rawcode function SetUnitBuffTimeout takes unit u, integer rawcode, real timeout returns nothing / //Starts dissipation timer function SetUnitBuffPermanent takes unit u, integer rawcode, boolean flag returns nothing //Pauses dissipation timer function SetUnitBuffPositive takes unit u, integer rawcode, boolean flag returns nothing // By default this parameter inherits buff type settings function SetUnitBuffLevel takes unit u, integer rawcode, integer level returns nothing function SetUnitBuffTip takes unit u, integer rawcode, string tip returns nothing function SetUnitBuffUbertip takes unit u, integer rawcode, string tip returns nothing function SetUnitBuffArt takes unit u, integer rawcode, string path returns nothing function IsUnitBuffPermanent takes unit u, integer rawcode returns boolean function IsUnitBuffPositive takes unit u, integer rawcode returns boolean function GetTriggerBuff takes nothing returns integer //Actually this can be achieved with current methods, but one must use GetUnitAbilityLevel(buffRawcode) function which is not intuitive. function GetUnitBuffTimeout takes unit u, integer rawcode returns real function GetUnitBuffElapsed takes unit u, integer rawcode returns real function GetUnitBuffRemaining takes unit u, integer rawcode returns real function GetUnitBuffLevel takes unit u, integer rawcode returns integer function GetUnitBuffTip takes unit u, integer rawcode returns string function GetUnitBuffUbertip takes unit u, integer rawcode returns string function GetUnitBuffArt takes unit u, integer rawcode returns string //=========================================================================== // ITEMS //=========================================================================== function GetItemAbilityCooldownRemaining takes item whichItem returns real //Returns the remaining cooldown time on a used item. function GetItemAbilityCooldownTimeoutById takes integer itemId returns real //Returns the default timeout cooldown of an item type. function SetItemAbilityCooldown takes item whichItem, real timeout, real remaining returns real //Sets the remaining cooldown time of an item to a specific value. Timeout will clamp remaining for logical reasons and might be ignored for unowned items. Set timeout or remaining to zero to instantly complete cooldown. function EnableItem takes item whichItem, boolean flag returns nothing //Enables/Disables an item. Items that are disabled provide no modifiers and cannot be used. // > ALREADY ADDED NATIVES IN 1.29 PTR /* native SetItemName takes item whichItem, string name returns nothing native SetItemDescription takes item whichItem, string name returns nothing native GetItemDescription takes item whichItem returns string native SetItemTooltip takes item whichItem, string name returns nothing native GetItemTooltip takes item whichItem returns string native SetItemExtendedTooltip takes item whichItem, string name returns nothing native GetItemExtendedTooltip takes item whichItem returns string native SetItemIconPath takes item whichItem, string name returns nothing native GetItemIconPath takes item whichItem returns string */ //=========================================================================== // UI //=========================================================================== constant minimapevent PING //Trigger on a minimap ping constant minimapevent MINIMAP_BUTTON_PRESSED //Triggers when one of the associated minimap buttons have been pressed. function ShowUI takes boolean flag returns nothing //True/false arguments would show/hide the UI. That includes disabling the black borders at the top and bottom of the screen. // > HP / MANA UI function ShowManaBar takes boolean flag returns nothing //Turns mana bar display over units on or off. Whether they display depends on the player's Gameplay options but this can overwrite that for a session. function SetPlayerHPBarColor takes player p, real red, real green, real blue returns nothing //Changes the health bar color of units belonging to a particular player. function SetPlayerMPBarColor takes player p, real red, real green, real blue returns nothing //Changes the mana bar color of units belonging to a particular player. function SetPlayerHPTextColor takes player p, real red, real green, real blue returns nothing //Changes the health text color under units portrait belonging to a particular player. function SetPlayerMPTextColor takes player p, real red, real green, real blue returns nothing //Changes the mana text color under units portrait belonging to a particular player. // > BAR function CreateBar takes real red, real green, real blue, real alpha returns bar //'New' object type. Creates a bar (like the health bars above units) and colours them according to the values used. Eg recreating Protoss shields. function AttachBarTarget takes bar whichBar, widget target, real z returns nothing //Attaches a bar to a unit, destructable, item etc with the option to move it up and down the z axis. function GetBarX takes bar whichBar returns real //Returns the x coordinate of a bar. function GetBarY takes bar whichBar returns real //Returns the y coordinate of a bar. function GetBarZ takes bar whichBar returns real //Returns the z coordinate of a bar. function SetBarPos takes bar, real x, real y, real heightOffset returns nothing //Manually repoisitions a bar to map relative coordinates like floating texts. // > SCREEN function DisplayScreenMessage takes string s, real x, real y, real timeout returns nothing //This displays a text message for a period but with respect to normalised X / Y value of the screen. Can overlap other text messages. An invalid timeout will automatically compute a timeout based on message length. function GetLocalDisplayResolutionHorizontal takes nothing returns real //Returns the horizontal resolution in pixels being used to display Warcraft III for the local client. Not net safe. function GetLocalDisplayResolutionVertical takes nothing returns real //Returns the vertical resolution in pixels being used to display Warcraft III for the local client. Not net safe. // > MINIMAP function GetPingX takes ping whichPing returns real //returns the corresponding map relative x coordinate of a ping. function GetPingY takes ping whichPing returns real //returns the corresponding map relative y coordinate of a ping. function TriggerRegisterPlayerPingEvent takes trigger whichTrigger, player whichPlayer returns event //New event that fires the trigger when the specified player sends a ping. Both GetTriggerPlayer and GetTriggerPing are valid with this event. function GetTriggerPing takes nothing returns ping //In response to a player ping event returns the ping object that triggered the event. //=========================================================================== // CUSTOM UI //=========================================================================== /* Someone suggested the ability to customize the UI similar to StarCraft II where one can place custom UI elements anywhere on a clients screen. They did not suggest an API to do this however. Due to the complexity of such an API I would suggest looking at StarCraft II's implementation which allows the UI to be heavilly customized. */ //=========================================================================== // MULTIBOARD //=========================================================================== function SetMultiboardScreenPositionXY takes multiboard mb, real x, real y returns nothing //This changes the position of a multiboard with respect to normalised X / Y value of the screen //=========================================================================== // LEADERBOARD //=========================================================================== function SetLeaderboardScreenPositionXY takes leaderboard lb, real x, real y returns nothing //This changes the position of a leaderboard with respect to normalised X / Y value of the screen //=========================================================================== // TEXTTAG //=========================================================================== constant textagalignment TEXTTAG_CENTER constant textagalignment TEXTTAG_RIGHT constant textagalignment TEXTTAG_LEFT function SetTexTagAlignment takes texttag tt, textagalignment alignment returns nothing // left—the text is aligned along the left margin (default); // right—the text is aligned along the right margin; // centered—text is aligned to neither the left nor right margin; there is an even gap on each side of each line. //=========================================================================== // DIALOG //=========================================================================== function IsPlayerInDialog takes player p returns boolean //Returns true if the player currently has any dialog box visible to them. Might require net sync. //=========================================================================== // HARDWARE INPUT //=========================================================================== constant mouseevent MOUSE_WHEEL_ANY //Triggers when the mouse wheel scrolls up or down constant mouseevent MOUSE_WHEEL_UP //Triggers when the mouse wheel scrolls up constant mouseevent MOUSE_WHEEL_DOWN //Triggers when the mouse wheel scrolls down // > MOUSE function GetLocalCursorTargetX takes nothing returns real //Returns the map relative x coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe. function GetLocalCursorTargetY takes nothing returns real //Returns the map relative y coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe. function GetLocalCursorTargetZ takes nothing returns real //Returns the map relative z coordinate that the local client cursor is targeting. If the cursor is not targeting anything on the map returns 0. Not net safe. function SetLocalCursorX takes real x returns nothing //Set the local client cursor position to the specified screen space normalised x coordinate. function SetLocalCursorY takes real y returns nothing //Set the local client cursor position to the specified screen space normalised y coordinate. function IsLocalCursorOverUI takes nothing returns boolean //Returns true if the cursor is currently not targeting the map. Not net safe. function IsLocalMouseButtonPressed takes mousebutton mouseButton returns boolean //Returns true or false depending on which mouse button is being held down. Will be useful for click-and-drag functions. Not net safe. function GetTriggerPlayerMouseEvent takes nothing returns mouseevent //In response to player mouse event returns which mouseevent triggered the trigger. function GetTriggerPlayerMouseScreenX takes nothing returns real //In response to player mouse event returns the screen space normalised x coordinate the event occurred at. Is net safe. function GetTriggerPlayerMouseScreenY takes nothing returns real //In response to player mouse event returns the screen space normalised y coordinate the event occurred at. Is net safe. function GetTriggerPlayerMouseY takes nothing returns real //In response to player mouse event returns the map relative z coordinate the event occurred at. Return value non 0.0 only if the mouse event targeted the map. Is net safe. // > KEYBOARD function TriggerRegisterPlayerKeyboardEvent takes trigger whichTrigger, player whichPlayer, keyboardbutton hotkey, boolean state returns event //Fires when the corresponding key is pressed by the player. The keyboardbutton constants are not mentioned but should cover most common keyboard buttons. If state is true then fires when key is pressed, otherwise fires when key is released. Attaching this event causes keyboard button sync traffic from the player. function GetTriggerKeyboardButton takes nothing returns keyboardbutton //In response to player keyboard event returns which button caused the event. function GetTriggerKeyboardState takes nothing returns boolean //In response to player keyboard event returns the state that caused the event. True if it was pressed, false if released. function GetLocalKeyboardButtonState takes keyboardbutton whichButton returns boolean //Returns true if the local client has the specified keyboard button (eg arrow keys) depressed or false if released. Not net safe. // > ALREADY ADDED NATIVES IN 1.29 PTR /* constant mousebuttontype MOUSE_BUTTON_TYPE_LEFT = ConvertMouseButtonType(1) constant mousebuttontype MOUSE_BUTTON_TYPE_MIDDLE = ConvertMouseButtonType(2) constant mousebuttontype MOUSE_BUTTON_TYPE_RIGHT = ConvertMouseButtonType(3) constant playerevent EVENT_PLAYER_MOUSE_DOWN = ConvertPlayerEvent(269) constant playerevent EVENT_PLAYER_MOUSE_UP = ConvertPlayerEvent(270) constant playerevent EVENT_PLAYER_MOUSE_MOVE = ConvertPlayerEvent(271) native GetTriggerPlayerMouseX takes nothing returns real native GetTriggerPlayerMouseY takes nothing returns real native GetTriggerPlayerMousePosition takes nothing returns location native GetTriggerPlayerMouseButton takes nothing returns mousebuttontype */ //=========================================================================== // AI //=========================================================================== /* One of the biggest problems with the AI is the very inflexible use of captain widgets. Currently, captain widgets are a "middleman" in charge of orders given to the computer player. The AI player moves, or teleports, the captain widget to a target location and the units assigned to the captain follow. There are two captains: attack and defense, each with it's own problems. The units assigned to the defense captain will stay still even when given an order to change location, until one of three cases: aggroed, player town under attack, another unit is added to the defense captain. But the bigger problem is with the attack captain: once a unit has been added to the attack captain, it cannot be removed manually. If it is injured, and the attack group requires units with a higher health percentage, then the unit will be removed, but it cannot be done manually. I have two ideas for solutions in mind, both in a way that should not break backwards compatibility and enhance the AI greatly: 1. Add an */Empty attack group /* native. A simple native that will allow one to manually remove all units from the attack group. That alone will not change existing scripts and will remove a lot of limitations. 2. Allow multiple captains. This one is a bit more radical change, but it will make the AI far better and more flexible. The thing with captains is that you can only have one of each, but that is not to say that you can't create more. In fact, you can use the */native CreateCaptains /* as many times as you want, and it will create new captains. Also, it doesn't remove the old captains, as units assigned to them cannot be added to the new captains, and will continue following the old captain to the last target it received. The problem here, is that referencing the captains is done by constant integers set in the common.ai file: */ constant integer ATTACK_CAPTAIN = 1 constant integer DEFENSE_CAPTAIN = 2 constant integer BOTH_CAPTAINS = 3 /* Once you create new captains, these variables will reference the new captains instead of the old ones. If you could allow users to reference older captains (for example allocating another 3 numbers for older captains for every time CreateCaptains is called), AI will be much more usable. */ //=========================================================================== // MISSILE //=========================================================================== type missile extends agent //New variable type - missile type missileevent extends eventid //New event type for missiles constant unitevent EVENT_UNIT_MISSILE //Event of missile hitting a unit constant missileevent EVENT_MISSILE_IMPACT //Even of missile reaching a point function CreateMissileOnUnitToUnit takes unit target, unit source, real height, real speed, real arcangle, real scale, string modelpath returns missile //Creates a missile that moves from one point to another. Upon impact triggers EVENT_UNIT_MISSILE. function CreateMissileOnPointToUnit takes unit source, unit target, real x, real y, real height, real speed, real arcangle, real scale, string modelpath returns missile //Like one above but from point to unit function CreateMissileOnPointToPoint takes unit source, real x1, real y1, real x2, real y2, real height, real speed, real arcangle, real scale, string modelpath returns missile //Like ones above but from point to point. Upon impact triggers EVENT_MISSILE_IMPACT. function SetMissileX takes missile m, real x returns nothing //Sets X coordinate of missile function SetMissileY takes missile m, real y returns nothing //Sets Y coordinate of missile function SetMissileHeight takes missile m, real height returns nothing //Sets height of missile function SetMissileTargetPoint takes missile m, real x, real y returns nothing //Sets the target that missile will move at function SetMissileTargetUnit takes missile m, unit u returns nothing //Missile will move to targeted unit function SetMissileSourceUnit takes missile m, unit u returns nothing //Detects a unit that spawned missile function SetMissileSpeed takes missile m, real speed returns nothing //Sets missile speed function SetMissileScale takes missile m, real scale returns nothing //Sets missile size function SetMissileArcAngle takes missile m, real angle returns nothing //Sets missile arcangle function SetMissileModel takes missile m, string path returns nothing //Sets missile model function GetEventMissile takes nothing returns missile //Returns a missile that reached its target function GetMissileX takes missile m returns real //Returns current X of a missile function GetMissileY takes missile m returns real //Returns current Y of a missile function GetMissileHeight takes missile m returns real //Returns current height of a missile function GetMissileSpeed takes missile m returns real //Returns current speed of a missile function GetMissileScale takes missile m returns real //Returns current size of a missile function GetMissileArcAngle takes missile m returns real //Returns current arcangle of a missile function RemoveMissile takes missile m, boolean animation returns nothing //Deletes a missile. Flag animation depends if it will play death animation or not //=========================================================================== // OBJECT EDITOR API //=========================================================================== /* Read only object editor API. Similar to StarCraft II catalog natives, hence the naming. The field string would be the attribute key in the object editor, ie "regenHP" for the unit's base health regeneration. Passing an invalid key (or one that would return an incorrect data type for the function) would return some sensible default (0, 0.0, null, etc). */ constant catalog CATALOG_UNIT //Used by natives below. constant catalog CATALOG_ITEM //Used by natives below. constant catalog CATALOG_ABILITY //Used by natives below. constant catalog CATALOG_BUFF //Used by natives below. constant catalog CATALOG_UPGRADE //Used by natives below. constant catalog CATALOG_DOODAD //Used by natives below. constant catalog CATALOG_DESTRUCTABLE //Used by natives below. function GetUnitTypeAttributeInteger takes catalog whichCatalog, integer typeId, string field returns integer function GetUnitTypeAttributeReal takes catalog whichCatalog, integer typeId, string field returns real function GetUnitTypeAttributeString takes catalog whichCatalog, integer typeId, string field returns string //=========================================================================== // BENCHMARKING //=========================================================================== /* Whoever suggested these did not explain their purpose or what they are meant to do. I am guessing they are meant to be client local performance counters for measuring performance of various scripts. If this is the case then all calls made to these during multiplayer these should return default safe values that do nothing. */ function CreateStopWatch takes nothing returns stopwatch //Create a performance counter stop watch. function StopWatchStart takes stopwatch returns nothing //Start the stop watch, causing it to record time progression. If it has been paused, resumes recording. function GetStopWatchTime takes stopwatch returns real //Pause the stop watch and get the current elapsed stop watch time, which is the sum of all time it has been left running. function StopWatchEnd takes stopwatch returns nothing //Destroy the stop watch freeing all resources it used. function StopWatchPause takes stopwatch returns nothing //Pause the stop watch causing it to stop recording time progression. If trying to accuratly measure execution time of a piece of script this should be called between game frames to prevent the stop watch measuring the game loop time. //=========================================================================== // DEBUG //=========================================================================== function DisplayErrorMsg takes string s, real duration returns nothing //Display the given error message string in the error message area. The message is also written out to an error log file. function GetOPLimit takes nothing returns integer //Get the current remaining JASS thread operation limit. Due to how the JASS virtual machine works the returned value may be larger than the actual limit by the time it can be processed. function SetOPLimit takes integer newlimit returns nothing //Changes the current JASS thread operation limit to the specified value. Due to how the JASS virtual machine works the actual limit may be slightly smaller than the specified amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit. function ResetOPLimit takes nothing returns nothing //Resets the current JASS thread operation limit to the default operation limit of that thread, as if it was freshly created. Due to how the JASS virtual machine works the actual limit may be smaller than the default amount by the time the function returns. Care must be taken when using this native as it negates the infinite loop protection offered by the operation limit. type func extends code //Function type to be used with debugging natives. Possibly has special syntax requirements to prevent code exploit. function TriggerRegisterJassOpLimitEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of the thread reaching its operation limit. Useful for detecting when a thread crash occurs. function TriggerRegisterJassDivideByZeroEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempted division by 0. Useful for detecting when a thread crash occurs. function TriggerRegisterJassNoBlockEvent takes trigger whichTrigger returns event //Event fires in response to a JASS virtual machine thread crash as a result of attempting to block when blocking is not allowed (eg TriggerSleepAction in a condition function). Useful for detecting when a thread crash occurs. function GetTriggerFunction takes nothing returns func //In response to all JASS thread crash events returns the function the crash occured at. function GetEventJassError takes nothing returns string //In response to all JASS thread crash events returns a human readable string with as much information about the crash as possible. Intended to be printed out or logged to help map makers track down where/why a thread crash occured. function GetHandleIdCount takes nothing returns integer //Returns the number of currently allocated handle ids. If this number is observed increasing as a game progresses there is likely an object leak of sorts. function GetHandleIdFreeCount takes nothing returns integer //Returns the number of handle ids on the free handle id stack. If this number is very large then either the map has suffered from object count reduction over time or there was a step that required a large number of objects be created and destroyed. //=========================================================================== // BINARY DATA //=========================================================================== // Each function is annotated with it's C++ equivalent function BitwiseNot takes integer a returns integer // ~a function BitwiseAnd takes integer a, integer b returns integer // a & b function BitwiseOr takes integer a, integer b returns integer // a | b function BitwiseXor takes integer a, integer b returns integer // a ^ b function BitwiseShl takes integer a, integer b returns integer // a << b function BitwiseShr takes integer a, integer b returns integer // a >> b function Char2Byte takes string a returns integer // Returns the byte value of the first character in the string, or -1 if string is empty // Return value is guaranteed to be in the bound of [0, 256) function Byte2Char takes integer a returns string // Converts the byte into a single character corresponding to that character's value // The argument should be in the bound of [0, 256), if it is not, the returned string should be null //=========================================================================== // FILE I/O //=========================================================================== constant integer FILEMODE_READ = 1 constant integer FILEMODE_WRITE = 2 constant integer FILEMODE_READWRITE = 3 type file extends handle type directory extends handle function FileExists takes string path returns boolean function DirectoryExists takes string path returns boolean function GetDirectory takes string path returns directory // Returns an iterator to a directory's contents // Returns null if path doesn't exist or isn't a directory function ForDirectory takes directory dir, code callback returns nothing function GetEnumPath takes nothing returns string // Callback-style iteration function PopDirectoryPath takes directory dir returns string // Pops a single path from this directory object, allowing us to iterate it using a while loop function OpenFile takes string path, integer mode returns file // Opens a new file, creating it if necessary // There should probably be a restriction on which extensions are allowed // Good candidates are probably ".txt" and ".dat" function OpenFile takes string path, integer mode, player owner returns file // Opens a new file only for a certain player // This is necessary to allow reading/writing locally, because creating a handle locally would desync, so // we need to create it in shared code // Reading/Writing for other players on this handle will have no effect, unless SyncFile has been called, // then reading operations should become available function SyncFile takes file f, player sender returns nothing // (I'm not sure if this should be added or not) Tries to send the contents of an entire file from one players to the rest // Calling this in a local block will read the whole file and start sending it to other players, allowing us to read the file // synchronously in shared code without issues function SyncFileWait takes file f returns nothing // If this can be implemented, it'd be really neat // Pauses the current thread until the file has finished syncing function TriggerRegisterFileSync takes trigger t returns nothing function GetSyncedFile takes nothing returns file // Async events for syncing to signal when it's finished function CloseFile takes file f returns nothing // Flushes the changes and closes the file function GetFileSize takes file f returns integer function SetFileSeekPos takes file f, integer pos returns nothing function GetFileSeekPos takes file f returns integer function IsFileEOF takes file f returns boolean // Checks whether the file has hit EOF function FileReadString takes file f, integer max returns string // Reads the contents of the file into a string, up to specified amount of characters function FileWriteString takes file f, string s returns nothing // Writes the contents of the string into the file as-is, without null-terminators function FileWriteUInt8 takes file f, integer a returns nothing function FileWriteUInt16 takes file f, integer a returns nothing function FileWriteUInt32 takes file f, integer a returns nothing function FileWriteInt8 takes file f, integer a returns nothing function FileWriteInt16 takes file f, integer a returns nothing function FileWriteInt32 takes file f, integer a returns nothing // Natives for reading and writing bytes directly, rather than using a string // Since WC3 runs only on little-endian platforms, these too should probably be little-endian function FileReadUInt8 takes file f returns integer function FileReadUInt16 takes file f returns integer function FileReadUInt32 takes file f returns integer function FileReadInt8 takes file f returns integer function FileReadInt16 takes file f returns integer function FileReadInt32 takes file f returns integer // Natives for reading bytes directly function FileWriteReal takes file f, real a returns nothing function FileReadReal takes file f returns real // Writing/Reading reals //=========================================================================== // SYNCH //=========================================================================== // > METHOD 1 function SyncHashtableParent takes hashtable ht returns nothing // When called locally, will start syncing the contents of this hashtable to other players function SyncHashtableChild takes hashtable ht, integer parentKey returns nothing // Same as SyncHashtable, but only for a child hashtable function SyncHashtableWait takes hashtable ht returns nothing // Pauses the thread until the specified hashtable has finished syncing function TriggerRegisterHashtableSync takes trigger t returns nothing function GetSyncedHashtable takes nothing returns hashtable // Events for hashtable syncs // > METHOD 2 type bytes extends handle function CreateBytes takes nothing returns bytes function DestroyBytes takes bytes b returns nothing function BytesWriteUInt8 takes bytes b, integer pos, integer a returns nothing function BytesWriteUInt16 takes bytes b, integer pos, integer a returns nothing function BytesWriteUInt32 takes bytes b, integer pos, integer a returns nothing function BytesWriteInt8 takes bytes b, integer pos, integer a returns nothing function BytesWriteInt16 takes bytes b, integer pos, integer a returns nothing function BytesWriteInt32 takes bytes b, integer pos, integer a returns nothing function BytesReadUInt8 takes bytes b, integer pos returns integer function BytesReadUInt16 takes bytes b, integer pos returns integer function BytesReadUInt32 takes bytes b, integer pos returns integer function BytesReadInt8 takes bytes b, integer pos returns integer function BytesReadInt16 takes bytes b, integer pos returns integer function BytesReadInt32 takes bytes b, integer pos returns integer function BytesWriteReal takes bytes b, integer pos, real r returns nothing function BytesReadReal takes bytes b, integer pos returns nothing function BytesWriteString takes bytes b, integer pos, string s returns nothing function BytesReadString takes bytes b, integer pos, integer amount returns string function GetBytesSize takes bytes b returns integer // Get the amount of data in this buffer function ReserveBytesCapacity takes bytes b, integer capacity returns nothing // Reserve capacity for this buffer function GetBytesCapacity takes bytes b returns bytes // Get capacity for this buffer function SyncBytes takes bytes b returns nothing // Tries to sync the local contents of this bytes object to other players function SyncBytesWait takes bytes b returns nothing // Pauses the current thread until syncing has finished function TriggerRegisterBytesSync takes trigger t returns nothing function GetSyncedBytes takes nothing returns bytes // Events //=========================================================================== // STREAMLINING //=========================================================================== /* This list of suggested additions is meant as a way to streamline existing processes or change them entirely. */ //Proxies /* Proxies are essentially units - dummy casters to be exact, that are less performance-heavy. They have no collision, no model (though you may attach something to their "origin"), no movement type, nothing. They only move through triggers (SetUnitX/Y) and can cast spells regardless of mana cost, tech requirement, cooldown. They can also cast an unlimited amount of spells without any downtime so potentially only 1 proxy will ever be needed per map, or per player. One key aspect to proxies is that all actions they take is creditted to a source unit, so this way if a proxy kills a unit using a spell, the game will register the source unit as having earned that kill. Depending on the allegiance of the source will determine whether a target can be hit with a spell or not (eg: if the source is an ally of the target of the Proxy, the Proxy cannot cast Storm Bolt at the target). NB: the Proxy type is affected by most of the relevant unit triggers, like SetUnitX/Y and RemoveUnit. It can be added to unit groups, etc. */ function CreateAbilityProxy takes unit source, real x, real y, real z returns proxy //This is essentially a dummy of which all the actions it takes will be credited to the source. function SetProxySource takes proxy dummy, unit source returns nothing //Modifies the source of the proxy. //ApllySpellEffect /* This approach is an attempt to change the way modders apply spells to targets. Rather than using dummy units, what if spells - and their corresponding effect - could be cast directly on a target unit/point? There are multiple ways in which we thought this could happen, but ultimately it's up to the people with the source code who will know how best to do this. */ //Method 1 //The ApplySpellEffect idea will look like spells can be cast at any point, anywhere. However, there's the issue of auras, which means that those natives should probably return something other than a boolean (maybe a spelleffect type?) function ApplySpellEffect takes player owner, real x, real y, integer abilcode returns nothing //returns false for spells that only affect the caster (eg. Storm Crow Form) function ApplySpellEffectTarget takes player owner, unit target, integer abilcode returns boolean //returns null if the target is invalid (eg Spell immune, invulnerable, etc) function ApplySpellEffectPoint takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, integer abilcode returns boolean //returns false on untargertable context (eg Inferno over water, Force of Nature with no trees) function ApplySpellEffectChanneled takes player owner, real x, real y, real timeout, integer abilcode returns boolean //ends after the timer has expired. The timeout overrides the spell's internal duration. function ApplySpellEffectTargetChanneled takes player owner, unit target, real timeout, integer abilcode returns boolean function ApplySpellEffectPointChanneled takes player owner, real xcast, real ycast, real zcast, real xtarget, real ytarget, real timeout, integer abilcode returns boolean //Method 2 //While the above could work, I suppose it's hardly the most elegant solution to go around. User MindWorX suggested the atomic approach: local leveldata data = CreateLevelData() call SetLevelDataDuration(1.00) call SetLevelDataDataA(RealData(10)) call SetLevelDataDataB(RealData(100)) call ApplyBuff(target, 'Ahea', data) //Method 3 //Implement structs and have Struct-based triggers to use. local leveldata data = CreateAbility() set leveldata.Duration = 1.00 set leveldata.DataA = RealData(10) //etc... //=========================================================================== // //===========================================================================
$ sqlite3 jass.db 'select fnname, value from annotations where anname == "bug"'
GetRandomSubGroup|Not an even distribution. See <http://www.hiveworkshop.com/forums/l-715/g-275344/>.
TimerGetRemaining|This might not return the correct value if the timer was paused and
restarted at one point. See <http://www.wc3c.net/showthread.php?t=95756>.
GetExpiredTimer|Might crash the game if called when there is no expired timer.
<http://www.wc3c.net/showthread.php?t=84131>
DestroyImage|May crash the game if an invalid image is used (null, before the first image is created).
SetImageRender|Does not work. Use `SetImageRenderAlways` instead.
SetSoundPitch|This native has very weird behaviour.
See [this](http://www.hiveworkshop.com/threads/setsoundpitch-weirdness.215743/#post-2145419) for an explenation
and [this](http://www.hiveworkshop.com/threads/snippet-rapidsound.258991/#post-2611724) for a non-bugged implementation.
PlayMusic|This native may cause a short lag spike as soon as the music starts. To circumvent this lag, stop the current music without fadeout before calling this function (`call StopMusic(false)`).
PlayMusicEx|This native may cause a short lag spike as soon as the music starts. To circumvent this lag, stop the current music without fadeout before calling this function (`call StopMusic(false)`).
SetTerrainFog|Does nothing
DisplayTimedTextFromPlayer|Using formatters like "%i" will also print garbage and following "%s" wont
work either.
DisplayTimedTextFromPlayer|Only the first "%s" will be replaced correctly. Following "%s" will be
printed as garbage.
CreateQuest|Do not use this in a global initialisation as it crashes the game there.
CameraSetupApplyWithZ|If a player pauses the game after the camerasetup has been applied, the
z-offset of the game camera will change to the z-offset of the camerasetup for that player.
OrderId|Do not use this in a global initialisation as it returns 0 there.
OrderId2String|Do not use this in a global initialisation as it returns null there.
UnitId2String|Do not use this in a global initialisation as it returns null there.
UnitId2String|Always returns null after the game is loaded/if the game is a replay.
AbilityId|Not working correctly
AbilityId2String|Not working correctly
GetObjectName|Do not use this in a global initialisation as it crashes the game there.
ResetUbersplat|Does nothing.
FinishUbersplat|Does nothing.
LoadGame|The filename seems to have some limitations:
- No underscores in campaign names.
- Shorter file names for savegames.
- Probably no dots in savegames or campaign names.
For more info see <http://www.hiveworkshop.com/threads/map-transition-does-not-work-when-loading-a-custom-savegame.286927/>
GetEventPlayerChatString|This function only returns `""` when called in response to `EVENT_PLAYER_CHAT`.
GetEventPlayerChatStringMatched|This function only returns `""` when called in response to `EVENT_PLAYER_CHAT`.
AddSpellEffect|Does nothing.
AddSpellEffectLoc|Does nothing.
GetAbilityEffect|Does nothing.
GetAbilitySound|Does nothing.
GroupEnumUnitsOfTypeCounted|Causes irregular behavior when used with large numbers
GroupEnumUnitsInRectCounted|Causes irregular behavior when used with large numbers
GroupEnumUnitsInRangeCounted|Causes irregular behavior when used with large numbers
GroupEnumUnitsInRangeOfLocCounted|Causes irregular behavior when used with large numbers
FirstOfGroup|May return `null` even if there are still units in the group.
This happens when a unit in the group dies and decays since the group still
holds a reference to that unit but that unit is pretty much null.
See <http://wc3c.net/showthread.php?t=104464>.
CreateMultiboard|Do not use this in a global initialisation as it crashes the game there.
MultiboardDisplay|`MultiboardDisplay(mb,false)`, where mb is an arbitrary non-null multiboard
will close any open multiboard, regardless of whether it's `mb` or not.
<http://www.wc3c.net/showthread.php?p=971681#post971681>
MultiboardSetRowCount|It is only safe to change the row count by one. Use multiple calls for bigger values.
<http://www.hiveworkshop.com/forums/l-715/m-250775/>
<http://www.hiveworkshop.com/forums/t-269/w-234897/>
GetRandomInt|If you call `GetRandomInt(INT_MIN, INT_MAX)` or `GetRandomInt(INT_MAX, INT_MIN)`
it will always return the same value, namely `INT_MIN` or `INT_MAX`.
Player|Crashes the game if used with wrong values, that is values greather than 15
or values lower than 0.
DestroyTrigger|Do not destroy the current running Trigger (when waits are involved) as
it can cause handle stack corruption as documented [here](http://www.wc3c.net/showthread.php?t=110519).
CreateLeaderboard|Do not use this in a global initialisation as it crashes the game there.
GetLocalizedString|Cannot assign it to a constant variable as it will crash the game.
`constant string foo = GetLocalizedString("bar")`
SetUnitScale|Only takes scaleX into account and uses scaleX for all three dimensions.
UnitModifySkillPoints|If `skillPointDelta` is positive but greater than 10 only 10 points will
be added but negative `skillPointDelta` works as expected with
values smaller than -10.
AddHeroXP|If the value will become lower than zero, the experience won't
be negative, instead of it it'll be equal
to `4294967296+(supposed_negative_experience_value)` which actually proves
that WarCraft III uses unsigned int type for storing experience points.
AddHeroXP|Adding negative value to experience will decrease it
by the stated value, but won't lower the level even if the experience value
after deduction is lower than the lower bound of the experience required to get
the stated level.
GetUnitX|If the unit is loaded into a zeppelin this will not return the position
of the zeppelin but the last position of the unit before it was loaded into
the zeppelin.
GetUnitY|If the unit is loaded into a zeppelin this will not return the position
of the zeppelin but the last position of the unit before it was loaded into
the zeppelin.
GetUnitLoc|If the unit is loaded into a zeppelin this will not return the position
of the zeppelin but the last position of the unit before it was loaded into
the zeppelin.
UnitDamagePoint|Has been known to cause crashes in battle.net
AddResourceAmount|If the value after adding negative amount will be less than zero, then it
will display negative resource amount, but if some peasant or peon will try to
gather resources from such a mine, he will bring back 0 gold and the mine will
be auto-destroyed.