• 🏆 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!

SINGLE TARGET ABILITY TEMPLATE v0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
--Ability Format
--CATD base
(Caster unit, ability level, target unit, dummy unit) simplified.

vJASS + Dummy Unit Required.

This is a template for a single target spell simplification. It's as simple as modifying 9 globals: 5 strings, 1 real, 3 integers to the specifications of the user, as well as, setting up the 'results' function for what the user plans to have done to the 'target unit'.

I use this template in my current project (an RPG), and it works great for saving time just mass producing a few single target spells for the heroes.

Goodluck. No credit needed, it really isn't that hard to make.

(note: this download does not come with a dummy unit model that is used in the template, and one is required for the dummy unit used in the actual spell.)

[JASS="code"]
//-=-=-=-=-=-=-=-=-=-=-
//-=- Ability Format -=-
//-=- CATD base -=-
//-=-=-=-=-=-=-=-=-=-=-

library YourLibraryHere initializer init
globals
private integer Ability = '????' // Ability ID
// ^- Rewrite the value based on what the Ability ID you've chosen is.

private integer dummy = '????' // UnitType ID
// ^- Rewrite the value based on what the UnitType ID you've chosen for your dummy unit.

private group abilGroup = CreateGroup( )
// ^- Do not modify. This will store your dummy units in a group for 'active spells'.

private integer mT = 10 // maximum Time
// ^- The amount of time the spell will exist before destroying itself as a fail.

private real v = 10 // velocity
// ^- The speed at which your dummy spell will travel.

private string seCi = "..."
// ^- Model string chosen for the Casting units initial effects

private string seTi = "..."
// ^- Model string chosen for the Target units initial effects

private string seTfA = "..."
// ^- Model string chosen for the Target units final effects (PART A)

private string seTfB = "..."
// ^- Model string chosen for the Target units final effects (PART B)

private string seD = "..."
// ^- Model string chosen for the dummy unit.
endglobals

private function results takes unit t, integer l returns nothing
// FINISH THIS FUNCTION WITH THE RESULTS YOU'VE DECIDED FOR THE TARGETED UNIT.
// THIS FUNCTION TAKES THE TARGETED UNIT (t) AND CASTER'S ABIlITY LEVEL (l).
endfunction

// Do not modify beyond this point, unless you understand what you're doing.
// The following is pre-coded to work itself given that you've finished the above.

private struct data
unit c // caster
integer a // ability level
unit t // target
unit d // dummy

effect eCi // effect Caster initial
effect eTi // effect Target initial
effect eTf // effect Target final
effect eD // effect Dummy

real exp // spell expiration Timer

static method create takes unit c, real x, real y, integer a, unit t returns data
local data d = data.allocate()

set d.c = c
set d.a = a
set d.t = t
set d.d = CreateUnit(GetOwningPlayer(d.c), dummy, x, y, GetUnitFacing(c))
call GroupAddUnit(abilGroup, d.d)

set d.eCi = AddSpecialEffectTarget(seCi, d.c, "origin")
set d.eTi = AddSpecialEffectTarget(seTi, d.t, "origin")
set d.eD = AddSpecialEffectTarget(seD, d.d, "origin")
set d.exp = 0

call DestroyEffect(d.eCi)
set d.eCi = null

call SetUnitUserData(d.d, d)
return d
endmethod

static method update takes nothing returns nothing
local unit u = GetEnumUnit()
local data d = GetUnitUserData(u)
local location loc = GetUnitLoc(u)
local location col = GetUnitLoc(d.t)

set d.exp = d.exp + .05 // update timer.

call SetUnitFacing(u, AngleBetweenPoints(loc,col))
call SetUnitX(u, GetUnitX(u) + v * Cos(GetUnitFacing(u) * bj_DEGTORAD))
call SetUnitY(u, GetUnitY(u) + v * Sin(GetUnitFacing(u) * bj_DEGTORAD))

if ( DistanceBetweenPoints(loc,col) <= v ) then // if spell hits.
set d.exp = mT
call results(d.t, d.a)

set d.eTf = AddSpecialEffectTarget(seTfA, d.t, "origin")
call DestroyEffect(d.eTf)
set d.eTf = AddSpecialEffectTarget(seTfB, d.t, "origin")
call DestroyEffect(d.eTf)
set d.eTf = null
endif

if ( d.exp >= mT ) then // if spell expires.
call DestroyEffect(d.eTi)
set d.eTi = null
call DestroyEffect(d.eD)
set d.eD = null

set d.c = null
set d.t = null
set d.d = null

call RemoveUnit(u)
call GroupRemoveUnit(abilGroup,u)
call d.destroy()
endif

set u = null
call RemoveLocation(loc)
set loc = null
call RemoveLocation(col)
set col = null
endmethod
endstruct

private struct store
unit target

static method create takes unit c, unit t returns store
local store s = store.allocate()

set s.target = t
call SetUnitUserData(c, s)

return s
endmethod
endstruct

private function cast takes nothing returns nothing
local unit u = GetTriggerUnit()
local store s = GetUnitUserData(u)

if ( GetSpellAbilityId() == Ability ) then
call data.create(u, GetUnitX(u), GetUnitY(u), GetUnitAbilityLevel(u, Ability), s.target)
// caster x y ability level target
call s.destroy()
endif

set u = null
endfunction

private function periodic takes nothing returns nothing
local integer i = CountUnitsInGroup(abilGroup)

if ( i > 0 ) then
call ForGroup(abilGroup, function data.update)
endif
endfunction

private function identify takes nothing returns nothing
if ( GetSpellAbilityId() == Ability ) then
call store.create(GetTriggerUnit(), GetSpellTargetUnit())
endif
endfunction

private function init takes nothing returns nothing
local trigger t
local integer i

set i = 0
set t = CreateTrigger( )
loop
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_CAST, null)
endif

set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(t, function identify)

set i = 0
set t = CreateTrigger( )
loop
if ( GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING ) then
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_FINISH, null)
endif

set i = i + 1
exitwhen i > 11
endloop
call TriggerAddAction(t, function cast)

set t = CreateTrigger( )
call TriggerRegisterTimerEvent(t, .05, true)
call TriggerAddAction(t, function periodic)

set t = null
endfunction
endlibrary
[/code]

Keywords:
spell, template, target, spells, mmu, zerio, phenomenon
Contents

Just another Warcraft III map (Map)

Reviews
18:09, 7th Dec 2009 TriggerHappy: Review for SINGLE TARGET ABILITY TEMPLATE This is a horrible template. I mean why the hell is the struct even needed and the BJ event is completely fine. And on top of that this is just a plain...

Moderator

M

Moderator

18:09, 7th Dec 2009
TriggerHappy:


Review for SINGLE TARGET ABILITY TEMPLATE

This is a horrible template. I mean why the hell is the
struct even needed and the BJ event is completely fine.

And on top of that this is just a plain vJass script, go submit it
to the Jass Submission forum, though that may not be a great idea
either because this is pointless.

Status

Rejected
 
Top