• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS] Trigger breaks the map

Status
Not open for further replies.
Level 2
Joined
Apr 20, 2011
Messages
20
Hello, I'm having difficulties with a vjass spell that I'm making. The map compiles it fine, without syntax errors, but it makes map unplayable. Any help would be greatly appreciated ^_^

Basically, this spell procs when a unit damages a unit, for that I used Weep's GDD. When the unit takes damage, it has a certain % chance to spawn three illusions that damage it, and if the attack procs from behind, it will spawn a lot of images that push the unit forward. It also uses kenny's Knockback System, and Trollvottel's Unit Fading System to knockback and create the illusions, respectively. I know that these aren't the problem, though, because when I comment out the function calls to these systems, the spell is still broken... and I can't figure out what's wrong:vw_wtf:

I also used TimerUtils, but I highly doubt that's the problem O-o

Anyways, here's the code:

Yes, I know the conditions are messed up(useless BJs), but I was too lazy to change it when I converted the trigger ^_^ And yes I use PolarProjectionBJ, I really don't want to learn trig functions xD

JASS:
struct LingeringFront
unit pred
unit predtarg
real lingdmg
endstruct

struct LingeringBack
unit pre
unit pretarg
real lindmg
real linface
endstruct

struct LingBackDmg
unit pr
unit prtarg
real lidmg
endstruct

//yeah didn't clean the messy conditions part up yet.... but i doubt that this is the problem 

function Trig_Lingering_Shadows_Init_Conditions takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A02X', udg_UNIT_Heroes[GetConvertedPlayerId(GetOwningPlayer(udg_GDD_DamageSource))]) > 0 ) ) then
        return false
    endif
    if ( not ( GetRandomInt(1, 100) <= ( GetUnitAbilityLevelSwapped('A02X', udg_DamageEventSource) * 2 ) ) ) then
        return false
    endif
    return true
