ScriptUO

Scripting Resources & Utilities => Orion UO Client => Orion UO Scripts => Topic started by: altiric on June 12, 2023, 07:48:50 PM

Title: Sampire Helper
Post by: altiric on June 12, 2023, 07:48:50 PM
Got a request for this script. Just extracted a few main functions from my own script. Will spend the next few days re-working it based on feedback here.

Usage: Autostart should run in the background. It will scan all valid targets on the screen, and add them to a find list called mobTypes if the targets graphic does not already exists. The comments of each graphic are used as tags in the script. The first element is the mobile name and is currently unused in the script. The second entry is for the slayer type. If you change the value from false, that word will be used to find the correct slayer in your inventory. For example "a water elemental|elemental|false" will try to find an elemental slayer in your pack and equip it when the attack function is called. The third element will be used to ignore that mob when scanning for valid targets(not completed yet).

You can assign a hotkey to the attack function which will attempt to attack the closest valid target. If the target is at full health, and is in range, it will be honored. The targets type will be checked for a slayer, if one is returned, and that slayer is found in your inventory, it will be equipped. The script will then try to move and stay within one tile of the target. The best bushido stance will then be selected. If only one target is in range, swordsmanship mastery is active, and you are holding a double axe, onslaught will be used every 6 seconds. Then Primary Ability will be activated if only one target is in range. Momentum strike will be used if there are two targets. If you are holding a double axe, and 3 or more targets are in range, whirlwind will be used instead. Once the target dies, a counter for its graphic type will be increased giving a decent approximation of how many of those targets have been killed(if the target becomes invalid, but did not die the counter will still increase).

Bit of a messy explanation, and currently does not have any Chivalry spells in use, but if more people are interested in this type of a script i am willing to get it cleaned up and expand it a little further. I have not fully tested this script since my own sampire script runs just fine even though i have only provided some of its functionality here.
Title: Re: Sampire Helper
Post by: Crisis on June 13, 2023, 07:49:21 AM
I will check it out, sounds cool.
Title: Re: Sampire Helper
Post by: Kandie on June 13, 2023, 07:45:33 PM
is this for easyuo or orion?  if for Orion I am very interested :)
Title: Re: Sampire Helper
Post by: DieselKush420 on June 14, 2023, 06:01:30 AM
I have it on auto start but I can't get her it to do anything when I hit play. My samp just stands there and gets attacked. I would try to touch it up but I don't have a clue on writing scripts. I use Orion
Title: Re: Sampire Helper
Post by: altiric on June 14, 2023, 12:22:37 PM
Autorun on its own wont do anything. This script is not meant to play the game for you. Autorun only keeps a log of mobiles, and some information about them. The attack function needs to be added to a hotkey and called each time you want to attack a new target. It is very easy to add a function that will loop the attack function if thats how you want the script to work but is out of the scope of this script. I'll add a section on assigning hotkeys to functions if anyone needs clarification on that.
Title: Re: Sampire Helper
Post by: DieselKush420 on June 14, 2023, 07:28:23 PM
Awesome thank you ill be looking for that post
Title: Re: Sampire Helper
Post by: Caio Neto on June 18, 2023, 08:30:50 AM
hiii

Post Merge: June 18, 2023, 08:31:51 AM
i wanna it
Title: Re: Sampire Helper
Post by: JackWalters on July 03, 2023, 12:56:47 AM
So script is working. But was wrong command cast. Instead
Code: Javascript
  1.  [color=red]if(Player.Hits("%") < 30)
  2.             cast('Evasion'); // Use evasion for ciritical health
  3.         else if(Player.Hits("%") < 70)
  4.             cast('Confidence'); // Use confidenc for a boost
  5.         else
  6.             cast('Counter Attack'); // Counter attack[/color]
