Spell Not Working

Carl-Fredrik

New Member
Reaction score
51
Hi everyone! :)

So... A long time ago I requested a spell called Magical Shield . It's supposed to cause the target to receive 25% less damage from spells as well as sharing 50% of the damage caused to it by ALL sorts of attacks with the caster's mana. (Example, target is damaged 500 damage by a non-spell, then the caster loses 250 mana).

I used the GUI version because my JassHelper was broken (I thought, I've fixed it now though), but now I would rather use the vJass version since I've understood the pros of using Jass... I haven't learned it very well though, lazy as I am. :p

So, this spell causes a bunch of errors, does anyone know why..?

JASS:
scope MagicalShield

globals
    private constant integer AbilityID = 'A00Y' // Ability Code of Magical Shield
    private constant integer BuffID = 'B005' // Buff Code of Magical Shield
    private constant integer ReductID = 'A00Z' // Ability Code of Spell Reduction
    private constant real SharedDmg = 0.50  // Percent Shared damage. < = .50 would make no damage addition transferred, 
    private constant real Duration = 60.0     // Duration of Magical Shield, if you ever want to change it
endglobals

struct mshield
    unit caster
    unit attacked
    trigger transfer
    trigger death
    
    static method create takes nothing returns mshield
        local mshield magics = mshield.allocate() 
        set magics.attacked = GetSpellTargetUnit()
        set magics.caster= GetTriggerUnit()
        call UnitAddAbility( GetSpellTargetUnit(), ReductID)
        return magics
    endmethod
    
private method onDestroy takes nothing returns nothing
    
    call UnitRemoveAbility(.attacked, BuffID)
    call UnitRemoveAbility(.attacked, ReductID)
    set .caster = null
    set .attacked = null
    call ClearTriggerStructA(.transfer)
    call ClearTriggerStructA(.death)
    endmethod
endstruct

//============================Conditions=====================================

private function msConditions takes nothing returns boolean
   return GetSpellAbilityId() == AbilityID
endfunction

private function transConditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetTriggerUnit(), BuffID) > 0)
endfunction

private function Greater takes unit whichUnit returns boolean
     return GetUnitState(whichUnit, UNIT_STATE_MANA) > (GetEventDamage() * 0.51 ) 
endfunction

//===========================Actions=========================================

private function transAction takes nothing returns nothing
    local mshield magics = GetTriggerStructA(GetTriggeringTrigger())
    local integer DamageTaken = R2I(GetEventDamage())
    
    if ( Greater(magics.caster) ) == true then
        call SetWidgetLife( magics.attacked , GetWidgetLife( magics.attacked ) + DamageTaken * SharedDmg)
        call SetUnitState(magics.caster, UNIT_STATE_MANA, GetUnitState(magics.caster, UNIT_STATE_MANA) - DamageTaken * SharedDmg)
    else
    endif
endfunction
   

function deaAction takes nothing returns nothing
    local mshield magics = GetTriggerStructA(GetTriggeringTrigger())
    call magics.destroy()
endfunction
    
private function Actions takes nothing returns nothing
    local mshield magics = mshield.create()
    set magics.transfer = CreateTrigger( )
    set magics.death = CreateTrigger( )
       
    call SetTriggerStructA(magics.transfer, magics)
    call SetTriggerStructA(magics.death, magics)
    
    call TriggerRegisterUnitEvent( magics.transfer, magics.attacked, EVENT_UNIT_DAMAGED )
    call TriggerAddCondition( magics.transfer, Condition( function transConditions ) )
    call TriggerAddAction( magics.transfer, function transAction)
    
    call TriggerRegisterUnitEvent( magics.death, magics.caster, EVENT_UNIT_DEATH  )
    call TriggerRegisterUnitEvent( magics.death, magics.attacked, EVENT_UNIT_DEATH  )
    call TriggerAddAction(magics.death, function deaAction)
    
    call TriggerSleepAction(Duration)
    call magics.destroy()
    
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger generic = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( generic, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( generic, Condition( function msConditions ) )
    call TriggerAddAction( generic, function Actions )
endfunction
endscope


Here's a link to the thread by the way: http://www.thehelper.net/forums/showthread.php?t=102702


Thanks in advance!

By the way I might not be able to look at thread responses before this evening, but I am most thankful for any help :)

