Spell Fear

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
This is my first spell that I posted here so please be kind with your comments, I'll learn so I'll be better next time. ;)

Version 1.21


The caster will choose a victim, the victim will immediatly flee in terror to random directions. The unit will stop fleeing either after 4 / 8 / 12 seconds or by a random event. Also every 0.4 second the chance that the unit will be damaged will increase. Once the target is damaged the unit will get out of the fleeing sitaution and become stunned for one second before fighting again

SpellFear.jpg


JASS:
constant function Fear_EffectID takes nothing returns string
    return "Abilities\\Spells\\Undead\\Curse\\CurseTarget.mdl"
endfunction

constant function Fear_Time takes nothing returns real
    // The amount of time the spell will last. It is level of the ability * this function (4).
    return 4.00
endfunction

constant function Fear_IgnorePercent takes nothing returns real
    // The increasement rate of the ignoring percent.
    return 2.00
endfunction

constant function Fear_DamagePercent takes nothing returns real
    // The increasement rate of the damaging percent.
    return 10.00
endfunction

constant function Fear_TurnPercent takes nothing returns real
    // The increasement rate of the turning percent.
    return 20.00
endfunction

constant function Fear_RunTime takes nothing returns real
    // What is the frequency that the timer will run
    return 0.4
endfunction

constant function Fear_SpellId takes nothing returns integer
    // The spell ID, you should modify this so it will match your map.
    return 'A000'
endfunction

constant function Fear_DummySpellId takes nothing returns integer
    // The dummy spell ID, you should modify this so it will match your map.
    return 'A001'
endfunction

constant function Fear_Dummy takes nothing returns integer
    // The dummy ID, you should modify this so it will match your map.
    return 'h000'
endfunction

// ============================================================================================== \\

// You should not modify the functions found under this line, they are influnced from the above
// functions.

function Fear_Conditions takes nothing returns boolean
  return GetSpellAbilityId() == Fear_SpellId()
endfunction

function Fear_Mover takes nothing returns nothing
    local timer mover         =   GetExpiredTimer()
    local unit target         =   GetHandleUnit(mover,"target")
    local real facing         =   GetHandleReal(mover,"facing")
    local location targetLoc  =   GetUnitLoc(target)
    local location goalLoc

    set goalLoc  =   PolarProjectionBJ(targetLoc,GetRectMaxX(GetWorldBounds()),facing)
    call IssuePointOrderLoc(target,"move",goalLoc)
   
    call RemoveLocation(goalLoc)
    call RemoveLocation(targetLoc)

    set goalLoc  =   null
    set target   =   null
    set target   =   null
    set mover    =   null
endfunction

function Fear_Main takes nothing returns nothing
    local timer caller        =   GetExpiredTimer()
    local unit target         =   GetHandleUnit(caller,"target")
    local effect sfx          =   GetHandleEffect(caller,"sfx")
    local real turnPercent    =   GetHandleReal(caller,"turnPercent") + Fear_TurnPercent()
    local real damagePercent  =   GetHandleReal(caller,"damagePercent") + Fear_DamagePercent()
    local real ignorePercent  =   GetHandleReal(caller,"ignorePercent") + Fear_IgnorePercent()
    local real fearTime       =   GetHandleReal(caller,"fearTime")
    local real count          =   GetHandleReal(caller,"count") + Fear_RunTime()
    local integer level       =   GetHandleInt(caller,"level")
    local timer mover         =   GetHandleTimer(caller,"mover")
    local unit dummy
    local location targetLoc


    if count >= fearTime then
        call DestroyEffect(sfx)
        call PauseTimer(mover)
        call FlushHandleLocals(mover)
        call DestroyTimer(mover)
        set mover   =   null
        set target  =   null
        set sfx     =   null
        call FlushHandleLocals(caller)
        call PauseTimer(caller)
        call DestroyTimer(caller)
        set caller  =   null
        return
    endif

    if GetRandomReal(1,100) < ignorePercent then
        call DestroyEffect(sfx)
        call PauseTimer(mover)
        call FlushHandleLocals(mover)
        call DestroyTimer(mover)
        set mover   =   null
        set target  =   null
        set sfx     =   null
        call FlushHandleLocals(caller)
        call PauseTimer(caller)
        call DestroyTimer(caller)
        set caller  =   null
        return
    endif

    if GetRandomReal(1,100) < turnPercent then
        call SetUnitFacing(target,GetRandomReal(0,360))
        call SetHandleReal(mover,"facing",GetUnitFacing(target))
        set turnPercent  =   0
    endif

    if GetRandomReal(1,100) < damagePercent then
        set targetLoc = GetUnitLoc(target)
        set dummy=CreateUnitAtLoc(Player(12),Fear_Dummy(),targetLoc,0)
        call UnitAddAbility(target,Fear_DummySpellId())
        call SetUnitAbilityLevel(target,Fear_DummySpellId(),level)
        call IssueTargetOrder(dummy,"thunderbolt",target)
        call UnitApplyTimedLife(dummy,'BTLF',2)
        call DestroyEffect(sfx)
        call SetUnitOwner(target,Player(12),true)
        call DestroyEffect(sfx)
        call PauseTimer(mover)
        call FlushHandleLocals(mover)
        call DestroyTimer(mover)
        set mover   =   null
        set target  =   null
        set sfx     =   null
        call FlushHandleLocals(caller)
        call PauseTimer(caller)
        call DestroyTimer(caller)
        set caller  =   null
    endif

    call SetHandleReal(caller,"damagePercent",damagePercent)
    call SetHandleReal(caller,"turnPercent",turnPercent)
    call SetHandleReal(caller,"ignorePercent",ignorePercent)
    call SetHandleReal(caller,"count",count)

    call RemoveLocation(targetLoc)

    set caller     =   null
    set targetLoc  =   null
    set target     =   null
    set sfx        =   null
    set dummy      =   null
    set mover      =   null

