[SOLVED] Remove Steal Skill Limitation

Started by namerpus18, Nov 14, 2022, 01:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

namerpus18

Notes
Only items dropped by monsters can be stolen.
A successful attempt will not affect what is dropped when the monster dies.
Counter-intuitively, this skill cannot be used while in stealth. All robberies must be done out in the open.
After success, it is not possible to steal again from the same target.
Boss monsters cannot be stolen from.

//** Do i need to change this value to 255?

//from "skill.c"

// How many times you could try to steal from a mob.
// Note: It helps to avoid stealing exploit on monsters with few rare items
// Use 0 to disable (Max allowed value is 255)
skill_steal_max_tries: 0


// How can i make it work that i can use steal until mob dies. You can obtain same items again and again. I dont know but i think there is this thing called "skill_steal_max success" that is located somewhere i cannot find that also limit the skill to be used only once per monster. And someone told me i need to make the conf to the "conf/import/battle.conf". I am planning to make a new skill from it.

Thank you so much, total noob here

//from "pc.c"
* Steal an item from bl (mob).
* Return:
*   0 = fail
*   1 = succes
*------------------------------------------*/
static int pc_steal_item(struct map_session_data *sd, struct block_list *bl, uint16 skill_lv)
{
    int i,itemid,flag;
    int rate;
    struct status_data *sd_status, *md_status;
    struct mob_data *md = BL_CAST(BL_MOB, bl);
    struct item tmp_item;
    struct item_data *data = NULL;

    if (sd == NULL || md == NULL)
        return 0;

    if(md->state.steal_flag == UCHAR_MAX || ( md->sc.opt1 && md->sc.opt1 != OPT1_BURNING && md->sc.opt1 != OPT1_CRYSTALIZE ) ) //already stolen from / status change check
        return 0;

    sd_status= status->get_status_data(&sd->bl);
    md_status= status->get_status_data(bl);

    if (md->master_id || md_status->mode&MD_BOSS || mob_is_treasure(md) ||
        map->list[bl->m].flag.nomobloot || // check noloot map flag [Lorky]
        (battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus]
            md->state.steal_flag++ >= battle_config.skill_steal_max_tries)
    ) { //Can't steal from
        md->state.steal_flag = UCHAR_MAX;
        return 0;
    }

    // base skill success chance (percentual)
    rate = (sd_status->dex - md_status->dex)/2 + skill_lv*6 + 4 + sd->bonus.add_steal_rate;

    if( rate < 1 )
        return 0;

    // Try dropping one item, in the order from first to last possible slot.
    // Droprate is affected by the skill success rate.
    for (i = 0; i < MAX_MOB_DROP; i++) {
        if (md->db->dropitem[i].nameid == 0)
            continue;
        if ((data = itemdb->exists(md->db->dropitem[i].nameid)) == NULL)
            continue;
        if (data->type == IT_CARD)
            continue;
        if (rnd() % 10000 < apply_percentrate(md->db->dropitem[i].p, rate, 100))
            break;
    }
    if (i == MAX_MOB_DROP)
        return 0;

    itemid = md->db->dropitem[i].nameid;
    memset(&tmp_item,0,sizeof(tmp_item));
    tmp_item.nameid = itemid;
    tmp_item.amount = 1;
    tmp_item.identify = itemdb->isidentified2(data);
    flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);

    //TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
    //md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more

    if(flag) { //Failed to steal due to overweight
        clif->additem(sd,0,0,flag);
        return 0;
    }

    if(battle_config.show_steal_in_same_party)
        party->foreachsamemap(pc->show_steal,sd,AREA_SIZE,sd,tmp_item.nameid);

    //Logs items, Stolen from mobs [Lupus]
    logs->pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item, data);

    return 1;
}

namerpus18

So apparently Skill gank is not the one i need to modify but the skill "TF_STEAL" so that it can be casted multiple times to the same monster.
1.Steal attempts to "steal" an item from the targeted monster.
2.Only items dropped by the monster can be stolen.
3.A successful attempt will not affect what is dropped when the monster dies.
4.After success, it is not possible to Steal again from the same monster. <<<< I want to remove this restriction on the skill i tried adding AfterCastDelay and Cooldown but it did not work.

Thank you so much. Sorry I am really a noob.

