Spellpack Aim, Reflective Counter, and Rock Bounce

Tom Jones

N/A
Reaction score
437
No wonder, your destroying the triggers.
Also that code is a mess, please clean it up. For example:
JASS:
private function Trig_AimTimer_Actions takes nothing returns nothing
call Exec(AimStop) //Why not simply ExecuteTrigger(AimStop)
call DestroyTimer(GetExpiredTimer())
endfunction
And there's a whole bunch of those excessive calls. If I were you, I would put everything in three functions: Initialization function, trigger actions function, and timer actions function. It may be hard with your current jass knowledge, but it'll definitely teach you a lot. You should make your main trigger register all the events, and then determine the eventid of a instance in the trigger actions function:
JASS:
function SomeFunction ...
    if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
        //Perform actions, etc. starting a timer.
    elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
        //Perform actions, etc. stopping a timer.
    endif
endfunction

function InitTrig_...
    local integer i = 0
    local integer a = GetPlayers()

    set SomeTrigger = CreateTrigger()
    loop
        exitwhen i > a
        call TriggerRegisterPlayerUnitEvent(SomeTrigger,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
        call TriggerRegisterPlayerUnitEvent(SomeTrigger,Player(i),EVENT_PLAYER_UNIT_SPELL_ENDCAST,null)
        set i = i+1
    endloop
    call TriggerAddAction(SomeTrigger,function SomeFunction)
endfunction
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>No wonder, your destroying the triggers
if i am not destroying it...it will just stack and makes more trigger of the same event same action?

>>It may be hard with your current jass knowledge
yeah it is preeeeeety hard....T.T

well...
idk this returns in checking a trigger's event :p



why null?
 

Sim

Forum Administrator
Staff member
Reaction score
534
> why null?

It's the native, and it takes as last argument a boolexpr filter.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>last argument a boolexpr filter
last argument...when is the last argument?

Edit:
Well...anyway...see this trigger, i had revise it...now the problem is...the AimStop trigger...if i put it at top...i cant call DisTrg ....if i put at btm...Trig_AimStop_Action undeclared...

What should i do ><''
JASS:
constant function RawC takes nothing returns integer
return &#039;A006&#039; // the raw code if Aim
endfunction

constant function RawS takes nothing returns integer
return &#039;A003&#039; //the raw code of Stop
endfunction

function AimSetCond takes nothing returns boolean
return GetSpellAbilityId() == RawC()
endfunction

function Trig_AimStop_Conditions takes nothing returns boolean
return GetSpellAbilityId() == RawS()
endfunction

function Trig_AimStopChannel_Conditions takes nothing returns boolean
return GetSpellAbilityId() == RawC()
endfunction

//scope1
scope trg
    globals
    private timer timez
    private unit caster
    private unit target
    private real damage
    endglobals
    
public function StartTimer takes real time, boolean perio, code func returns nothing
set timez = CreateTimer()
call TimerStart(timez, time, perio, func)
endfunction

public function EnaTrg takes trigger ena returns nothing
call EnableTrigger(ena)
endfunction

public function Abi takes boolean add, integer ablid returns nothing
if add == true then
    call UnitAddAbility(caster, ablid)
elseif add == false then
    call UnitRemoveAbility(caster, ablid)
endif
endfunction

public function SetDmg takes nothing returns nothing
set damage = damage + GetRandomReal(0.00,100.00)
endfunction

public function SetUnitVar takes boolean who, unit Manupulate returns nothing
if who == true then
set caster = Manupulate
else
set target = Manupulate
endif
endfunction

public function DamageTrg takes nothing returns nothing
call UnitDamageTarget(caster, target, damage, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endfunction

public function Exe takes trigger x returns nothing
call TriggerExecute(x)
endfunction

public function Effe takes nothing returns nothing
call DestroyEffect(AddSpecialEffectTarget(&quot;LasercannonfinalRED.mdx&quot;, target, &quot;origin&quot;))
endfunction
endscope
//endscope1

function Trig_AimCount_Actions takes nothing returns nothing
call trg_SetDmg()
endfunction

function Trig_AimTimer_Actions takes nothing returns nothing
call trg_Exe(AimStop)
endfunction

library timerwait
function TimerWaitz takes real durationz returns nothing  
local timer ct = CreateTimer()
local real tL 
if (durationz &gt; 0) then
call TimerStart(ct, durationz, false, null)
loop 
set tL = TimerGetRemaining(ct) 
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
exitwhen tL &lt;= 0 
endloop  
call DestroyTimer(ct) 
set ct = null 
endif 
endfunction
endlibrary

//scope start
scope trgtwo
    globals
    private trigger AimStop
    private trigger AimCount
    private trigger AimStopChannel
    private trigger AimTimer
    private boolean check
    endglobals

public function CreateTrg takes nothing returns nothing
if check == false then
set AimStop = CreateTrigger()
set AimCount = CreateTrigger()
set AimStopChannel=CreateTrigger()
set AimTimer = CreateTrigger()
    call TriggerAddAction(AimTimer, function Trig_AimTimer_Actions )
    call TriggerRegisterTimerExpireEvent(AimTimer, timez)
    call TriggerRegisterTimerEvent(AimCount, 0.5, true)
    call TriggerAddAction(AimCount, function Trig_AimCount_Actions )
    call TriggerRegisterAnyUnitEventBJ( AimStop, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( AimStop, Condition( function Trig_AimStop_Conditions ) ) 
    call TriggerAddAction(AimStop, function Trig_AimStop_Actions)
    call TriggerRegisterAnyUnitEventBJ(AimStopChannel, EVENT_PLAYER_UNIT_SPELL_ENDCAST )
    call TriggerAddCondition(AimStopChannel, Condition( function Trig_AimStopChannel_Conditions ) )
    call TriggerAddAction(AimStopChannel, function Trig_AimTimer_Actions )
set check = true
endif
endfunction

public function DisTrg takes string dis returns nothing
    if dis == &quot;AimCount&quot; then
call DisableTrigger(AimCount)
    elseif dis == &quot;AimStop&quot; then
call DisableTrigger(AimStop)
    elseif dis ==&quot;AimStopChannel&quot; then
call DisableTrigger(AimStopChannel)
    elseif dis == &quot;AimTimer&quot; then
call DisableTrigger(AimTimer)
endfunction
endscope
//endscope

function Trig_AimStop_Actions takes nothing returns nothing
call trg_Effe()
call trgtwo_DisTrg(&quot;AimCount&quot;)
call trg_Abi(false, RawS())
call TimerWaitz (1.20)
call trg_DamageTrg()
endfunction

function Trig_AimSet_Actions takes nothing returns nothing
local unit cast = GetSpellAbilityUnit()
local unit trg = GetSpellTargetUnit()
local integer LvlOfSpell = GetUnitAbilityLevel(cast, RawC())
call trgtwo_CreateTrg()
call trgtwo_DisTrg(&quot;AimCount&quot;)
call trg_abi(true, RawS())
call SetUnitVar(true,cast)
call SetUnitVat(false, trg)
call trg_StartTimer(I2R(LvlOfSpell)+4, false, null)
call trg_EnaTrg(AimCount)
endfunction

//===========================================================================
function InitTrig_AimSet takes nothing returns nothing
    set gg_trg_AimSet = CreateTrigger(  )
	call TriggerRegisterAnyUnitEventBJ(gg_trg_AimSet, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_AimSet, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_AimSet, function Trig_AimSet_Actions )
endfunction
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Remaked the whole spell....see first post for details
 

Sim

Forum Administrator
Staff member
Reaction score
534
Better already :p

Might want to fix the tooltips. It says damage is indicated by displayed text, but there is none. More constant functions should be needed also, such as the duration and damage.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
it is not mui though...how should i make it mui?
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Aw....i just forgoten i can set constant global thingy :p....will fix that in later version...
_______________________
Doing those tower and holy contest now...no time to care about Cloud Torture and this spell...sorry
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
The spell is almost done but something lame occur and i cant really fix it..
JASS:
scope Aim

constant function RawC takes nothing returns integer
    return &#039;A006&#039; // the raw code if Aim
endfunction

private function ChannelingCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimCountAct takes nothing returns nothing
local effect array laser
local timer t = GetExpiredTimer()
local real Time = GetHandleReal(t,&quot;time&quot;)
local real dmg = I2R(GetHandleInt(t,&quot;dmg&quot;))
local unit caster = GetHandleUnit(t,&quot;caster&quot;)
local unit target = GetHandleUnit(t,&quot;target&quot;)
        if (OrderId2StringBJ(GetUnitCurrentOrder(caster)) == &quot;channel&quot;) then
            if Time &gt;= .5 then
                call SetHandleInt(t,&quot;dmg&quot;,R2I(dmg)+GetRandomInt(1,100))
                call SetHandleReal(t,&quot;time&quot;,Time-.5)
            else
                call PauseTimer(GetExpiredTimer())
                set laser[1] = AddSpecialEffectTarget(&quot;LasercannonfinalRED.mdx&quot;, target, &quot;origin&quot;)
                set laser[2] = AddSpecialEffectTarget(&quot;Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl&quot;,caster,&quot;origin&quot;)
                call TriggerSleepAction(1.20)
                call BJDebugMsg(R2S(dmg)) //testing
                call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
                call FlushHandleLocals(t)            
                call DestroyTimer(GetExpiredTimer())
                call DestroyEffect(laser[1])
                call DestroyEffect(laser[2])
                set laser[1] = null
                set laser[2] = null
            endif
        else
            call PauseTimer(GetExpiredTimer())
            set laser[1] = AddSpecialEffectTarget(&quot;LasercannonfinalRED.mdx&quot;, target, &quot;origin&quot;)
            set laser[2] = AddSpecialEffectTarget(&quot;Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl&quot;,caster,&quot;origin&quot;)
            call BJDebugMsg(R2S(dmg)) //testing
            call TriggerSleepAction(1.20)
            call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call FlushHandleLocals(t)
            call DestroyTimer(GetExpiredTimer())
            call DestroyEffect(laser[1])
            call DestroyEffect(laser[2])
            set laser[1] = null
            set laser[2] = null
        endif
    set t = null
    set caster = null
    set target = null
endfunction

private function AimSetCond takes nothing returns boolean
    return GetSpellAbilityId() == RawC()
endfunction

private function AimSetAct takes nothing returns nothing
local integer dmg = 0
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
local integer LvlOfSpell = GetUnitAbilityLevel(caster,RawC())
local real Time = I2R(LvlOfSpell)+4
    call SetHandleReal(t,&quot;time&quot;,Time)
    call SetHandleInt(t,&quot;dmg&quot;,dmg)
    call SetHandleHandle(t,&quot;caster&quot;,caster)
    call SetHandleHandle(t,&quot;target&quot;,target)
    call TimerStart(t,0.5,true,function AimCountAct)
set caster = null
set target = null
set t = null
endfunction

//===========================================================================
function InitTrig_FullAimSetTryHandleVars takes nothing returns nothing
    set gg_trg_FullAimSetTryHandleVars = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_FullAimSetTryHandleVars, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_FullAimSetTryHandleVars, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_FullAimSetTryHandleVars, function AimSetAct )
endfunction

endscope

This is the code of the spell currently...and it just wont dealt damage..

Refer back to this page
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
yes it does...
There is a value in dmg variable...but it somehow...didn't damage the target...

I had check the target and the caster variable contains a unit...
I had check if the dmg and Time contains value....

Bump~!
Had fixed all bug and a new version is uploaded :D

Here is the code if you dont want to go to first page
JASS:
scope Aim

// Aim by Kentchow74+1 / ~GaLs~
// Special thanks to KaTTaNa&#039;s Local Handle Variable System
//
// Implementation
// 1. Copy the Aim spell from object editor to your map
// 2. Press Ctrl+D and check the rawcode of the spell...The first four number.
// 3. Replace it in the constant function ARawC
// 4. Copy the code from this map&#039;s header to your map header
// 5. Copy this whole trigger to your map
// 6. Replacing the value of the constant function to what you need.
// 7. Copy the 4 items from import manager to your map
// 8. Spell Ready.

//==================================================================================================
constant function ARawC takes nothing returns integer
    return &#039;A006&#039; // the raw code if Aim
endfunction

constant function ADuration takes real LevelOfAbility returns real
    return (LevelOfAbility)+4
endfunction

constant function LaserEffect takes nothing returns string
return &quot;LasercannonfinalRED.mdx&quot;
endfunction

constant function FlareEffect takes nothing returns string
return &quot;Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl&quot;
endfunction

constant function DelayBeforeDamageDealt takes nothing returns real
return 1.4
endfunction

constant function CheckingInterval takes nothing returns real
return .5
endfunction
//===================================================================================================

private function T2Act takes nothing returns nothing
local timer t2 = GetExpiredTimer()
local unit caster = GetHandleUnit(t2,&quot;caster&quot;)
local unit target = GetHandleUnit(t2,&quot;target&quot;)
local real dmg = GetHandleReal(t2,&quot;dmg&quot;)
    call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call PauseTimer(t2)
    call DestroyTimer(t2)
    call FlushHandleLocals(t2)
set t2 = null
set caster = null
set target = null
endfunction

private function AimCountAct takes nothing returns nothing
local effect array laser
local timer t = GetExpiredTimer()
local timer t2 = CreateTimer()
local real Time = GetHandleReal(t,&quot;time&quot;)
local real dmg = I2R(GetHandleInt(t,&quot;dmg&quot;))
local unit caster = GetHandleUnit(t,&quot;caster&quot;)
local unit target = GetHandleUnit(t,&quot;target&quot;)
        if (OrderId2StringBJ(GetUnitCurrentOrder(caster)) == &quot;channel&quot;) then
            if Time &gt;= .5 then
                call SetHandleInt(t,&quot;dmg&quot;,R2I(dmg)+GetRandomInt(1,100))
                call BJDebugMsg(R2S(Time))
                call SetHandleReal(t,&quot;time&quot;,Time-.5)
                call BJDebugMsg(R2S(GetHandleReal(t,&quot;time&quot;)))
            elseif Time&lt;= .5 then
                call PauseTimer(GetExpiredTimer())
                set laser[1] = AddSpecialEffectTarget(LaserEffect(), target, &quot;origin&quot;)
                set laser[2] = AddSpecialEffectTarget(FlareEffect(),caster,&quot;origin&quot;)
                call SetHandleHandle(t2,&quot;caster&quot;,caster)
                call SetHandleHandle(t2,&quot;target&quot;,target)
                call SetHandleReal(t2,&quot;dmg&quot;,dmg)
                call TimerStart(t2,DelayBeforeDamageDealt(),false,function T2Act)
                call FlushHandleLocals(t)            
                call DestroyTimer(GetExpiredTimer())
                call DestroyEffect(laser[1])
                call DestroyEffect(laser[2])
                set laser[1] = null
                set laser[2] = null
                set t = null
                set t2 = null
                set caster = null
                set target = null
                return
            endif
        elseif (OrderId2StringBJ(GetUnitCurrentOrder(caster)) != &quot;channel&quot;) then
            call PauseTimer(GetExpiredTimer())
            set laser[1] = AddSpecialEffectTarget(LaserEffect(), target, &quot;origin&quot;)
            set laser[2] = AddSpecialEffectTarget(FlareEffect(),caster,&quot;origin&quot;) 
            call SetHandleHandle(t2,&quot;caster&quot;,caster)
            call SetHandleHandle(t2,&quot;target&quot;,target)
            call SetHandleReal(t2,&quot;dmg&quot;,dmg)
            call TimerStart(t2,DelayBeforeDamageDealt(),false,function T2Act)         
            call FlushHandleLocals(t)
            call DestroyTimer(GetExpiredTimer())
            call DestroyEffect(laser[1])
            call DestroyEffect(laser[2])
            set laser[1] = null
            set laser[2] = null
            set t = null
            set t2= null
            set caster = null
            set target = null
        endif
endfunction

private function AimSetCond takes nothing returns boolean
    return GetSpellAbilityId() == ARawC()
endfunction

private function AimSetAct takes nothing returns nothing
local integer dmg = 0
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
local integer LvlOfSpell = GetUnitAbilityLevel(caster,ARawC())
local real Time = ADuration(I2R(LvlOfSpell))
    call SetHandleReal(t,&quot;time&quot;,Time)
    call SetHandleInt(t,&quot;dmg&quot;,dmg)
    call SetHandleHandle(t,&quot;caster&quot;,caster)
    call SetHandleHandle(t,&quot;target&quot;,target)
    call TimerStart(t,CheckingInterval(),true,function AimCountAct)
set caster = null
set target = null
set t = null
endfunction

//===========================================================================
function InitTrig_FullAimSetTryHandleVars takes nothing returns nothing
    set gg_trg_FullAimSetTryHandleVars = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_FullAimSetTryHandleVars, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_FullAimSetTryHandleVars, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_FullAimSetTryHandleVars, function AimSetAct )
endfunction

endscope


Now i need someone to tell me if it is MUI..:p
 

Exide

I am amazingly focused right now!
Reaction score
448
>Now i need someone to tell me if it is MUI..
You could try the spell with 2 or more units at once, and see what happens..
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>You could try the spell with 2 or more units at once, and see what happens..
Tried, but it works as fine..
Sometimes it looks fine but it is not when you look at the coding, the most important is the coding ;)
 

