| 03-01-2009, 05:49 PM | #1 |
Well the spell is called Decadence, and what it does is that it shoots green bolts every .3 second at a different angle for about 5 seconds. These bolts explode upon colliding with an enemy, slowing them and creating a cloud of damaging gas at their location. The triggering for it works, however sometimes during the the duration of the spell, it will crash if the caster dies. Could somebody possibly take a look at this code for me, I'm still a bit of a novice at vJASS, but more than willing to learn about it. Thank you in advance, I hope I placed this vJASS in correctly, if not just let me know. JASS:scope Decadence globals private real DECAD_ANGLE = 0.00 private real DECAD_ANG_X = 0.00 private real DECAD_ANG_Y = 0.00 private trigger DECAD_TRIGGER private trigger DECAD_TRIGGER2 //Sets Parameters for the Bile Bolts private constant integer SPELL_ID = 'A0B1' private constant real DECAD_SPEED = 800.00 private constant real DECAD_MAXDIST = 500.00 private constant real DECAD_COLLISION = 100.00 private constant real DECAD_HEIGHT = 150.00 private constant string DECAD_MISSILEART = "Abilities\\Weapons\\ChimaeraAcidMissile\\ChimaeraAcidMissile.mdl" private constant string DECAD_FIRINGART = "Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl" endglobals private struct decadencedata unit caster endstruct private struct triggerdata unit caster triggeraction ac timer t endstruct private struct timedata unit caster triggeraction ac timer t endstruct private function Conditions takes nothing returns boolean return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetTriggerPlayer()) == true ) endfunction private function Bolthit takes nothing returns nothing local decadencedata D = decadencedata(CollisionMissile_GetTag(GetTriggerCollisionMissile())) local unit targ = GetTriggerUnit() local unit missile = GetTriggerCollisionMissile() local unit dummy local texttag t local integer damage_type local location loc = GetUnitLoc(targ) local real damage = ( 10.00 + (GetHeroInt(D.caster, true) * ( .75 + ( 0.25 * GetUnitAbilityLevel(D.caster,'A0B1'))))) local integer textdamage = R2I(damage) set damage_type = DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FORCE) if IsUnitEnemy(targ,GetOwningPlayer(D.caster)) then call UnitDamageTarget(D.caster,targ,damage, true, false, ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FIRE, null) call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Undead\\DeathCoil\\DeathCoilSpecialArt.mdl", loc )) set t = CreateTextTag() call SetTextTagColor(t, 255, 50, 50, 175) call SetTextTagText(t, I2S(textdamage), 0.022) call SetTextTagPos(t, GetUnitX(targ), GetUnitY(targ), 0.00) call SetTextTagVelocity(t, 0, 0.03) call SetTextTagVisibility(t, true) call SetTextTagFadepoint(t, 2) call SetTextTagLifespan(t, 3) call SetTextTagPermanent(t, false) set dummy = CreateUnit(GetOwningPlayer(D.caster),'u00B',GetUnitX(targ),GetUnitY(targ),0.00) call IssueTargetOrder(dummy,"cripple",targ) call UnitApplyTimedLife(dummy,'BTLF',8.00) call CollisionMissile_Destroy(missile) set missile = null else call D.destroy() endif call RemoveLocation(loc) set loc = null set targ = null endfunction private function Decadbolts takes nothing returns nothing local trigger t = GetTriggeringTrigger() local decadencedata D = decadencedata.create() local triggerdata T = triggerdata( GetCSData(t) ) local timedata R = timedata( GetCSData(DECAD_TRIGGER2) ) local real x = GetUnitX(T.caster) local real y = GetUnitY(T.caster) local unit missile local unit temp local unit u = T.caster local effect se if (u!=null) then set DECAD_ANGLE = DECAD_ANGLE + 30.00 set DECAD_ANG_X = PolarProjectionX(x,300.00,DECAD_ANGLE) set DECAD_ANG_Y = PolarProjectionY(y,300.00,DECAD_ANGLE) set D.caster = T.caster endif if (u==null) then call TriggerRemoveAction(DECAD_TRIGGER2,R.ac) call TriggerRemoveAction(t,T.ac) call T.destroy() call R.destroy() call DestroyTrigger(t) call DestroyTrigger(DECAD_TRIGGER2) endif if (u!=null) then set missile = CollisionMissile_Create(DECAD_MISSILEART,x,y,DECAD_ANGLE,DECAD_SPEED,0.00,DECAD_MAXDIST, DECAD_HEIGHT,true,DECAD_COLLISION,function Bolthit) call CollisionMissile_SetTag(missile, integer(D)) endif set missile = null endfunction private function Timer takes nothing returns nothing local trigger r = GetTriggeringTrigger() local triggerdata T = triggerdata( GetCSData(DECAD_TRIGGER) ) local timedata R = timedata( GetCSData(r) ) call TriggerRemoveAction(DECAD_TRIGGER,T.ac) call TriggerRemoveAction(r,R.ac) call R.destroy() call T.destroy() call DestroyTrigger(r) call DestroyTrigger(DECAD_TRIGGER) endfunction private function Actions takes nothing returns nothing local unit cast = GetTriggerUnit() local triggerdata T = triggerdata.create() local timedata R = timedata.create() local real x = GetUnitX(cast) local real y = GetUnitY(cast) local effect se local location target = Location(x,y) local trigger t = CreateTrigger() local trigger r = CreateTrigger() set se = AddSpecialEffectTarget(DECAD_FIRINGART,cast,"chest") call DestroyEffect( se ) set se = null set DECAD_TRIGGER = t set DECAD_TRIGGER2 = r call SetCSData(t, integer(T) ) set T.caster = cast set T.ac = TriggerAddAction(t,function Decadbolts) call TriggerRegisterTimerEvent(t,.3,true) call TriggerRegisterTimerEvent(t,0,false) call SetCSData(r, integer(R) ) set R.ac = TriggerAddAction(r,function Timer) call TriggerRegisterTimerEvent(r,5.00,false) call TriggerRegisterTimerEvent(r,5.00,false) call RemoveLocation(target) set cast = null set target = null endfunction //=========================================================================== public function InitTrig takes nothing returns nothing call OnAbilityEffect( SPELL_ID, SCOPE_PRIVATE+"Actions" ) endfunction endscope |
| 03-01-2009, 06:29 PM | #2 |
This could just be me, but don't Event Responses only work in Conditions and Actions, not custom made functions within a scope? |
| 03-01-2009, 08:06 PM | #3 |
They work in any function triggered by an event. The custom functions are the conditions/actions in this case. It could be GetOwningPlayer(D.caster) I can't remember exactly how that works, but I know things like Player(-1) causes the game to crash. My other thought was a divide by zero error, but I can't see one anywhere. |
| 03-02-2009, 01:37 PM | #4 |
Dang, thanks anyways Jazradel. I hope someone can see a problem in my JASS spell. |
| 03-02-2009, 01:50 PM | #5 |
JASS:local integer textdamage = R2I(damage) call SetTextTagText(t, I2S(textdamage), 0.022) so why not JASS:local string textdamage = I2S(R2I(damage)) JASS:
if (u!=null) then
set DECAD_ANGLE = DECAD_ANGLE + 30.00
set DECAD_ANG_X = PolarProjectionX(x,300.00,DECAD_ANGLE)
set DECAD_ANG_Y = PolarProjectionY(y,300.00,DECAD_ANGLE)
set D.caster = T.caster
endif
if (u==null) then
call TriggerRemoveAction(DECAD_TRIGGER2,R.ac)
call TriggerRemoveAction(t,T.ac)
call T.destroy()
call R.destroy()
call DestroyTrigger(t)
call DestroyTrigger(DECAD_TRIGGER2)
endif
JASS:
if (u!=null) then
set DECAD_ANGLE = DECAD_ANGLE + 30.00
set DECAD_ANG_X = PolarProjectionX(x,300.00,DECAD_ANGLE)
set DECAD_ANG_Y = PolarProjectionY(y,300.00,DECAD_ANGLE)
set D.caster = T.caster
else
call TriggerRemoveAction(DECAD_TRIGGER2,R.ac)
call TriggerRemoveAction(t,T.ac)
call T.destroy()
call R.destroy()
call DestroyTrigger(t)
call DestroyTrigger(DECAD_TRIGGER2)
endif
JASS:
if (u!=null) then
set missile = CollisionMissile_Create(DECAD_MISSILEART,x,y,DECAD_ANGLE,DECAD_SPEED,0.00,DECAD_MAXDIST, DECAD_HEIGHT,true,DECAD_COLLISION,function Bolthit)
call CollisionMissile_SetTag(missile, integer(D))
endif
Why not doing this JASS:CollisionMissile_SetTag(CollisionMissile_Create(DECAD_MISSILEART,x,y,DECAD_ANGLE,DECAD_SPEED,0.00,DECAD_MAXDIST, DECAD_HEIGHT,true,DECAD_COLLISION,function Bolthit),integer(D)) ??? It would safe a bit of code and needs less memory. |