{
   Id: 50
   Name: "TF_STEAL"
   Description: "Steal"
   MaxLevel: 10
   Range: 1
   Hit: "BDT_SKILL"
   SkillType: {
      Enemy: true
   }
   AttackType: "Weapon"
   DamageType: {
      NoDamage: true
   }

   CoolDown: 0
   AfterCastActDelay: 0
   Requirements: {
      SPCost: 10
   }

Martreus

#2
I suppose you are on Hercules? The variable you are looking for is on Hercules/src/map/battle.h


int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus].


But you don't need to source change it, as there is a config file for it. On Hercules/conf/map/skill.conf you have

Quote
// How many times you could try to steal from a mob.
// Note: It helps to avoid stealing exploit on monsters with few rare items
// Use 0 to disable (Max allowed value is 255)
skill_steal_max_tries: 0

You probably want to use import files instead of editing this file, as recommended by Hercules' setting guides.

For successful attempts, however, think you need to edit the function pc_steal_item in Hercules/src/map/pc.c.


//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more

namerpus18

Quote from: Martreus on Nov 14, 2022, 07:14 PM
I suppose you are on Hercules? The variable you are looking for is on Hercules/src/map/battle.h


int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus].


But you don't need to source change it, as there is a config file for it. On Hercules/con/map/skill.conf you have

You probably want to use import files instead of editing this file, as recommended by Hercules' setting guides.

For successful attempts, however, think you need to edit the function pc_steal_item in Hercules/src/map/pc.c.


//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more


Tried messing with this last night but still cant able to make it work. :)
I am figuring now where i can locate this "skill_steal_max_success" maybe.

The codes are all messed up now all over hehe
I already read all scripts in emulator folder to be more familiar.

Thank you


Martreus

There are some ways the flag md->state.steal_flag is set within the function. You want to program your logic around it and recompile to test. You can probably use the config file structure to have a better control of it when you trying to balance the count of successful attempts.

Quote
I am figuring now where i can locate this "skill_steal_max_success" maybe.
This doesn't exist, I think. This is what you need to program a logic before setting on the flag that prevents another success steal. If you want unlimited successful steals, think you can not set the flag on and it might work. Don't know the side effects of it, better to read the function step by step.

namerpus18

#5
//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more


Yah I will focus into this one that you point out last time.

I am figuring now how to modify it and put it on "conf/import" as you said it should be done there.

Thanks,

Blinzer

if you want to be able to steal from the same mob over and over again,

remove the line of code that flags the monster to have been stolen from, or the check. either work

it's in the code you posted


and no, you can't do this in the conf files if your goal is to get more than one steal off on the same monster



namerpus18

Quote from: Blinzer on Nov 18, 2022, 12:37 PM
if you want to be able to steal from the same mob over and over again,

remove the line of code that flags the monster to have been stolen from, or the check. either work

it's in the code you posted


and no, you can't do this in the conf files if your goal is to get more than one steal off on the same monster
I did remove the code lines that i think limit skill stealing again but it wont work i dont know what else i should do.
**I removed this

//md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more

I also tried removing this.

if(md->state.steal_flag == UCHAR_MAX || ( md->sc.opt1 && md->sc.opt1 != OPT1_BURNING ) ) //already stolen from / status change check
return false;



*steal item from from bl (mob).
* @param sd: Player data
* @param bl: Object to steal from
* @param skill_lv: Level of skill used
* @return True on success or false otherwise
*/
bool pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv)
{
int i;
t_itemid itemid;
double rate;
unsigned char flag = 0;
struct status_data *sd_status, *md_status;
struct mob_data *md;

if(!sd || !bl || bl->type!=BL_MOB)
return false;

md = (TBL_MOB *)bl;

if(md->state.steal_flag == UCHAR_MAX || ( md->sc.opt1 && md->sc.opt1 != OPT1_BURNING ) ) //already stolen from / status change check
return false;

sd_status= status_get_status_data(&sd->bl);
md_status= status_get_status_data(bl);

if (md->master_id || status_has_mode(md_status, MD_STATUSIMMUNE) || util::vector_exists(status_get_race2(&md->bl), RC2_TREASURE) ||
map_getmapflag(bl->m, MF_NOMOBLOOT) || // check noloot map flag [Lorky]
(battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus]
md->state.steal_flag++ >= battle_config.skill_steal_max_tries)
  ) { //Can't steal from
md->state.steal_flag = UCHAR_MAX;
return false;
}

// base skill success chance (percentual)
rate = (sd_status->dex - md_status->dex)/2 + skill_lv*6 + 4;
rate += sd->bonus.add_steal_rate;