Must be: 
Code: Javascript
  1. [color=green]function checkStance(){
  2.     if(Orion.SkillValue('Bushido') < 500) return;
  3.     if(!Orion.BuffExists('Confidence') && !Orion.BuffExists('Evasion') && !Orion.BuffExists('Counter Attack') && Player.Mana() > 15){
  4.         if(Player.Hits("%") < 30)
  5.            Orion.Cast('401'); // Use evasion for ciritical health
  6.         else if(Player.Hits("%") < 70)
  7.              Orion.Cast('402'); // Use confidenc for a boost
  8.         else
  9.             Orion.Cast('404'); // Counter attack[/color]

So full script:
Spoiler: show


const color = {
  label: '0x008E',
  value: '0x0037',
  black: '0x0000',
  green:  { light: '0x0046', norm: '0x0044', dark: '0x00A7' },
  blue:   { light: '0x0064', norm: '0x0062', dark: '0x00C5' },
  red:    { light: '0x0028', norm: '0x0026', dark: '0x0089' },
  occ:    { light: '0x002D', norm: '0x002B', dark: '0x008E' },
  purple: { light: '0x001E', norm: '0x0017', dark: '0x007A' },
  yellow: { light: '0x0037', norm: '0x0035', dark: '0x0098' },
  white:  { light: '0x7FA',  norm: '0x7EE',  dark: '0x7E2' }
};

function Autostart(){
    Orion.ClearJournal();
    Orion.ClientViewRange(24);

    while(Orion.Connected()){
        //Open paperdoll and save config every 5 minutes (to keep mobTypes updated)
        if(!Orion.TimerExists('antiIdle') || Orion.Timer('antiIdle') > 300000){
            Orion.SetTimer('antiIdle');
            Orion.OpenPaperdoll(Player.Serial());
            Orion.SaveConfig();
        }

        //Don't take any actions while dead
        if(Player.Dead()){
            while(Player.Dead())
                Orion.Wait(500);
            Orion.Wait(3000);
            //Equip gear set when alive
            Orion.Dress('sampire');
        }
       
        //Scan all local mobs, and add to mobTypes if not found
        var mobList = Orion.GetFindList('mobTypes').Items().map(function(mob){ return mob.Graphic() });
        loadMobs().filter(function(mob){
            return mobList.indexOf(mob.Graphic()) === -1;
        }).forEach(function(mob){
            if(mob.Name())
                Orion.AddFindList('mobTypes', mob.Graphic(), 'any', mob.Name() +'|false|false');
           
        });

        Orion.Wait(500);
    }
}

function loadMobs(dist){
    var noto = Player.Notoriety() === 6 ? 'innocent|criminal|enemy|murderer' : 'innocent|gray|criminal|enemy|murderer';
    dist = dist ? dist : Orion.OAOptionGet('MaxTargetDistance');
    var mobs = Orion.FindTypeEx(any, any, ground, 'mobile|live|ignoreself|ignorefriends', dist, noto);
    return mobs || false;
}

function honor(mob){
    if(Orion.HaveTarget())
        Orion.CancelTarget();
    Orion.CancelWaitTarget();
    Orion.AddHighlightCharacter(mob.Serial(), color.green.norm, false);
    if(mob.Distance() < 8 && mob.Hits("%") === 100){
        Orion.InvokeVirtue('Honor');
        if(Orion.WaitForTarget())
            Orion.TargetObject(mob.Serial());
        Orion.Wait(100);
        if(Orion.HaveTarget())
            Orion.CancelTarget();
    }
}

function attack(){
    var mobs = loadMobs() // Load mobs to array
        .filter(function(m){ return m.InLOS() }) // Filter out of sight mobs
        .filter(function(m){ return !m.IsHuman() }) // Filter Humans
        .sort(function(a, b){ // Sort targets by distance, then health
            if(a.Distance() !== b.Distance())
                return a.Distance() - b.Distance();
            return a.Hits() - b.Hits();
        });
    var mob = mobs.shift(); // Select focused mob, or select weakest, closest mob from array
    if(!mob) return; // No mobs, leave function
    var primary = Orion.AbilityStatus('Primary');
    var secondary = Orion.AbilityStatus('Secondary');
    honor(mob); // Honor target

    var tags = loadTags(mob.Graphic())[0];
    if(tags)
        equipSlayer(tags.slayer);
    var combatStart = Orion.Now(); // Set combat timer
    Orion.Attack(mob.Serial()); // Attack mobile
    Orion.SetTimer('loadLocals');
    var inRange = 1;
    var mobType = mob.Graphic();
    var mastery = loadMastery();

    while(mob.Exists() && Player.WarMode()){ // While the mob is alive and player is in warmode
        inRange = loadMobs(1).length; // Load mobs in combat range to array
        var combatTime = Orion.Now() - combatStart; // determine length of combat so far
        var chivalry = Orion.SkillValue('Chivalry') > 500;
        if(mob.Distance() > 1 && combatTime > 3000) // If mob is out of range
            Orion.WalkTo(mob.X(), mob.Y(), mob.Z(), 1, 255, 1); // Get in range

        checkStance();

        if(inRange === 1 && !Orion.SpellStatus('onslaught') &&
            mastery.match(/Swordsmanship/gi) &&
            Player.Mana() > 20 &&
            Orion.ObjAtLayer('LeftHand').Graphic() != 0x26BD &&
            (!Orion.TimerExists('onslaught') || Orion.Timer('onslaught') > 6000)){
                Orion.SetTimer('onslaught');
                Orion.Cast('729'); // Use Onslaught!
        } else if(inRange === 2 && !Orion.SpellStatus('Momentum Strike')){
            Orion.Cast('406'); // If 2 mobs are in range
        } else if(inRange > 2 && !primary && !secondary && !Orion.BuffExists('Momentum Strike')){
            if(!Orion.UseAbility('secondary')) // If 3 or more are in range
               Orion.Cast('406');
        } else if(!Orion.AbilityStatus('Primary') &&
                  !Orion.SpellStatus('Onslaught') &&
                  Player.Mana() > 30){
                        Orion.UseAbility('Primary');
                        Orion.Wait(750);
        }
        Orion.Attack(mob.Serial());
        Orion.Wait(50);
    }

    addKillCount(mobType); // Increase mobs kill count
    Orion.RemoveTimer('onslaught'); // Reset the onslaught timer
}

function loadMastery(){
    var book = Orion.FindTypeEx(0x225A, 0x0000, backpack)[0];
    return book.Properties().match(/(.*)\sMastery/gi)[0];
}

function checkStance(){
    if(Orion.SkillValue('Bushido') < 500) return;
    if(!Orion.BuffExists('Confidence') && !Orion.BuffExists('Evasion') && !Orion.BuffExists('Counter Attack') && Player.Mana() > 15){
        if(Player.Hits("%") < 30)
           Orion.Cast('401'); // Use evasion for ciritical health
        else if(Player.Hits("%") < 70)
             Orion.Cast('402'); // Use confidenc for a boost
        else
            Orion.Cast('404'); // Counter attack
    }
}

function addKillCount(type){
    var list = Orion.GetFindList('mobTypes');
    var items = list.Items();
    var object = items.filter(function(item){
        return item.Graphic() == type;
    }).forEach(function(item){
        var count = item.Count();
        count++;
        item.SetCount(count);
    });
    Orion.UpdateFindList(list);
}

function equipSlayer(graphic){
    var tags = loadTags(graphic);
    if(!tags.slayer) return;
    var weapon = Orion.FindTypeEx('0x0F4B', any, backpack).filter(function(weap){
        return Orion.Contains(weap.Properties(), tags.slayer +" Slayer");
    })[0];
    if(!weapon) return;
    Orion.SetTimer('weaponSwap');
    Orion.Print(color.purple.norm, tags.slayer +" slayer equipped");
    Orion.Wait('moveitemdelay');
    Orion.Equip(weapon.Serial());
}

function loadTags(graphic){
    var tags = Orion.GetFindList('mobTypes').Items()
        .filter(function(type){
            return type.Graphic() == graphic;
        }).map(function(tag){
            var comments = tag.Comment().split('|');
            return {
                name    : comments[0] ? comments[0].toString() : "missing",
                slayer  : comments[1] ? comments[1].toString() : false,
                ignore  : comments[2] ? Boolean(comments[1]) : false
            }
    });
    return tags || false;
}


How said script maker. Autolog must be activated all time. Attack script must be binded to any button.


Title: Re: Sampire Helper
Post by: altiric on July 03, 2023, 09:23:38 AM
Heh there actually should have been a cast function in there. You are the first person to point out it's missing/broken. I'll add it in if I ever do an update. Right now there seems to be no interest, so no reason too. Your fix should work fine, may need to add a slight delay after Orion.Cast since my cast function adds the delays based on fcr, etc.
Title: Re: Sampire Helper
Post by: JackWalters on July 03, 2023, 11:47:23 PM
Heh there actually should have been a cast function in there. You are the first person to point out it's missing/broken. I'll add it in if I ever do an update. Right now there seems to be no interest, so no reason too. Your fix should work fine, may need to add a slight delay after Orion.Cast since my cast function adds the delays based on fcr, etc.
Thank you for your answer. You are right, must be delay because script activate Whirwind attack very fast. And also tried to activate this attack with busido abilities but it no possible.  So modification in progress. If you can give me some advices i will be appreciate. Thank you in advance.
Title: Re: Sampire Helper
Post by: crashtestdummy on July 06, 2023, 08:30:35 AM
 :) I am SO SO SO very looking forward to trying/using this out...... thank you so much!  Look forward to using it and offering up feedback!
Title: Re: Sampire Helper
Post by: altiric on July 06, 2023, 12:09:26 PM
Heh there actually should have been a cast function in there. You are the first person to point out it's missing/broken. I'll add it in if I ever do an update. Right now there seems to be no interest, so no reason too. Your fix should work fine, may need to add a slight delay after Orion.Cast since my cast function adds the delays based on fcr, etc.
Thank you for your answer. You are right, must be delay because script activate Whirwind attack very fast. And also tried to activate this attack with busido abilities but it no possible.  So modification in progress. If you can give me some advices i will be appreciate. Thank you in advance.

Code: [Select]
function cast(spell, target){
    var fcr = (6 - Player.FCR()) / 4 * 1000 + 250;
        Orion.CancelWaitTarget();
        if(Orion.HaveTarget())
            Orion.CancelTarget();
        if(Player.Frozen())
            return;

        if(target)
            Orion.CastTarget(spell, target);
        else
            Orion.Cast(spell);
       
        Orion.Wait(500);
        while(Player.Frozen() && !Player.Paralyzed())
            Orion.Wait(10);

        Orion.Wait(fcr);
}

Adding that to the script should solve a lot of issues. If you find anymore, feel free to post them here. Seems more people are getting interested, i may do an update to make sure everything is tweaked correctly and add some other features i have handy if it keeps up :)
Title: Re: Sampire Helper
Post by: DieselKush420 on July 09, 2023, 06:03:58 PM
can u please update it i am not script smart and still cannot find one to run my samp
thank you
Title: Re: Sampire Helper
Post by: Kandie on July 19, 2023, 07:54:17 AM
Can you please add Chivalry to this script?  I like being able to rez my co-players and use some of the chiv spells. Would be much appreciated... TIA    Kandie
Title: Re: Sampire Helper
Post by: The Ghost on July 19, 2023, 03:53:57 PM
Which spell, do you have in might,  Like  D Fury and EoE. 
Title: Re: Sampire Helper
Post by: Kandie on July 19, 2023, 04:27:37 PM
consecrate weapon    Divine fury    and would be nice if it used rose of trinsic when needed and be able to turn any of these off when not needed.
Title: Re: Sampire Helper
Post by: DieselKush420 on July 28, 2023, 01:04:59 PM
consecrate weapon    Divine fury    and would be nice if it used rose of trinsic when needed and be able to turn any of these off when not needed.
evade confidence onslaught primary and secondary ability enemy of one would be good too if u can set. It for spawn boss somehow
Title: Re: Sampire Helper
Post by: COOPEREBC on August 19, 2023, 05:04:08 PM
I would like to try it out.