Tinki3

Special Member
Reaction score
418
You havn't taken this function into consideration:
JASS:
function LocalVars takes nothing returns gamecache
    // Replace InitGameCache(&quot;jasslocalvars.w3v&quot;) with a global variable!!
    return InitGameCache(&quot;jasslocalvars.w3v&quot;)
endfunction

Not to mention your not even using a game cache :p.

// Implementation
// 1. Copy the Aim spell from object editor to your map
// 2. Press Ctrl+D and check the rawcode of the spell...The first four number.
// 3. Replace it in the constant function ARawC
// 4. Copy the code from this map's header to your map header
// 5. Copy this whole trigger to your map
// 6. Replacing the value of the constant function to what you need.
// 7. Copy the 4 items from import manager to your map
// 8. Spell Ready.
9. What about New Gen?
You need to also give people a link to any imported models used for the spell.
After all, it isn't really anything special without the eyecandy.

In the function "AimCountAct", you can null all locals outside
those If-Then-Else statements, which saves a few lines.

Why use BJDebugMsg to display text, and yet text that has 000 after the decimal point?
Floating text would be a great alternative.

> call SetHandleReal(t,"time",Time-.5)

What if they changed the timer interval to .1? Uh oh.
Use CheckingInterval() as to .5 there, and in these 2 statements: "if Time = .5", "elseif Time<= .5".