EDIT1:

The shown error messages are:
Following errors show up:
Code:
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function SetTriggerStructA"
"Undeclared function SetTriggerStructA"
"Undeclared function MagicalShield_InitTrig"
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"

EDIT2:

The main problem is solved but now that the trigger runs I notice it doesn't do anything... any ideas? :/
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
you forgot to type [ljass] endstruct [/ljass]

But there is...

JASS:
struct mshield
    unit caster
    unit attacked
    trigger transfer
    trigger death
    
    static method create takes nothing returns mshield
        local mshield magics = mshield.allocate() 
        set magics.attacked = GetSpellTargetUnit()
        set magics.caster= GetTriggerUnit()
        call UnitAddAbility( GetSpellTargetUnit(), ReductID)
        return magics
    endmethod
    
private method onDestroy takes nothing returns nothing
    
    call UnitRemoveAbility(.attacked, BuffID)
    call UnitRemoveAbility(.attacked, ReductID)
    set .caster = null
    set .attacked = null
    call ClearTriggerStructA(.transfer)
    call ClearTriggerStructA(.death)
    endmethod
endstruct<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 

Carl-Fredrik

New Member
Reaction score
51
Oh.. the initializer, true :p Added it but it doesn't help :/

The problem seems to be that the function "ClearTriggerStructA" is undeclared?

Following errors show up:
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function SetTriggerStructA"
"Undeclared function SetTriggerStructA"
"Undeclared function MagicalShield_InitTrig"
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Oh.. the initializer, true :p Added it but it doesn't help :/

The problem seems to be that the function "ClearTriggerStructA" is undeclared?

Following errors show up:
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function GetTriggerStructA"
"Cannot convert null to integer"
"Undeclared function SetTriggerStructA"
"Undeclared function SetTriggerStructA"
"Undeclared function MagicalShield_InitTrig"
"Undeclared function ClearTriggerStructA"
"Undeclared function ClearTriggerStructA"

This ClearTriggerStructA stuff must be a snippet or something like that u doesn't have.

Cannot convert null to integer, I think you can fix that one
 

Laiev

Hey Listen!!
Reaction score
188
you don't need an [ljass]initializer[/ljass] when you use [ljass]public function InitTrig[/ljass] to start an trigger

[ljass]public function[/ljass] is like normal function, but when you will callback it, you need name the scope/library before the function

example:

JASS:
scope Hey

public function InitTrig takes nothing returns nothing
endfunction

endscope

    call Hey_InitTrig()
 

Carl-Fredrik

New Member
Reaction score
51
I'm sorry, but I've never heard of this ABC thing... I'll try to locate it, thanks a lot. Rep will be given when I've found it if the trigger works :)
 

Carl-Fredrik

New Member
Reaction score
51
Importing the ABC system helped - no errors anymore, thanks a lot :D

Though there is one other problem.. The spell doesn't work :banghead:
Does anyone know why..? I can use the GUI version if not but I'm afraid it will bug if many players use it :/

Thanks in advance!
+Rep to everyone who helped so far anyway :)
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
    static method create takes nothing returns mshield
        local mshield magics = mshield.allocate() 
        set magics.attacked = GetSpellTargetUnit()
        set magics.caster= GetTriggerUnit()
        call UnitAddAbility( GetSpellTargetUnit(), ReductID)
        return magics
    endmethod


can be

JASS:
    static method create takes nothing returns mshield
        local mshield magics = mshield.allocate() 
        set magics.attacked = GetSpellTargetUnit()
        set magics.caster= GetTriggerUnit()
        call UnitAddAbility( magics.attacked, ReductID)
        return magics
    endmethod


~~

JASS:
private function transConditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetTriggerUnit(), BuffID) > 0)
endfunction


not sure but i think this don't will work because [ljass]GetTriggerUnit() != magics.caster[/ljass]

i think you can expand the struct to get this condition too, sorry if i'm wrong, i'm not too good with abc :(
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Er... Do you follow the implement instruction, like change the rawcodes...
 
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