endfunction

function Fear_Actions takes nothing returns nothing
    local unit target    =   GetSpellTargetUnit()
    local timer mover    =   CreateTimer()
    local timer caller   =   CreateTimer()
    local effect sfx     =   AddSpecialEffectTarget(Fear_EffectID(),target,"overhead")
    local integer level  =   GetUnitAbilityLevel(GetTriggerUnit(),Fear_SpellId())
    local real fearTime  =   Fear_Time()*level
    local real facing    =   GetUnitFacing(target)

    call SetHandleHandle(caller,"mover",mover)
    call SetHandleHandle(caller,"target",target)
    call SetHandleHandle(caller,"sfx",sfx)
    call SetHandleInt(caller,"level",level)
    call SetHandleReal(caller,"fearTime",fearTime)
    call SetHandleReal(mover,"facing",facing)
    call SetHandleHandle(mover,"target",target)

    call TimerStart(caller,Fear_RunTime(),true,function Fear_Main)
    call TimerStart(mover,0.004,true,function Fear_Mover)

    set target  =   null
    set caller  =   null
    set sfx     =   null
endfunction

//===========================================================================
function InitTrig_Fear takes nothing returns nothing
  set gg_trg_Fear = CreateTrigger()
  call TriggerRegisterAnyUnitEventBJ(gg_trg_Fear,EVENT_PLAYER_UNIT_SPELL_EFFECT)
  call TriggerAddCondition(gg_trg_Fear,Condition(function Fear_Conditions))
  call TriggerAddAction(gg_trg_Fear,function Fear_Actions)
endfunction


Feedbacks are welcomed, thanks.
 

Attachments

  • [Spell] Fear v1.21.w3x
    25.3 KB · Views: 309

ManyTimes

I'm so lonesome I could cry...
Reaction score
293
lol,
if you remove the "pause unit" thingy everytime I am casting it, it would be great. And btw; does it _ever_ do some damage to the unit? I tried like, 70-80 times on only one unit ( removed all except one), since ye, if it got healed/anything it would stop.
Cheerio
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
" if you remove the "pause unit" thingy everytime I am casting it, it would be great. "

The unit is paused only if it takes damage.

" does it _ever_ do some damage to the unit? "

No.
 

Sim

Forum Administrator
Staff member
Reaction score
534
> Also every 0.4 second the cahnce that the unit will be damaged will increase. O Once damaged the unit will get out of the fleeing sitaution and become
> stunned.

You mean the chance that the fear will break once it takes damage? At least, I hope :p
 

waaaks!

Zinctified
Reaction score
255
if u post JASS triggers, please post on what system did u use, to create this

good job at jass +rep
 

elmstfreddie

The Finglonger
Reaction score
203
Well... I would give you rep, but this isn't really a creative idea. It's in almost every game (not Warcraft games, but you know what I mean).
Otherwise the coding looks nice (it'd help if I went over it, so I will, and I'll edit with what I think :p)

Edit >
Ok, you have the constant functions which is good.. BUT, the damage shouldn't be Level * constant function, the constant function should take the level of the ability, and do Level of (ability + 0) * 4 (the +0 is only because when I made my first spell Daxtreme told me I needed to do that...)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
" You mean the chance that the fear will break once it takes damage? At least, I hope "

