• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Works, but not Perfect...

Status
Not open for further replies.
Level 4
Joined
Jul 23, 2008
Messages
99
BG :
I have created a spell named "Assasination".

How it works?
Targets a unit, then hero will be invisible and engage target, to be attacked. While engaging, hero receives bonus damage and maximum movespeed for one attack to target. If hero changes target, the buff will lost.

Rawcode Translator :
'e001' = dummy
'A01H' = Invisibility (dummy)
'A01I' = Hero Bonus Damage
'A01G' = Assasination (Hero)
'A01J' = Assasinated Indicator

This spell consists of two triggers. Main Trigger and Target Rechecker.

JASS:
function AssProc takes nothing returns boolean
      if (GetEventDamageSource() == udg_AssCaster and GetEventDamage() != 0 and udg_isAttack == true) then
            return true
      endif
      return false     
endfunction

function Assasination_Act_Ons takes nothing returns nothing
    local unit x = GetEventDamageSource()
    local unit y = udg_AssTarget
    local integer i = GetRandomInt(1,100)
    local location z = GetUnitLoc(y)
    //call DisplayTextToForce( GetPlayersAll(), ( "Success damaging target by equal of : " + R2S(GetEventDamage()) ) )
    call UnitRemoveAbilityBJ( 'A01I', x )
    call SetUnitMoveSpeed( x, GetUnitDefaultMoveSpeed(x) )
    if i <= 15 then
      call UnitDamageTarget(x,y,1000000000,true,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FIRE,WEAPON_TYPE_WHOKNOWS)
      call DestroyEffect(AddSpecialEffectLoc( "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl",z))
    endif
    call UnitRemoveBuffBJ('B00H',y)
    call DisableTrigger(gg_trg_AssasinCheckFX)
    set x = null
    set y = null
    set udg_isAttack = false
    call DestroyTrigger ( GetTriggeringTrigger() )
    set udg_AssCaster = null
    set udg_AssTarget = null
    call RemoveLocation(z)
    set z = null  
endfunction

function Trig_Assasination_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01G' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Assasination_Func009C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A01G', GetSpellAbilityUnit()) < 3 ) ) then
        return false
    endif
    return true
endfunction



function Trig_Assasination_Actions takes nothing returns nothing
    //INIT VARS
    local unit LCU
    local unit LCU2
    local unit caster = GetSpellAbilityUnit()
    local unit target = GetSpellTargetUnit()                      
    local location casterloc = GetUnitLoc(GetSpellAbilityUnit())
    local location targetloc = GetUnitLoc(GetSpellTargetUnit())
    local trigger cptrig = CreateTrigger()
    //Hashtable Declaration
    //call InitHashtableBJ()
    //call SaveUnitHandleBJ(caster,StringHash("caster"),StringHash("Assasination"),bj_lastCreatedHashtable)
    //call SaveUnitHandleBJ(target,StringHash("target"),StringHash("Assasination"),bj_lastCreatedHashtable)
    set udg_AssCaster = caster
    set udg_AssTarget = target
    //Trigger
    call EnableTrigger(gg_trg_AssasinCheckFX)
    call CreateNUnitsAtLoc( 1, 'e001', GetOwningPlayer(caster), casterloc, bj_UNIT_FACING )
    set LCU = GetLastCreatedUnit()
    call UnitAddAbilityBJ( 'A01H', LCU)
    call IssueTargetOrderBJ( LCU, "invisibility", caster )
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', LCU )
    call SetUnitMoveSpeed( caster, 700.00 )
    call UnitAddAbilityBJ( 'A01I', caster )
    call SetUnitAbilityLevelSwapped( 'A01I', caster, GetUnitAbilityLevelSwapped('A01G', caster) )
    if ( Trig_Assasination_Func009C() ) then
        call CreateNUnitsAtLoc( 1, 'e001', GetOwningPlayer(caster), targetloc, bj_UNIT_FACING )
        set LCU2 = GetLastCreatedUnit()
        call UnitAddAbilityBJ( 'A01J', LCU2 )
        call IssueTargetOrderBJ( LCU2, "acidbomb", target)
        call UnitApplyTimedLifeBJ( 2.00, 'BTLF', LCU2)
    endif
    call TriggerRegisterUnitEvent( cptrig, target, EVENT_UNIT_DAMAGED )
    call TriggerAddCondition ( cptrig , Condition ( function AssProc ) )
    call TriggerAddAction(cptrig, function Assasination_Act_Ons)
    call SaveTriggerHandleBJ(cptrig,StringHash("trigger"),StringHash("Assasination"),udg_SkillTable)
    call PolledWait(0.43)
    call IssueTargetOrderBJ( caster, "attack", target )
    set cptrig = null
    set caster = null
    set target = null
    call RemoveLocation(targetloc)
    call RemoveLocation(casterloc)
    set targetloc = null
    set casterloc = null
    set LCU = null
    set LCU2 = null
endfunction

//===========================================================================
function InitTrig_Assasination takes nothing returns nothing
    set gg_trg_Assasination = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Assasination, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Assasination, Condition( function Trig_Assasination_Conditions ) )
    call TriggerAddAction( gg_trg_Assasination, function Trig_Assasination_Actions )
endfunction

And the Rechecker :

  • AssasinCheckFX
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacking unit) Equal to AssCaster
      • (AssCaster has buff Assasination ) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Attacked unit) Not equal to AssTarget
        • Then - Actions
          • Unit - Set AssCaster movement speed to (Default movement speed of AssCaster)
          • Unit - Remove AssasinationDamageBonus from AssCaster
          • Unit - Remove Assasinated buff from AssTarget
          • Custom script: call DestroyTrigger(LoadTriggerHandleBJ(StringHash("trigger"),StringHash("Assasination"),udg_SkillTable))
          • Set AssCaster = No unit
          • Set AssTarget = No unit
          • Set isAttack = False
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set isAttack = True
NOTE : Trigger above is initially off.

=====================================
All works properly, no recent bugs. Now, what's the problem? Here, there is...

When I cast this spell, it causes extreme lag (fps drop from 64 to 18-20 or from 45 to 8-12). I have debugged this spell and the problem comes from function Assasination_Act_Ons, but I still not find any "memory" because I did not create units, widgets or massive effects in the function.

Uniquely, the trigger works when target takes damage, but lag happens before it. Even, the lag disappeared when trigger are executed.

Do you have any solution of this?
 
Level 4
Joined
Jul 23, 2008
Messages
99
hm... is that failure?

And... that vars causing lag on the game?

I don't understand what you mean...

Please... I need resolution...
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
i was actually laughing at the fact that your abbreviation for assassin is "ass"

Do you really need all this to make a wind walk remake that doesnt let u switch targets?
 
Status
Not open for further replies.
Top