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
256
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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top