Yes, I will fix this. Darn, I hate object editor stuff. :) Thanks for pointing it out.

" if u post JASS triggers, please post on what system did u use, to create this "

In the READ ME I say what system I use (KaTTaNa's handle system). I think it's one of the best and simplest systems out there.

" but this isn't really a creative idea. . It's in almost every game (not Warcraft games "

I just got the idea, I didn't copy from another game. Also I added many features as you can see (turning, damaging and even evading).

" Otherwise the coding looks nice "

Thanks, I worked on this hard. :)

" the damage shouldn't be Level * constant function "

I use Strom Bolt to damage the unit, nothing in the trigger effects the damage that the unit will take (if it will take it)
 
I

IKilledKEnny

Guest
Nice spell, good job, I don't see anyway to improve it. :)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
" Nice spell, good job, I don't see anyway to improve it. "

Thanks, still waiting to see if it can be approved. :)
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Nice Spell, but Credits should be properly given in WE, here, and the readme if any because not many people open the readme because most people don't like reading all of the information, they just want to see the spell. :D
 

Tom Jones

N/A
Reaction score
437
Overall nice, but there were some things I didn't like, for example the way you disable the control of the targeted unit. If the unit is a hero, it's icon will disappear from the owning players display. Also if you enable a AI for Player Passive, your spell messes up. I would also like to point out, that if both damagePercent and turnPercent evaluates true, you'll create a location leak. Another issue that'll happen if damagePercent evaluates true, is that your nulling the timer, and later on stores values on it, which is nothing serious, the only that happes is that the values will be stored on null. I didn't like the fact that your using locations instead of coordinates either, but that's a personal preference :)

Keep it up.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Thanks for the comments Tom Jones, I will work on those, although it might take a while. :) I'm thinking of simply ordering the unit to keep moving forward while only once and a while changing it's facing, I might use another timer.
 

Tom Jones

N/A
Reaction score
437
When you are using gamecaches, why not take advantage of it? Restoring a unit properly removes Locust.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Updated, does the exact thing without changing owner.

I would also like to point out, that if both damagePercent and turnPercent evaluates true, you'll create a location leak.

No, the location is nulled, I set it only later.

Another issue that'll happen if damagePercent evaluates true, is that your nulling the timer, and later on stores values on it, which is nothing serious, the only that happes is that the values will be stored on null.

If damagePercent is true then the spell is disabled so nothing to worry here.

I didn't like the fact that your using locations instead of coordinates either, but that's a personal preference

Locations simply ease things, in this simple trigger I saw no reason to complicate it and got such a small achievement. Sure if it was a bigger, more important trigger the I wouldn't have cared abot readability and just used coordinates.

Keep it up.

I hope I will. ;)

Feedbacks, as always are welcomed.
 

Tom Jones

N/A
Reaction score
437
No, the location is nulled, I set it only later.
Indeed, but I were refering to the first code you submitted.

If damagePercent is true then the spell is disabled so nothing to worry here.
Try setting Fear_DamagePercent to 100, and then add this to the code:
JASS:
    call SetHandleReal(caller,"damagePercent",damagePercent)
    call SetHandleReal(caller,"turnPercent",turnPercent)
    call SetHandleReal(caller,"ignorePercent",ignorePercent)
    call SetHandleReal(caller,"count",count)

    call BJDebugMsg("test = "+R2S(GetHandleReal(null,"damagePercent"))) //Add this one.


Does the movement work?
JASS:
    local location targetLoc  =   GetUnitLoc(target)
    local location goalLoc

    call PolarProjectionBJ(targetLoc,GetRectMaxX(GetWorldBounds()),facing)
    call IssuePointOrderLoc(target,"move",goalLoc)
Because it shouldn't.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
" Because it shouldn't. "

Sorry, old version posted. Updated.
 

Tom Jones

N/A
Reaction score
437
Maybe you could point out especially what you feel is bad, and offer alternatives? Criticism for the sake of constructiveness rules, criticism for the sake of criticism is lame.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
" the spell was bad.. "

Thanks for being so polite, positive comments always cheer me up!!

" not much fantasy in it "

I don't know how you describe fantasy, but magical fear sounds unrealistic to me.

________________________________________________________________

Any constructive, polite comments are still welcomed!
 
I

IKilledKEnny

Guest
> the spell was bad..
not much fantasy in it

Do you always post discouraging unconstructive comments?

I find this spell good Rheias, see if you can make it using one timer though, it would make it cleaner. ;)

You can do that using counter (like you are doing now) to see how much time the spell has ran, if it feets with modulo 0.004 then do with it somthing...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top