Been messing around with scripts today, be good to see one that is more polished than anything I have.
Title: Re: Sampire Helper
Post by: Bukowski on December 21, 2023, 07:42:14 PM
How do I download the script?
Title: Re: Sampire Helper
Post by: Crisis on December 22, 2023, 10:28:07 AM
How do I download the script?


The better of a job you do the first time, the quicker you are accepted and can enjoy the benefits of the site.
Title: Re: Sampire Helper
Post by: STOTTS on March 24, 2024, 01:31:14 AM
Anyway to make this script auto attack things? so I can run around a spawn and let it do its thing? Ive tried but my super super limited scripting knowledge let me down
Title: Re: Sampire Helper
Post by: deathwillow on April 03, 2024, 02:29:18 PM
Looking through the code, the slayer wep swap will never work... Is there a way to do this pragmatically?  or would you have to manually create a Mob Graphics -> Slayer Type mapping somewhere?
Title: Re: Sampire Helper
Post by: sundaymood216 on April 06, 2024, 08:31:48 PM
I will check it out
Title: Re: Sampire Helper
Post by: Mustang58lx on April 28, 2024, 02:34:17 PM
Heh there actually should have been a cast function in there. You are the first person to point out it's missing/broken. I'll add it in if I ever do an update. Right now there seems to be no interest, so no reason too. Your fix should work fine, may need to add a slight delay after Orion.Cast since my cast function adds the delays based on fcr, etc.
Thank you for your answer. You are right, must be delay because script activate Whirwind attack very fast. And also tried to activate this attack with busido abilities but it no possible.  So modification in progress. If you can give me some advices i will be appreciate. Thank you in advance.

