| 12-03-2007, 04:46 PM | #1 |
Hi guys, This community has been a great help to me in my quest to make JASS spells lol, so in turn I would like to share it, but I was wondering where I could post it for it to get evaluated, I mean it needs to be evaluated as it is my first spell ever written in jass. I would like experienced people to flame, advice and help me in optimizing it so other forum members might be able to put it to use. Also its not too original, I took the idea from warcraft's holy light and added a twist to it. What it basically does is heal units within x range of the caster, units within x range of the healed units get damaged. So basically I used another idea from DoTA, I merged them both and theres my spell. Here is the code so it can be pre-evaluated. Thanks! JASS:// ==============Spell Data Configuration================= constant function HolyLight takes nothing returns integer return 'A000' endfunction constant function heal takes integer level returns integer return 100*level endfunction constant function damage takes integer level returns integer return (100*level)/2 endfunction constant function healrange takes nothing returns real return 300.00 endfunction constant function damagerange takes nothing returns real return 200.00 endfunction // =============================================== function HolyLightcondition takes nothing returns boolean return GetSpellAbilityId() == HolyLight() endfunction function HolyLightfilterally takes nothing returns boolean return IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and GetWidgetLife( GetFilterUnit()) > 0.405 and IsUnitAlly( GetFilterUnit(), GetOwningPlayer( GetTriggerUnit() )) == true endfunction function HolyLightfilterenemy takes unit fu, unit eu returns boolean return IsUnitType( eu, UNIT_TYPE_STRUCTURE) == false and GetWidgetLife( eu) > 0.405 and IsUnitEnemy( eu, GetOwningPlayer( fu)) == true endfunction function blankfilter takes nothing returns boolean return true endfunction function HolyLightactions takes nothing returns nothing local unit u = GetTriggerUnit() local unit fu local unit eu local real ux = GetUnitX(u) local real uy = GetUnitY(u) local integer level = GetUnitAbilityLevel( u, HolyLight()) local integer i = 0 local group g = CreateGroup() local group fg = CreateGroup() local boolean b local boolexpr ally = Condition(function HolyLightfilterally) local boolexpr NULL = Condition(function blankfilter) call GroupEnumUnitsInRange( g, ux, uy, healrange(), ally) loop set fu = FirstOfGroup(g) exitwhen fu == null call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" , fu, "origin")) call SetUnitState( fu, UNIT_STATE_LIFE, GetUnitState( fu, UNIT_STATE_LIFE) + I2R(heal(level))) call GroupEnumUnitsInRange( fg, GetUnitX(fu), GetUnitY(fu), damagerange(), NULL) loop set eu = FirstOfGroup(fg) exitwhen eu == null set b = HolyLightfilterenemy( fu, eu) if b == true then call UnitDamageTarget( u, eu, damage(level), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_UNIVERSAL, null) call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl" , eu, "origin")) endif call GroupRemoveUnit( fg, eu) endloop call GroupRemoveUnit(g, fu) endloop call DestroyGroup(g) call DestroyGroup(fg) set ally = null set NULL = null set u = null set fu = null set eu = null set fg = null set g = null endfunction //=========================================================================== function InitTrig_Holy_Light takes nothing returns nothing local integer i = 0 set gg_trg_Holy_Light = CreateTrigger( ) loop call TriggerRegisterPlayerUnitEvent( gg_trg_Holy_Light, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT,null) set i = i + 1 exitwhen i== bj_MAX_PLAYERS endloop call TriggerAddCondition( gg_trg_Holy_Light, Condition( function HolyLightcondition ) ) call TriggerAddAction( gg_trg_Holy_Light, function HolyLightactions ) call Preload("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl") call Preload("Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl") endfunction |
| 12-03-2007, 06:02 PM | #2 |
Don't use constant functions for stuff like that, use constant globals JASS:globals constant integer HolyLight = 'A000' endglobals Also, you might want to not use global variables for each trigger. Try either locals, or a temporary global. |
| 12-03-2007, 06:06 PM | #3 |
I think its ok using constant functions as long as he's using plain Jass and not vJass. To submit your spell: I think you can submit spell-packs as a resource, but therefore you would probably need more than one spell and a demo map. Else you could just submit it in the scripts and triggers forum and ask for comments. PS: For a first timer your spell-code looks amazingly good |
| 12-03-2007, 06:29 PM | #4 |
@ vesuvan: thanks for the tip. I used it like that because I want this to be easily imported to other maps, using globals would mean they would need to create the value itself, Thanks again. @tamisrah: Thanks for the info, Now ill try to post it in there + REP for your effort guys. |
| 12-03-2007, 09:47 PM | #5 |
You don't need to destroy boolexprs afaik. Condition(function X) creates the boolexpr and saves it in a table. When it's called again, it just refers to the table, it doesn't create a new one each time. |
| 12-03-2007, 11:23 PM | #6 |
Listen to Jazradel, he's right. |
| 12-04-2007, 04:47 AM | #7 |
@ Jazradel: thanks for pointing that out. I'll edit it right now. @ Pyrogasm: thanks for droping by, I'm your fan lol + REP for helping guys |
| 12-04-2007, 06:43 AM | #8 | |
Quote:
|
| 12-04-2007, 09:48 AM | #9 |
I need help guys, Is there a tutorial for MUI spellmaking, I haven't had any tutorials like that so far so I can't determine if the spell I made is multi-unit Instanceable, I do want to submit this as a spell resource. : ) thanks lol @ Pyrogasm: I had to go to dictionary.com to get the meaning of posse lol, thanks for the new vocabulary word |
| 12-04-2007, 10:58 AM | #10 |
It's MUI if all the references you use after the trigger initially runs are local (GetTriggerUnit(and maybe some other functions), locals, arrays using a unique index) |
| 12-04-2007, 12:54 PM | #11 |
Thanks Jaz now, now I can continue working on it! |
