three random spells

jackall

You can change this now in User CP.
Reaction score
37
Hello there...lame entry.......
Anyways, i was bored the other day and thought about making some spells which i actually did.
Here they are(code only, no screens):
Mana Blade(lame name...i know)
First trigger that adds damage and a 20% chance to burn 100 mana from the target
JASS:
function MainFuncMBBD takes nothing returns nothing
  local unit damager = GetEventDamageSource()
  local unit dummy = CreateUnit(GetOwningPlayer(damager),'h000',GetUnitX(damager),GetUnitY(damager),0)
  local real damage = (GetUnitState(damager,UNIT_STATE_MANA)*.01)
  local unit damaged = GetTriggerUnit()
  local integer chance = GetRandomInt(0,100)
    call DisableTrigger(GetTriggeringTrigger())
    call ApplyDummyLife(dummy,1)
    call SetUnitPathing(dummy,false)
  if GetUnitAbilityLevel(damaged,'B001')>0 then
      call UnitDamageTargetBJ(dummy,damaged,damage,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNKNOWN)
  else
  endif
  if chance<=20 then
    call SetUnitState(damaged,UNIT_STATE_MANA,(GetUnitState(damaged,UNIT_STATE_MANA)-100))
  endif
    call EnableTrigger(GetTriggeringTrigger())
  set dummy = null
  set damaged = null
  set damager = null
endfunction

function InitTrig_Mana_Blade_Damage takes nothing returns nothing
  set gg_trg_Mana_Blade_Damage = CreateTrigger()
    call TriggerAddAction(gg_trg_Mana_Blade_Damage,function MainFuncMBBD)
endfunction

Second trigger that regenerates some mana every second
JASS:
function MainFuncMBBR takes nothing returns nothing
  local unit wielder = udg_ManaBladeWielder
  local real manaToadd = GetUnitState(wielder,UNIT_STATE_MANA)+(GetUnitState(wielder,UNIT_STATE_MAX_MANA)*0.05)
    call SetUnitState(wielder,UNIT_STATE_MANA,manaToadd)
endfunction

function InitTrig_Mana_Blade_Reg takes nothing returns nothing
  set gg_trg_Mana_Blade_Reg = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic(gg_trg_Mana_Blade_Reg,1)
    call TriggerAddAction(gg_trg_Mana_Blade_Reg,function MainFuncMBBR)
endfunction

NOTE: i used a global in the regeneration trigger because the weapon is supposed to be unique

Fire Shield(lame name #2)
Just one trigger that creates a dummy unit and then.....oh just read the code and you'll more than likely figure out what it does
JASS:
function MainFuncFS takes nothing returns nothing
  local unit damager = GetEventDamageSource()
  local unit damaged = GetTriggerUnit()
  local unit dummy = CreateUnit(GetOwningPlayer(damaged),'h000',GetUnitX(damager),GetUnitY(damager),0)
  local integer chance = GetRandomInt(0,100)
    call ApplyDummyLife(dummy,1)
    call SetUnitPathing(dummy,false)
  if chance<=25 and GetUnitAbilityLevel(damaged,'B002')>0 then
    call UnitAddAbility(dummy,'A008')
    call SetUnitAbilityLevel(dummy,'A008',1)
    call IssueTargetOrder(dummy,"acidbomb",damager)
  else
  endif
  set dummy = null
  set damaged = null
  set damager = null
endfunction

function InitTrig_Fire_Shield takes nothing returns nothing
    set gg_trg_Fire_Shield = CreateTrigger()
    call TriggerAddAction(gg_trg_Fire_Shield,function MainFuncFS)
endfunction


Nature's Armor(originality hurts to me...)
JASS:
function MainFuncNAP takes nothing returns nothing
  local unit damaged = GetTriggerUnit()
  local unit damager = GetEventDamageSource()
  local unit dummy = CreateUnit(GetOwningPlayer(damaged),'h000',GetUnitX(damager),GetUnitY(damager),0)
    call SetUnitPathing(dummy,false)
    call ApplyDummyLife(dummy,1)
  if GetUnitAbilityLevel(damaged,'B004') > 0 then
      call UnitAddAbility(dummy,'A00A')
      call SetUnitAbilityLevel(dummy,'A00A',1)
      call IssueTargetOrder(dummy,"acidbomb",damager)
  endif
  set dummy = null
  set damaged = null
  set damager = null
endfunction

function InitTrig_Natures_Armor_Poison takes nothing returns nothing
    set gg_trg_Natures_Armor_Poison = CreateTrigger()
    call TriggerAddAction(gg_trg_Natures_Armor_Poison,function MainFuncNAP)
endfunction

I really hope this will help someone :D aaaaaaaaand i'll try to make some more
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
For [lJASS]UnitHasBuffBJ[/lJASS]..
Use this:
JASS:
GetUnitAbilityLevel(Unit, IntegerOfBuff) > 0

[EDIT]
Also, your trigger leaks.
You need to null your unit variables.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
And now, time to introduce scopes and global private constants! =D

*Advertisement shows*
Are you tired of looking at all these ugly gg_trg_TriggerName and InitTrig in your codes?
Do you want your triggers to look neat and tidy?

Do you want the person who uses your spell to have an easy time configuring them to his needs?
Well, here's a product for you!

Buy our scopes and get an initializer PLUS a global header for FREE!
That's it! FREE!
*End of advertisement*

Well, scopes are really simple.
To use them, you just need to do this:

JASS:
scope ManaBlade

endscope


Initializers are the nice things about scopes.
They eliminate the need for those ugly gg-trg and InitTrig keywords =)
JASS:
scope ManaBlade initializer ManaBladeDetectAttack //The name is awfully long, but it is for educational purposes

    function ManaBladeDetectAttack takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t,function MainFuncMBBD)
    endfunction
endscope

See what I did there?
Doesn't it look neater now? xD

Now, what if you were afraid that the person importing your spells already has a function called ManaBladeDetectAttack?
You know, 2 functions must never have the same name.

Add in the word 'private' in front of your functions!

JASS:
scope ManaBlade initializer ManaBladeDetectAttack //The name is awfully long, but it is for educational purposes

    private function ManaBladeDetectAttack takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t,function MainFuncMBBD)
    endfunction
endscope
 

jackall

You can change this now in User CP.
Reaction score
37
I have JNGP and i placed the 1.24c or d version of WE in the JNGP folder but i don't really use it... it scares me :confused: sooo many additions but i'll try to begin using it asap ;)
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
which is why..
Practise in this thread!
Lol.

This:
JASS:
scope Lol initializer Init
    private function Init takes nothing returns nothing
        call BJDebugMsg("Lol")
    endfunction
endscope


Is the same as this:
JASS:
function Trig_Lol_Actions takes nothing returns nothing
    call BJDebugMsg("Lol")
endfunction

function InitTrig_Lol takes nothing returns nothing
    set gg_trg_Lol = CreateTrigger()
    call TriggerAddAction(gg_trg_Lol, function Trig_Lol_Actions)
endfunction


See which looks nicer? =D
Now go add scopes to your spells.
Nao.
 

jackall

You can change this now in User CP.
Reaction score
37
I can't atm, it's about 0 AM here so... good night
I'll change the spells tomorrow and upload them
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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 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