• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Cutting Saw v1.2

The Goblin Shredder hits the target with his saw, leaving the saw in the unit. The saw spin inside the target, dealing 70/100/130 damage over 5/6/7 seconds. When it stops spinning, it will explode, dealing 60/80/100 damage to the target.


I made the spell for a spell pack i intend to do (Goblin Shredder) but I'm too lazy to make the other spells now so I'm uploading this one now and the others will come in a few days.

The spell is MUI, doesn't cause lag and it's leakless (as far as I know).

If you find any bugs, let me know. Oh and if you have any suggestions, post them here and I'll see what I can do.

[JASS="Code"]//Made by Destroyer95

scope Saw initializer Initi

globals

private constant integer SPELL_ID = 'A000' //Put the ID of your spell here!
private constant string SAW_LOOK = "Abilities\\Weapons\\SentinelMissile\\SentinelMissile.mdl" //How the saw looks
private constant string SAW_ATTACH = "chest" //Attachment point of the saw and the blood effect
private constant string SAW_EFFECT = "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //How the blood effect look (doesn't have to be blood ofcourse)
private constant string EXPLODE_EFFECT = "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl" //How the explosion looks when the timer runs out
private constant real PERIOD = 0.2


/////////////////Don't touch this part/////////// //
private integer total = 0 //
private timer TIMER = CreateTimer() // **************************
private effect array saws // **More adjustables down!**
private real array durrations // **************************
private unit array targets //
private unit array casters //
private integer array levels //
/////////////////////////////////////////////////
endglobals

private function SAW_DURRATION takes integer lvl returns real //The time before the saw explodes
return lvl + 4.
endfunction

private function DAMAGE takes integer lvl returns real //The total damage that the saw deals over time
return lvl * 30 + 40.
endfunction

private function EXPLODE_DMG takes integer lvl returns real //The damage that the saw does when it explodes
return lvl * 20 + 40.
endfunction

////////////////////////////////////////////////////////////////////////////////
//////////Don't touch anything below unless you know what you're doing//////////
////////////////////////////////////////////////////////////////////////////////

private function Callback takes nothing returns nothing
local integer i = 0
loop
exitwhen i >= total
if durrations > 0 and GetWidgetLife(targets) > 0.405 then
call DestroyEffect(AddSpecialEffectTarget(SAW_EFFECT, targets, SAW_ATTACH))
call UnitDamageTarget(casters, targets, DAMAGE(levels) / SAW_DURRATION(levels) * PERIOD, false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
set durrations = durrations - PERIOD
else
call DestroyEffect(AddSpecialEffect(EXPLODE_EFFECT, GetUnitX(targets), GetUnitY(targets)))
call DestroyEffect(saws)
call UnitDamageTarget(casters, targets, EXPLODE_DMG(levels), false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
set total = total - 1
set casters = casters[total]
set targets = targets[total]
set durrations = durrations[total]
set saws = saws[total]
set levels = levels[total]
set i = i - 1
endif
set i = i + 1
endloop
if total == 0 then
call PauseTimer(TIMER)
endif
endfunction

private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction

private function Act takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target = GetSpellTargetUnit()
set casters[total] = caster
set targets[total] = target
set durrations[total] = SAW_DURRATION(GetUnitAbilityLevel(caster, SPELL_ID))
set saws[total] = AddSpecialEffectTarget(SAW_LOOK, target, SAW_ATTACH)
set levels[total] = GetUnitAbilityLevel(caster, SPELL_ID)
if total == 0 then
call TimerStart(TIMER, PERIOD, true, function Callback)
endif
set total = total + 1
set caster = null
set target = null
endfunction

private function Initi takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Cond))
call TriggerAddAction(t, function Act)
endfunction

endscope

//Made by Destroyer95[/code]

Removed the DoT Systemr


A few minor fixes
Screenshot changed


Keywords:
Saw, Cutting, Damage over Time, DoT, Goblin
Contents

Cutting Saw (Map)

Reviews
10:48, 7th Jun 2010 The_Reborn_Devil: It's very simple and a bit short, but the coding looks ok. You could remove the locals in the function Act though. Here: local unit caster = GetTriggerUnit() local unit target =...

Moderator

M

Moderator

10:48, 7th Jun 2010
The_Reborn_Devil:

It's very simple and a bit short, but the coding looks ok.
You could remove the locals in the function Act though.
Here:
JASS:
   local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    set casters[total] = caster
    set targets[total] = target
Could be:
JASS:
    set casters[total] = GetTriggerUnit()
    set targets[total] = GetSpellTargetUnit()

It's not that much, but at least you lose 4 lines of code (two lines for declaration and two lines for nulling) ^^



Status: Approved
Rating: Lacking (it was a bit too short and simple)
 
Level 8
Joined
Jul 28, 2008
Messages
211
I saw his system (and it's a little bit different) and that's why I didn't post mine seperatley. And how else should I name a system which deals damage over time? I mean I saw a lot of Inventory Systems and Camera Systems but they all have the same name (who wants to name a system which improves the inventory Someguy's Owning System) so I think it's ok.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Review said:
Cutting Saw

Very clean and concise, though there really isn't any necessity in using your "DoT" library. You already set up a timer with a stack so there is no need to use another one that is specifically for dmg/time.

- I'm not sure how acceptable it is that you use a library that has not been approved by our moderators, talking specifically about your "DoT" library. There don't appear to be any problems with it, though, so I'll ignore that for now.

- Again, (as in your last spell) you can eliminate the use of the "I2R" functions by typecasting the integers. By now I know you have acknowledged this and how to fix it so I won't provide examples.

- There are two leaks in your "Act" function. Both of the unit variables you allocate are not nulled.

- You forget to use a constant variable instead of a hard-coded value:

JASS:
            set durrations[i] = durrations[i] - 0.2

You should be using the "checkperiod" value.

- Oh, and one more thing. You need a better picture, the current one is generic and doesn't show a damn thing about the spell.

Dark_Axl said:
but i like the way it use single timer...

Actually it uses two.

Destroyer95 said:
If the system is by you, you should've checked Hive before naming it as you wanted.

The name may be fine, but you should have definitely searched the resources section for something similar to use for your spell so that a user doesn't need to have several systems that do the same thing just for a handful of spells.
 
Last edited:
Level 8
Joined
Jul 28, 2008
Messages
211
I'll fix it another day... too busy with school now. Anyway, I'm glad a mod rewieved it.

It's very simple, but the coding looks ok.
The coding looks ok, but isn't it a bit simpel?
i don't know but in my opinion, this spell is too simple...
Yea it is simple. I can't think of good spell ideas. But, I saw a few other spells (enhanced critical, vampiric strike) which were also simple but nobody said they were simple in those posts. So am I a simple-spell-hater (not really hater but I couldn't find a better word) magnet or something? :grin:
 
Top