> local timer t2 = CreateTimer()

Why create a timer per function execution if the caster isn't ready to fire yet?

> call PauseTimer(GetExpiredTimer())
> call DestroyTimer(GetExpiredTimer())

Why isn't "t" used as to GetExpiredTimer() here?

> set laser[1] = AddSpecialEffectTarget(LaserEffect(), target, "origin")
> set laser[2] = AddSpecialEffectTarget(FlareEffect(),caster,"origin")

Why use an array.. waste of time and lines with the nulling.
Simply use: "call DestroyEffect(AddSpecialEffectTarget(LaserEffect(), target, "origin"))"

In the function "T2Act" you should Flush Handles before destroying the timer.

> WEAPON_TYPE_WHOKNOWS

Yea... who does know?
I always use "null" there, but it's your choice.

Looking forward to seeing some optimized code :).
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
>>Why use BJDebugMsg to display text, and yet text that has 000 after the decimal point?
Floating text would be a great alternative.

Opps...sorry sorry, it was just for testing, forgot to remove it :p

>>9. What about New Gen?
Will add-in on next version.

>>Use CheckingInterval() as to .5 there, and in these 2 statements: "if Time = .5", "elseif Time<= .5".
OK ;D

>>Why create a timer per function execution if the caster isn't ready to fire yet?
k

