Name | Type | is_array | initial_value |
Hero | unit | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
Thx for Downloading and testing this map. We hope that you like the spell
and play the campaign in a nearby future.
Credits
Create of the original Spell: Flame_Phoenix
Optimization made by: PurplePoot
Campaign leader: Pyritie
Project name: Pyritie campaign
Remember to credit us if you use this spell. The creation of it took us
several months, and therefore we would like not be be ignored.
Implementing the spell:
1 - Create a dummy unit
2 - Create a stun dummy ability based on Magic Bolt
3 - create a slow dummy ability based on Slow
4 - Create the Lightning Bolt ability, with base on Cripple
5 - MAKE SURE YOUR FIELDS MATCH OUR FIELDS IN THIS MAP
6 - Copy and paste the selected trigger
7 - Change the rawcodes as necessary
In alternative you can:
1 - Copy all abilities into your map
2 - Copy the dummy unit
3 - Copy the code and change the rawcodes as necessary
What is a rawcode ??
A rawcode is the computer's name for an object. For example, the computer
recognizes a Footman by it's rawcode "hfoo".
You can access the rawcodes of you map by:
1 - Open Object Editor
2 - View
3 - Display Values as raw Data
Every rawcode has the following syntax: .... 'rawcode' ....
Example: ..... 'A001' ......
And this is valid for every JASS coders in the world.
Once you found the rawcodes of your abilities, just replace them, and
code will be fully working.
Hope that this Mini-tutorial helped.
Regards Flame_Phoenix, PurplePoot and Pyritie.
//TESH.scrollpos=86
//TESH.alwaysfold=0
//===========================================================================
//A spell that makes a thunder fall over an enemy, adding chances to do many
//things to him
//
//@author Flame_Phoenix
//@credits Pyritie and PurplePoot
//@version 1.2
//===========================================================================
function LightningBolt_Conds takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
//This is the condition that checks if the spell being
//cast is the Lightning Bolt Spell. If it is, then it will
//activate the acts function.
endfunction
//===================================================
function LB_InstantKill_Conds takes integer level returns boolean
return GetRandomReal(1, 100) <= .5*(level-3)
//this is the algebric formulae for the 5 levels.
//if the real I get from random obeys the formulae, it will
//return true, else it will return false.
endfunction
//===================================================
function LB_DoubleDamage_Conds takes integer level returns boolean
local real chance = 2*level + 2 // algebric formulae for DoubleDamage
if level == 1 then
set chance = 0
endif
//the formulae only works after lv 1, so we have this if,
//featuring a special case.
return GetRandomReal(1, 100) <= chance
//If the real I get from random obeys the formulae,it will
//return true, else it will return false.
//works from level 2 - 5.
endfunction
//===================================================
function LB_DoNothing_Conds takes integer level returns boolean
local real chance = .25*Pow(level-2,2) //algebric formulae for DoNothing
if level < 3 then
set chance = 0
endif
//because the formulae does not includes lv 3, we must have
//an if featuring this exception
return GetRandomReal(1, 100) <= chance
//If the real I get from random obeys the formulae, it will
//return true, else it will return false.
//works for levels 1, 2, 4 and 5.
endfunction
//===================================================
function LightningBolt_Acts takes nothing returns nothing
local unit caster = GetTriggerUnit() //variable to store the casting unit
local unit target = GetSpellTargetUnit() //variable to store the target
local integer i = GetUnitAbilityLevel(caster,'A002') //level of the ability
local unit dummy = CreateUnit( GetOwningPlayer(caster), 'h000', GetUnitX(target), GetUnitY(target), 0) //creates a dummy unit foe the caster at target's position
local texttag t = CreateTextTag() //a variable to create text Tag
local effect e //the thunder effect
local boolean b = LB_DoNothing_Conds(i) //boolean variable. It is tru or false, depending on the DoNothing Condition return
call SetTextTagPosUnit( t, caster, 0 ) //creates the text at caster's position
call SetTextTagPermanent(t, false) //disbales infinite life for the text
call SetTextTagVelocity( t, 0, .0277 ) //makes the text go up
if not b then //if DoNothing == false
set e = AddSpecialEffectTarget("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", target, "origin") //creates the thunder at target
endif
if b then //if DoNothing == true
set e = AddSpecialEffect("Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl", GetUnitX(target) + GetRandomReal(8, 160) * Cos(GetRandomReal(0, 2 * 3.14159)),GetUnitY(target) + GetRandomReal(15, 150) * Sin(GetRandomReal(0, 2* 3.14159))) //Creates the thunder at a random position from the target
call SetTextTagText(t, "Missed", .023 ) //sets text to missed
call SetTextTagColor(t, 255, 0, 0, 255 ) //sets the color of the text
elseif LB_InstantKill_Conds(i) then // if Instant Kill returns true
call KillUnit(target) //kill the target
call SetTextTagText(t, "Fried", .023 ) //sets text to fried
call SetTextTagColor(t, 255, 250, 0, 255 ) //sets color of text
else //if DoNothing == false and Instant Kill == false then
if LB_DoubleDamage_Conds(i) then //if Double damage returns true
call UnitDamageTarget(caster, target, 75 * i, true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null) //damages target for normal ammount of damage
call SetTextTagText(t, "Doubled", .023 ) //sets text to doubled
call SetTextTagColor(t, 80, 80, 255, 255 ) //sets color of the text
endif
call UnitAddAbility(dummy, 'A000') //add stun to dummy unit
call UnitAddAbility(dummy, 'A001') //add slow to dummy unit
call SetUnitAbilityLevel(dummy, 'A000', i) //sets level of stun to the level of the caster's ability
call SetUnitAbilityLevel(dummy, 'A001', i) //sets level of slow to the level of the caster's ability
call IssueTargetOrder(dummy, "thunderbolt", target)//orders dummy to stun target
call TriggerSleepAction(.5) //waits for dummy to finish casting the stun spell
call IssueTargetOrder(dummy, "slow", target)//Orders dummy to slow the target
call UnitApplyTimedLife(dummy, 'BTLF', 2)//gives a 2 sec life time to dummy
call UnitDamageTarget(caster, target, 75 * i, true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null) //damages thetarget by normal damage
endif
call DestroyEffect(e) //destroy thunder
set caster = null //helps avoiding leaks, thus increasing speed
set target = null //helps avoiding leaks, thus increasing speed
set dummy = null //helps avoiding leaks, thus increasing speed
set e = null //helps avoiding leaks, thus increasing speed
call SetTextTagLifespan(t, 2) //adds a life time to the text, if created
set t = null //removes text from memory
endfunction
//==========================================================
function InitTrig_Lightning_Bolt_opt takes nothing returns nothing
local integer index = 0
set gg_trg_Lightning_Bolt_opt = CreateTrigger()
loop
exitwhen index == 16
call TriggerRegisterPlayerUnitEvent(gg_trg_Lightning_Bolt_opt, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index +1
endloop
//All this above is to check an event.
call TriggerAddCondition( gg_trg_Lightning_Bolt_opt, Condition( function LightningBolt_Conds ) ) //checks for the condition
call TriggerAddAction( gg_trg_Lightning_Bolt_opt, function LightningBolt_Acts ) //runs this action if both event and condition are true
endfunction