Page 1 of 1

target players only

Posted: Wed Jan 29, 2014 5:44 pm
by 883Dman
This is primarily a DIYCE problem but can be helpful as a general macro. The script I have should target a player (not pet or npc) and lock on until that player is dead. The problem is it is not locking on. It spastically tabs between everything in range. If my code is correct, I think the problem is with the placement of the end statements.

Code: Select all

function WarriorRogue(arg1, potslot)
    local Skill = {}
    local i = 0
    local combat = GetPlayerCombatState()
    local friendly = (not UnitCanAttack("player", "target"))
    local enemy = (UnitCanAttack("player","target")) 
    local rage = UnitMana("player")
    local energy = UnitSkill("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local front = UnitIsUnit("player", "targettarget")
    local tDead = UnitIsDeadOrGhost("target")
    local melee = GetActionUsable(32)
    local LockedOn = UnitExists("target")
    local _1,potcd

    if potslot ~= nil then
        _1,potcd=GetActionCooldown(potslot)
   end

   if (PctH("player")<.70) and (potcd == 0) then
      UseAction(potslot)
      return
   end
    
    i=i+1; Skill[i] = { name = "Survival Instinct",  use = (PctH("player") < .5) }
    i=i+1; Skill[i] = { name = "Probing Attack",     use = (enemy and (rage >= 20)) }
    i=i+1; Skill[i] = { name = "Open Flank",         use = (enemy and (rage >= 10) and (string.find(tbuffs,"Vulnerable"))) }
    i=i+1; Skill[i] = { name = "Keen Attack",        use = (enemy and (energy >= 20) and (string.find(tbuffs,"Vulnerable"))) }
    i=i+1; Skill[i] = { name = "Splitting Chop",     use = (enemy and (rage >= 15) and (string.find(tbuffs,"Weakened"))) }
    i=i+1; Skill[i] = { name = "Thunder",            use = (enemy and (rage >= 15) and (string.find(tbuffs,"Weakened"))) }
    i=i+1; Skill[i] = { name = "Shadowstab",         use = (enemy and (energy >= 20) and (not string.find(tbuffs,"Excessive Bleeding"))) }
    i=i+1; Skill[i] = { name = "Attack",             use = (enemy and (PctH("target") == 1)) }
    i=i+1; Skill[i] = { name = "Attack",             use = (tDead or (not combat and not enemy)) }
        
        MyCombat(Skill,arg1)
    
    if tDead then
        TargetNearestEnemy()
    end    
    
    if (not LockedOn) then
        TargetNearestEnemy()
    end
    
    if LockedOn and (not enemy) then
        TargetNearestEnemy()
    end
end


Re: target players only

Posted: Wed Jan 29, 2014 11:56 pm
by rock5
I'm not familiar with DIYCE but it looks like there might be a problem with this part.

Code: Select all

    if tDead then
        TargetNearestEnemy()
    end   
   
    if (not LockedOn) then
        TargetNearestEnemy()
    end
   
    if LockedOn and (not enemy) then
        TargetNearestEnemy()
    end
Because the values are not updated except at the top of the function it possible more than 1 of these is triggered at a time, so you get multiple TargetNearestEnemy happening.

I can think of 2 solutions. Either update LockedOn and enemy after each TargetNearestEnemy or make sure only one of those events are triggered by using an if elseif statement, eg.

Code: Select all

    if tDead then
        TargetNearestEnemy()
    elseif (not LockedOn) then
        TargetNearestEnemy()
    elseif LockedOn and (not enemy) then
        TargetNearestEnemy()
    end
Or maybe just

Code: Select all

    if tDead or (not LockedOn) or (not enemy) then
        TargetNearestEnemy()
    end