找回密码
 点一下
查看: 2038|回复: 14

caster system 的部分内容

[复制链接]
发表于 2008-12-8 20:39:16 | 显示全部楼层 |阅读模式
[jass]
* Casting functions
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These were the original intention of the caster system, functions that save you the job of having
to make dummy caster triggers every time.
______________________________________________________________________________________________________________________________________________________________________
function CasterCastAbility takes player owner, integer abilid, string order, unit target, boolean instant returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Calls a Caster to cast an ability for a player on an unit, abilid is the ability's
    rawcode inside '' (ex: 'Aloc'), you must also give it the ability's orderstring, if the
    ability doesn't have an order string use the Order Id betwen quotes (ex: "782042").

    * The instant boolean determines the way of recicling the caster, when it is true it will
    recycle the caster instantly, and when it is false will wait until the caster finishes
    casting the ability.

    * Returns the caster used, so if the spell is channeling you can choose when to order the caster
    to stop the ability.

    * The Rune of Bloodlust is an example of using this function, the Rune of Illusions shows
    how to use special orderids.
______________________________________________________________________________________________________________________________________________________________________
function CasterCastAbilityPoint      takes player owner, integer abilid, string order, real x, real y, boolean instant returns unit
function CasterCastAbilityPointLoc   takes player owner, integer abilid, string order, location loc, boolean instant returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will make a caster cast a point order ability on a point, the difference betwen the first
    one and the loc version is that CasterCastAbilityPoint uses reals for x and y,
    CasterCastAbilityPointLoc uses a location (point) argumment that has to be saved / removed to
    avoid memory leaks.

    * It also works with no target orders like thunder clap, or Essence of blight.

    * Returns the caster used, so if the spell is channeling you can choose when to order the caster
    to stop the ability.

    * See the Muradins Hammer and the Firewall sample triggers as an example of the usage of these
      functions,
______________________________________________________________________________________________________________________________________________________________________
function CasterUseAbilityStatic      takes player owner, string modelpath, integer abilityid, real duration, real x, real y returns unit
function CasterUseAbilityStaticLoc   takes player owner, string modelpath, integer abilityid, real duration, location loc returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will leave a caster with a given special effect and a given passive ability on a point for a given
    duration, good to use this with phoenix fire or auras. Leave modelpath as "" if you don't want the
    caster to be visible.

    * See the Poisonous Weeds sample trigger to see an usage example on this function.
______________________________________________________________________________________________________________________________________________________________________
function CasterCastAbilityAOE      takes player owner, integer abilid, string order, real x, real y, real radius, boolean goodeffect, boolean instant returns nothing
function CasterCastAbilityAOELoc   takes player owner, integer abilid, string order, location center, real radius, boolean goodeffect, boolean instant returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * The AOE versions of CasterCastAbility, radius determines the area of effect, x and y or
    center determine the center of the area of effect. The boolean goodeffect determines if
    the spell will work on allies or enemies. (This is only for abilities with target orders)

    * See the Sheep Staff sample trigger as an example of the usage of this function as a bad
      effect, the Scroll of Rejuvenation sample trigger is an example of this function as a good
      effect, the Thors Hammer sample trigger as an example of non instant abilities.
______________________________________________________________________________________________________________________________________________________________________
function CasterCastAbilityGroup    takes player owner, integer abilid, string order, group targetgroup, boolean instant returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will make casters to cast an ability on a Unit Group, It will affect every unit in the group
    and remember that the set bj_wantDestroyGroup hack will work on this function.

    * See the Cripple Everything sample trigger as an example of the usage of this function.
______________________________________________________________________________________________________________________________________________________________________________________________
function CasterCastAbilityLevel           takes player owner, integer abilid, integer level, string order, unit target, boolean instant returns unit
function CasterCastAbilityLevelPoint      takes player owner, integer abilid, integer level, string order, real x, real y, boolean instant returns unit
function CasterCastAbilityLevelPointLoc   takes player owner, integer abilid, integer level, string order, location loc, boolean instant returns unit
function CasterUseAbilityLevelStatic      takes player owner, string modelpath, integer abilityid, integer level, real duration, real x, real y returns unit
function CasterUseAbilityLevelStaticLoc   takes player owner, string modelpath, integer abilityid, integer level, real duration, location loc returns unit
function CasterCastAbilityLevelAOE        takes player owner, integer abilid, integer level, string order, real x, real y, real radius, boolean goodeffect, boolean instant returns nothing
function CasterCastAbilityLevelAOELoc     takes player owner, integer abilid, integer level, string order, location center, real radius, boolean goodeffect, boolean instant returns nothing
function CasterCastAbilityLevelGroup      takes player owner, integer abilid, integer level, string order, group targetgroup, boolean instant returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * These are the same as the functions I already mentioned, but you can specify the level in the level
    integer parameter, this is specially useful when making hero spells.

    * The blinding Light trigger sample uses CasterCastAbilityLevelAOELoc .

______________________________________________________________________________________________________________________________
function CasterSetCastSource     takes real x, real y returns nothing
function CasterSetCastSourceLoc  takes real x, real y returns nothing
set udg_sourcehack = location (JASS)      |      set sourcehack = Point (GUI)
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will set the position where casters are moved before casting an ability, so you can make
      them cast an ability from the point determined by this function, by default the point where
      casters appear is the position of the target, use this to temporary change it.

    * This will only affect the Caster System functions that are next to this call, after a wait
      or in another instance of the trigger you'll have to set this again.

    * You can get the same effect if you set the value of the sourcehack variable, but don't ever
      forget to set it to null after calling the functions you want to affect.

    * See the Blessed Sword and Thors Hammer sample triggers to see an usage example on this hack.

______________________________________________________________________________________________________________________________
function CasterSetRecycleDelay    takes real Delay returns nothing
set udg_delayhack = Real (JASS)           |      Set delayhack = Real (GUI)
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will set the wait time before recicling a caster if you used false as instant argument, by
      default the Caster System will wait till the caster is not casting that ability before
      recycling it, use this to also add an extra delay before recycling it.

    * This will only affect the Caster System functions that are next to this call, after a wait
      or in another instance of the trigger you'll have to set this again.

    * The delayhack global variable determines the time the system will wait before recicling
      the casters used in a function when the ability is not instant. If you were experiencing
      that damage abilities were not giving bounty/experience if the kill was after a while from
      the time the casters cast the ability, set delayhack to the maximum time the damage can
      take. Always set delayhack to 0.00 after calling the functions.

    * See the Thor's hammer, the Blessed Sword and the Fire Wall sample triggers to see an
      usage example on this hack.

___________________________________________________________________________________________________________________________________________________________________________________________________________
function CasterCastAbilityEx           takes player owner, real x, real y, real z, integer abilid, integer level, string order, widget target, real delay returns unit
function CasterCastAbilityExLoc        takes player owner, location source, real z, integer abilid, integer level, string order, widget target, real delay returns unit

function CasterCastAbilityPointEx      takes player owner, real x1, real y1, real z1, integer abilid, integer level, string order, real x2, real y2, real delay returns unit
function CasterCastAbilityPointExLoc   takes player owner, location loc, real z1, integer abilid, integer level, string order, real x2, real y2, real delay returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * These versions of CasterCastAbility and CasterCastAbilityPoint, allow you to choose everything,
    including the level of the ability, the source point and ELEVATION and the recycle delay.

    * They IGNORE CasterSetCastSource and CasterSetRecycleDelay , also udg_delayhack and udg_sourcehack

______________________________________________________________________________________________________________________________
function GetACaster                 takes nothing returns unit
function RecycleCaster              takes unit caster returns nothing
function RecycleCasterAfterCast     takes unit caster, integer abilid returns nothing
function RecycleCasterAfterCastEx   takes unit caster, real delaytime, integer abilid, boolean activeability returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * These are functions that you may find useful in certain situations.

    * GetACaster will return an available caster or create one if necessary. (Will mark it as
      unavailable )

    * RecycleCaster will make the caster available again, and reset stuff from movement
      speed to scale.

    * RecycleCasterAfterCast will wait until the caster stops casting an ability, remove the
      ability then wait udg_delayhack seconds, then recycle the caster, it uses its own thread.

    * RecycleCasterAfterCastEx will wait until the caster stops casting the ability, then if the
      argument activeability is false remove the ability, then wait delaytime seconds, then if
      activeability was true remove the ability, then recycle the caster.

    * Check the IceWave and the Shield of divinity Trigger samples to see usage examples on this
    functions.
