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.

      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