Random Discussion

Status
Not open for further replies.

Rheiko

Spell Reviewer
Level 28
Joined
Aug 27, 2013
Messages
4,264
Discuss random things here


guys, i did it!! :goblin_yeah:
my very first jass spell! (well actually it is a simple spell. cast a spell => special effect => deals damage = > done)
check out the code :3
JASS:
function Trig_War_Stomp_Conditions takes nothing returns boolean
   if (GetSpellAbilityId() == 'AHca')
endfunction

function Trig_War_Stomp_Actions takes nothing returns nothing
   local unit a = GetTriggerUnit()
   local unit b = GetSpellTargetUnit()
   local string c = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
   local real x = GetUnitX(b)
   local real y = GetUnitY(b)
   call DestroyEffect(AddSpecialEffect(c, x, y))
   call UnitDamageTarget(a, b, 30, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_COLD, null)
   set a = null
   set b = null
endfunction

//===========================================================================
function InitTrig_War_Stomp takes nothing returns nothing
    set gg_trg_War_Stomp = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_War_Stomp, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(gg_trg_War_Stomp, function Trig_War_Stomp_Actions)
    call TriggerAddCondition(gg_trg_War_Stomp, function Trig_War_Stomp_Conditions)
endfunction
 
JASS:
function Trig_War_Stomp_Conditions takes nothing returns boolean
   if (GetSpellAbilityId() == 'AHca') then
   return TRUE
   endif
   return FALSE
endfunction

Inefficient :/

JASS:
function Trig_War_Stomp_Conditions takes nothing returns boolean
   if GetSpellAbilityId() == 'AHca'
endfunction
Efficient =))

JASS:
   local real x = GetUnitX(b)
   local real y = GetUnitY(b)
Slower :/

JASS:
   local real x = GetWidgetX(b)
   local real y = GetWidgetY(b)
Faster =))

JASS:
set gg_trg_War_Stomp = CreateTrigger()
:((
JASS:
local trigger t = CreateTrigger()
Yey! XD

JASS:
local string c = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" and 'AHca'
://
JASS:
// This can be used in vJASS but I don't know if it is accesible in JASS :((
globals
    constant integer ABILITY_RAW_CODE_OR_ID_XD = 'AHca'
    constant string YOUR_SPECIAL_EFFECT = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
endglobals
// If you want JASS then write a function that returns a value like:
constant function ABILITY_CODE takes nothing returns integer // Ability_Raw_Code is integer
    return 'AHca'
endfunction
// Then so on..
Nice!

remember that if you call a function then you must call it like this: call ABILITY_CODE() // calls a function
the "()" thing is the function what it takes, example: if you want the function to takes integer level then write it in takes part.
After you call it like this: call DAMAGE(lvl) // calls a function and it takes integer parameters

EDIT:
I forgot to add these constant that you must add:
ATTACK_TYPE_CHAOS, DAMAGE_TYPE_COLD
 
JASS:
function Trig_War_Stomp_Conditions takes nothing returns boolean
   local unit a
   local unit b
   local real x
   local real y
   if GetSpellAbilityId() == 'Ahca' then
      set a = GetTriggerUnit()
      set b = GetSpellTargetUnit()
      set x = GetUnitX(b)
      set y = GetUnitY(b)
      call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x, y))
      call UnitDamageTarget(a, b, 30, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_COLD, null)
      set a = null
      set b = null
   endif
   return false
endfunction

//===========================================================================
function InitTrig_War_Stomp takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Trig_War_Stomp_Conditions))
    set t = null
endfunction
 
Faster =))

Jass:
set gg_trg_War_Stomp = CreateTrigger()
:((
Jass:
local trigger t = CreateTrigger()

NO. It wastes a reference. (gg_trg_War_Stomp)

JASS:
function Trig_War_Stomp_Conditions takes nothing returns boolean
   local unit a
   local unit b
   local real x
   local real y
   if GetSpellAbilityId() == 'Ahca' then
      set a = GetTriggerUnit()
      set b = GetSpellTargetUnit()
      set x = GetWidgetX(b)
      set y = GetWidgetY(b)
      call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", x, y))
      call UnitDamageTarget(a, b, 30, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_COLD, null)
      set a = null
      set b = null
   endif
   return false
endfunction

//===========================================================================
function InitTrig_War_Stomp takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function Trig_War_Stomp_Conditions))
    set t = null
endfunction

Pointless optimization. Use for dynamic triggers.

It will be in my pro trick :)
It's not, it's a fucking hack.

Okay, cohadar mode disabled.
 
Actions don't leak dude, triggeraction do when you destroy the trigger it is attached to, and it causes handle corruption too. The point is if you're not destroying the trigger, the triggeraction won't leak because it's in use.

It's really a hack, Vexorian was experementing with dynamic triggers when he discovered that triggerconditions were safer to use than triggeractions on dynamic triggers. It is indeed faster than triggeractions on execution because it doesn't create a seperate thread when the event fires, unlike the triggeraction which does, but you can't make the triggercondition sleep. (thread skipping)
 
Yo guys, new addition to warcraft 3 modding, jaws and vjaws. I have a request Malhorne, can you change my request type to jaws/vjaws? please I beg you. xD kidding.
 
Just a little suggestion guys, what if we make some little template map so that we would have some uniformity? We could import one DDS in one map so that if one of us makes a spell with a specific DDS, we could just pick the one with the DDS and make the spell for it. No more hassle importing for the DDS.

I dunno, Just a thought from me.
 
That sounds nice!
@Malhorne, people good at coding would just make their own systems lol, kinda like you.
 
Status
Not open for further replies.
Back
Top