Author Topic: Sampire Helper  (Read 7202 times)

0 Members and 2 Guests are viewing this topic.

Offline altiricTopic starter

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Sampire Helper
« 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.

There are 1 attachment(s) in this post. You must register and post an acceptable introduction to download
Sampire1.0.js

Offline Crisis

  • Global Moderator
  • *
  • *
  • Posts: 3016
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Referrals: 2
    • View Profile
Re: Sampire Helper
« Reply #1 on: June 13, 2023, 07:49:21 AM »
I will check it out, sounds cool.

Offline Kandie

  • Full Member
  • ***
  • Posts: 193
  • Activity:
    0.2%
  • Reputation Power: 3
  • Kandie has no influence.
  • Gender: Female
  • a.k.a "Granny"
  • Referrals: 7
    • View Profile
Re: Sampire Helper
« Reply #2 on: June 13, 2023, 07:45:33 PM »
is this for easyuo or orion?  if for Orion I am very interested :)

Offline DieselKush420

  • Jr. Member
  • **
  • Posts: 11
  • Activity:
    0%
  • Reputation Power: 1
  • DieselKush420 has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #3 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

Offline altiricTopic starter

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Sampire Helper
« Reply #4 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.

Offline DieselKush420

  • Jr. Member
  • **
  • Posts: 11
  • Activity:
    0%
  • Reputation Power: 1
  • DieselKush420 has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #5 on: June 14, 2023, 07:28:23 PM »
Awesome thank you ill be looking for that post

Offline Caio Neto

  • Restricted
  • *
  • Posts: 1
  • Activity:
    0%
  • Reputation Power: 1
  • Caio Neto has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #6 on: June 18, 2023, 08:30:50 AM »
hiii

Post Merge: June 18, 2023, 08:31:51 AM
i wanna it

Offline JackWalters

  • Newbie
  • *
  • Posts: 5
  • Activity:
    0%
  • Reputation Power: 1
  • JackWalters has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #7 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.



Offline altiricTopic starter

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Sampire Helper
« Reply #8 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.

Offline JackWalters

  • Newbie
  • *
  • Posts: 5
  • Activity:
    0%
  • Reputation Power: 1
  • JackWalters has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #9 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.

Offline crashtestdummy

  • Jr. Member
  • **
  • Posts: 11
  • Activity:
    0%
  • Reputation Power: 1
  • crashtestdummy has no influence.
  • Howdy! :D
  • Referrals: 1
    • View Profile
Re: Sampire Helper
« Reply #10 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!

Offline altiricTopic starter

  • Jr. Member
  • **
  • Posts: 81
  • Activity:
    0%
  • Reputation Power: 2
  • altiric has no influence.
  • Referrals: 1
    • View Profile
Re: Sampire Helper
« Reply #11 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 :)
« Last Edit: July 06, 2023, 12:11:02 PM by altiric »

Offline DieselKush420

  • Jr. Member
  • **
  • Posts: 11
  • Activity:
    0%
  • Reputation Power: 1
  • DieselKush420 has no influence.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #12 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

Offline Kandie

  • Full Member
  • ***
  • Posts: 193
  • Activity:
    0.2%
  • Reputation Power: 3
  • Kandie has no influence.
  • Gender: Female
  • a.k.a "Granny"
  • Referrals: 7
    • View Profile
Re: Sampire Helper
« Reply #13 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

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Referrals: 0
    • View Profile
Re: Sampire Helper
« Reply #14 on: July 19, 2023, 03:53:57 PM »
Which spell, do you have in might,  Like  D Fury and EoE. 

Tags: