- Joined
- Jul 26, 2008
- Messages
- 1,009
I could use some help. I'm pretty sure I'm not doing this Activatable spell correctly, so helpful advice there would be great. I know Activatables can be tricky.
[Solved!]Also my other question is when it comes to multiple events how do they work? Lets say I'm doing this:
Is it going to be an Or, or is it going to be an And? I'm trying to do a transformation spell and I want to save his abilities in local variables before he transforms, then give him new ones based on what his old ones are after the change. This will also happen when reverting back to normal. Perhaps there's an easier way to do this though, like finding out when the spell starts and ends? Recommendations?
[Unsolved!]Also, here is the Activatable spell that isn't working. So far the problem must lie somewhere in the Conditions or Trigger Initialize, because I'm getting no debug messages when testing.
EDIT: I've recently attempted the spell in vJASS. Of course It's nowhere near perfect and I don't fully understand the tutorial provided, like how do I set the caster variable as the Triggering Unit?
It didn't really explain that or a multitude of other things. Also when I save, it gives this error:
Invalid typecast
For this line:
Here is the vJASS code:
[Solved!]Also my other question is when it comes to multiple events how do they work? Lets say I'm doing this:
JASS:
call TriggerRegisterAnyUnitEventBJ( Trigger, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerRegisterAnyUnitEventBJ( Trigger, EVENT_PLAYER_UNIT_ISSUED_ORDER )
Is it going to be an Or, or is it going to be an And? I'm trying to do a transformation spell and I want to save his abilities in local variables before he transforms, then give him new ones based on what his old ones are after the change. This will also happen when reverting back to normal. Perhaps there's an easier way to do this though, like finding out when the spell starts and ends? Recommendations?
[Unsolved!]Also, here is the Activatable spell that isn't working. So far the problem must lie somewhere in the Conditions or Trigger Initialize, because I'm getting no debug messages when testing.
JASS:
globals
hashtable HashFindBlood
set HashFindBlood = InitHashtable()
endglobals
function FindBlood_Timer takes nothing returns nothing
local timer tim = GetExpiredTimer()
local unit caster = LoadUnitHandle(HashFindBlood, GetHandleId(tim), 1)
local group lowblood = CreateGroup()
local unit temp
local integer abillvl = GetUnitAbilityLevel(caster, 'fibl')
local integer orderid = LoadInteger(HashFindBlood, GetHandleId(tim), 2)
local real tempHP
call BJDebugMsg("Timer Action Begins, skill activated/unactivated")
//Register Locals
if GetUnitAbilityLevel(caster, 'B000') <= 0 or GetUnitState(caster, UNIT_STATE_MANA) <= 10. or orderid == OrderId("unimmolation") then
call BJDebugMsg("Unit has not enough mana, the Buff is gone, or the unit has used unimmolation")
//Does unit not have ImmolationDetection buff, less than 10 mana, or is disabling the skill? Then release the timer and remove skills.
call UnitRemoveAbility(caster, 'aspd')
call UnitRemoveAbility(caster, 'mspd')
call ReleaseTimer(tim)
else
call GroupEnumUnitsInRange(lowblood, GetUnitX(caster), GetUnitY(caster), 100.0 + 400 * abillvl, null)
call BJDebugMsg("The enemies in range are grouped")
//Put all units within 500 radius near caster into lowblood
loop
set temp = FirstOfGroup(lowblood)
exitwhen temp == null
if IsUnitEnemy(temp, GetOwningPlayer(caster)) then
call BJDebugMsg("Unit checked is an enemy")
//Make sure unit is enemy, otherwise remove from group
set tempHP = GetWidgetLife(temp) / GetUnitState(temp, UNIT_STATE_MAX_LIFE)
//Set a real variable to check the target's life as a %
if tempHP <= 0.20 + 0.05 * abillvl and tempHP >= 0 then
call BJDebugMsg("Unit checked has low HP")
//Check HP of enemy, if it's below 30% then run the calls
call UnitAddAbility(caster, 'mspd')
call SetUnitAbilityLevel(caster, 'mspd', abillvl * 2)
call UnitAddAbility(caster, 'aspd')
call SetUnitAbilityLevel(caster, 'aspd', abillvl)
//Add Movespeed and attackspeed skills to the caster and set them to the right level
else
//If the current target is not less than 30% HP the skills are removed, the unit is removed, and we go on to check the next unit
call BJDebugMsg("Unit doesn't have LowHP, keep checking")
call UnitRemoveAbility(caster, 'mspd')
call UnitRemoveAbility(caster, 'aspd')
call GroupRemoveUnit(lowblood, temp)
endif
else
call GroupRemoveUnit(lowblood, temp)
endif
endloop
endif
set caster = null
set lowblood = null
endfunction
function FindBlood_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local timer tim = NewTimer()
local integer orderid = GetIssuedOrderId()
call BJDebugMsg("First actions fire")
//Register caster, timer, and OrderId
call SaveUnitHandle(HashFindBlood, GetHandleId(tim), 1, caster)
call SaveInteger(HashFindBlood, GetHandleId(tim), 2, orderid)
call TimerStart(tim, 0.5, true, function FindBlood_Timer)
//Transfer variables, start time
set caster = null
endfunction
function FindBlood_Conditions takes nothing returns boolean
//Pretty much is the hero casting a spell with immolation ID, allows checking OrderID
return GetUnitAbilityLevel(GetTriggerUnit(),'fibl') > 0 and (GetIssuedOrderId() == OrderId("unimmolation") or GetIssuedOrderId() == OrderId("immolation"))
endfunction
//===========================================================================
function InitTrig_FindBlood takes nothing returns nothing
local trigger FindBlood = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( FindBlood, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( FindBlood, function FindBlood_Conditions )
call TriggerAddAction( FindBlood, function FindBlood_Actions )
endfunction
EDIT: I've recently attempted the spell in vJASS. Of course It's nowhere near perfect and I don't fully understand the tutorial provided, like how do I set the caster variable as the Triggering Unit?
Invalid typecast
For this line:
JASS:
//
call SetTimerData(tim, integer(D))
//
Here is the vJASS code:
JASS:
scope FindBlood
globals
private constant integer SpellID = 'fibl' //Spell Rawcode
private constant integer BuffID = 'B000' //Buff Rawcode
private constant real dur = 0.1 //Periodic of timer
endglobals
private struct Data
unit caster
integer orderid
static method create takes unit c returns Data
local Data D = Data.allocate()
set D.caster = c
set D.orderid = id
return D
endmethod
endstruct
private function FindBlood_Timer takes nothing returns nothing
local timer tim = GetExpiredTimer()
local Data D = Data.create(GetTimerData(tim))
local group lowblood = CreateGroup()
local unit temp
local integer abillvl = GetUnitAbilityLevel(D.caster, SpellID)
local real tempHP
call BJDebugMsg("Timer Action Begins, skill activated/unactivated")
//Register Locals
if GetUnitAbilityLevel(D.caster, BuffID) <= 0 or GetUnitState(D.caster, UNIT_STATE_MANA) <= 10. or D.orderid == OrderId("unimmolation") then
call BJDebugMsg("Unit has not enough mana, the Buff is gone, or the unit has used unimmolation")
//Does unit not have ImmolationDetection buff, less than 10 mana, or is disabling the skill? Then release the timer and remove skills.
call UnitRemoveAbility(D.caster, 'aspd')
call UnitRemoveAbility(D.caster, 'mspd')
call ReleaseTimer(tim)
else
call GroupEnumUnitsInRange(lowblood, GetUnitX(D.caster), GetUnitY(D.caster), 500.0 + 400. * (abillvl - 1.), null)
call BJDebugMsg("The enemies in range are grouped")
//Put all units within 500 radius near caster into lowblood
loop
set temp = FirstOfGroup(lowblood)
exitwhen temp == null
if IsUnitEnemy(temp, GetOwningPlayer(D.caster)) then
call BJDebugMsg("Unit checked is an enemy")
//Make sure unit is enemy, otherwise remove from group
set tempHP = GetWidgetLife(temp) / GetUnitState(temp, UNIT_STATE_MAX_LIFE)
//Set a real variable to check the target's life as a %
if tempHP <= 0.25 + 0.05 * (abillvl - 1.) and tempHP >= 0 then
call BJDebugMsg("Unit checked has low HP")
//Check HP of enemy, if it's below 30% but the unit isn't dead then run the calls
call UnitAddAbility(D.caster, 'mspd')
call SetUnitAbilityLevel(D.caster, 'mspd', abillvl * 2)
call UnitAddAbility(D.caster, 'aspd')
call SetUnitAbilityLevel(D.caster, 'aspd', abillvl)
//Add Movespeed and attackspeed skills to the caster and set them to the right level
else
//If the current target is not less than 30% HP the skills are removed, the unit is removed, and we go on to check the next unit
call BJDebugMsg("Unit doesn't have LowHP, keep checking")
call UnitRemoveAbility(D.caster, 'mspd')
call UnitRemoveAbility(D.caster, 'aspd')
call GroupRemoveUnit(lowblood, temp)
endif
else
call GroupRemoveUnit(lowblood, temp)
endif
endloop
endif
call D.destroy()
set lowblood = null
endfunction
private function FindBlood_Actions takes nothing returns nothing
local timer tim = NewTimer()
local Data D = Data.create(GetTriggerUnit())
//Setup our data to be transfered
call BJDebugMsg("First actions fire")
call SetTimerData(tim, D)
call TimerStart(tim, dur, true, function FindBlood_Timer)
set tim = null
endfunction
private function FindBlood_Conditions takes nothing returns boolean
//Pretty much is the hero casting a spell with immolation ID, allows checking OrderID
return GetUnitAbilityLevel(GetTriggerUnit(),SpellID) > 0 and (GetIssuedOrderId() == OrderId("unimmolation") or GetIssuedOrderId() == OrderId("immolation"))
endfunction
//===========================================================================
function InitTrig_FindBlood takes nothing returns nothing
local trigger FindBlood = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( FindBlood, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddCondition( FindBlood, function FindBlood_Conditions )
call TriggerAddAction( FindBlood, function FindBlood_Actions )
endfunction
endscope
Last edited: