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.
So, this spell causes a bunch of errors, does anyone know why..?
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:
EDIT2:
The main problem is solved but now that the trigger runs I notice it doesn't do anything... any ideas? :/
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.
So, this spell causes a bunch of errors, does anyone know why..?
JASS:
scope MagicalShield
globals
private constant integer AbilityID = 039;A00Y039; // Ability Code of Magical Shield
private constant integer BuffID = 039;B005039; // Buff Code of Magical Shield
private constant integer ReductID = 039;A00Z039; // 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? :/