endfunction
// the condition to check for if it's a backstab or not
function Trig_Lingering_Shadows_Init_Func003Func012C takes nothing returns boolean
    if ( ( AngleBetweenPoints(GetUnitLoc(udg_GDD_DamageSource), GetUnitLoc(udg_GDD_DamagedUnit)) <= ( GetUnitFacing(udg_GDD_DamagedUnit) - 340.00 ) ) ) then
        return true
    endif
    if ( ( AngleBetweenPoints(GetUnitLoc(udg_GDD_DamageSource), GetUnitLoc(udg_GDD_DamagedUnit)) >= ( GetUnitFacing(udg_GDD_DamagedUnit) - 20.00 ) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Lingering_Shadows_Init_Func003C takes nothing returns boolean
    if ( not Trig_Lingering_Shadows_Init_Func003Func012C() ) then
        return false
    endif
    return true
endfunction

//actions to take if backstab
function LingeringBackDmg takes nothing returns nothing
local timer t = GetExpiredTimer()
local LingBackDmg data2 = GetTimerData(t)

call UnitDamageTargetEx(data2.pr,data2.prtarg,((GetUnitAbilityLevel(data2.pr,'A02X')*.1*data2.lidmg) + (GetHeroAgi(data2.pr,true)*GetUnitAbilityLevel(data2.pr,'A07T')*.5)), false,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",data2.prtarg,"chest"))

call ReleaseTimer(GetExpiredTimer())
call data2.destroy()

set t = null
endfunction

function LingeringBackH takes nothing returns nothing
local timer t = GetExpiredTimer()
local LingeringBack data = GetTimerData(t)
local location linloc1 = GetUnitLoc(data.pretarg)
local location linloc = PolarProjectionBJ(linloc1,128.,data.linface)
local timer lint
local LingBackDmg data2 = LingBackDmg.create()
set data2.pr = data.pre
set data2.prtarg = data.pretarg
set data2.lidmg = data.lindmg
//this checks if unit is sliding, if it is, it will spawn an illusion and create a timer that will damage the unit .3 seconds later(LingeringBackDmg), and starting a new timer that will check if the unit is sliding again in .2 seconds. If unit is no longer sliding, then destroy the structs and release the timer
if KBS_IsUnitSliding(data.pretarg) then
    call UFSYS_CreateFadeUnitAnimation('h00J',GetLocationX(linloc),GetLocationY(linloc),(data.linface + 180.),.5,"attack two",2.)
    set lint = NewTimer()
    call SetTimerData(lint,data2)
    call TimerStart(lint,.3,false,function LingeringBackDmg)
    call SetTimerData(t,data)
    call TimerStart(t,.2,false,function LingeringBackH)
else
    call ReleaseTimer(GetExpiredTimer())
    call data.destroy()
    call data2.destroy()
endif
    
    
call RemoveLocation(linloc1)
call RemoveLocation(linloc)
set linloc1 = null
set linloc = null
set t = null
set lint = null

endfunction

function LingeringBackfunc takes unit predd, unit preddtarg, real pdmg returns nothing
local unit u = predd
local unit t = preddtarg
local real d = pdmg
local timer t2
local LingeringBack data = LingeringBack.create()
set data.pre = u
set data.pretarg = t
set data.lindmg = d
set data.linface = (GetUnitFacing(u) - 180.)
//starts knockback
call KBS_BeginCommon(t,700.,2.,GetUnitFacing(u))
  
set t2=NewTimer()
call SetTimerData(t2,data)
call TimerStart(t2,.2,false,function LingeringBackH)

set t = null
set u = null
set t2 = null

endfunction
//actions to take if not a backstab
function LingeringFrontH takes nothing returns nothing

local timer t = GetExpiredTimer()
local LingeringFront data = GetTimerData(t)
call ReleaseTimer(GetExpiredTimer())

call UnitDamageTargetEx(data.pred,data.predtarg,((GetUnitAbilityLevel(data.pred,'A02X')*.6*data.lingdmg) + (GetHeroAgi(data.pred,true)*GetUnitAbilityLevel(data.pred,'A07T')*.5)), false,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",data.predtarg,"chest"))

call data.destroy()

set t = null
endfunction

function Trig_Lingering_Shadows_AltActions takes unit predator, unit predatortarg, real dmg returns nothing

local location loc1
local location loc2
local location loc3
local unit pred = predator
local unit predtarg = predatortarg
local timer t
local LingeringFront data = LingeringFront.create()
set data.pred = pred
set data.predtarg = predtarg
set data.lingdmg = dmg

set loc1 = PolarProjectionBJ(GetUnitLoc(predtarg),128.,(GetUnitFacing(predtarg)+180.))
set loc2 = PolarProjectionBJ(GetUnitLoc(predtarg),128.,(GetUnitFacing(predtarg)+90.))
set loc3 = PolarProjectionBJ(GetUnitLoc(predtarg),128.,(GetUnitFacing(predtarg)-90.))

call UFSYS_CreateFadeUnitAnimation('h00J',GetLocationX(loc1),GetLocationY(loc1),GetUnitFacing(predtarg),1.,"attack unarmed",1.)
call UFSYS_CreateFadeUnitAnimation('h00J',GetLocationX(loc2),GetLocationY(loc1),(GetUnitFacing(predtarg)-90.),1.,"attack unarmed",1.)
call UFSYS_CreateFadeUnitAnimation('h00J',GetLocationX(loc2),GetLocationY(loc1),(GetUnitFacing(predtarg)+90.),1.,"attack unarmed",1.)

call RemoveLocation(loc1)
call RemoveLocation(loc2)
call RemoveLocation(loc3)
set t = NewTimer()
call SetTimerData(t,data)
call TimerStart(t,.5,false,function LingeringFrontH)

set t = null
set pred = null
set predtarg = null
set loc1 = null
set loc2 = null
set loc3 = null
endfunction

function Trig_Lingering_Shadows_Init_Actions takes nothing returns nothing
local unit u = udg_GDD_DamageSource
local unit t = udg_GDD_DamagedUnit
local real d = udg_GDD_Damage
//checks if it's a backstab or not
if ( Trig_Lingering_Shadows_Init_Func003C() ) then
    call LingeringBackfunc(u,t,d)
    else
    call Trig_Lingering_Shadows_AltActions(u,t,d)    
endif

set u = null
set t = null

endfunction

//init trig (also didn't clean up yet ^-^)
function InitTrig_Lingering_Shadows_Init takes nothing returns nothing
    set gg_trg_Lingering_Shadows_Init = CreateTrigger(  )
    call DisableTrigger( gg_trg_Lingering_Shadows_Init )
    call TriggerRegisterVariableEvent( gg_trg_Lingering_Shadows_Init, "udg_GDD_Event", EQUAL, 0 )
    call TriggerAddCondition( gg_trg_Lingering_Shadows_Init, Condition( function Trig_Lingering_Shadows_Init_Conditions ) )
    call TriggerAddAction( gg_trg_Lingering_Shadows_Init, function Trig_Lingering_Shadows_Init_Actions )
endfunction
 
Status
Not open for further replies.
Top