- Joined
- Aug 19, 2008
- Messages
- 491
I don't play dota!Anyway, Timers ... do what do you think of ... Mmmmm a spell like Ranger arrow from Dota?
xD

I don't play dota!Anyway, Timers ... do what do you think of ... Mmmmm a spell like Ranger arrow from Dota?
xD
I don't play dota!![]()
I don't play dota!
Then you both have good taste =PNor do I.
local trigger InstantJusticeTrg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(InstantJusticeTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(InstantJusticeTrg, Condition( function Conditions ) )
call TriggerAddAction( InstantJusticeTrg, function Actions )
Ok, you see, a when you click new trigger button, you are NOT really creating a trigger, you are instead creating a document of text, or a project (in C++ if you use Eclipse, or IDE::Blocks). Each text document can contain several triggers inside it. Triggers control what happens when a player does an action. Triggers fire on certain events. In this case, every time a player casts ANY spell, it will fire this trigger, and it will run the code you made.local trigger InstantJusticeTrg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(InstantJusticeTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(InstantJusticeTrg, Condition( function Conditions ) )
call TriggerAddAction( InstantJusticeTrg, function Actions )
Mostly because most map makers finds it boring to play.Nice tutorial, it was my first vJass tutorial and i could understand everything.
Btw, why the hate against dota. I often think people are just jealous that they haven't got a map that is so popular. Ok, i must admit some spells suck hard (like Return skill of centaur), but in overall the gameplay is better than wow IMO.
Because even this simple spell is better then half Dota spells. Morale ? Dota doesn't have enough quality for the reputation it has. Dota is popular because gamers are ignorants that can't distinguish a good quality spell from a rip-off spell.Btw, why the hate against dota.
Oh my f**king God. I've been waiting for this since... early april?I now officially say I will start on a new tutorial. I will start it on day 20 July and I intend to cover the basis of structures and timers as well as modularity. Wish me luck people !
Then check my project xDAny way , i don't know any other maps with more than 360 spells.
Yep, kind of. InitTrig_ can be compared to Events in GUI, just that you can do alot more with InitTrig_.I have a question. Is the Init function where the Event is?
Good answer. rep++Yep, kind of. InitTrig_ can be compared to Events in GUI, just that you can do alot more with InitTrig_.
Wrong? vJass supports structs, which is not supported on JASS2. Its basically converted back to JASS2, but its features get lost.vJass can't do anything Jass2 can't, but it's so much easier. I'd totally recommend it, even if you're not going to utilize all of its features (I myself only use free global declaration and scopes).
Meaning that JASS CAN but in a much harder, insane, and ridiculously not modular way.Wrong? vJass supports structs, which is not supported on JASS2. Its basically converted back to JASS2, but its features get lost.
//===========================================================================
// I thought it was spelled effect, not effetc?
//A vJASS and JESP spell that will have an effetc depending on the number
//of units in the AOE. If there are more allies than enemies, we heal allies
//if there are more enemies that allies we damage enemies, if the number of
//allies equals the number of enemies we heal the allies and damage the enemies
//
//@author Flame_Phoenix
//
//@credits
//- Blade.dk, for the CopyCroup function
//
//@version 1.0
//===========================================================================
scope InstantJustice initializer Init
//===========================================================================
//=============================SETUP START===================================
//===========================================================================
// Why such long names? SPELL_ID is fine, but why use underscores? DummyID works fine. I guess I`m a speed freak.
globals
private constant integer SPELL_ID = 'ANsi' //the rawcode of the spell
private constant integer DUMMY_ID = 'h000' //rw of the dummy unit
private constant string AOE_EFFECT = "Units\\NightElf\\Wisp\\WispExplode.mdl" //effect that will be created when we cast the spell on the AOE
private constant string HEAL_EFFECT = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" //effect that will be created when we heal units
private constant string DAMAGE_EFFECT = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" //effect that will be created when we damage units
private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL //the attack type of the spell
private constant attacktype A_TYPE = ATTACK_TYPE_MAGIC //the damage type of the spell
endglobals
private function Range takes integer level returns real
//returns the range the spell will affect
return level * 150.
endfunction
private function Heal takes integer level returns real
//returns the heal allies will take
return level * 75.
endfunction
private function Damage takes integer level returns real
//returns the damage enemies will take
return level * 50.
endfunction
private function Targets takes unit target returns boolean
//the units the spell will affect
return (GetWidgetLife(target) > 0.405) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false)
endfunction
//===========================================================================
//=============================SETUP END=====================================
//===========================================================================
globals
private group all
private group copy
private boolexpr b
endglobals
//===========================================================================
//Function made by Blade.dk; Search for [url=http://www.wc3campaigns.com]wc3campaigns.com[/url] for more info
private function CopyGroup takes group g returns group
set bj_groupAddGroupDest = CreateGroup()
call ForGroup(g, function GroupAddGroupEnum)
return bj_groupAddGroupDest
endfunction
//===========================================================================
private function Pick takes nothing returns boolean
return Targets(GetFilterUnit())
endfunction
//===========================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
//===========================================================================
// These variables are too long. You need to shorten them, it kills me.
private function Actions takes nothing returns nothing
local location spellLoc = GetSpellTargetLoc()
local real spellX = GetLocationX(spellLoc)
local real spellY = GetLocationY(spellLoc)
local unit caster = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
local unit f
local integer allies = 0
local integer enemies = 0
//create the AOE effect
call DestroyEffect(AddSpecialEffect(AOE_EFFECT, spellX, spellY))
//counting the units
call GroupEnumUnitsInRange(all, spellX, spellY, Range(level), b)
set copy = CopyGroup(all)
loop
set f = FirstOfGroup(copy)
exitwhen(f == null)
call GroupRemoveUnit(copy, f)
if IsUnitAlly(f, GetOwningPlayer(caster)) then
set allies = allies + 1
else
set enemies = enemies + 1
endif
endloop
//making the effect of the spell
if allies > enemies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//heal allies
if IsUnitAlly(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin")) //the healing effect
call SetWidgetLife(f, GetWidgetLife(f) + Heal(level))
endif
endloop
elseif enemies > allies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//damage enemies
if IsUnitEnemy(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin")) //the damaging effect
call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null)
endif
endloop
elseif allies == enemies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//heal allies
if IsUnitAlly(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin"))
call SetWidgetLife(f, GetWidgetLife(f) + Heal(level))
//if an unit is not an ally than it is an enemy
else
call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin"))
call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null)
endif
endloop
endif
call RemoveLocation(spellLoc)
set spellLoc = null
set caster = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger InstantJusticeTrg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(InstantJusticeTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(InstantJusticeTrg, Condition( function Conditions ) )
call TriggerAddAction( InstantJusticeTrg, function Actions )
//setting globals
set all = CreateGroup()
set copy = CreateGroup()
set b = Condition(function Pick)
//preloading effects
call Preload(AOE_EFFECT)
call Preload(HEAL_EFFECT)
call Preload(DAMAGE_EFFECT)
//preloading the ability
// BJ...? I didn`t look that up, but I think it has a native replacement.
set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMY_ID, 0, 0, 0)
call UnitAddAbility(bj_lastCreatedUnit, SPELL_ID)
call KillUnit(bj_lastCreatedUnit)
endfunction
endscope
Because teaching modularity is also a good thing to do, and a good thing for you to learn.The great problem in THW is because of people like you that refuse to be modular and to follow community standards. At the time this tutorial was written, it compiled to all known standards of the coding community.You also rely on a system in a tutorial. Why rely on a system when you are teaching? This isn`t a very good spell to teach, tbh.
JASS:
function funcName takes type1 varName returns type2
statements
endfunction
//would be in cJASS:
type2 funcName(type1 varName)
{
statements
}
JASS:
function funcName takes type1 varName returns type2
statements
return bla
endfunction
//would be in cJASS:
type2 funcName(type1 varName)
{
statements
return bla
}
Flame_Phoenix said:The "v" is for very and not for "Vexorian". Vexorian wanted to call it JASS++ however Zoxc suggested vJASS for veryJASS and Vexorian liked the idea. Thanks to Vexorian for explaining me the origin of the name.
//===========================================================================
//A vJASS and JESP spell that will have an effetc depending on the number
//of units in the AOE. If there are more allies than enemies, we heal allies
//if there are more enemies that allies we damage enemies, if the number of
//allies equals the number of enemies we heal the allies and damage the enemies
//
//@author Flame_Phoenix
//
//@credits
//- Blade.dk, for the CopyCroup function
//
//@version 1.0
//===========================================================================
scope InstantJustice initializer Init
//===========================================================================
//=============================SETUP START===================================
//===========================================================================
globals
private constant integer SPELL_ID = 'A00W' //the rawcode of the spell
private constant integer DUMMY_ID = 'h002' //rw of the dummy unit
private constant string AOE_EFFECT = "Units\\NightElf\\Wisp\\WispExplode.mdl" //effect that will be created when we cast the spell on the AOE
private constant string HEAL_EFFECT = "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" //effect that will be created when we heal units
private constant string DAMAGE_EFFECT = "Abilities\\Weapons\\Bolt\\BoltImpact.mdl" //effect that will be created when we damage units
private constant damagetype D_TYPE = DAMAGE_TYPE_NORMAL //the attack type of the spell
private constant attacktype A_TYPE = ATTACK_TYPE_MAGIC //the damage type of the spell
endglobals
private function Range takes integer level returns real
//returns the range the spell will affect
return level * 300.
endfunction
private function Heal takes integer level returns real
//returns the heal allies will take
return level * 500.
endfunction
private function Damage takes integer level returns real
//returns the damage enemies will take
return level * 500.
endfunction
private function Targets takes unit target returns boolean
//the units the spell will affect
return (GetWidgetLife(target) > 0.405) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitType(target, UNIT_TYPE_MECHANICAL) == false)
endfunction
//===========================================================================
//=============================SETUP END=====================================
//===========================================================================
globals
private group all
private group copy
private boolexpr b
endglobals
//===========================================================================
//Function made by Blade.dk; Search for [url]www.wc3campaigns.com[/url] for more info
private function CopyGroup takes group g returns group
set bj_groupAddGroupDest = CreateGroup()
call ForGroup(g, function GroupAddGroupEnum)
return bj_groupAddGroupDest
endfunction
//===========================================================================
private function Pick takes nothing returns boolean
return Targets(GetFilterUnit())
endfunction
//===========================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
//===========================================================================
private function Actions takes nothing returns nothing
local location spellLoc = GetSpellTargetLoc()
local real spellX = GetLocationX(spellLoc)
local real spellY = GetLocationY(spellLoc)
local unit caster = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
local unit f
local integer allies = 0
local integer enemies = 0
//create the AOE effect
call DestroyEffect(AddSpecialEffect(AOE_EFFECT, spellX, spellY))
//counting the units
call GroupEnumUnitsInRange(all, spellX, spellY, Range(level), b)
set copy = CopyGroup(all)
loop
set f = FirstOfGroup(copy)
exitwhen(f == null)
call GroupRemoveUnit(copy, f)
if IsUnitAlly(f, GetOwningPlayer(caster)) then
set allies = allies + 1
else
set enemies = enemies + 1
endif
endloop
//making the effect of the spell
if allies > enemies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//heal allies
if IsUnitAlly(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin")) //the healing effect
call SetWidgetLife(f, GetWidgetLife(f) + Heal(level))
endif
endloop
elseif enemies > allies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//damage enemies
if IsUnitEnemy(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin")) //the damaging effect
call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null)
endif
endloop
elseif allies == enemies then
loop
set f = FirstOfGroup(all)
exitwhen (f == null)
call GroupRemoveUnit(all, f)
//heal allies
if IsUnitAlly(f, GetOwningPlayer(caster)) then
call DestroyEffect(AddSpecialEffectTarget(HEAL_EFFECT, f, "origin"))
call SetWidgetLife(f, GetWidgetLife(f) + Heal(level))
//if an unit is not an ally than it is an enemy
else
call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, f, "origin"))
call UnitDamageTarget(caster, f, Damage(level), true, false, A_TYPE, D_TYPE, null)
endif
endloop
endif
call RemoveLocation(spellLoc)
set spellLoc = null
set caster = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger InstantJusticeTrg = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(InstantJusticeTrg, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(InstantJusticeTrg, Condition( function Conditions ) )
call TriggerAddAction( InstantJusticeTrg, function Actions )
//setting globals
set all = CreateGroup()
set copy = CreateGroup()
set b = Condition(function Pick)
//preloading effects
call Preload(AOE_EFFECT)
call Preload(HEAL_EFFECT)
call Preload(DAMAGE_EFFECT)
//preloading the ability
set bj_lastCreatedUnit = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMY_ID, 0, 0, 0)
call UnitAddAbility(bj_lastCreatedUnit, SPELL_ID)
call KillUnit(bj_lastCreatedUnit)
endfunction
endscope