Explorar o código

Added zeny from mobs option.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/athena@175 54d463be-8e91-2dee-dedb-b68131a5f0ec
valaris %!s(int64=20) %!d(string=hai) anos
pai
achega
3e65de1d4e
Modificáronse 8 ficheiros con 55 adicións e 15 borrados
  1. 1 0
      Changelog.txt
  2. 3 0
      conf-tmpl/battle_athena.conf
  3. 2 0
      src/map/battle.c
  4. 2 0
      src/map/battle.h
  5. 1 1
      src/map/map.h
  6. 39 10
      src/map/mob.c
  7. 6 3
      src/map/party.c
  8. 1 1
      src/map/party.h

+ 1 - 0
Changelog.txt

@@ -1,5 +1,6 @@
 Date	Added
 11/14
+	* Added zeny_from_mobs option. [Valaris]
 	* Corrected the file type attribute on most of the files in three which fixes the
 	  newline issues between linux and dos [MouseJstr]
               svn propset -R svn:eol-style native .

+ 3 - 0
conf-tmpl/battle_athena.conf

@@ -721,5 +721,8 @@ max_cloth_color: 4
 // Visible area size (how many squares away from a player can they see)
 area_size: 14
 
+// Zeny from mobs
+zeny_from_mobs: no
+
 import: conf/import/battle_conf.txt
 

+ 2 - 0
src/map/battle.c

