Jump to content
  • 0
Sign in to follow this  
Mary Magdalene

Damage depending on distance

Question

11 answers to this question

Recommended Posts

  • 0

Well I'm actually trying to make a passive skill wherein your damage increases as you go near your target, so I'm asking if there's already an existing function of it so i could have some reference to use.

 

EDIT: If there's none then I'll try making my own.

Edited by Mary Magdalene

Share this post


Link to post
Share on other sites
  • 0

The skill Charge Attack of Knight increment the damage by distance, try check in Battle.c this:

 

case KN_CHARGEATK:					{						int k = (flag-1)/3; //+100% every 3 cells of distance						if( k > 2 ) k = 2; // ...but hard-limited to 300%.						skillratio += 100 * k;					}					break;

 

Share this post


Link to post
Share on other sites
  • 0

 

The skill Charge Attack of Knight increment the damage by distance, try check in Battle.c this:

 

case KN_CHARGEATK:					{						int k = (flag-1)/3; //+100% every 3 cells of distance						if( k > 2 ) k = 2; // ...but hard-limited to 300%.						skillratio += 100 * k;					}					break;

 

Thanks for the reply, but i don't understand this formula:

 

int k = (flag-1)/3;

Share this post


Link to post
Share on other sites
  • 0

 

Thanks for the reply, but i don't understand this formula:

 

int k = (flag-1)/3;

I don't understand much this, I assimilate that this refers to the damage of KN_CHARGEATK:

 

int k (flag-1)/3; //+100% every 3 cells of distance

if( k > 2 ) k = 2; // ...but hard-limited to 300%.

skillratio += 100 * k;

 

k = 1 every 3 cells, if k > 2, k always be = 2. Finally, skillratio (damage) is 100% * k.

Eg: if Charge Attack is on 6 cells of distance "k = 2", so skillratio is 200%.

 

Try apply this on your passive skills ~

Edited by Easycore

Share this post


Link to post
Share on other sites
  • 0

It's pretty simple if you look at it this way:

 

Let's take this situation per example:

x0000t00

Where x is player and t is target.

 

Usually distance between two entities is calculated from one of them, in this case player stands on cell 0, target stands on cell 5. So distance will return 5. But we need to know amount of cells between for skill, in this case it'll be (5-1), or 4.

 

Next, we get extra 100% damage per every 3 cells between, so we need to find out how many times 3 is included in the number we have above. Here "/" stands for integer division, pretty much "how many times something fits into our number fully". In this case we'll have (4/3) = 1.

 

So there you have it, result of this operations in our case is 1. If there were 7 cells between players, result would be 2 and damage would increase by another 100%.

 

Where did I get that flag is distance? By reviewing where the call came from. In this case it comes from skill.c:

 

unsigned int dist = distance_bl(src, bl);skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, dist);/* int skill_attack(int attack_type, struct block_list* src, struct block_list *dsrc, struct block_list *bl, uint16 skill_id, uint16 skill_lv, int64 tick, int flag) */battle->calc_attack(attack_type,src,bl,skill_id,skill_lv,flag&0xFFF);/* struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct block_list *target,uint16 skill_id,uint16 skill_lv,int count) */battle->calc_weapon_attack(bl,target,skill_id,skill_lv,count)/* struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag) */battle->calc_skillratio(BF_WEAPON, src, target, skill_id, skill_lv, skillratio, wflag)/* int battle_calc_skillratio(int attack_type, struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int skillratio, int flag) */
Edited by Garr

Share this post


Link to post
Share on other sites
  • 0

Thanks for the replies but i made it much more simple tho the only problem is i dunno how to make it as a passive skill.

 

So what i did is:

 

battle.c

		if (sc){		if(sc->data[SC_CUSTOMSKILL] ) {		int range = distance_bl(src, target);		int skilllv = sc->data[SC_CUSTOMSKILL]->val1;		if(range == 1){		ATK_ADDRATE(skilllv * 10);		}		}		}

 

So it clearly states when you're 1 cell apart from your enemy, you'll get additional bonus of custom skill level * 10 damage.

Share this post


Link to post
Share on other sites
  • 0

Why not makes this skill similar of Blitz Beat? (Autocast)
 

In skill.c

switch(skill_id) {		case 0: { // Normal attacks (no skill used)			if( attack_type&BF_SKILL )				break; // If a normal attack is a skill, it's splash damage. [Inkfish]			if(sd) {				// Automatic trigger of Blitz Beat				if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 &&					rnd()%1000 <= sstatus->luk*3 ) {					rate = sd->status.job_level / 10 + 1;					skill->castend_damage_id(src,bl,HT_BLITZBEAT,(temp<rate)?temp:rate,tick,SD_LEVEL);				}

Add:

if((temp=pc->checkskill(sd,CS_CUSTOMSKILL))>0 && rnd()%1000 <= sstatus->luk*3 ) {skill->castend_damage_id(src,bl,CS_CUSTOMSKILL,temp,tick,0);}

rnd()%1000 <= sstatus->luk*3: This is the chance of autocast, there chance aument of luk*3.

Change this as you wish.

Share this post


Link to post
Share on other sites
  • 0

Why not makes this skill similar of Blitz Beat? (Autocast)

 

In skill.c

switch(skill_id) {		case 0: { // Normal attacks (no skill used)			if( attack_type&BF_SKILL )				break; // If a normal attack is a skill, it's splash damage. [Inkfish]			if(sd) {				// Automatic trigger of Blitz Beat				if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 &&					rnd()%1000 <= sstatus->luk*3 ) {					rate = sd->status.job_level / 10 + 1;					skill->castend_damage_id(src,bl,HT_BLITZBEAT,(temp<rate)?temp:rate,tick,SD_LEVEL);				}

Add:

if((temp=pc->checkskill(sd,CS_CUSTOMSKILL))>0 && rnd()%1000 <= sstatus->luk*3 ) {skill->castend_damage_id(src,bl,CS_CUSTOMSKILL,temp,tick,0);}

rnd()%1000 <= sstatus->luk*3: This is the chance of autocast, there chance aument of luk*3.

Change this as you wish.

 

This is a good idea, with just small modifications like making it 100% chance. I'll be trying this one,

 

Thank you!

 

EDIT: Ah nah, i don't think that's gonna work well since it won't auto-cast if I'm gonna use a skill. And by the way it's some sort of a buff skill not an attack skill XD

Edited by Mary Magdalene

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.