>>Why isn't "t" used as to GetExpiredTimer() here?

changed

>>Simply use: "call DestroyEffect(AddSpecialEffectTarget(LaserEffect(), target, "origin"))"
So Sorry, the laser is destroyed before it reaches ground.

>>In the function "T2Act" you should Flush Handles before destroying the timer.
Settled

>>You need to also give people a link to any imported models used for the spell.
I lost track to the maker..

>>In the function "AimCountAct", you can null all locals outside
those If-Then-Else statements, which saves a few lines.

Notice i had a return in the inner IF-s ?

>>Not to mention your not even using a game cache
Don't understand...what do you mean?

Map updated
JASS:
scope Aim

// Aim by Kentchow74+1 / ~GaLs~
// Special thanks to KaTTaNa&#039;s Local Handle Variable System
//
// Implementation
// 1. Copy the Aim spell from object editor to your map
// 2. Press Ctrl+D and check the rawcode of the spell...The first four number.
// 3. Replace it in the constant function ARawC
// 4. Copy the code from this map&#039;s header to your map header
// 5. Copy this whole trigger to your map
// 6. Replacing the value of the constant function to what you need.
// 7. Copy the 4 items from import manager to your map
// 8. Get NewGen World Editor from <a href="http://wc3campaigns.net/showthread.php?t=90999" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://wc3campaigns.net/showthread.php?t=90999</a>
// 9. I appologize that i lost track of the maker of the model, but i do get it from hiveworkshop.com and wc3campaigns.net