if( rate < 1
#ifdef RENEWAL
|| rnd()%100 >= rate
#endif
)
return false;

// Try dropping one item, in the order from first to last possible slot.
// Droprate is affected by the skill success rate.
for( i = 0; i < MAX_MOB_DROP; i++ )
if( item_db.exists(md->db->dropitem[i].nameid) && !md->db->dropitem[i].steal_protected && rnd() % 10000 < md->db->dropitem[i].rate
#ifndef RENEWAL
* rate/100.
#endif
)
break;
if( i == MAX_MOB_DROP )
return false;

itemid = md->db->dropitem[i].nameid;
struct item tmp_item = {};
tmp_item.nameid = itemid;
tmp_item.amount = 1;
tmp_item.identify = itemdb_isidentified(itemid);
if( battle_config.skill_steal_random_options ){
mob_setdropitem_option( &tmp_item, &md->db->dropitem[i] );
}
flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);

//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
//md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more

if(flag) { //Failed to steal due to overweight
clif_additem(sd,0,0,flag);
return false;
}

if(battle_config.show_steal_in_same_party)
party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid);

//Logs items, Stolen from mobs [Lupus]
log_pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item);

//A Rare Steal Global Announce by Lupus
if(md->db->dropitem[i].rate <= battle_config.rare_drop_announce) {
struct item_data *i_data;
char message[128];
i_data = itemdb_search(itemid);
sprintf (message, msg_txt(sd,542), (sd->status.name[0])?sd->status.name :"GM", md->db->jname.c_str(), i_data->ename.c_str(), (float)md->db->dropitem[i].rate / 100);
//MSG: "'%s' stole %s's %s (chance: %0.02f%%)"
intif_broadcast(message, strlen(message) + 1, BC_DEFAULT);
}
return true;
}

Blinzer

really? did you make clean && make afterwards?



namerpus18

Quote from: Blinzer on Nov 20, 2022, 09:32 AM
really? did you make clean && make afterwards?
I just got same question from a reply yesterday and been working on VS to rebuild or recompiling still on process of researching how to do it on "cmd" but i am noob so i tried searching something else i found something called "cmder" but it requires username and password from "gitlab" so maybe its a paid 3PP it does not mentioned in their site.  I am looking now on guide section how to do it. I just simply taught i can making it working just by editing the script i like normally doing.
Thank you so much, /no1


Blinzer

Quote from: namerpus18 on Nov 20, 2022, 05:52 PM
I just got same question from a reply yesterday and been working on VS to rebuild or recompiling still on process of researching how to do it on "cmd" but i am noob so i tried searching something else i found something called "cmder" but it requires username and password from "gitlab" so maybe its a paid 3PP it does not mentioned in their site.  I am looking now on guide section how to do it. I just simply taught i can making it working just by editing the script i like normally doing.
Thank you so much, /no1

yeah you have to recompile the server files in order for code changes to work, since compiling is what creates the program you're running(the server). if you already have a server up and running compiling should be extremely easy, you just use putty(it's a program) to access your server and use the cd command to go into your ragnarok server folder, and then type make clean && make

then turn the server off and back on, and test your changes



namerpus18

I keep having this error using puTTY.
I think i am still missing something regarding VS C C++ that need to be downloaded something like 6-8gb. And regarding MySQL.

Now I saw a latest emulator that claims to be pre-configured and already compile and does not require compiling anymore. Does it count if i use that instead? Or do i still need to recompile the server if i make this changes so it wont make any difference if i switch to that emulator.

THank you so much

yC

#12
Quote from: namerpus18 on Nov 21, 2022, 08:47 AM
I keep having this error using puTTY.
I think i am still missing something regarding VS C C++ that need to be downloaded something like 6-8gb. And regarding MySQL.

Now I saw a latest emulator that claims to be pre-configured and already compile and does not require compiling anymore. Does it count if i use that instead? Or do i still need to recompile the server if i make this changes so it wont make any difference if i switch to that emulator.

THank you so much

The error in your screenshot is a generic error.  Usually happens with unstable connection either on your end or the server's end. 

The "pre-configured and already compile" packages only mean you can change the config files (such as server rates txt yml).  Any time you change the server code, you need to recompile for the changes to take effect.

namerpus18

Thank you everyone for the help. It seems the problem is I dont build/rebuild solution in VS code.