______________________________________________________________________________________________________________________________
function CreateCasters   takes integer N returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will Create a N number of casters ( ex: call CreateCasters(5) ) use it at map initialization.
______________________________________________________________________________________________________________________________
function PreloadAbility  takes integer abilid returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Having lag the first time a caster uses an ability?, Use call PreloadAbility( 'Abil') at
    map initialization, (Being 'Abil' the Ability's rawcode betwen '' (once again the 'Aloc'
    example) (This command should be after CreateCasters()

    * This Map's Caster Setup trigger is an example on the usage of CreateCasters and
    PreloadAbility. JASS spells can have PreloadAbility in their InitFunction (Check IceWave
    and Shield of divinity)


______________________________________________________________________________________________________________________________
function AddCaster         takes nothing returns unit
function AddCasterFacing   takes real fac returns unit
function CreateCaster      takes real fac, real x , real y returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Functions that Create a Caster you can then use for stuff like moving special effects. Sometimes you'd have to use
these instead of GetACaster , but note that then the Caster should not be recycled. AddCaster simply creates a caster you
can then move. AddCasterFacing creates a caster and makes sure it faces
a specific direction, this is important because of eye candy reasons. You can't change a unit facing instantly and the
only way to get a missile that points to an angle without having eye candy issues is to use AddCasterFacing.

CreateCaster is AddCasterFacing but allows you to set starting position by x and y.





[/jass]
 楼主| 发表于 2008-12-8 20:42:10 | 显示全部楼层
Damage and project
[jass]

  Whenever you read damageoptions, remember that all the information related to damageoptions
is in the Appendix A , which is in the Damage and Target Options trigger.

* Damage and projectile functions
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Someday I decided to add damaging functions to the caster system, that was in the times when there
wasn't any way to make flexible damage with triggers considering bounty and experience.

   Later Blizzard made patch 1.17 and thanks to my suggestions in bnet forums, they added the damage
functions, so know the caster system functions play more of an auxiliar role to help blizzard's damage
natives to do what you want.

   Projectile functions are a result of the lack of moving special effect options, they lack something
and it is that because of the unit movement speed limit they can't be faster than 522, but they can
be really useful.

___________________________________________________________________________________________________________________________________________________________________________________________________________
function GetDamageFactor            takes unit u,attacktype a, damagetype d returns real
function GetDamageFactorByOptions   takes unit hurter, unit target, integer DamageOptions returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * GetDamageFactor Will return the factor for specific damage and attack types for the unit u.

    * GetDamageFactorByOptions uses an unit argument that determines the unit that would do the
    damage, and uses DamageOptions, DamageOptions are a conjunctions of flags that determine what
    to do, see Appendix A for more information.
___________________________________________________________________________________________________________________________________________________________________________________________________________
function DamageUnitByTypes     takes unit hurter, unit target, real dmg, attacktype attT, damagetype dmgT returns boolean
function DamageUnitByOptions   takes unit hurter, unit target, real dmg, integer DamageOptions returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * The normal target damage function , but calls the last functions.
    * I had to create DamageUnitByTypes, Blizzard's native ignores the damage type, this function
      won't ignore the damage type, and once blizzard fixes the bug it will be deprecated.
    * Alternativelly DamageUnitByOptions, uses a DamageOptions argument, you have to see
      Appendix A for more information.
___________________________________________________________________________________________________________________________________________________________________________________________________________
function UnitDamageUnitTimed takes unit hurter, real damageps, real damageperiod, real duration, unit target, string modelpath, string attachPointName, attacktype attT, damagetype dmgT returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will add damage per second for an unit to a unit, hurter is the damaging unit, duration
    is self explanatory, damageps is the damage per second, target is the unit to affect,
    damageperiod is the time before the unit takes the damage again note that damageperiod
    values lower than ~0.4 will be considered ~0.4

    * You can set modelpath to a special effect and attachPointName is the attachment point,
    but if you don't want it to have a special effect use "" for the modelpath and attachment.

    * Last 2 options are the attacktype and damagetype values, check appendixex B and C for more
    information.

    * Also you can turn this function into a healing per second by using a negative value for damageps.
_____________________________________________________________________________________________________________________________________________________________________
function DamageUnitsInAOEEx      takes unit hurter, real damage, real x, real y, real radius, boolean affectallied, integer DamageOptions returns nothing
function DamageUnitsInAOEExLoc   takes unit hurter, real damage, location loc, real radius, boolean affectallied, integer DamageOptions returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Perform AOE damage on an area for an unit useful when UnitDamagePoint doesn't have enough
    options for you.

    * if affectallied is true will affect non-enemy
    units too. x and y or loc determine the center of the circle, and radius the radius

    * DamageOptions are a conjunctions of flags that determine what to do, see Appendix A for
    more information.

    * See the Light of Redemption Sample Trigger for an usage example.
______________________________________________________________________________________________________________________________________________________________________
function DamageUnitGroupEx takes unit hurter, real damage, group targetgroup, integer DamageOptions returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Performs damage on an unit group, it will affect every unit in the unit group, depending
    on the damage options,  and remember that the set bj_wantDestroyGroup = true will work for
    this function.

    * Keep in mind that DamageTrees() doesn't work with this.
______________________________________________________________________________________________________________________________________________________________________
function AddAreaDamagerForUnit      takes unit hurter, string modelpath, string targetart, string targetattach, real x, real y, real damage , real damageperiod, real duration, real area, boolean affectallies, integer DamageOptions returns unit
function AddAreaDamagerForUnitLoc   takes unit hurter, string modelpath, string targetart, string targetattach, location loc, real damage , real damageperiod, real duration, real area, boolean affectallies, integer DamageOptions returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will create a special effect at a point with a duration and each second will damage the units
    in an area around the effect, the effect is a unit and that unit is returned by the function, you
    can use the currentcaster variable to get the effect unit, you can move the unit or change its
    size / color.

    * targetart is the special effect that appears on the units affected by the damage,
    targetattach is the attachment point for that effect and damageperiod is the period of time
    before each moment the damage does effect

    * You can also use a huge number (1000000) as duration and call RecicleCaster() on it
     to stop it, instead of making it have a fixed duration.

    * DamageOptions are a conjunctions of flags that determine what to do, see Appendix A for
    more information.

    * See the Poisonous Weeds and the The deadly fire star sample triggers to see usage
      examples on this function.

    * You can use 0 area, and 0 damage, to use this function for just the effect, it would allow
    you to easily have effects with duration, the 'Deadly Fire Star Effect' sample does that.

_______________________________________________________________________________________________________________________________________________________________________________________________
function ProjectileLaunch            takes string modelpath, real speed, real arc,real x1, real y1, real z1, real x2, real y2, real z2 returns nothing
function ProjectileLaunchLoc         takes string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2 returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will Create A missile effect from place1 to place2, x1 and y1 determine the starting
    position of the missile, z1 determines its starting flying height, x2 and y2 the target
    position and z2 the target height.

    * Modelpath determines the model used, must be betweeen quotes and needs to have double '\\',
    example: "abilities\\\\weapons\\\\DemolisherMissile\\\\DemolisherMissile.mdl".

    * Speed and Arc should work like the missiles in the object editor, Arc is a real number
    between 1 and 0. ex: 0.15

    IMPORTANT : This is valid for every projectile function, There are 2 modes for the projectile
    functions, one looks really good and allows any positive speed value,
    but is bad efficiency-wise, the other one looks ok, and will only happen with speed that are
    less than or equal to 522 (and greater than 0).

    Speed is a positive real number, when speed is less than or equal to 522, the projectile
    function would use the normal unit movement, but if it is greater than 522 it will use a timer
    with gamecache allowing high speeds, but the second mode has one problem: It is not too
    efficient and it would cause problems if you use way too many of them at the same time.

    * The ProjectileLaunchLoc uses location arguments instead of x and y coordinates, loc1
    determines the starting position and loc2 the target position.

    * Stops threads (The trigger that uses this function will wait until the missile effect
    reaches to the target)
_____________________________________________________________________________________________________________________________________________________________________________________________________________________________
function ProjectileLaunchEx          takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc,real x1, real y1, real z1, real x2, real y2, real z2 returns nothing
function ProjectileLaunchExLoc       takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, location loc1, real z1, location loc2, real z2 returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Extended versions of ProjectileLaunch, let you specify the scale and vertex coloring used
    by the projectily, colors and alpha (opacity) are in integers from 0 to 255.
__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
function DamagingProjectileLaunchAOE    takes unit hurter, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2, real aoeradius, real damage, boolean affectallied, integer DamageOptions returns unit
function DamagingProjectileLaunchAOELoc takes unit hurter, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2, real aoeradius, real damage, boolean affectallied, integer DamageOptions returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Like the previous function but doesn't stop the thread and will deal damage for the
    hurter unit to the units in the target area, will return the missile unit used, damage,
    aoeradius, affectallied  and DamageOptions work like the AOEDamage functions.

    * See the Grenade and Stone of Lightning sample triggers to see usage examples of these functions.

    * Returns the missile unit created, you can change its scale / vertex coloring with using
    the returned unit, you can also use the unit variable currentcaster .
_______________________________________________________________________________________________________________________________________________________________________________________________
function ProjectileLaunchKill        takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2 returns unit
function ProjectileLaunchKillLoc     takes player owner, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2 returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Will create a missile effect, won't stop the thread and will kill the missile unit once it
    reaches the target position, use a dead event to know when this kind of missile effect comes
    to its target.

    * Returns the missile unit created, you can change its scale / vertex coloring with using
    the returned, unit you can also use the unit variable currentcaster.
______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
function ProjectileLaunchToUnit        takes string modelpath, real speed, real arc,real x1, real y1, real z1, unit target, real zoffset returns nothing
function ProjectileLaunchToUnitLoc     takes string modelpath, real speed, real arc, location loc1, real z1, unit target, real zoffset returns nothing
function ProjectileLaunchToUnitEx      takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset returns nothing
function ProjectileLaunchToUnitExLoc   takes player owner, string modelpath, real scale, integer red, integer green, integer blue, integer alpha, real speed, real arc, location loc1, real z1, unit target, real zoffset returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * The same as ProjectileLaunch but uses an unit argument instead of a second point, zoffset is
    the height difference between the target flying height and the final height for the projectile,
    like ProjectileLaunchEx, ProyectileLaunchToUnitEx is the extended version.

    * The projectile is homing, if you don't want it to be homing use the normal projectile functions
    and make them go to the position of the target unit.
______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
function DamagingProjectileLaunchTarget takes unit hurter, string modelpath, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset, real damage, attacktype attT, damagetype dmgT returns unit
function DamagingProjectileLaunchTargetLoc takes unit hurter, string modelpath, real speed, real arc, location loc, real z1, unit target, real zoffset, real damage, attacktype attT, damagetype dmgT returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    * Like the last functions but won't stop the thread and will hurt the target unit.

    * attT and dmgT determine the attack and damage types, (like the ones that blizzard functions
    take, for more info see appendixes B and C.

    * Use the returned unit or the currentcaster variables to know the projectile.

    * See the Green Fire balls trigger sample for an usage example for this function.


* Appendix E: Deprecated functions:
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These functions were used in the pre patch 1.17 caster system versions, I left them
here for compatibility, and in case you find an use for them.
___________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
function DamageUnit                        takes player hurter, real damage, unit victim returns boolean
function DamageUnitTimed                   takes player owner, real damageps, real duration, unit target, string modelpath, string attachPointName returns nothing
function DamageUnitTimedEx                 takes player owner, real damageps, real damageperiod, real duration, unit target, string modelpath, string attachPointName returns nothing
function DamageUnitsInAOE                  takes player hurter, real damage, real x, real y, real radius, boolean affectallied returns nothing
function DamageUnitsInAOELoc               takes player hurter, real damage, location loc, real radius, boolean affectallied returns nothing
function DamageUnitGroup                   takes player hurter, real damage, group targetgroup returns nothing
function AddDamagingEffect                 takes player owner, string modelpath, real x, real y, real damageps , real duration, real area, boolean affectallies returns unit
function AddDamagingEffectLoc              takes player owner, string modelpath, location loc, real damageps , real duration, real area, boolean affectallies returns unit
function AddDamagingEffectEx               takes player owner, string modelpath, string targetart, string targetattach, real x, real y, real damage , real damageperiod, real duration, real area, boolean affectallies returns unit
function AddDamagingEffectExLoc            takes player owner, string modelpath, string targetart, string targetattach, location loc, real damage , real damageperiod, real duration, real area, boolean affectallies returns unit
function ProjectileLaunchDamage            takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, real x2, real y2, real z2, real aoeradius, real damage, boolean affectallied returns unit
function ProjectileLaunchDamageLoc         takes player owner, string modelpath, real speed, real arc, location loc1, real z1, location loc2, real z2, real aoeradius, real damage, boolean affectallied returns unit
function ProjectileLaunchToUnitDamage      takes player owner, string modelpath, real speed, real arc, real x1, real y1, real z1, unit target, real zoffset, real damage returns unit
function ProjectileLaunchToUnitDamageLoc   takes player owner, string modelpath, real speed, real arc, location loc1, real z1, unit target, real zoffset, real damage returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    A good thing about them is that they only need a player argument instead of an unit, they
will use the defaults on the top of the caster system functions.
[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:44:03 | 显示全部楼层
[jass]

* Collision Missiles
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Note: Collision missiles' creation is kind of blocked if done too close to the map bounds.

    Collision Missiles are projectiles, but they don't use parabolic movement, they have collision
and you can detect when the projectiles hit an unit, and you can also destroy Collision Missiles
when you need to.
_______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
function CollisionMissile_Create      takes string MissileModelPath, real x, real y, real dirangle, real speed, real AngleSpeed, real MaxDist,  real height, boolean UseNewCaster, real Collision, code OnImpact returns unit
function CollisionMissile_CreateLoc   takes string MissileModelPath, location loc, real dirangle, real speed, real AngleSpeed, real MaxDist,  real height, boolean UseNewCaster, real Collision, code OnImpact returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    As always, CollisionMissile_CreateLoc is the version that uses point instead of coordinates,
MissileModelPath is the path of the model of the missile.

* real dirangle is the Angle of the Direction of the missile

* real speed is the movement speed of the missile

* real AngleSpeed should often be 0, is the angle increment per second for the direction, so you
can make Impact missiles that don't go in straight lines.

* real MaxDist is Seriously an important value and determines the duration of the missile, it
determines the maximum wc3 distance units the missile can travel.

* real height is just the flying height of the missile

* boolean UseNewCaster .- This is blizzard's fault, since for no reason It is impossible to
instantly change a unit's facing angle, and to have a unit facing an angle instantly you have to
create it, when UseNewCaster is true it will create a new caster, it will be slow in masses but
it will look right, if UseNewCaster is false it will be efficient in masses but the initial
facing angle of the missile won't be right most of the times.

Aboid to use true unless the model for the missile has a noticeable front.

* real Collision the collision size of the missile.

* code OnImpact , most important part of CollisionMissile is their collision and the ability they
give to you to know when they hit something, use this argument to specify a function to be called
when the projectile hits a unit.

Because of this, you would have to use Pure JASS if you want to call CollisionMissile_Create .

This function will be called whenever the missile encounters a unit, Use GetTriggerUnit()
(Triggering unit) to now the unit that was hit by the missile.

NOTE: It will ALSO be executed when the Missile is destroyed because of the Maximum distance,
Map Bounds or manually destroyed by user, in that case GetTriggerUnit() will be null . I made
it because I thought it would be good to be able to detect that.

* The returned unit is the CollisionMissile, use it to Attach Information on it, change team
color, scale or other stuff.

Check The Sample Trigger Inferno for an example about CollisionMissiles.

_____________________________________________________________________________________________________
function GetTriggerCollisionMissile    takes nothing returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    You detected when the missile hit a unit, great, but you may need to know which Missile Hit
the unit, then you use this Event Response.

    This function should be able to survive waits, but I won't recomend waits on functions called
with collisions, because the missile might be destroyed in the process and that would cause caos.
_____________________________________________________________________________________________________
function CollisionMissile_Destroy takes unit m returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    This is useful when you want Non Homing projectiles that hit units and explode because of that.
You may also find it useful on other situations, What this function does is destroying a
CollisionMissile , remember that the OnImpact function will be called when this happens.

_____________________________________________________________________________________________________
function CollisionMissile_SetAngleSpeed      takes unit m, real newAspeed returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Allows you to change a CollisionMissile's angle speed
_____________________________________________________________________________________________________
function CollisionMissile_SetSpeed           takes unit m, real newspeed returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Allows you to change a CollisionMissile's Movement speed. As a matter of fact, negative speed
values are allowed and make the missiles go backwards

_____________________________________________________________________________________________________
function CollisionMissile_PeriodicFX         takes unit m, string fx, real dur returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Adds an effect that spawns and is destroyed periodically to the effect, m is the collision
missile, fx is the path of the effect, and dur is the spawn delay.


* CollisionMissiles: Targets
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    CollisionMissiles may now have targets, when they have a target the collision missiles will
still advance to their speed, but will try to turn to the direction of the target, A
CollisionMissile must have a non zero AngleSpeed in order to be able to 'follow' targets.
_____________________________________________________________________________________________________
function CollisionMissile_SetTargetPoint     takes unit m, real tx, real ty returns nothing
function CollisionMissile_SetTargetPointLoc  takes unit m, location tloc returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Makes the CollisionMissile 'm' consider the given point as a target, the first one is the
coodinate version and the second one is the location version

_____________________________________________________________________________________________________
function CollisionMissile_SetTarget          takes unit m, widget Target returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Makes the CollisionMissile consider the widget 'Target' as a its target, although you can use
destructables and items as widgets I suppose that this is only good for unit values.

_____________________________________________________________________________________________________
function CollisionMissile_ForgetTarget       takes unit m returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Makes the CollisionMissile forget any target.

   Of course, you can make a CollisionMissile change its target everytime you want.




[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:44:41 | 显示全部楼层
[jass]

    Caster System comes with functions like AddAreaDamagerForUnit, that use a effect that
deals damage periodically to the area, It has some problems:

    - The period of time is inaccurate and limited
    - They use a big loop
    - When used in groups they are imbalanced because 2 or more AreaDamagers can damage
      the same unit, so you have to make sure their area is small enough so a unit is damaged
      by only one of them.
    - When used in groups they lag the game out.

    I decided to add DamagerGroups as an alternative when you have these issues, specially
to be used in groups, they are also really flexible unlike that AddAreaDamagerForUnit and
derivated functions, and I was trying to simulate object oriented programming this time.

* DamagerGroup
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    DamagerGroup is the main class here, it determines the damage, damage period, area and
damageoptions used.

    We can pretend DamagerGroup inherits from Timer.
________________________________________________________________________________________________________________________________________________
function DamagerGroup_Create    takes unit hurter, real damage, real damageperiod, real area, integer DamageOptions returns timer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Constructor of DamagerGroup.

    Creates a DamagerGroup for unit hurter (this means the damage will credit that unit) ,
damage is the damage it will do, damageperiod the Period of time in seconds for each damage
wave, area the Area of effect of the damage (per Damager) , and it uses DamageOptions as well.

    The area is used for each Damager in the group.

    Note that this function will not make any damage by itself, you'd have to add Damagers
to the DamagerGroup before it has any effect.

    The minimum damageperiod is 0.01, but note that a damageperiod of 0.01 means a periodic
timer of 0.01 seconds that is executed and executed every time, then picks a lot of units
uses gamecache and damage options, don't expect to use low values like 0.03, 0.02 and 0.01
without Lag Problems. I would actually recomend 0.2 as the minimum for DamagerGroups.

________________________________________________________________________________________________________________________________________________
function DamagerGroup_AddDamager   takes timer DamagerGroup, string modelpath, real x, real y, real LifeSpan returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Now this is the way to use DamagerGroups , with this function you create a damager for the
DamagerGroup, this created Damager is returned and you can use the Damager functions on it.

DamagerGroup is the timer that is returned by DamagerGroup_Create , in other words it is the
              DamagerGroup that you want to have a new Damager

modelpath    is the path of the model for the Damager .

real x and y are the coordinates of the point you want to locate the Damager

LifeSpan is the maximum duration of the Damager, after this time in seconds, the Damager
is self destructed, if you use 0 here it will last forever or until you change its lifespan,
remove the Damager, or the DamagerGroup is Destroyed.
________________________________________________________________________________________________________________________________________________
function DamagerGroup_AddDamagerLoc   takes timer DamagerGroup, string modelpath, location loc, real LifeSpan returns unit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  Does the same as DamagerGroup_AddDamager, but uses a location (point) as argument instead
of coordinates.

________________________________________________________________________________________________________________________________________________________
function DamagerGroup_Update    takes timer DamagerGroup, unit hurter, real damage, real damageperiod, real area, integer DamageOptions returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  You may want to change a DamagerGroup 's options, use this function for that, DamagerGroup
is the DamagerGroup you want to change (duh) , the rest works like the constructor.

  This will affect the DamagerGroup and because of that it affects the Damagers used by the
DamagerGroup .

________________________________________________________________________________________________________________________________________________________
function DamagerGroup_Destroy   takes timer DamagerGroup returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  Deconstructor of DamagerGroup.

  Destroys a DamagerGroup, meaning this will remove any memory used by the DamagerGroup,
will also Remove the Damagers used by the DamagerGroup.

________________________________________________________________________________________________________________________________________________________
function DamagerGroup_SetLifeSpan   takes timer DamagerGroup, real lifespan returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  Sets the Duration in seconds of the DamagerGroup, meaning that after (lifespan) seconds
the DamagerGroup will call DamagerGroup_Destroy over itself, Each time you use this function
the previous times you used it over that DamagerGroup will be ignored.
________________________________________________________________________________________________________________________________________________________
function DamagerGroup_AutoDestruct  takes timer DamagerGroup, boolean auto returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  Sets a DamagerGroup to destroy itself once it has no Damagers remaining, you should set this
to true only after the DamagerGroup got some Damagers that have lifespan durations.

* Damager
ˉˉˉˉˉˉˉˉˉ
    Damager is a class that is used by DamagerGroup, Damagers are the effects that make the
DamagerGroup deal damage over the units around (area of DamagerGroup) of each Damager.

    Let's pretend that Damager is a class that inherits from unit, well it actually inherits
from the Caster System's casters but are they a class ? Actually nothing here is a class
there is no Object Oriented Programming in JASS so I don't know what the hell I am talking
about. Its constructor is DamagerGroup_AddDamager , but how could it have a constructor
if it is not a class afterall ? Whatever is happening here is a great lie.

    You can freely use unit natives on Damagers like changing colors, position, scale and
flying height.

________________________________________________________________________________________________________________________________________________________
function Damager_Remove       takes unit Damager returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Deconstructor, will Destroy a Damager (it will actually recycle the caster) It will
destroy its effect, and it will no longer do damage nor be considered a part of a
DamagerGroup.

________________________________________________________________________________________________________________________________________________________
function Damager_SetAbility   takes unit Damager, integer abilid, integer l returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    I thought it might be useful to be able to add abilities to Damagers, why? I don't know
but I can think of at least two uses for this:

- Damagers have a disadvantage towards AddAreaDamagerForUnit and derivates, and it is that
they don't have target effects, I didn't add them because they would have been major anti
efficiency features, but you can use an ability to create the effects.

- You may also want to use an extra effect for the Damagers themselves.

    Why use this instead of UnitAddAbility ? because whatever you add with UnitAddAbility
will not be removed when recycling the caster, and after that the caster might be used
for something else and it will have the ability you added to it, let's say it will screw
everything.

________________________________________________________________________________________________________________________________________________________
function Damager_SetLifeSpan takes unit Damager, real lifespan returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Will change a Damager's LifeSpan, in other words the Damager will be self destructed
after LifeSpan seconds, using this will make it ignore the LifeSpan argument you gave when
creating the Damager, and it will also ignore any previous usage of this function over that
Damager. Using 0 for lifespan means it will never be selfdestructed.


[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:45:15 | 显示全部楼层
[jass]

* Appendix A: Damage Options
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Damage options are important when using aoe damage functions, they can help you specify a lot
of things, and are an addition for 1.17 , because the old functions got obsolette with 1.17
in case you didn't note.

   Latelly I have been using them a lot to configure my spells too. Since they were invented for
the damage functions, they are called Damage Options, but they should have been called Target
options for their skill to help me configure immunity to spells.

   One important note is that they can't really work in variables, you can't save Damage Options
in a variable and use it 6 seconds after you save them, each time you make some DamageOptions
they will keep the values till the next time you use damage options. Fortunally you can save
them in a variable if you use the variable INSTANTLY after saving it, no waits nor other functions
between the damage options and the functions please.

   DamageOptions is often an integer, if you use 0 as value there, it works as a default gatherer
you can set the default attack type and damage type at the top of the caster system functions,
so if there are a pair of attack type and damage type you almost always use, you can set them to
whatever you want.
__________________________________________________________________________________________________________
function DamageTypes takes attacktype attT, damagetype dmgT returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Specifies the Damage and Attack type (the ones used by blizzard's UnitDamage functions ) ,
they determine how the damage acts on different armors and ethereal / magic immune and that stuff,
for more info on damage and attack types see Appendixes B and C.

Example : DamageTypes(ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL)

   Makes the attack type chaos and the damage universal.

* flags:
__________________________________________________________________________________________________________
function DamageException takes unittype Exception, real ExceptionFactor returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Specifies a unit classification that uses a special factor for the damage, for more info about
unittypes (classifications) see appendix C, if factor is 0 then it doesn't harm the units with
that classification.

Example : DamageException(UNIT_TYPE_STRUCTURE,0.33)

   Will Make structures take 33 percent of the given damage.
__________________________________________________________________________________________________________
function DamageOnlyTo takes unittype ThisUnitType returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Makes the damage functions ignore any unit that doesn't have the given classification.

Example : DamageOnlyTo(UNIT_TYPE_GROUND)

   Will make it so only ground units take the damage.
__________________________________________________________________________________________________________
function DamageIgnore takes unittype ThisUnitType returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    The opposite to DamageOnlyTo , units of this type will be ignored by the damage. (works the
same as using DamageException with 0 as factor)

Example : DamageIgnore(UNIT_TYPE_RESISTANT)
__________________________________________________________________________________________________________
function DontDamageSelf takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   In the case the damage affects allies too, use this flag to avoid the damage to affect the
unit given as hurter

Example : DontDamageSelf()
__________________________________________________________________________________________________________
function DamageTrees takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   The damage will also kill the trees in the area, this flag shouldn't be used by DamageGroupEx,
in that case it will surelly cause serious glitches, only use this on AOE damge functions.

Example : DamageTrees()
__________________________________________________________________________________________________________
function DamageOnlyVisibles takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Some spells shouldn't affect units that are invisible to the player,
use this flag in that case

Example : DamageOnlyVisibles()
__________________________________________________________________________________________________________
function DamageOnlyEnemies takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Will Force the function to ignore allied units, this makes it so it ignores even the affectallied
argument in the AOE damage functions.

Example : DamageOnlyEnemies()

   You shouldn't it with DamageOnlyAllies() or DamageOnlyAllies(), it doesn't have any sense and
the bitflags would screw everything.
__________________________________________________________________________________________________________
function ForceDamageAllies takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Will Force the function to damage allied units, this makes it so it ignores even the affectallied
argument in the AOE damage functions.

Example : ForceDamageAllies()

   You shouldn't it with DamageOnlyAllies() or DamageOnlyEnemies(), it doesn't have any sense and
the bitflags would screw everything.
__________________________________________________________________________________________________________
function DamageOnlyAllies takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Will Force the function to only affect units that are allied, damage allied units.

Example : DamageOnlyAllies()

   You shouldn't combine it with ForceDamageAllies() or DamageOnlyEnemies(), it doesn't have any sense and
the bitflags would screw everything.
__________________________________________________________________________________________________________
function DamageAlliedFactor takes real fct returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   When a spell may damage allies as well as enemies, you can use this option so it performs
different damage to allied units, you can even give this option a negative factor so the spell
will heal allies but damage enemies.

Example : DamageAlliedFactor(0.5)

  Would make allies take only 50% of the damage.
__________________________________________________________________________________________________________
function DamageFactorAbility1   takes integer spellid, real factor returns integer
function DamageFactorAbility2   takes integer spellid, real factor returns integer
function DamageFactorAbility3   takes integer spellid, real factor returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Really useful damage options, with this you can make abilities that add damage factors for your
trigger spells, you can use 0 as factor so an ability gives immunity, 0.~ and you give the unit
resistances, or a number higher than 1 so you make the unit extra vulnerable, or a negative value
so the unit gets healed by the damage that uses that damage option.

   Note that using a buff's rawcode would make it work with the buff instead of an ability, also
note that when an unit holds an item it counts as if it had the abilities of the item.

   There are 3 functions, this is because using an option twice won't do any effect, it would
actually mess everything because I use bitflags for the damage options.

Example:

    DamageFactorAbility1('A001',2)+DamageFactorAbility1('A002',-1)

IS TOTALLY WRONG, while

    DamageFactorAbility1('A001',2) + DamageFactorAbility2('A002',-1)

   Is right, it would mean that if the unit has A001, it will take double damage when effected with
that function, if it has A002 the unit will get healed by it. Note that if the unit had both
abilities, it would get healed with twice the damage value.

__________________________________________________________________________________________________________
function ConsiderOnlyDeadUnits  takes nothing returns integer
function IgnoreDeadState        takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Now this is a contradiction, these things are called DamageOptions but now there are DamageOptions
that allow you to pick dead units or even force you to pick dead units.

    They are more useful when you use GetDamageFactorByOptions  , thing is that this system went out
of context and besides of picking behaviour of damage functions it now servers for a lot of things
like making spells easier to configure.

    Blade.dk was making a spell that was supposed to affect dead units. DamageOptions ignore dead units
automatically. So he asked me to do something to disable that.

    The result, 2 new damage options, note that using the togetheri is a very stupid thing to do.
ConsiderOnlyDeadUnits makes the opposite to what damage options do by default- ignore dead units, if
you add this option the DamageOptions will ignore living units.

     IgnoreDeadState will make it pick living or dead units without distinction



* Combining.

    You can combine these flags in order to make the effect you want,
use the operator + for that, for example:

   DamageOnlyTo(UNIT_TYPE_GROUND)+DamageException(UNIT_TYPE_STRUCTURE,0)

  Will make it so the damage only affects ground units and doesn't affect buildings, will use the
default attack and damage types.

   DamageTypes(ATTACK_TYPE_SIEGE,DAMAGE_TYPE_FORCE) + DamageTrees()

  Will Do siege phisical damage and kill trees.
  

  You CANNOT use a flag twice , for example:

  DamageOnlyTo(UNIT_TYPE_UNDEAD)+DamageOnlyTo(UNIT_TYPE_STRUCTURE) WON'T WORK

  I hope you understand this rather confusing stuff, if you need more help see samples that use
Damage Options and if that doesn't help pm Post your question in the Caster System forum.

  The sample spells that use the options are:
    - Grenade
    - Stone of Lightning
    - Deadly Fire Star
    - Light of redemption
    - Poisonous Weeds

* Saving and loading for later use:

    As it was said, DamageOptions are temporal and can't be saved in a variable, however I made
some system to allow you to save them in variables or gamecache for later use.
_______________________________________________________________________________________________________
function CreateDamageOptions    takes integer DamageOptions returns integer
function SetDamageOptions       takes integer id, integer DamageOptions
function LoadDamageOptions      takes integer id returns integer

function DestroyDamageOptions   takes integer id returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Allows you to create saveable DamageOptions , CreateDamageOptions will create one of these
pseudo handles from some DamageOptions, likelly:

    set somevar = CreateDamageOptions(DamageOnlyTo(UNIT_TYPE_UNDEAD)+DamageTrees())

    So later when calling a caster system function that uses damage options and want to use the
saved value, use:

     call DamageUnitsInAOEEx(GetTriggerUnit(),500,0,0,250,true,LoadDamageOptions(somevar))

    These things work like handles so you have to destroy them if you will no longer use them

     call DestroyDamageOptions(somevar)

    You can also replace a saveable damage option with a new value

     call SetDamageOptions(somevar,CreateDamageOptions(DamageOnlyTo(UNIT_TYPE_GROUND)+DontDamageSelf())

    Strangelly enough, you could set a saveable damage option after destroying it before version 13.5 ,
I do not recommend doing so after that version.

    Most of the times you won't need this at all, but for things like my templates system I
needed to create this.

* Damage Options functions:

_______________________________________________________________________________________________________________________
function IsDamageOptionIncluded    takes integer DamageOptions, integer whichDamageOption returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    If you are DamageOptions for a spell / trigger of yours and you might need to know if
some DamageOptions include a damageoption (for example DamageTrees() ) you might use this
function.

Example:

     IsDamageOptionIncluded( -SomeDamageOptions- , DamageTrees() )

Will return true if the DamageOptions argument includes DamageTrees()

  This will not work correctly with DamageOptions that use arguments. DamageOnlyEnemies(),
ForceDamageAllies() and  DamageOnlyAllies() Will not work either.

  In other words this function is only useful for DontDamageSelf(), DamageTrees()
and DamageOnlyVisibles()

* Appendix B : Attack Types
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   I'd rather suggest you to use variables for this, but unfortunally, blizzard screwed the
types disallowing us to make damage or attack type variables. So there are the instructions
for them in JASS, first thing is the thing you have to insert and second thing is the description

Attack types: (how they act depends on armor)

    ATTACK_TYPE_NORMAL          Spell
    ATTACK_TYPE_MELEE           Melee
    ATTACK_TYPE_PIERCE          Pierce
    ATTACK_TYPE_SIEGE           Siege
    ATTACK_TYPE_MAGIC           Magic
    ATTACK_TYPE_CHAOS           Chaos
    ATTACK_TYPE_HERO            Hero

I think that the attack type commonly used by spells is chaos, otherwise it is Magic-
  ˉˉˉˉˉ
* Appendix C : Damage Types
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   I'd rather suggest you to use variables for this, but unfortunally, blizzard screwed the
types disallowing us to make damage or attack type variables. So there are the instructions
for them in JASS, first thing is the thing you have to insert and second thing is the description

Damage types: (how they act depends on tft magic things:
- magical damage is buffed by etheral and resisted by spell immunes (normal spells)
- phisical damage is resisted by ethereal and is able to affect spell immunes (passive spells)
- Universal is buffed by ethereal and can even affect spell immunes (ultimates)

    DAMAGE_TYPE_FIRE                 Magical
    DAMAGE_TYPE_COLD                 Magical
    DAMAGE_TYPE_LIGHTNING            Magical
    DAMAGE_TYPE_DIVINE               Magical
    DAMAGE_TYPE_MAGIC                Magical
    DAMAGE_TYPE_SONIC                Magical
    DAMAGE_TYPE_FORCE                Magical
    DAMAGE_TYPE_DEATH                Magical
    DAMAGE_TYPE_MIND                 Magical
    DAMAGE_TYPE_PLANT                Magical
    DAMAGE_TYPE_DEFENSIVE            Magical
    DAMAGE_TYPE_SPIRIT_LINK          Magical
    DAMAGE_TYPE_SHADOW_STRIKE        Magical

    DAMAGE_TYPE_NORMAL               Phisical
    DAMAGE_TYPE_ENHANCED             Phisical
    DAMAGE_TYPE_POISON               Phisical
    DAMAGE_TYPE_DISEASE              Phisical
    DAMAGE_TYPE_ACID                 Phisical
    DAMAGE_TYPE_DEMOLITION           Phisical
    DAMAGE_TYPE_SLOW_POISON          Phisical

    DAMAGE_TYPE_UNKNOWN              Universal
    DAMAGE_TYPE_UNIVERSAL            Universal

* Appendix D : UnitTypes (Unit classification)
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    UNIT_TYPE_HERO                   Hero
    UNIT_TYPE_DEAD                   "Dead"
    UNIT_TYPE_STRUCTURE              Building

    UNIT_TYPE_FLYING                 Unit is flying
    UNIT_TYPE_GROUND                 Unit is ground *

    UNIT_TYPE_ATTACKS_FLYING         Unit can attack flying units
    UNIT_TYPE_ATTACKS_GROUND         Unit can attack ground units

    UNIT_TYPE_MELEE_ATTACKER         Unit has melee attack
    UNIT_TYPE_RANGED_ATTACKER        Unit has ranged attack

    UNIT_TYPE_GIANT                  "Giant"
    UNIT_TYPE_SUMMONED               Unit is summoned (a.k.a takes damage from dispel)
    UNIT_TYPE_STUNNED                "Stunned" doesn't work as you might think though
    UNIT_TYPE_PLAGUED                "Plagued" doesn't work as you might think though
    UNIT_TYPE_SNARED                 "Snared" doesn't work as you might think though

    UNIT_TYPE_UNDEAD                 Undead
    UNIT_TYPE_MECHANICAL             Mechanical
    UNIT_TYPE_PEON                   Worker
    UNIT_TYPE_SAPPER                 Suicide
    UNIT_TYPE_TOWNHALL               Townhall
    UNIT_TYPE_ANCIENT                Ancient

    UNIT_TYPE_POISONED               'Poisoned'
    UNIT_TYPE_POLYMORPHED            'Polymorphed'
    UNIT_TYPE_SLEEPING               Sleeping
    UNIT_TYPE_RESISTANT              Resistant (has spell based of Resistant skin) *
    UNIT_TYPE_ETHEREAL               Etheral
    UNIT_TYPE_MAGIC_IMMUNE           Immune to magic


* Notes:
    - Damage options read UNIT_TYPE_GROUND as if it meant ANY NON FLYING UNIT , this is to
      fix a bug from blizzard that causes amphibious to do not be considered ground.
    - Damage options read UNIT_TYPE_RESISTANT as units with a resistant skin based ability
      OR Heroes , this is because HEROES ARE RESISTANT.


[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:47:20 | 显示全部楼层
[jass]

CSCache Module:
===============

* Attached Variables
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Attached Variables allows you to put labeled variables on any handle (handles are units, items,
timers, triggers and a lot like those)

   If you are familiar with Handle Variables, Attached variables are the same, but they allow things
like attached sets and tables. Tables are important because of their flezibility and because they
perform faster.

* Functions
ˉˉˉˉˉˉˉˉˉˉˉ
________________________________________________________________________________________________
function AttachInt       takes handle h, string label, integer x returns nothing
function AttachReal      takes handle h, string label, real x returns nothing
function AttachBoolean   takes handle h, string label, boolean x returns nothing
function AttachString    takes handle h, string label, string x returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   So the idea is simple, an attached variable , is a variable that you can create in game, and
the best thing is that you can 'Attach' it to anything, you have this unit called Bob, you can
attach some stuff to it likelly:

   call AttachInt(udg_bob, "age" , 345)

Or you have a trigger called "kill mephisto" , you can attach him a boolean:

   call AttachBoolean(gg_trg_kill_mephisto,"already killed",true)

Anyways, just in case you don't know:

   Integers (the AttachInt function uses them):
   - numbers without decimal values  ( 3 , 45 , -1 , 10993493)
   - Wc3 Object 4 letter rawcodes ( 'Aloc' , 'h000' , 'S001' )
   - Leet looking Hexadecimal values =) ( 0xffffffff , 0xccdecca , 0xFFFFFFFF , 0xEE32 , 0xA )

   Reals:
   - numbers with dots acting as decimal separators: 3.1416 , 0.3333 , 12536.35
   - numbers without dots : 2 ,3 ,  6, 1000 (they are actualyl integers, but if you save them as real they will be considered reals)

   Booleans:
   - true
   - false
   - null (equivalent to false)

   Strings:
   - Text between quotes : "hello" , "news flash" , "we are wasting time here"
   - null

What is handle h?
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   A handle is an object, in wc3 a handle is a variable type that is not an integer, real, boolean,
string or 'code', for example, units are handles, items are handles too, triggers are handles,
points and unit groups are handles too.

   So it means, that with these functions you can attach labels to virtually anything.
_________________________________________________________________________________________________________
function AttachObject         takes handle h, string label, handle x returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   This works exactly as attaching an integer or string or that stuff, but you can attach a handle
see above to know what can a handle be, ex:

    call AttachObject( gg_trg_kill_mephisto,"mephisto",bj_lastCreatedUnit)

will attach the last created unit to the kill mephisto trigger, labeled as mephisto

    call AttachObject( GetSummonedUnit() , "master", GetSummoningUnit() )

  will attach the summoned unit to the summoning unit with the "master" label , so later you will be
able to know who summoned that unit.

_________________________________________________________________________________________________________
function GetAttachedInt       takes handle h, string label returns integer
function GetAttachedReal      takes handle h, string label returns real
function GetAttachedString    takes handle h, string label returns string
function GetAttachedBoolean   takes handle h, string label returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    So, you attached something to something, you obviously did that for a reason, use these
functions to read stored values into something, a variable for instance.

  set udg_bvar = GetAttachedBoolean( gg_trg_kill_mephisto, "already killed")

the bvar variable would be true.

   Keep in mind that the LABELS ARE NOT CASE SENSITIVE , a label "A" will be the same as a label "a"
_________________________________________________________________________________________________________
function GetAttachedObject         takes handle h, string label returns handle
function GetAttachedUnit           takes handle h, string label returns unit
function GetAttachedItem           takes handle h, string label returns item
function GetAttachedEffect         takes handle h, string label returns effect
function GetAttachedLightning      takes handle h, string label returns lightning
function GetAttachedImage          takes handle h, string label returns image
function GetAttachedUbersplat      takes handle h, string label returns ubersplat
function GetAttachedDestructable   takes handle h, string label returns destructable
function GetAttachedTrigger        takes handle h, string label returns trigger
function GetAttachedGroup          takes handle h, string label returns group
function GetAttachedTimer          takes handle h, string label returns timer
function GetAttachedTriggerAction  takes handle h, string label returns triggeraction
function GetAttachedWidget         takes handle h, string label returns widget
function GetAttachedRect           takes handle h, string label returns rect
function GetAttachedRegion         takes handle h, string label returns region
function GetAttachedTimerDialog    takes handle h, string label returns timerdialog
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   When you use AttachObject, it is not as easy to recover the value as it would with the last
functions, you have to use a special function for each type, this is because while it is true that
you can store everything as a handle, you can use handle as everything (got it?) you have to first
make sure the parser is considering it what you want it to.

    set udg_Mephisto =  GetAttachedObject( gg_trg_kill_mephisto,"mephisto")
Will cause an ERROR

    set udg_Mephisto =  GetAttachedUnit( gg_trg_kill_mephisto,"mephisto")

Will work. (this is in case Mephisto is an unit variable)

   According to me, the most used types for this are unit, item, effect (special effect),
  destructable , trigger and group (unit group) , so I only made functions for them.

    If you stored something weird, you'd have to make a typecasting function yourself! this is not
something difficult at all, actually.

    Let's say you stored a rect for some reason , you'd have to do something like this

function GetRectFromTriggerMephisto takes nothing returns rect
    return GetAttachedObject(gg_trg_kill_mephisto,"therect")
endfunction

    it would work , anyways you can have whatever you like as function name, arguments and contents
the return is needed to typecast the handle value to the value you need.

______________________________________________________________________________________________________________
function CleanAttachedVars   takes handle h returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   I just forgot to tell you that these variables use memory , if you care about efficiency you
should clean them once you don't need them anymore there are two ways, one is by using
this function.

   call CleanAttachedVars(gg_trg_kill_mephisto)

   CleanAttachedVars will just remove whatever was attached to the object, I would only reccomend
to do this before destroying or removing the object. Note that I mean this would remove the
created variables, this won't remove the things that the variables are pointing out.

   Another way to clean the memory used by these variables, is to just use the Attach functions,
I designed them to be intelligent, if you use variables like:

  - For integers and reals use 0 to clean the variable
  - For booleans use false to clean the variable
  - For strings use "" to clean the variable
  - For Objects use null to clean the variable

BTW whenever you read a variable that was cleaned it will return those values. ^

* Tables
ˉˉˉˉˉˉˉˉ
    Table is a class (yeah right) that allows you to, well have tables, you generally use the
table to set a field to a value for example. They are actually Hash tables, but was crazy
when naming this.

    Basically tables act the same as when using attached variables but instead of specyfing
a handle (object) you specify the table.

    The magic stuff is that you can create / destroy tables in game and you can copy the
contents of a table to another. But this procedure requires you to first specify the fields
to copy and their types using a FieldData "object" (See bellow) Anyways, keep in mind that
copying stuff is optimized to the max. But it would still be lag friendly if you copy a
great quantity of data.

    Also, you can access a handle's attached variables with a table. Have I said that I made
tables because I found out that Attached Variables / Handle Variables are slow because of
calling I2S(CS_H2I()) everytime? In other words, using tables is FASTER than using Attach
variables ( But the speed difference is only meaningful when you use a lot of them without
any wait)

    The optimization a table can allow is good when you have a periodic timer that keeps
using Attached Variables, you can instead attach a table to the timer (Using AttachString
and GetAttachedString) and  just use the table instead of reading attached stuff of the timer.

    Without the need of attaching a table you can also read/write attached variables using
GetAttachmentTable, which is also faster.

    Basically Use tables when you have to use tables, tables are great for having some non
declared variables if you just use labels between "(" ")" or "[" "]" for example:

  SetTableInt("[Variables]","UnitId",'hfoo')

    Tables are also good since you can create/
destroy them on the fly, you can attach a table to a unit and you just use the spell/system
specific name to the label where the table is attached and then just flush the table and
the label. This is helpful when a spell attach a lot of information to a public unit or
any handle, and you want to flush all that information when you don't need it.

    Finally for intense operations that involve a periodic timer that runs a lot of times
using a table would be faster than using a lot of attached variables.

    Note: Be careful with table functions: make sure you never send "" or null string as table
or field argument, that will cause crashes

__________________________________________________________________________________________________
function NewTable             takes nothing returns string
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    First of all, tables ARE strings. NewTable will create a new string that you are free to
use as table (It would actually be a number) . But I must say, that you can use any string
with the other table functions, but please I recomend that any table name that is not
acquired with this function is used between "(" ")" or "[" "]"

__________________________________________________________________________________________________
function NewTableIndex        takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Does the same as NewTable but it returns an integer (NewTable() just calls this function
and converts the returned integer to string) To store table pointers in gamecache / arrays
it would be better to use integers since strings are slower. But, obviously you will need to
use I2S() on the returned value in order to be able to use the table on other functions.
__________________________________________________________________________________________________
function GetAttachmentTable   takes handle h returns string
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    As I said you can write/read attached variables with the table functions, use this to
get the table that is used by handle. This table is destroyed automatically whenever
CleanAttachedVars is used on the handle.

__________________________________________________________________________________________________
function DestroyTable         takes string table returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    This function should only be used on tables created by NewTable, although it is safe
to use it on other tables, it would only do the same thing ClearTable does, but will take
some extra execution time.

    Basically cleans the contents of a table. And allows NewTable to return it again.

    Storing stuff on the table after destroying it is possible but it is a BAD idea,
because NewTable could return the table that is supposed to be destroyed again, and it
could be used by other spell/system/trigger but with already set values and there is the
possibility of conflict.

    IF you just want to clear a table that was created by NewTable but plan using it again
later, use ClearTable:

__________________________________________________________________________________________________
function ClearTable         takes string table returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Cleans the contents of a table, if the table was created by NewTable, it WILL NOT, make
it available to be returned by NewTable.

    You can also use it on non-created tables and Attachment Tables, consider that using
ClearTable on a handle's attachment table WILL NOT clear Attached Sets.
__________________________________________________________________________________________________
function SetTableBoolean      takes string table, string field, boolean val returns nothing
function SetTableInt          takes string table, string field, integer val returns nothing
function SetTableReal         takes string table, string field, real val returns nothing
function SetTableString       takes string table, string field, string val returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Set values of a table's field, false, 0 and "" will "flush" the field so it doesn't take
more memory. Yeah, they work like the Attached Variables stuff
__________________________________________________________________________________________________
function GetTableBoolean      takes string table, string field returns boolean
function GetTableInt          takes string table, string field returns integer
function GetTableReal         takes string table, string field returns real
function GetTableString       takes string table, string field returns string
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Read table values, If that field was never set they return false, 0 or "" . Note:
Although you can use table functions to access Attached Variables, you can't Use
FromSetElement with GetTableInt.
__________________________________________________________________________________________________
function SetTableObject       takes string table, string field, handle val returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    You can set any object inside a table. Use null to "flush" the field so it doesn't take
memory. Like attached variables you can use it to set anything on that field, from units to
effects or whatever handle you like. But the number of preset GetTableXXXX functions is
limited like AttachableVariables.
__________________________________________________________________________________________________
function GetTableObject        takes string table, string field returns handle
function GetTableUnit          takes string table, string field returns unit
function GetTableEffect        takes string table, string field returns effect
function GetTableLightning     takes string table, string field returns lightning
function GetTableUbersplat     takes string table, string field returns ubersplat
function GetTableImage         takes string table, string field returns image
function GetTableItem          takes string table, string field returns item
function GetTableDestructable  takes string table, string field returns destructable
function GetTableWidget        takes string table, string field returns widget
function GetTableGroup         takes string table, string field returns group
function GetTableRect          takes string table, string field returns rect
function GetTableRegion        takes string table, string field returns region
function GetTableTimer         takes string table, string field returns timer
function GetTableTrigger       takes string table, string field returns trigger
function GetTableTimerDialog   takes string table, string field returns timerdialog
function GetTableTriggerAction takes string table, string field returns triggeraction
function GetTableBoolExpr      takes string table, string field returns boolexpr
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These work the same as the Attached Variables' GetAttachedXXXX . Note: FromSetElement
won't work with table functions.

________________________________________________________________________________________________
function HaveSetField   takes string table, string field, integer fieldType returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Returns true if the fiel contains a value different from 0, false,  null, or ""
(depending on the type) it is worthless to use this with boolean, since it would be the
same as reading the boolean value.

   fieldType is the type of the field:

  bj_GAMECACHE_BOOLEAN : Boolean (Totally worthless)
  bj_GAMECACHE_INTEGER : Integer or Object
  bj_GAMECACHE_REAL    : Real
  bj_GAMECACHE_STRING  : String

For Example:      if (HaveSetField("(variables)","Unit",bj_GAMECACHE_INTEGER)) then
Would use the stuff inside the if then block only in the case a non-null value was stored
in the "Unit" field of the "(variables)" table.

__________________________________________________________________________________________________
function CopyTable takes integer FieldData, string sourceTable, string destTable returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Copies values of fields from a table to the fields of another table. You first need a
FieldData object to do so (See bellow) . The more Fields a FieldData object points, the more
time this operation will take (But this is way faster than doing so manually) And Yes, you
can use this in conjunction with GetAttachmentTable to copy values of the AttachedVariables
of a handle to the AttachedVariables of another handle.

* FieldData
ˉˉˉˉˉˉˉˉˉˉˉ
    FieldData is an object that was created for the only purpose of allowing to copy tables,
to copy a table, CopyTable first has to know which fields of which type to copy. So a
FieldData object contains all that information.

_____________________________________________________________________________________________________
function FieldData_Create    takes nothing returns integer
function FieldData_Destroy   takes integer fielddata returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Create a FieldData Object or Destroy a FieldData Object, the integer returned by
FieldData_Create is the one that should be used with Destroy , AddField or CopyTable
______________________________________________________________________________________________________
function FieldData_AddField takes integer fielddata, string field, integer valueType returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    This is the important function that allows you to determine which fields to copy.
valuetype is an integer, specifically:

    bj_GAMECACHE_BOOLEAN
    bj_GAMECACHE_INTEGER
    bj_GAMECACHE_REAL
    bj_GAMECACHE_UNIT
    bj_GAMECACHE_STRING

  Note: Objects are actually integers internally.


  Example:

    In this example, function First is executed on Map initialization , and function Second
is executed after a unit does something.



function First takes nothing returns nothing
local integer i=FieldData_Create()
local string T1=NewTable()
    call FieldData_AddField(i,"xVel",bj_GAMECACHE_REAL)
    call FieldData_AddField(i,"yVel",bj_GAMECACHE_REAL)
    call FieldData_AddField(i,"Level",bj_GAMECACHE_INTEGER)

    call SetTableReal(T1,"xVel" ,100.0)
    call SetTableReal(T1,"yVel" ,200.0)
    call SetTableInt( T1,"Level",1)

    call SetTableString("[Example]","Table1",T1)
    call SetTableInt("[Example]","TheFieldData",i)
endfunction



function Second takes nothing returns nothing
local string T1=GetTableString("[Example]","Table1")
local integer i =GetTableInt("[Example]","TheFieldData")
local string T2=GetAttachmentTable( GetTriggerUnit() )

    call CopyTable(i,T1,T2)
endfunction


   Lame example indeed, but I just managed to use as much of these functions as possible.

The First function will create a FieldData Object and a table. It will also use a table
"(Example)" to save values for later (Variables are not needed anymore=) , The Second
function will simply copy the values of the First table to the "attachment table"  of the
Triggering Unit.

     The result is that Triggering unit will have these attached variables:

"xVel"  100.0
"yVel"  200.0
"Level" 1





[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:48:05 | 显示全部楼层
[jass]
* Lower Level Table Handling
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
_____________________________________________________________________________________________________
function CSCache    takes nothing returns gamecache
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   You can always use CSCache to get the gamecache where tables are stored and use it directly with
gamecache natives, probably for speed and that kind of things.

   Calls to CSCache() will  be converted to usage of a variable when you use the optimizer on your map
(Should use the clean useless code option)


   This is important to know cause you can get rid of Table usage and use gamecache directly in some
situations, and it will be 6% faster (not really a lot)


   For every table function but SetTableObject , GetTableObject and GetTable(SomeHandle)  you can use
gamecache natives directly instead.

_____________________________________________________________________________________________________
   variable udg_cscache
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   As long as you are sure that CSCache() was called already you can save some time and use
   udg_csache instead

___________________________________________________________________________________________________________________
native  StoreInteger        takes gamecache cache, string missionKey, string key, integer value returns nothing
native  StoreReal           takes gamecache cache, string missionKey, string key, real value returns nothing
native  StoreBoolean        takes gamecache cache, string missionKey, string key, boolean value returns nothing
native  StoreString         takes gamecache cache, string missionKey, string key, string value returns boolean

native  GetStoredInteger    takes gamecache cache, string missionKey, string key returns integer
native  GetStoredReal       takes gamecache cache, string missionKey, string key returns real
native  GetStoredBoolean    takes gamecache cache, string missionKey, string key returns boolean
native  GetStoredString     takes gamecache cache, string missionKey, string key returns string


native  FlushStoredMission  takes gamecache cache, string missionKey returns nothing

native  FlushStoredInteger  takes gamecache cache, string missionKey, string key returns nothing
native  FlushStoredReal     takes gamecache cache, string missionKey, string key returns nothing
native  FlushStoredBoolean  takes gamecache cache, string missionKey, string key returns nothing
native  FlushStoredUnit     takes gamecache cache, string missionKey, string key returns nothing
native  FlushStoredString   takes gamecache cache, string missionKey, string key returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   The only requisite is that you use the gamecache returned by CSCache() with these natives and you can access
the data used by tables faster. And use the table string  in the missionKey argument


For example you can use 'call StoreInteger(CSCache(),"[Hello]","a",34)' instead of 'call SetTableInt("[Hello]","a",34)

   It is gonna be kinda faster, notice that this should be used only on speed critical operations, and that the
difference itself is not that big unless there are plenty of calls.

   When there are many calls you can save CSCache() in a variable, but notice that it is a worthless optimization if
you are going to use the optimizer on it.

   For storing/retrieving objects it is better to use the tables' functions instead and even if you used your own
return bug exploiters the GetTableXXXXX functions would be as fast.

   When using the Store natives they do not have auto flushing, so you'd have to use  the Flush natives to clean
memory.

* CSArrays (Dynamic Arrays)
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   The fact is that gamecache is slow (and because of that tables and attacheable variables are slow as well)
That's the reason Dynamic Arrays had to be invented.

   They simply use 2 global integer arrays to write/read information, in case both arrays are full it will use gamecache instead.

Dynamic Arrays are much faster than tables but they have their own disadvantages:
- Fixed size (you can't extend an array's size after it has been created)
- Use indexes instead of string fields (No GetTableInt(k,"fxpath") , instead GetArrayInt(k,4))

But they have their advantages:  
- Really fast (check out the caster system's projectile system of 13.4 and compare it to 13.5 it has become incredibly fast)
- Fast Method to entirelly copy the contents of an array. (No need of fielddata auxiliar things)

______________________________________________________________________________
function NewArray takes integer size, boolean doinit returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Creates an array, you just need to specify size which can be any number greater than 0 and lower than 145.
If the doinit argument is true it will initialize all the values of the array with zeroes, otherwise it
won't initialize the indexes so you could expect random numbers there.

If you are gonna set the values manually after creating the array you should use false in the doinit argument
If you might try to read a value without being sure it was initialized correctly, then better use doinit.

Notice that arrays are of type integer so it is easy to nest them.

There are 16382 available spaces of memory before it starts using gamecache. Of the 16382 spaces, 147 are taken
automatically when the map starts and are used for internal things of the CSCache module. Each Array takes
one space to store its size + X other indexes. X is lowest fibonacci number that is greater than or equal to the
size you give to the array.

So If you create an Array of size=100 , it will actually take 145 (1+144) values.

As long as you destroy arrays you no longer need you won't have problems, although if you have a lot of created
arrays and do not destroy them, they can start to use big indexes. Big indexes use gamecache instead of the global
arrays. So it will become slow. The good news is that the worst case scenario is that the arrays become as slow
as gamecache. But it is better to not abuse this system. Only use it for things that are temporary. You can use
global non-dynamic arrays for other things.

Is the 144 size limit too small? I could actually make the limit bigger but didn't feel like one would ever need
such a big array, you can always combine arrays by nesting them btw.

______________________________________________________________________________
function DestroyArray takes integer id returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Destroys an array, take a guess the integer you should use is the one that was returned by NewArray.

You shouldn't access an array after its destruction, although you can get the old values if you
try to access it immediayelly after destroying the array. DestroyArray marks the space the array
used as free so NewArray will eventually return that space so you can use it again.

______________________________________________________________________________
function GetArraySize takes integer id returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Returns the size of the array. The size returned is the value you used with NewArray.

_____________________________________________________________________________________
function SetArrayInt takes integer id, integer index, integer val returns nothing
function GetArrayInt takes integer id, integer index returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Integer values are the fastest for arrays, id is the value returned by NewArray, index
is the index of the value you have to Set/Get (start with 0) and val is the value
you want to place there.

GetArrayInt returns the value stored on index 'index' of the array.

If you didn't initialize the array with the doinit argument, and you didn't use
SetArrayInt to initialize the index, GetArrayInt will return a random,
umpredictable value.

And array of size 4 has these available indexes: 0,1,2,3
And array of size 9 has these available indexes: 0,1,2,3,4,5,6,7,8

Notice that an array of size 4 is actually an array of size 5 (fibonacci number) so
you *could* access index 4 , but it won't be initialized automatically by doinit.

It is possible to use any number as index , even negative numbers, that would be an
'access violation' you would be trying to access memory that is used by other
dynamic arrays or even their size values or other important things and cause chaos.
So please be careful, I didn't add bound checking because I wanted this to be fast.

____________________________________________________________________________________
function SetArrayReal takes integer id, integer index, real val returns nothing
function GetArrayReal takes integer id, integer index returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
They do exactly the same as the Int ones but using Reals. Notice that you have to
Set the value using SetArrayReal before trying GetArrayReal. Else it might crash.


____________________________________________________________________________________
function SetArrayBoolean takes integer id, integer index, boolean val returns nothing
function GetArrayBoolean takes integer id, integer index returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
I do not think I have to explain these...

_____________________________________________________________________________________
function SetArrayObject takes integer id, integer index, handle val returns nothing
function GetArrayObject takes integer id, integer index returns handle
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
The handle versions, since handles are integers these are 'safer' than reals. But
still make sure you used SetArrayObject on the index before using GetArrayObject.

If the index was initialized with 0 GetArrayObject will return null.
_________________________________________________________________________________________
function GetArrayWidget          takes integer id, integer index returns widget
function GetArrayTimer           takes integer id, integer index returns timer
function GetArrayUnit            takes integer id, integer index returns unit
function GetArrayLoc             takes integer id, integer index returns location
function GetArrayTrigger         takes integer id, integer index returns trigger
function GetArrayTriggerAction   takes integer id, integer index returns triggeraction
function GetArrayGroup           takes integer id, integer index returns group
function GetArrayEffect          takes integer id, integer index returns effect
function GetArrayItem            takes integer id, integer index returns item
function GetArrayLightning       takes integer id, integer index returns lightning
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
If you used SetArrayObject you can use these to retrieve the values, just as with tables
and attacheable variables, notice that you should use GetArrayUnit if you used SetArrayObject
to store an object.

Because of inheritance you can use GetArrayUnit and GetArrayWidget if you used
SetArrayObject to store a unit, the same happens with items and destructables.

_________________________________________________________________________________________
function GetArrayRect           takes integer id, integer index returns rect
function GetArrayRegion         takes integer id, integer index returns region
function GetArrayTimerDialog    takes integer id, integer index returns timerdialog
function GetArrayDestructable   takes integer id, integer index returns destructable
function GetArrayImage          takes integer id, integer index returns image
function GetArrayUbersplat      takes integer id, integer index returns ubersplat
function GetArraySound          takes integer id, integer index returns sound
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
The difference between these functions and the previous ones is that these are not optimized
for speed but are optimized for script size. In other words GetArrayRect is slightly slower
than GetArrayUnit, but GetArrayRect is a much smaller function than GetArrayunit.

_________________________________________________________________________________________
function SetArrayString takes integer id, integer index, string val returns nothing
function GetArrayString takes integer id, integer index returns string
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
These are just dummy functions, they do not use the actual global arrays but gamecache
to store the values. And as a matter of fact you could use index i to store an integer
and an string and you could access both values. But these strings will also get cleaned
correctly if you use DestroyArray. So they are useful. The only bad things about these
functions is that CloneArray does not copy string values and that they are just as slow
as gamecache.
_________________________________________________________________________________________
function CloneArray takes integer id returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Will return a new array that is the exact copy of the array that is specified by the id
argument.

It will NOT copy string values.


* Pools
ˉˉˉˉˉˉˉ
    Pools and the functions involved with them and full with name issues, probably a better name
instead of 'pool' would have been 'set' they are sets. Also what we call pool's items are the
elements of the sets. It kind of conflicts with wc3's items that are widgets (little treasures
that your hero picks up != pool items)

    I didn't bother to rename the function and cause conflicts.

    What are pools? Well you probably know JASS' group type (unit groups) I made the pool class
to simulate "integer groups" so this is something that works like unit groups but using integers.

    The number of times you add an element to a pool does not matter, the order does not matter
either.

    They have a lot of uses,  IsItemInPool is really helpful for configuration, then combining
PoolRemoveItem with PoolPickRandomItem also helps for randomizations, this is where the name pool
came from.

    Pools can store a lot of elements, limited only by wc3's gamecache limit which is kind of
huge. But they are optimized for 33 items. This means that having less than 34 elements in
a pool is faster than having more than 33. Starting from the 33th element the pool class would
need to use more gamecache to store information, otherwise it uses mostly dynamic arrays,

    You probably met pools before as a separate system, this is a variation designed to be included
as part of CSCache, apart from big optimizations, I also removed 2 functions, ForPool and ForPool2.
because they are too slow and it is much better to use PoolGetItem (see bellow)

    The biggest difference is that DestroyPool will now destroy the pool instead of just clearing
it. Old systems may require you to replace calls to DestroyPool with ClearPool in order to
function correctly.

___________________________________________________________________________________________________
function CreatePool              takes nothing returns integer
function DestroyPool             takes integer poolid returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * CreatePool returns an integer value that points to the created pool, it is useless to create
   a pool without saving the pointer into an integer variable (Kinda like CreateGroup() ) From
   now we will call this integer the pool's id.

   * DestroyPool will clear the memory used by a pool like DestroyGroup() . Once you are not going
   to use a pool anymore use DestroyPool on its id. Otherwise you would leak memory and add chances
   to make the dynamic arrays use gamecache and become slow.
___________________________________________________________________________________________________
function ClearPool               takes integer poolid returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * Simply clears a pool, but you can still add items to the pool without problem.

___________________________________________________________________________________________________
function PoolAddItem             takes integer poolid, integer value returns nothing
function PoolRemoveItem          takes integer poolid, integer value returns nothing
function IsItemInPool            takes integer poolid, integer it returns boolean
function CountItemsInPool        takes integer poolid returns integer
function GetFirstOfPool          takes integer poolid returns integer
function PoolPickRandomItem      takes integer poolid returns integer
function PoolAddPool             takes integer sourcepoolid, integer destpoolid returns nothing
function PoolRemovePool          takes integer sourcepoolid, integer destpoolid returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * The Functions above work exactly like their group counterparts.

   * Keep in mind that like groups a pool cannot contain a value twice.

___________________________________________________________________________________________________
function PoolGetItem             takes integer poolid, integer itemn returns integer
function GetItemPositionInPool   takes integer poolid, integer it returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * Added these functions to make everything easier, specially PoolGetItem can be worthy when
   making loops that pick every item of a pool without the problems ForPool can cause.
   GetItemPositionInPool seems useless for an accessor user but it worked to help the other
   functions,

   * Keep in mind that pools aren't supposed to be sorted, and the order of the items
   change when removing items to let things be faster.

   * For technical issues, These functions use 1-based positions (a pool starts with item 1 not
   item 0) that is because I made it so GetItemPositionInPool returns 0 when the item is not in
   the Pool.

   * To iterate through the contents of a pool p do something like this:

                        set n=CountItemsInPool(p)
                        set i=1
                        loop
                            exitwhen (i>n)
                            set a=PoolGetItem(p,i)
                            call BJDebugMsg(I2S(a)) //(for example)
                            set i=i+1
                        endloop


___________________________________________________________________________________________________
function S2Pool                  takes string s returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * Will Convert a tokenized string into a new pool
     example: S2Pool( "1;2;3;4") will return a pool that has 1, 2, 3 and 4 inside
___________________________________________________________________________________________________
function PoolAddS                takes integer poolid, string s returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * The same as the last function, but it will add the numbers to a pool, instead of creating
     a new one.


___________________________________________________________________________________________________
function Pool2S                  takes integer P returns string
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * Does the opposite of S2Pool if pool contains 1 ,2 ,3 and 4 then this function returns
   "1;2;3;4" should be useful for debugging, you can also use this couple of functions to store
   pools in string format, although this is unnecesarily slow.

___________________________________________________________________________________________________
function Rawcodes2Pool           takes string s returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * Handy, it will do something similar to S2Pool , but it will do it with rawcodes (Object IDs)

       Rawcodes2Pool("AHbz;AHfs;AHwe") will return a pool that has blizzard, flame strike and
       water elemental inside
___________________________________________________________________________________________________
function PoolAddRawcodes         takes integer poolid, string s returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   * The same as the last one, but this one will add the rawcodes to an existing pool instead of
   creating a new one.

      call PoolAddRawcodes( <a pool> , "AHbx;AHfs;AHwe")


* CSData
ˉˉˉˉˉˉˉˉ
CSData are like Item's and Unit's UserData (Custom value in GUI). But they work for every handle.

They are faster than using gamecache (attacheable variables/tables) to attach information to
a handle. But they only store one integer and they are global.

They have a limit, in case there are many (a lot of) handles in your map CSData will need to use
gamecache , and it will get as slow as gamecache. But "faster most of the times"
beats "always slow" . The handle limit is 8191 notice that many handles are created automatically
by blizzard.j or by default when the game starts the map.

Notice that for public spells or systems to be distributed you should only use these
for private objects (those who the mapper would never have access to) If you are making something
for your map you can use them wherever you want.

Best to be used in conjunction to CSArrays so you just specify an array id for a handle.

DO NOT USE THIS ON THESE HANDLE TYPES: lightning, ubersplat, image, texttag, player,
                                        any 'argument' handle (like playerstate, damagetype, etc)

_________________________________________________________________________________
function SetCSData    takes handle h, integer v returns nothing
function GetCSData    takes handle h returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Kind of obvious. NOTE: Don't ever try to GetCSData if SetCSData was not called
for that handle. It is not like it would explode on your face or anything, but
it would probably have npredictable data (don't assume it will be 0)



* Location based Linked List Kit
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Locations can be used in conjunction of the return bug to make single linked lists that are
dynamic and fast (they can be faster than dynamic arrays but have more limitations, but they
don't use indexes so it is easier to add/remove things to them)

These functions are all what is needed to make linked lists that use locations, I won't really
explain how to use them right now. Maybe later

______________________________________________________________________________________________
function Location_IntLoc      takes integer x , location y returns location
function Location_ObjectLoc   takes handle x , location y returns location
function Location_LocLoc      takes handle x , location y returns location
function Location_RealLoc     takes real x , location y returns location
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
These are dummy constructors of locations that take other types of values instead of Location(x,y)

______________________________________________________________________________________________
function SetLocation_IntLoc      takes location loc, integer x , location y returns nothing
function SetLocation_ObjectLoc   takes location loc, handle x , location y returns nothing
function SetLocation_LocLoc      takes location loc, handle x , location y returns nothing
function SetLocation_RealLoc     takes location loc, real x , location y returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
These are dummy functions that allow you to set both values of the location at the same time
using different types than MoveLocation(loc,x,y)

______________________________________________________________________________________________
function SetLocationX_Object   takes location loc, handle val returns nothing
function SetLocationX_Loc      takes location loc, location val returns nothing
function SetLocationX_Real     takes location loc, real val returns nothing
function SetLocationX_Int      takes location loc, integer val returns nothing

function SetLocationY_Loc      takes location loc, location val returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
There is no native way to set just one of the values, these use MoveLocation and GetLocationX/Y to
change one of the values and keep the other one. They allow you to use other types. Notice that
you could just use SetLocationX_Object instead of SetLocationX_Loc , SetLocationX_Loc was added
as eye candy.




______________________________________________________________________________________________
function GetLocationX_Loc    takes location loc returns location
function GetLocationY_Loc    takes location loc returns location

function GetLocationX_Int             takes location loc returns integer
function GetLocationX_Unit            takes location loc returns unit
function GetLocationX_Item            takes location loc returns item
function GetLocationX_Effect          takes location loc returns effect
function GetLocationX_Lightning       takes location loc returns lightning
function GetLocationX_Widget          takes location loc returns widget
function GetLocationX_Object          takes location loc returns handle
function GetLocationX_Rect            takes location loc returns rect
function GetLocationX_Region          takes location loc returns region
function GetLocationX_TimerDialog     takes location loc returns timerdialog
function GetLocationX_Destructable    takes location loc returns destructable
function GetLocationX_Trigger         takes location loc returns trigger
function GetLocationX_Timer           takes location loc returns timer
function GetLocationX_Group           takes location loc returns group
function GetLocationX_TriggerAction   takes location loc returns triggeraction
function GetLocationX_Image           takes location loc returns image
function GetLocationX_Ubersplat       takes location loc returns ubersplat
function GetLocationX_Sound           takes location loc returns sound
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
Get X/Y functions that allow you to use other types

________________________________________________________________________________________________
function CS_h2r   takes handle h returns real
function CS_i2r   takes integer h returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
You can just use these functions in combination of Location() and MoveLocation() instead of the
dummy constructors and set functions, that would be faster.

You should not use return bug directly for the Get functions though, because of a weird bug with
real->int conversion. The Get functions I've included are safer and faster than using return bug
exploiter + GetLocationX/Y


Linked List?
ˉˉˉˉˉˉˉˉˉˉˉˉ
All right I am going to explain, this is a linked list:

__________   __________   __________   __________   
| value |--->| value |--->| value |--->| value |--> null
ˉˉˉˉˉˉˉˉˉˉ   ˉˉˉˉˉˉˉˉˉˉ   ˉˉˉˉˉˉˉˉˉˉ   ˉˉˉˉˉˉˉˉˉˉ   
See? Node #1 has a value + a pointer to node #2 which has its value + pointer to node #4 and so
and so until the last node points to null instead.

If you need more explanations maybe linked lists aren't for you, keep using the other things instead.

Many people ask me about this topic, but well I can redirect them to :
   http://en.wikipedia.org/wiki/Linked_lists



* Auxiliar functions
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
As a side effect of the pools' PoolAddRawcodes function, the CSCache engine is ready to help you convert
any rawcode in string format into integer format:

____________________________________________________________________________
function CS_Rawcode2Int    takes string s returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ

  for example: CS_Rawcode2Int("Aloc") equals 'Aloc'


* Recommendation
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
In case CSCache is not used during map initialization for the first time, then it might go to the heavy
process of initializing CSCache() the time you need a system that uses CSCache. And it would cause
"first time cast lag"

In order to prevent this I recommend you to add this line to a trigger that is run at map initialization:

set udg_cscache=CSCache()

If you are going to implement the caster system, then don't worry, CreateCasters() will do this call.
[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:48:47 | 显示全部楼层
[jass]

Spell Events
ˉˉˉˉˉˉˉˉˉˉˉˉ
    This module has 2 causes to exist:

- It will optimize a map that has plenty of enhanced spells, because there would only be one
   global trigger with one check for every spell instead of one for each spell.
- In the case of Passive abilities it allows to detect them easily in the multiple situations
   that they could be used (won't detect the action of a passive ability but the acquiring of it)

____________________________________________________________________________________________________________
function OnAbilityEffect    takes integer abilid, string funcname returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   This function registers a "starts the effect of an ability" event, directly for the abilid
spell. funcname is the name of a function to execute whenever that happens, this name is case
sensitive and it will cause crashes if you misspell it so make sure you are refferencing a true  
function in the funcname argument.

Example: call OnAbilityEffect('AHbz',"FlashQuestDialogButton")

   Will call FlashQuestDialogButton (the quest button will get a highlight)
whenever a unit casts blizzard (AHbz) . You can, in fact you are supposed to use your own
custom functions for the argument.

   You can check out the samples on this map, IceWave and Inferno to see how it works.

It is safe to use waits inside the event function. And you can register the same function for
many abilities. Also the event response functions to use are the same that you use for the
"starts the effect of an ability" event, GetTriggerUnit() , GetSpellAbilityId(),
  GetSpellTargetLoc() and GetSpellTargetUnit()
____________________________________________________________________________________________________________
function OnAbilityPreCast   takes integer abilid, string funcname returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Does exactly the same as OnAbilityEffect but registers the "begins casting an ability"
event instead, the difference is that this event actually happens BEFORE the unit spends
mana / cooldown, so you can stop the spell if you have to without letting the unit spend
mana / cooldown. The event responses are the same of the OnAbilityEffect event

____________________________________________________________________________________________________________
function OnAbilityEndCast   takes integer abilid, string funcname returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Is executed when the event EVENT_UNIT_SPELL_ENDCAST triggers.

____________________________________________________________________________________________________________
function OnAbilityGet takes integer abilid, string funcname returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  Registers function called funcname to execute whenever a unit gets an ability, in fact the
function will execute whenever:

- A hero learns or increases the level of a skill.
- A unit is created/trainned/summoned and has that ability, but doesn't have 'Aloc'
- A preplaced unit has the ability
- You use UnitAddAbility_ConsiderEvent to add the ability to the unit (see bellow)

  Because of the mixed kind of this event it has dummy event responses:
____________________________________________________________________________________________________________
function GetAbilityAcquiringUnit   takes nothing returns unit
function GetAcquiredAbilityId      takes nothing returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   GetAbilityAcquiringUnit() is the unit that just got the ability, GetAcquiredAbilityId() is the
spell id of the ability.

Note: These event responses behave like global variables, so it is not safe to call them after
waits, instead save their values in local variables.

--
This event does not detect an ability when it is added by a trigger or by an upgrade or by
morphing, you can use:
____________________________________________________________________________________________________________
function UnitAddAbility_ConsiderEvent takes unit whichUnit, integer abilid, integer level returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   To add an ability with a level directly to a unit and make sure it is considered by the registered
event of the ability.


Note: This event requires some checks for every unit that is created every time, depending on
the number of passive abilities in the map in can get pretty bad for the performance side, if
you have just like 20 abilities registered with this event and a unit may only have a maximum
of 2 of these abilities, it won't be a really big problem, The engine adapts to each unit type
so after the first heavy check it will only remember which abilities the unit type had and just
check for them.

_____________________________________________________________________________________________________________
function OnAbilityLearn    takes integer abilid, string funcname returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   If you are sure that ability is just a hero skill and there are no other ways to get it than
learning, you can use this function to register its event and just use the normal "learns a skill"
event responses in the event function, note that OnAbilityGet automatically registers this event
to be used in conjunction with other events. As an exception, if you use UnitAddAbility_ConsiderEvent
it may also consider the spells registered with OnAbilityLearn.


NOTE: You can't register the same event for the same ability twice, and you should only use
these spells in map initialization.

NOTE: Only use OnAbilityCast, OnAbilityEffect or OnAbilityLearn in case that you have 3 or
more abilities registered with that function, otherwise it wouldn't really be worth it.




[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:49:35 | 显示全部楼层
[jass]
*  Spell Helpers
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These are miscelaneus functions that were added to Vexorian to give him more freedom
in his future spells, and they would be helpful to you in the future, they use casters to
retrieve what they want.

    More shall be added with each version.

- Boolean Stuff
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These are functions that help you recognize what is what. To use these boolean returning
functions, you'd rather have some JASS knowledge or if you want to keep it GUI-ish, use a
boolean variable in a custom script line:

Custom Script: set udg_Bvar = IsDestructableTree(GetDyingDestructable())

    this would give true to the Bvar variable in case the dying destructable is a tree.
_______________________________________________________________________________________________
function IsDestructableTree    takes destructable d returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Determines if a destructable is a tree, your spell shall want to avoid to affect doors
when you want to affect trees.
_______________________________________________________________________________________________
function IsPointWater takes real x, real y returns boolean
function IsPointWaterLoc takes location loc returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Determines if the given point is water, doesn't matter if it is deep or shallow, it
would return true.
_______________________________________________________________________________________________
function IsUnitSpellImmune takes unit u returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
     Determines if an unit is Immune to Magic damage, Since 1.18 it just uses IsUnitType with
UNIT_TYPE_SPELL_IMMUNE .
_______________________________________________________________________________________________
function IsUnitImmuneToPhisical takes unit u returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
     Determines if an unit is Immune to Phisical damage
_______________________________________________________________________________________________
function IsUnitInvulnerable takes unit u returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
     Determines if an unit is Invulnerable (immune to magic and phisical damage)

- Graphical
ˉˉˉˉˉˉˉˉˉˉˉ
_______________________________________________________________________________________________
function Caster_SetZAngle    takes unit caster, real ang returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    A moving special effect, projectile, Static ability caster or Area damager effect, or
just a Caster you gave a special effect, can now rotate at the Z axis to help you have some
extra possibilities when making special effects for your abilities.

    Just use this function and use an angle from the ground and you are now able to rotate
any model on the Z plane.

    This function requires you to have the latest version of the dummy.mdx model.

Note: For some odd reason the angle resets back to normal whenever you use this function
again, so you can't make loop movement.

Note: As a secondary effect, the facing angle of the caster will get locked

_______________________________________________________________________________________________
native ResetUnitLookAt     takes unit whichUnit returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Use this when you want to cancel the effects of Caster_SetZAngle


_______________________________________________________________________________________________
function Caster_SetZAngle2 takes unit caster, integer ang returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    This is a variation that uses another method to rotate the unit, it can only take integer
calues from -90 to 90 . The advantage is that it won't reset the rotation each time you use
this function. To restore things up use this function as 0 as ang argument


- Enuming Stuff
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These functions are helpful to detect units that match certain conditions.
_______________________________________________________________________________________________________
function CS_EnumUnitsInAOE      takes group g, real x, real y, real area, boolexpr bx returns nothing
function CS_EnumUnitsInAOELoc   takes group g, location loc, real area, boolexpr bx returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    CS_EnumUnitsInAOE does the same as GroupEnumUnitsInRange, but it has the advantage that it
is as accurate as a targetting circle, so if the targetting circle of a spell highlights a unit
you can be 100% sure that this function will detect that unit if you use the target point of
the ability for its point argument and the area of effect of the ability for area argument.

    CS_EnumUnitsInAOELoc does the same thing but it is the version that takes a location argument.

- Angle Stuff:
ˉˉˉˉˉˉˉˉˉˉˉˉˉ
    These are helpful when making spells and other stuff, all these functions use Deg angles, and
the values might be on every range, negative values, or values greater than 360 are automatically
translated into the right angles.

_______________________________________________________________________________________________________
function Angles_GetAngleDifference      takes real a1, real a2 returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Returns the angle distance between angles a1 and a2:
      ____________________________
      | a1  |  a2 | return value |
      |ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉˉˉˉˉˉˉˉˉˉ|
      |  30 |  60 |     30       |
      | -30 |  15 |     45       |
      | 370 |  20 |     10       |
      | -10 | -40 |     30       |
      ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
______________________________________________________________________________________________________
function Angles_GetMidAngle             takes real a1, real a2 returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Returns the "mid angle" between a1 and a2 (here we call it bisectriz, I don't know how
it is called in english)
      ____________________________
      | a1  |  a2 | return value |
      |ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉˉˉˉˉˉˉˉˉˉ|
      |  30 |  60 |     45       |
      | -30 |  15 |    352.5     |
      | 370 |  20 |     15       |
      | -10 | -40 |    335       |
      ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
____________________________________________________________________________________________________
function Angles_MoveAngleTowardsAngle   takes real a1, real a2, real i returns real
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Moves angle a1 towards angle a2 by i units, but if the distance between the angles is less than
i, it returns angle a2.
      _________________________________
      | a1  |  a2 |  i  | return value |
      |ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉˉˉˉˉˉˉˉˉˉ|
      |  30 |  60 | 10  |    40        |
      |  60 |  30 | 10  |    50        |
      | -10 | -15 |  5  |   -15        |
      ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ

____________________________________________________________________________________________________
function Angles_IsAngleBetweenAngles    takes real angle, real a1, real a2 returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Returns true if the angle is inside the shortest range formed between the angle1 and the angle2
angles ? Keep in mind that if the angle distance between a1 and a2 happens to be exactly 180
degrees, the result will be random.

      _________________________________
      |angle|  a1 | a2  | return value |
      |ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉ|ˉˉˉˉˉˉˉˉˉˉˉˉˉˉ|
      |  45 |  30 | 60  |    true      |
      |  65 |  30 | 10  |    false     |
      |   0 | -10 |355  |    true      |
      ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ

- Movement
ˉˉˉˉˉˉˉˉˉˉ
____________________________________________________________________________________________________
function CS_MoveUnit      takes unit u, real x, real y returns boolean
function CS_MoveUnitLoc   takes unit u, location loc returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Moves a unit instantly to the point, this is different from The standard way, this is a faster
way, it won't stop the unit from casting spells/ attacking / or playing animations, and it won't
consider pathing at all.

   The only thing it  will prevent is moving the unit out of the map bounds (would cause a crash)
in that case it will move it to a point inside the map but as close to the target point as possible
and will return false.


- Interface
ˉˉˉˉˉˉˉˉˉˉˉ
____________________________________________________________________________________________________
function CS_Error         takes player forWhichPlayer, string ErrorMessage
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   This function is the closest you can be to custom interface errors. Mimics an interface error
with sound and centered text. The text is a little higher than a normal interface error, it also
has the side effect of clearing the previous text messages, otherwise it would actually move them
and it would be worse.


- Other
ˉˉˉˉˉˉˉ
_______________________________________________________________________________________________
function DamageDestructablesInCircle      takes real x, real y, real radius, real dmg returns nothing
function DamageDestructablesInCircleLoc   takes location loc, real radius, real dmg returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Will deal damage to any noninvulnerable destructabe in the given circle

______________________________________________________________________________________________________________________________________________________________________
function DamageTreesInCircle      takes real x, real y, real radius returns nothing
function DamageTreesInCircleLoc   takes location loc, real radius returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   Will KILL any noninvulnerable TREE in the given circle
[/jass]
回复

使用道具 举报

 楼主| 发表于 2008-12-8 20:50:31 | 显示全部楼层
[jass]

Safe item hiding
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
  After making Pocket Stash and InvX I note serious problems when hiding items by using
SetItemVisible :

- Computer controlled heroes can in fact pick them up.
- Units might be ordered to pick them up by using triggers because they are detected
   when using pick every item in rect

- After saving a game and loading it, hidden items SUDDENLY BECOME VISIBLE AGAIN!

  These problems were too bad and forced me to take action. I added these functions
to the caster system because they make use of dummy casters and because Pocket Stash
and InvX already require it.


Important Notes
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
* Before using these functions make any trigger that uses item Acquire / Lose events
ignore units of the type Caster. Else you might have some problems (Like when you made
every trigger that used region enter/leave events ignore them too)

* Do not use any powerup (item that is auto consumed) with this function. It won't work.

* You need to have CS_InventoryId pointing to the rawcode of an inventory ability that
cannot use items, can drop/get items, and has 6 slots (in the rare case blizzard changes
the max inventory size to 9, then this ability should have 9 slots).

________________________________________________________________________________________
function CS_HideItem takes item  i returns integer
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   *Hides* the 'i' item and returns an integer. This integer is the unique key that will
allow you to recover the item later.

    It returns an integer as a way to enforce that you don't do anything directly the item
until you recover it. Avoid to do anything to the item while it is in hiden state, don't
change its life don't give it to a unit don't do anything.

    Save the returned integer in a variable or other storage method so whenever you want
to recover the item you use that integer to do so.

________________________________________________________________________________________
function CS_RestoreItem      takes integer hiddenindex, real x, real y returns item
function CS_RestoreItemLoc   takes integer hiddenindex, location loc returns item
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
    Recover the hidden item by giving the integer returned to CS_HideItem to this
function, also specify x and y - the point where you want the item to be placed.

    CS_RestoreItemLoc is the version that uses locations and you should know what the
difference is already.


________________________________________________________________________________________
function CS_SetItemVisible    takes item i, boolean flag returns nothing
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   This function works exactly the same as the native SetItemVisible but it is safe.
I think it is easier to use this function instead of the CS_HideItem/CS_RestoreItem
combo. Notice that if you hid an item using CS_SetItemVisible you cannot restore it
using CS_RestoreItem it is also not possible to restore an item hidden by CS_HideItem
using CS_SetItemVisible(item,true).


________________________________________________________________________________________
function CS_IsItemVisible     takes item it returns boolean
ˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉˉ
   This just allows you to recognize if an item has been hidden using CS_SetItemVisible.











[/jass]
回复

使用道具 举报

发表于 2008-12-8 22:04:06 | 显示全部楼层
膜拜,能写点汉字在里面么。
回复

使用道具 举报

发表于 2008-12-9 12:40:54 | 显示全部楼层
无字天书的感觉
回复

使用道具 举报

发表于 2008-12-9 16:29:31 | 显示全部楼层
英语...
回复

使用道具 举报

发表于 2008-12-11 23:46:35 | 显示全部楼层


- -写的内容真多

蛮实用饿
回复

使用道具 举报

kw 该用户已被删除
发表于 2008-12-12 17:48:43 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-5-2 17:27 , Processed in 0.045410 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表