//==================================================================================================
constant function ARawC takes nothing returns integer
    return &#039;A006&#039; // the raw code if Aim
endfunction

constant function ADuration takes real LevelOfAbility returns real
    return (LevelOfAbility)+4
endfunction

constant function LaserEffect takes nothing returns string
return &quot;LasercannonfinalRED.mdx&quot;
endfunction

constant function FlareEffect takes nothing returns string
return &quot;Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl&quot;
endfunction

constant function DelayBeforeDamageDealt takes nothing returns real
return 1.4
endfunction

constant function CheckingInterval takes nothing returns real
return .5
endfunction
//===================================================================================================

private function T2Act takes nothing returns nothing
local timer t2 = GetExpiredTimer()
local unit caster = GetHandleUnit(t2,&quot;caster&quot;)
local unit target = GetHandleUnit(t2,&quot;target&quot;)
local real dmg = GetHandleReal(t2,&quot;dmg&quot;)
    call UnitDamageTarget(caster, target, dmg, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
    call PauseTimer(t2)
    call FlushHandleLocals(t2)
    call DestroyTimer(t2)
set t2 = null
set caster = null
set target = null
endfunction

private function AimCountAct takes nothing returns nothing
local effect array laser
local timer t = GetExpiredTimer()
local timer t2 
local real Time = GetHandleReal(t,&quot;time&quot;)
local real dmg = I2R(GetHandleInt(t,&quot;dmg&quot;))
local unit caster = GetHandleUnit(t,&quot;caster&quot;)
local unit target = GetHandleUnit(t,&quot;target&quot;)
        if (OrderId2StringBJ(GetUnitCurrentOrder(caster)) == &quot;channel&quot;) then
            if Time &gt;= CheckingInterval() then
                call SetHandleInt(t,&quot;dmg&quot;,R2I(dmg)+GetRandomInt(1,100))
                call SetHandleReal(t,&quot;time&quot;,Time-CheckingInterval())
            elseif Time&lt;= CheckingInterval() then
                set t2 = CreateTimer()
                call PauseTimer(t)
                set laser[1] = AddSpecialEffectTarget(LaserEffect(), target, &quot;origin&quot;)
                set laser[2] = AddSpecialEffectTarget(FlareEffect(),caster,&quot;origin&quot;)
                call SetHandleHandle(t2,&quot;caster&quot;,caster)
                call SetHandleHandle(t2,&quot;target&quot;,target)
                call SetHandleReal(t2,&quot;dmg&quot;,dmg)
                call TimerStart(t2,DelayBeforeDamageDealt(),false,function T2Act)
                call FlushHandleLocals(t)            
                call DestroyTimer(t)
                call DestroyEffect(laser[1])
                call DestroyEffect(laser[2])
                set laser[1] = null
                set laser[2] = null
                set t = null
                set t2 = null
                set caster = null
                set target = null
                return
            endif
        elseif (OrderId2StringBJ(GetUnitCurrentOrder(caster)) != &quot;channel&quot;) then
            set t2 = CreateTimer()
            call PauseTimer(t)
            set laser[1] = AddSpecialEffectTarget(LaserEffect(), target, &quot;origin&quot;)
            set laser[2] = AddSpecialEffectTarget(FlareEffect(),caster,&quot;origin&quot;) 
            call SetHandleHandle(t2,&quot;caster&quot;,caster)
            call SetHandleHandle(t2,&quot;target&quot;,target)
            call SetHandleReal(t2,&quot;dmg&quot;,dmg)
            call TimerStart(t2,DelayBeforeDamageDealt(),false,function T2Act)         
            call FlushHandleLocals(t)
            call DestroyTimer(t)
            call DestroyEffect(laser[1])
            call DestroyEffect(laser[2])
            set laser[1] = null
            set laser[2] = null
            set t = null
            set t2= null
            set caster = null
            set target = null
        endif
endfunction

private function AimSetCond takes nothing returns boolean
    return GetSpellAbilityId() == ARawC()
endfunction

private function AimSetAct takes nothing returns nothing
local integer dmg = 0
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local timer t = CreateTimer()
local integer LvlOfSpell = GetUnitAbilityLevel(caster,ARawC())
local real Time = ADuration(I2R(LvlOfSpell))
    call SetHandleReal(t,&quot;time&quot;,Time)
    call SetHandleInt(t,&quot;dmg&quot;,dmg)
    call SetHandleHandle(t,&quot;caster&quot;,caster)
    call SetHandleHandle(t,&quot;target&quot;,target)
    call TimerStart(t,CheckingInterval(),true,function AimCountAct)
set caster = null
set target = null
set t = null
endfunction

//===========================================================================
function InitTrig_FullAimSetTryHandleVars takes nothing returns nothing
    set gg_trg_FullAimSetTryHandleVars = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_FullAimSetTryHandleVars, EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddCondition(gg_trg_FullAimSetTryHandleVars, Condition(function AimSetCond))
    call TriggerAddAction( gg_trg_FullAimSetTryHandleVars, function AimSetAct )
endfunction

endscope
 

Tinki3

Special Member
Reaction score
418
Cloud Thunder:

- Seems to be lagging from that Special Effect...
- Try using a different model (something like monsoon lightning)
- The clouds themselves could flee when attacked (why are 3 created on-cast?)
- Every line with "Condition(function <function>)" leaks a boolexpr (same for other triggers).
- Messy coding, screwed up function names...
- Set Kill = CreateGroup() -- set Kill = GetRandomSubGroup(Diff,cloud)
No need for the CreateGroup action, just set it to the random sub

Rock Bounce:

- Great, but don't forget that there's already a few triggered chain spells made already
- A sub-group is not needed to obtain 1 random unit from another group.
Simply use a unit variable and use GroupPickRandomUnit(), or whatever.
- A bit too slow. This can usually be easily fixed by giving the dummy 0.00
"Cast Backswing" and "Cast Point", under the Art field in the Object Editor.


Note that simple constant functions that return raw codes can be reduced
down to a single line when inside a 'globals' block. It'd also tidy up your code a bit.

You should learn how to use structs, and move on from the old local handle vars.
There's really not much point in using the NewGen WE otherwise...

Good work.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
I'll try fix those.

>>Great, but don't forget that there's already a few triggered chain spells made already
Those aren't made by me.

>>Simply use a unit variable and use GroupPickRandomUnit(), or whatever.
Aren't that will leave a group leak?

I dont really know much of using struct, but, you know..struct aren't MUI...i would still need local handle to attach a struct data to a unit.

Edit - Seems to be lagging from that Special Effect...
I tried changing model, no it is not from the model, it is from the code.
 

Tinki3

Special Member
Reaction score
418
All seemed fine apart from the fact that "Reflective Counter", atm, is only
good for one unit to have at a time.

What if 2 units with different model files had the spell?
You'll need to create some sort of "If-then-else" statement that checks to see
what unit-type is being attacked, so you can create the right type of reflection
for that attacked unit, otherwise a monkey will be created for a chicken, and such.

> Those aren't made by me

No, they aren't, but we still have spells which follow the same concept.
Just, I suppose, your's has a different name, is MUI, and has a different projectile.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top