@@ -5084,6 +5084,7 @@ static const struct {
 	{ "castrate_dex_scale",                &battle_config.castrate_dex_scale	}, // added by [MouseJstr]
 	{ "area_size",                         &battle_config.area_size	}, // added by [MouseJstr]
 	{ "muting_players",                   &battle_config.muting_players}, // added by [Apple]
+	{ "zeny_from_mobs",			&battle_config.zeny_from_mobs}, // [Valaris]
 //SQL-only options start
 #ifndef TXT_ONLY 
 	{ "mail_system",		&battle_config.mail_system	}, // added by [Valaris]
@@ -5303,6 +5304,7 @@ void battle_set_defaults() {
 	battle_config.max_hair_color = 9;
 	battle_config.min_cloth_color = 0;
 	battle_config.max_cloth_color = 4;
+	battle_config.zeny_from_mobs = 0;
 
 	battle_config.castrate_dex_scale = 150;
 

+ 2 - 0
src/map/battle.h

@@ -331,6 +331,8 @@ extern struct Battle_Config {
 	int castrate_dex_scale; // added by [MouseJstr]
 	int area_size; // added by [MouseJstr]
 
+	int zeny_from_mobs; // [Valaris]
+
 #ifndef TXT_ONLY /* SQL-only options */
 	int mail_system; // [Valaris]
 #endif

+ 1 - 1
src/map/map.h

@@ -378,7 +378,7 @@ struct npc_data {
 struct mob_data {
 	struct block_list bl;
 	short n;
-	short base_class,class,dir,mode;
+	short base_class,class,dir,mode,level;
 	short m,x0,y0,xs,ys;
 	char name[24];
 	int spawndelay1,spawndelay2;

+ 39 - 10
src/map/mob.c

@@ -124,7 +124,7 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
 	else
 		m=map_mapname2mapid(mapname);
 
-	if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>2000)	// 値が異常なら召喚を止める
+	if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000)	// 値が異常なら召喚を止める
 		return 0;
 
 	if(class<0){	// ランダムに召喚
@@ -161,6 +161,15 @@ int mob_once_spawn(struct map_session_data *sd,char *mapname,
 		else
 			md->lootitem=NULL;
 
+		if(class>4000) { // large/tiny mobs [Valaris]
+			md->size=2;
+			class-=4000;
+		}
+		else if(class>2000) {
+			md->size=1;
+			class-=2000;
+		}
+
 		mob_spawn_dataset(md,mobname,class);
 		md->bl.m=m;
 		md->bl.x=x;
@@ -211,7 +220,7 @@ int mob_once_spawn_area(struct map_session_data *sd,char *mapname,
 	max=(y1-y0+1)*(x1-x0+1)*3;
 	if(max>1000)max=1000;
 
-	if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>2000)	// 値が異常なら召喚を止める
+	if(m<0 || amount<=0 || (class>=0 && class<=1000) || class>6000)	// A summon is stopped if a value is unusual
 		return 0;
 
 	for(i=0;i<amount;i++){
@@ -726,7 +735,7 @@ static int mob_timer(int tid,unsigned int tick,int id,int data)
 
 	nullpo_retr(1, md=(struct mob_data*)bl);
 
-	if(md->bl.type!=BL_MOB)
+	if(!md->bl.type || md->bl.type!=BL_MOB)
 		return 1;
 
 	if(md->timer != tid){
@@ -924,6 +933,10 @@ int mob_spawn(int id)
 	if(!md->speed)
 		md->speed = mob_db[md->class].speed;
 	md->def_ele = mob_db[md->class].element;
+
+	if(!md->level) // [Valaris]
+		md->level=mob_db[md->class].lv;
+
 	md->master_id=0;
 	md->master_dist=0;
 
@@ -2048,7 +2061,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 	struct map_session_data *sd = NULL,*tmpsd[DAMAGELOG_SIZE];
 	struct {
 		struct party *p;
-		int id,base_exp,job_exp;
+		int id,base_exp,job_exp,zeny;
 	} pt[DAMAGELOG_SIZE];
 	int pnum=0;
 	int mvp_damage,max_hp;
@@ -2072,7 +2085,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 //	if(battle_config.battle_log)
 //		printf("mob_damage %d %d %d\n",md->hp,max_hp,damage);
 	if(md->bl.prev==NULL){
-		if(battle_config.error_log)
+		if(battle_config.error_log==1)
 			printf("mob_damage : BlockError!!\n");
 		return 0;
 	}
@@ -2124,7 +2137,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 			if(md->attacked_id <= 0 && md->state.special_mob_ai==0)
 				md->attacked_id = sd->bl.id;
 		}
-		if(src && src->type == BL_PET && battle_config.pet_attack_exp_to_master) {
+		if(src && src->type == BL_PET && battle_config.pet_attack_exp_to_master==1) {
 			struct pet_data *pd = (struct pet_data *)src;
 			nullpo_retr(0, pd);
 			for(i=0,minpos=0,mindmg=0x7fffffff;i<DAMAGELOG_SIZE;i++){
@@ -2316,7 +2329,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 
 	// 経験値の分配
 	for(i=0;i<DAMAGELOG_SIZE;i++){
-		int pid,base_exp,job_exp,flag=1;
+		int pid,base_exp,job_exp,flag=1,zeny=0;
 		double per;
 		struct party *p;
 		if(tmpsd[i]==NULL || tmpsd[i]->bl.m != md->bl.m)
@@ -2348,7 +2361,12 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 			job_exp*=1.15; // pk_mode additional exp if monster >20 levels [Valaris]
 		}
 		if(md->state.special_mob_ai >= 1 && battle_config.alchemist_summon_reward != 1) job_exp = 0;	// Added [Valaris]
-
+		else if(battle_config.zeny_from_mobs) { 
+			if(md->level > 0) zeny=(md->level+rand()%md->level)*per/256; // zeny calculation moblv + random moblv [Valaris]
+			if(mob_db[md->class].mexp > 0)
+				zeny*=rand()%250;
+		}
+		
 		if((pid=tmpsd[i]->status.party_id)>0){	// パーティに入っている
 			int j=0;
 			for(j=0;j<pnum;j++)	// 公平パーティリストにいるかどうか
@@ -2360,21 +2378,31 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 					pt[pnum].p=p;
 					pt[pnum].base_exp=base_exp;
 					pt[pnum].job_exp=job_exp;
+					if(battle_config.zeny_from_mobs)
+						pt[pnum].zeny=zeny; // zeny share [Valaris]
 					pnum++;
 					flag=0;
 				}
 			}else{	// いるときは公平
 				pt[j].base_exp+=base_exp;
 				pt[j].job_exp+=job_exp;
+				if(battle_config.zeny_from_mobs)
+					pt[j].zeny+=zeny;  // zeny share [Valaris]
 				flag=0;
 			}
 		}
-		if(flag)	// 各自所得
+		if(flag) {	// added zeny from mobs [Valaris]
+			if(base_exp > 0 || job_exp > 0)
 			pc_gainexp(tmpsd[i],base_exp,job_exp);
+			if (battle_config.zeny_from_mobs && zeny > 0) {
+				pc_getzeny(tmpsd[i],zeny); // zeny from mobs [Valaris]
+			}
+		}
+
 	}
 	// 公平分配
 	for(i=0;i<pnum;i++)
-		party_exp_share(pt[i].p,md->bl.m,pt[i].base_exp,pt[i].job_exp);
+		party_exp_share(pt[i].p,md->bl.m,pt[i].base_exp,pt[i].job_exp,pt[i].zeny);
 
 	// item drop
 	if(!(type&1)) {
@@ -2538,6 +2566,7 @@ int mob_damage(struct block_list *src,struct mob_data *md,int damage,int type)
 	}
 
 	clif_clearchar_area(&md->bl,1);
+	if(md->level) md->level=0;
 	map_delblock(&md->bl);
 	if(mob_get_viewclass(md->class) <= 1000)
 		clif_clearchar_delay(tick+3000,&md->bl,0);

+ 6 - 3
src/map/party.c

@@ -575,8 +575,8 @@ int party_send_hp_check(struct block_list *bl,va_list ap)
 	return 0;
 }
 
-// ŒoŒ±’lŒö•½•ª”z
-int party_exp_share(struct party *p,int map,int base_exp,int job_exp)
+// exp share and added zeny share [Valaris]
+int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny)
 {
 	struct map_session_data *sd;
 	int i,c;
@@ -589,8 +589,11 @@ int party_exp_share(struct party *p,int map,int base_exp,int job_exp)
 	if(c==0)
 		return 0;
 	for(i=0;i<MAX_PARTY;i++)
-		if((sd=p->member[i].sd)!=NULL && sd->bl.m==map)
+		if((sd=p->member[i].sd)!=NULL && sd->bl.m==map) {
 			pc_gainexp(sd,base_exp/c+1,job_exp/c+1);
+			if(battle_config.zeny_from_mobs) // zeny from mobs [Valaris]
+				pc_getzeny(sd,zeny/c+1);
+		}
 	return 0;
 }
 

+ 1 - 1
src/map/party.h

@@ -40,7 +40,7 @@ int party_check_conflict(struct map_session_data *sd);
 int party_send_xy_clear(struct party *p);
 int party_send_hp_check(struct block_list *bl,va_list ap);
 
-int party_exp_share(struct party *p,int map,int base_exp,int job_exp);
+int party_exp_share(struct party *p,int map,int base_exp,int job_exp,int zeny);
 
 void party_foreachsamemap(int (*func)(struct block_list *,va_list),struct map_session_data *sd,int type,...);