target players only

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
883Dman
Posts: 90
Joined: Sat Dec 08, 2012 9:25 pm

target players only

#1 Post 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

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: target players only

#2 Post 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
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Post Reply