| 07-06-2008, 07:32 PM | #1 |
i have a glitch with TT, or maybe im just misusing it, but here is the deal JASS:struct spelldata real x real y real distance real angle unit bullet endstruct globals group tempGroup = CreateGroup() unit tempUnit boolean tempBoo boolexpr tempBool endglobals function collision takes nothing returns boolean local unit u = GetFilterUnit() if GetWidgetLife(u) > 0.405 then call IssueImmediateOrder( u, "innerfireoff" ) set bj_lastCreatedUnit = CreateUnit( GetOwningPlayer( tempUnit ), 'dumy', 0, 0, 0) call UnitAddAbility( bj_lastCreatedUnit, 'bble') call IssueTargetOrderById( bj_lastCreatedUnit , OrderId("acidbomb"), u ) call UnitDamageTarget( tempUnit, u, GetRandomReal( 200, 1000 ), false, true, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_FORCE, WEAPON_TYPE_WHOKNOWS) call RemoveUnit( tempUnit ) set bj_lastCreatedEffect = AddSpecialEffect( "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl", GetUnitX(u), GetUnitY(u) ) call DestroyEffect( bj_lastCreatedEffect ) call TriggerSleepAction( 0.25 ) call RemoveUnit( bj_lastCreatedUnit ) set tempUnit = null set tempBoo = true endif set u = null return true endfunction function bullet_collision takes nothing returns boolean local unit u = GetFilterUnit() if GetWidgetLife(u) <= 0.405 and tempUnit != u then set bj_lastCreatedEffect = AddSpecialEffect( "Abilities\\Spells\\Items\\SpellShieldAmulet\\SpellShieldCaster.mdl", GetUnitX(u), GetUnitY(u) ) call DestroyEffect( bj_lastCreatedEffect ) call RemoveUnit( tempUnit ) call RemoveUnit( u ) set tempUnit = null set tempBoo = true endif set u = null return true endfunction function time takes nothing returns boolean local spelldata a = TT_GetData() if a.bullet == null then return true endif set a.distance = a.distance + (800 * 0.02) set a.x = a.x + (800 * 0.02) * Cos( a.angle * bj_DEGTORAD ) set a.y = a.y + (800 * 0.02) * Sin( a.angle * bj_DEGTORAD ) if GetUnitAbilityLevel( a.bullet, 'cool' ) > 0 then call RemoveUnit( a.bullet ) set bj_lastCreatedEffect = AddSpecialEffect( "Abilities\\Spells\\Undead\\ReplenishMana\\ReplenishManaCaster.mdl", a.x, a.y ) call DestroyEffect( bj_lastCreatedEffect ) endif if a.x > 2000 or a.x < -2000 then call RemoveUnit( a.bullet ) return true endif if a.y > 2000 or a.y < -2000 then call RemoveUnit( a.bullet ) return true endif set tempUnit = a.bullet call GroupClear( tempGroup ) set tempBoo = false set tempBool = Condition(function bullet_collision) call GroupEnumUnitsInRange( tempGroup, a.x, a.y, 9, tempBool) if tempBoo then return true endif call GroupClear( tempGroup ) set tempBool = Condition(function collision) call GroupEnumUnitsInRange( tempGroup, a.x, a.y, 9, tempBool) if tempBoo then return true endif call SetUnitX( a.bullet, a.x ) call SetUnitY( a.bullet, a.y ) if a.distance > 3000 then call RemoveUnit( a.bullet ) return true endif return false endfunction function Conditions takes nothing returns boolean if GetSpellAbilityId() == 'shot' then return true endif return false endfunction function shoot_Actions takes nothing returns nothing local spelldata a = spelldata.create() local timer t = CreateTimer() local unit u = GetTriggerUnit() local player p = GetOwningPlayer(u) set a.angle = (bj_RADTODEG * Atan2(GetLocationY(GetSpellTargetLoc()) - GetUnitY(u), GetLocationX(GetSpellTargetLoc()) - GetUnitX(u))) set a.bullet = CreateCorpse( p, 'hpea', 0,0, a.angle) call UnitSuspendDecay( a.bullet,true) call SetUnitAnimation( a.bullet, "stand" ) call PauseUnit( a.bullet, true ) call AddSpecialEffectTarget( "Abilities\\Weapons\\MakuraMissile\\MakuraMissile.mdl", a.bullet, "chest") set a.x = GetUnitX( u ) + ( 5 ) * Cos( a.angle * bj_DEGTORAD ) set a.y = GetUnitY( u ) + ( 5 ) * Sin( a.angle * bj_DEGTORAD ) call TT_Start( function time, a ) endfunction //=========================================================================== function InitTrig_Shoot takes nothing returns nothing set gg_trg_Shoot = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Shoot, Condition( function Conditions ) ) call TriggerAddAction( gg_trg_Shoot, function shoot_Actions ) endfunction In this trigger, as it is, it works just fine, but as you can see, i am not removing the spell data, the issue happens when I do remove the spell data. If I remove the spell data, the spell just completely stops working, and I have no clue why :/ |
| 07-06-2008, 07:55 PM | #2 |
Where do you remove the spell data? |
| 07-06-2008, 07:59 PM | #3 |
every time before returning true on the time function, or atleast thats what you're supposed to do. |
| 07-06-2008, 08:21 PM | #4 | |
Doesn't TT stop 'running' for the specified function when you return true? EDIT: Got it Quote:
So, by the looks of it, removing spelldata shouldn't be the problem, but rather the fact that you are constantly returning true. |
| 07-06-2008, 08:41 PM | #5 | |
Quote:
If you read my spell, you would see that it only returns true when the projectile collides with a target, which in case, I indeed want it to stop after it collides. |
| 07-06-2008, 08:51 PM | #6 |
Do you mean when you add data.destroy()? don't call data.destroy inside the shoot_Actions, destroy the struct when your missile collides, since you won't be needing the instance anymore. |
| 07-06-2008, 09:13 PM | #7 |
Move RemoveUnit in onDestroy method JASS:struct spelldata real x real y real distance real angle unit bullet private method onDestroy takes nothing returns nothing call RemoveUnit(.bullet) endmethod endstruct and call a.destroy() before EVERY return true in time function |
| 07-06-2008, 10:15 PM | #8 |
i don't want to do the ondestroy because on some of the things i remove the unit in a different function, and if i remove a null unit i dont know whats going to happen, but I do destroy thing before every single return true, and it still malfunctions edit: i guess i could just check in the method if bullet is null, but i mean i remove it every time before destroying the struct, so it would really be pointless |
| 07-06-2008, 10:19 PM | #9 |
JASS:struct spelldata real x real y real distance real angle unit bullet endstruct globals group tempGroup = CreateGroup() unit tempUnit boolean tempBoo boolexpr tempBool endglobals function collision takes nothing returns boolean local unit u = GetFilterUnit() if GetWidgetLife(u) > 0.405 then call IssueImmediateOrder( u, "innerfireoff" ) set bj_lastCreatedUnit = CreateUnit( GetOwningPlayer( tempUnit ), 'dumy', 0, 0, 0) call UnitAddAbility( bj_lastCreatedUnit, 'bble') call IssueTargetOrderById( bj_lastCreatedUnit , OrderId("acidbomb"), u ) call UnitDamageTarget( tempUnit, u, GetRandomReal( 200, 1000 ), false, true, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_FORCE, WEAPON_TYPE_WHOKNOWS) call RemoveUnit( tempUnit ) set bj_lastCreatedEffect = AddSpecialEffect( "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl", GetUnitX(u), GetUnitY(u) ) call DestroyEffect( bj_lastCreatedEffect ) call TriggerSleepAction( 0.25 ) call RemoveUnit( bj_lastCreatedUnit ) set tempUnit = null set tempBoo = true endif set u = null return true endfunction function bullet_collision takes nothing returns boolean local unit u = GetFilterUnit() if GetWidgetLife(u) <= 0.405 and tempUnit != u then set bj_lastCreatedEffect = AddSpecialEffect( "Abilities\\Spells\\Items\\SpellShieldAmulet\\SpellShieldCaster.mdl", GetUnitX(u), GetUnitY(u) ) call DestroyEffect( bj_lastCreatedEffect ) call RemoveUnit( tempUnit ) call RemoveUnit( u ) set tempUnit = null set tempBoo = true endif set u = null return true endfunction function time takes nothing returns boolean local spelldata a = TT_GetData() if a.bullet == null then a.destroy() return true endif set a.distance = a.distance + (800 * 0.02) set a.x = a.x + (800 * 0.02) * Cos( a.angle * bj_DEGTORAD ) set a.y = a.y + (800 * 0.02) * Sin( a.angle * bj_DEGTORAD ) if a.x > 2000 or a.x < -2000 then call RemoveUnit( a.bullet ) a.destroy() return true endif if a.y > 2000 or a.y < -2000 then call RemoveUnit( a.bullet ) a.destroy() return true endif set tempUnit = a.bullet call GroupClear( tempGroup ) set tempBoo = false set tempBool = Condition(function bullet_collision) call GroupEnumUnitsInRange( tempGroup, a.x, a.y, 9, tempBool) if tempBoo then a.destroy() return true endif call GroupClear( tempGroup ) set tempBool = Condition(function collision) call GroupEnumUnitsInRange( tempGroup, a.x, a.y, 9, tempBool) if tempBoo then a.destroy() return true endif call SetUnitX( a.bullet, a.x ) call SetUnitY( a.bullet, a.y ) if a.distance > 3000 then call RemoveUnit( a.bullet ) a.destroy() return true endif return false endfunction function Conditions takes nothing returns boolean if GetSpellAbilityId() == 'shot' then return true endif return false endfunction function shoot_Actions takes nothing returns nothing local spelldata a = spelldata.create() local timer t = CreateTimer() local unit u = GetTriggerUnit() local player p = GetOwningPlayer(u) set a.angle = (bj_RADTODEG * Atan2(GetLocationY(GetSpellTargetLoc()) - GetUnitY(u), GetLocationX(GetSpellTargetLoc()) - GetUnitX(u))) set a.bullet = CreateCorpse( p, 'hpea', 0,0, a.angle) call UnitSuspendDecay( a.bullet,true) call SetUnitAnimation( a.bullet, "stand" ) call PauseUnit( a.bullet, true ) call AddSpecialEffectTarget( "Abilities\\Weapons\\MakuraMissile\\MakuraMissile.mdl", a.bullet, "chest") set a.x = GetUnitX( u ) + ( 5 ) * Cos( a.angle * bj_DEGTORAD ) set a.y = GetUnitY( u ) + ( 5 ) * Sin( a.angle * bj_DEGTORAD ) call TT_Start( function time, a ) endfunction //=========================================================================== function InitTrig_Shoot takes nothing returns nothing set gg_trg_Shoot = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Shoot, EVENT_PLAYER_UNIT_SPELL_CAST ) call TriggerAddCondition( gg_trg_Shoot, Condition( function Conditions ) ) call TriggerAddAction( gg_trg_Shoot, function shoot_Actions ) endfunction thats the code when i do remove the struct, and its when it malfunctions |
| 07-06-2008, 10:55 PM | #10 |
call |
| 07-07-2008, 12:12 AM | #11 |
srry i didnt put call on that one, but thats because i quick just put that in there while editing, its not the actual code, the code itself does have the call destroy though |
| 07-07-2008, 12:38 AM | #12 |
JASS:function Conditions takes nothing returns boolean if GetSpellAbilityId() == 'shot' then return true endif return false endfunction JASS:function Conditions takes nothing returns boolean return GetSpellAbilityId() == 'shot' endfunction Not sure what the bug is exactly either, but it might help you if you combine this-- JASS:function bullet_collision takes nothing returns boolean local unit u = GetFilterUnit() if GetWidgetLife(u) <= 0.405 and tempUnit != u then set bj_lastCreatedEffect = AddSpecialEffect( "Abilities\\Spells\\Items\\SpellShieldAmulet\\SpellShieldCaster.mdl", GetUnitX(u), GetUnitY(u) ) call DestroyEffect( bj_lastCreatedEffect ) call RemoveUnit( tempUnit ) call RemoveUnit( u ) set tempUnit = null set tempBoo = true endif set u = null return true endfunction Also in the post above you forgot to add what cohadar said here: JASS:private method onDestroy takes nothing returns nothing call RemoveUnit(.bullet) endmethod |
| 07-07-2008, 12:46 AM | #13 |
You forgot to read what I said above. Thanks for changing my condition, but everything else shall remain the same. My code doesn't have a bug, if I add "call a.destroy()" thats when the bug appears, my only guess is that the bug is in TT. |
| 07-07-2008, 02:43 AM | #14 |
Well should I use a different attachment system for this spell, since this post was directed towards cohadar, since he demanded me to post this, after I PM'd it to him, and told me to post it, since he doesn't respond to "that kind of messages." |
| 07-07-2008, 02:47 AM | #15 | |
Quote:
'that kind of message' is a private message. There's a reason we have a forum - you only need to answer a question once. Then, if people ask the same question, you just go: "STFU NUB!!!#@!!! <link to search feature>" |
