summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-24 16:34:51 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-10-24 16:34:51 +0000
commitfff312c59262be01f7582dbde0b591be4ca95b5f (patch)
tree498cd1eb3cb8001432bfd7dae52ccd8439c64d7a /src/map
parent4dc8104b2a83a87caa5de69fa990a79f852d8bea (diff)
downloadhercules-fff312c59262be01f7582dbde0b591be4ca95b5f.tar.gz
hercules-fff312c59262be01f7582dbde0b591be4ca95b5f.tar.bz2
hercules-fff312c59262be01f7582dbde0b591be4ca95b5f.tar.xz
hercules-fff312c59262be01f7582dbde0b591be4ca95b5f.zip
- Cleaned up the "show_steal_in_party" setting so it only takes effect when the item was successfully stolen (there was no point in telling you the item couldn't be stolen due to being overweight)
- Cleaned up the pc_steal_item implementation (again). It now uses a more random, simple approach in each steal attempt. - Changed the way the skill_steal_max_tries work. Now it actually MEANS the max number of steal tries, use 0 to disable (unlimited tries). - Changed the default of skill_steal_max_tries to 0 as there's no proof anywhere that there should be such a limit. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9057 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/battle.c8
-rw-r--r--src/map/battle.h3
-rw-r--r--src/map/pc.c101
3 files changed, 48 insertions, 64 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 0469fea0f..bc9828764 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -3705,8 +3705,7 @@ static const struct battle_data_short {
{ "pk_min_level", &battle_config.pk_min_level}, // [celest]
{ "skill_steal_type", &battle_config.skill_steal_type}, // [celest]
{ "skill_steal_rate", &battle_config.skill_steal_rate}, // [celest]
- { "skill_steal_max_tries", &battle_config.skill_steal_max_tries}, // [Lupus]
-// { "night_darkness_level", &battle_config.night_darkness_level}, // [celest]
+ { "skill_steal_max_tries", &battle_config.skill_steal_max_tries}, // [Lupus]
{ "motd_type", &battle_config.motd_type}, // [celest]
{ "finding_ore_rate", &battle_config.finding_ore_rate}, // [celest]
{ "exp_calc_type", &battle_config.exp_calc_type}, // [celest]
@@ -4138,8 +4137,7 @@ void battle_set_defaults() {
battle_config.pk_min_level = 55;
battle_config.skill_steal_type = 1;
battle_config.skill_steal_rate = 100;
- battle_config.skill_steal_max_tries = 15; //=16 tries
-// battle_config.night_darkness_level = 9;
+ battle_config.skill_steal_max_tries = 0; //Default: unlimited tries.
battle_config.motd_type = 0;
battle_config.finding_ore_rate = 100;
battle_config.castrate_dex_scale = 150;
@@ -4392,7 +4390,7 @@ void battle_validate_conf() {
if (battle_config.sg_miracle_skill_duration_max < 2000)
battle_config.sg_miracle_skill_duration_max = 2000;
- if (battle_config.skill_steal_max_tries > UCHAR_MAX)
+ if (battle_config.skill_steal_max_tries >= UCHAR_MAX)
battle_config.skill_steal_max_tries = UCHAR_MAX;
#ifdef CELL_NOSTACK
diff --git a/src/map/battle.h b/src/map/battle.h
index 181f39340..be3a67c90 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -355,8 +355,7 @@ extern struct Battle_Config {
unsigned short pk_min_level; // [celest]
unsigned short skill_steal_type; // [celest]
unsigned short skill_steal_rate; // [celest]
- unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if=256, then w/o limit [Lupus]
-// unsigned short night_darkness_level; // [celest]
+ unsigned short skill_steal_max_tries; //max steal skill tries on a mob. if 0 or 256, then w/o limit [Lupus]
unsigned short motd_type; // [celest]
unsigned short finding_ore_rate; // orn
unsigned short exp_calc_type;
diff --git a/src/map/pc.c b/src/map/pc.c
index 782b51d79..98d581980 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3154,23 +3154,14 @@ int pc_show_steal(struct block_list *bl,va_list ap)
struct item_data *item=NULL;
char output[100];
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
- nullpo_retr(0, sd=va_arg(ap,struct map_session_data *));
-
+ sd=va_arg(ap,struct map_session_data *);
itemid=va_arg(ap,int);
- type=va_arg(ap,int);
- if(!type){
- if((item=itemdb_exists(itemid))==NULL)
- sprintf(output,"%s stole an Unknown Item.",sd->status.name);
- else
- sprintf(output,"%s stole %s.",sd->status.name,item->jname);
- clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
- }else{
- sprintf(output,"%s has not stolen the item because of being overweight.",sd->status.name);
- clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
- }
+ if((item=itemdb_exists(itemid))==NULL)
+ sprintf(output,"%s stole an Unknown Item.",sd->status.name);
+ else
+ sprintf(output,"%s stole %s.",sd->status.name,item->jname);
+ clif_displaymessage( ((struct map_session_data *)bl)->fd, output);
return 0;
}
@@ -3181,8 +3172,7 @@ int pc_show_steal(struct block_list *bl,va_list ap)
//** pc.c:
int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
{
- static int i = 0;
- int old_i,rate,itemid,flag;
+ int i,rate,itemid,flag;
struct status_data *sd_status, *md_status;
struct mob_data *md;
struct item tmp_item;
@@ -3194,47 +3184,40 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
md_status= status_get_status_data(bl);
md = (TBL_MOB *)bl;
- if(md->state.steal_flag>=battle_config.skill_steal_max_tries ||
+ if(md->state.steal_flag == UCHAR_MAX || //already stolen from
md_status->mode&MD_BOSS || md->master_id ||
(md->class_>=1324 && md->class_<1364) || // prevent stealing from treasure boxes [Valaris]
map[md->bl.m].flag.nomobloot || // check noloot map flag [Lorky]
md->sc.opt1 //status change check
)
return 0;
-
+
+ if(battle_config.skill_steal_max_tries &&
+ md->state.steal_flag++ >= battle_config.skill_steal_max_tries)
+ { //Reached limit of steal attempts.
+ md->state.steal_flag = UCHAR_MAX;
+ return 0;
+ }
+
rate = battle_config.skill_steal_type
? (sd_status->dex - md_status->dex)/2 + lv*6 + 10
- : sd_status->dex - md_status->dex + lv*3 + 10;
+ : (sd_status->dex - md_status->dex) + lv*3 + 10;
rate += sd->add_steal_rate; //Better make the steal_Rate addition affect % rather than an absolute on top of the total drop rate. [Skotlex]
if (rate < 1)
return 0;
- md->state.steal_flag++; //increase steal tries number
-
//preliminar statistical data hints at this behaviour:
//each steal attempt: try to steal against ONE mob drop, and no more.
- //We use a static index to prevent giving priority to any of the slots.
- old_i = i;
- do {
- i++;
- if (i == MAX_MOB_DROP-1 && lv <= 5)
- continue; //Cannot steal "last slot" (card slot)
- if (i == MAX_MOB_DROP)
- i = 0;
- } while (md->db->dropitem[i].p <= 0 && old_i != i);
-
- if(old_i == i) {
- md->state.steal_flag = UCHAR_MAX; //Tag for speed up in case you reinsist
- return 0; //Mob has nothing stealable!
- }
+ if (lv > 5) //Include last slot (card slot)
+ i = rand()%MAX_MOB_DROP;
+ else //Do not include card slot
+ i = rand()%(MAX_MOB_DROP-1);
if(rand() % 10000 >= md->db->dropitem[i].p*rate/100)
return 0;
- md->state.steal_flag = UCHAR_MAX; //you can't steal from this mob any more
-
malloc_set(&tmp_item,0,sizeof(tmp_item));
itemid = md->db->dropitem[i].nameid;
tmp_item.nameid = itemid;
@@ -3242,27 +3225,31 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, int lv)
tmp_item.identify = itemdb_isidentified(itemid);
flag = pc_additem(sd,&tmp_item,1);
- if(battle_config.show_steal_in_same_party)
- party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid,flag?1:0);
- if(flag)
+ //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);
- else
- { //Only invoke logs if item was successfully added (otherwise logs lie about actual item transaction)
- //Logs items, Stolen from mobs [Lupus]
- if(log_config.enable_logs&0x80) {
- log_pick_mob(md, "M", itemid, -1, NULL);
- log_pick_pc(sd, "P", itemid, 1, NULL);
- }
+ 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]
+ if(log_config.enable_logs&0x80) {
+ log_pick_mob(md, "M", itemid, -1, NULL);
+ log_pick_pc(sd, "P", itemid, 1, NULL);
+ }
- //A Rare Steal Global Announce by Lupus
- if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) {
- struct item_data *i_data;
- char message[128];
- i_data = itemdb_search(itemid);
- sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
- //MSG: "'%s' stole %s's %s (chance: %%%0.02f)"
- intif_GMmessage(message,strlen(message)+1,0);
- }
+ //A Rare Steal Global Announce by Lupus
+ if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) {
+ struct item_data *i_data;
+ char message[128];
+ i_data = itemdb_search(itemid);
+ sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100);
+ //MSG: "'%s' stole %s's %s (chance: %%%0.02f)"
+ intif_GMmessage(message,strlen(message)+1,0);
}
return 1;
}