Code: [Select]
function cast(spell, target){
    var fcr = (6 - Player.FCR()) / 4 * 1000 + 250;
        Orion.CancelWaitTarget();
        if(Orion.HaveTarget())
            Orion.CancelTarget();
        if(Player.Frozen())
            return;

        if(target)
            Orion.CastTarget(spell, target);
        else
            Orion.Cast(spell);
       
        Orion.Wait(500);
        while(Player.Frozen() && !Player.Paralyzed())
            Orion.Wait(10);

        Orion.Wait(fcr);
}

Adding that to the script should solve a lot of issues. If you find anymore, feel free to post them here. Seems more people are getting interested, i may do an update to make sure everything is tweaked correctly and add some other features i have handy if it keeps up :)


Did Altric update his script with the newest changes posted in this thread? Because when I run it I get errors. So I'm guessing the casting code needs to added. Do I need to change the items JackWalters mention about using Orion.Cast and the numbers instead of how Altiric has it?

Where exactly should the above cast code be added to Altiric's originally script he posted? I added it after the function equipSlayer(graphic){ and before function loadTags(graphic){
Code: [Select]
function equipSlayer(graphic){
    var tags = loadTags(graphic);
    if(!tags.slayer) return;
    var weapon = Orion.FindTypeEx('0x0F4B', any, backpack).filter(function(weap){
        return Orion.Contains(weap.Properties(), tags.slayer +" Slayer");
    })[0];
    if(!weapon) return;
    Orion.SetTimer('weaponSwap');
    Orion.Print(color.purple.norm, tags.slayer +" slayer equipped");
    Orion.Wait('moveitemdelay');
    Orion.Equip(weapon.Serial());
}

