Name | Type | is_array | initial_value |
group | group | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
scope HolyLight initializer Init
{ // We have a scope se we can make things private. This helps us avoid name conflicts.
private integer abilityID = 'A001'
// The ID of the ability.
// aka Raw Code
private attacktype attackType = ATTACK_TYPE_MAGIC
// The attack type of the ability's damage.
private damagetype damageType = DAMAGE_TYPE_DIVINE
// The damage type of the ability
private weapontype weaponType = WEAPON_TYPE_WHOKNOWS
// The weapon type of the ability.
// It's used for sound.
// I recommend leaving it like this.
private real texttagSize = 9.00
// The size of the text tag, in screen pixels
// Like normal fonts. Have you ever used
// Microsoft Office Word? :D
private real texttagVelocity = 45.00
// The velocity of the text tag.
// I've set it to go only up.
// Set to 0 for no movement.
private real texttagFadePoint = 3.00
// The (time) point at which the text tag
// starts fading (in seconds)
private real texttagDeathPoint = 5.50
// The (time) point at which the text tag
// will be completly invisible and gets
// DESTROYED (in seconds)
private boolean texttagVisible = true
// Show the text tag?
// Set to false for no text tag
private real texttagZoffset = 30.00
// The height of the text tag from the start.
// It will go up by the velocity.
private boolean Conditions() // This is the condition of the trigger. Shouldn't be changed.
{
return GetSpellAbilityId() == abilityID
}
private nothing Actions() // The real spell, the action of the trigger.
{
unit caster = GetSpellAbilityUnit(), target = GetSpellTargetUnit()
// The caster and the target unit.
// We store them here to avoid more calls.
// Results in speed.
real r = GetHeroInt(caster, true) * GetUnitAbilityLevel(caster), AbilityID)
// We calculate the damage with this formula
string sign // We'll use this string later and make it "+" or "-"
integer colorR, colorG, colorB, colorA // Our color variables. Look below for setup.
texttag tt = CreateTextTag()
// We create a simple text tag.
SetTextTagVelocity(tt, 0,texttagVelocity * 0.071 / 128 )
// We add the velocity to the text tag. Look at the top for values.
SetTextTagPermanent(tt, false )
// We need the text tag to dissapear after some time, so it will not be permanent.
SetTextTagFadepoint(tt,texttagFadePoint )
// We add the fadepoint to the text tag. Look at the top for values.
SetTextTagLifespan(tt,texttagDeathPoint )
// We add the death point to the text tag. Look at the top for values.
SetTextTagVisibility(tt,texttagVisible )
// We make the text tag visible. Look at the top for the setup.
SetTextTagPosUnit(tt, target,texttagZoffset)
// We position the text tag above our target.
if ( IsPlayerAlly(GetOwningPlayer(target), GetOwningPlayer(caster)) == true )
{ // The below code will run if the target is an ALLY of the caster!
SetWidgetLife( target, ( GetUnitState( target, UNIT_STATE_LIFE ) + r ) )
// We "heal" the ALLY
colorR = 230 // The RED value of the text tag's color.
colorG = 230 // The GREEN value of the text tag's color.
colorB = 150 // The BLUE value of the text tag's color.
colorA = 255 // The ALPHA value of the text tag's color.
sign = "+" // The sign which shows the health was given to the target.
// Colors have 4 values, Red, Green, Blue and Alpha.
// Play with these values to find your color.
}
else
{ // The below code will run if the target is an ENEMY of the caster!
UnitDamageTarget( caster, target, r, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DIVINE, WEAPON_TYPE_WHOKNOWS )
// We damage the ENEMY. We use this native so we don't have to take care of
// experience and bounty.
colorR = 230 // The RED value of the text tag's color.
colorG = 100 // The GREEN value of the text tag's color.
colorB = 150 // The BLUE value of the text tag's color.
colorA = 255 // The ALPHA value of the text tag's color.
sign = "-" // The sign which shows the damage was dealt to the enemy.
// Colors have 4 values, Red, Green, Blue and Alpha.
// Play with these values to find your color.
}
SetTextTagText(tt, ( sign + ( I2S ( R2I (r) ) + " HP" ) ), texttagSize * 0.023 / 10 ) //Avoided using a BJ.
// Now we make the text tag show "-" or "+" and the damage/heal
// If the target is ALLY, it will show "+damage"
// If the target is ENEMY, it will show "-damage"
SetTextTagColor(tt, colorR, colorG, colorB, colorA )
// Now we give the text the color we want.
// The colors are chosen above, depending if the target is ALLY or ENEMY.
}
private boolean AntiLeak() // A basic anti-leak function
{
return true
}
private nothing Init() // The initialization trigger of our spell.
{
trigger t = CreateTrigger() // We make the trigger local.
filterfunc f = Filter( function AntiLeak ) // The AntiLeak filter function.
// We make a variable to avoid 16 calls
integer i = 0 // An integer to keep track of the loop.
loop // The event(s) that will trigger the action.
{ // In this case, an unit casts an ability.
TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, f)
i += 1
exitwhen i >= 16
} // We're done for all 16 players (0 to 15)
TriggerAddCondition(t, Condition( function Conditions ) ) // Now we have a condition.
// The actions will run only if the condition returns true.
// In out case, if the ability being cast is the one we need.
TriggerAddAction(t, function Actions ) // The actions of the trigger.
// They will run when the event happends and the condition returns true.
DestroyFilter(f) // To avoid leaks, we need to destroy out filterfunc,
f = null // And null the variable.
}
}