function cast(spell, target){
    var fcr = (6 - Player.FCR()) / 4 * 1000 + 250;
        Orion.CancelWaitTarget();
        if(Orion.HaveTarget())
            Orion.CancelTarget();
        if(Player.Frozen())
            return;

        if(target)
            Orion.CastTarget(spell, target);
        else
            Orion.Cast(spell);
       
        Orion.Wait(500);
        while(Player.Frozen() && !Player.Paralyzed())
            Orion.Wait(10);

        Orion.Wait(fcr);
}

function loadTags(graphic){
    var tags = Orion.GetFindList('mobTypes').Items()
        .filter(function(type){
            return type.Graphic() == graphic;
        }).map(function(tag){
            var comments = tag.Comment().split('|');
            return {
                name    : comments[0] ? comments[0].toString() : "missing",
                slayer  : comments[1] ? comments[1].toString() : false,
                ignore  : comments[2] ? Boolean(comments[1]) : false
            }
    });
    return tags || false;
}


When I run this script it runs over to players pets and even players in different forms such as Wraith and tries to honor them. How do I get it to ignore player's pets and players in different forms? Those pets and players turn green to me.

When I use the hokey for the attack function there are times I get the following error message
Line 114 ReferenceError: Can't find variable: ability


For the new Shrouded Sails event it it isn't attacking the pirates in the Void Pool either. How do I resolve that?