Jump to content

New skill cast times system


Rytech

Recommended Posts


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  319
  • Reputation:   198
  • Joined:  11/14/11
  • Last Seen:  

This recode is a response to some issues that rose on 3CeAM when I added Ventus's 1 second fixed time reduction, as well as other issues I discovered when testing the system after that, like how it was very messy. So the new system fixed all the problems and uses a lot less coding, while giving a bunch of configs options for users to set. It even integrates the status's checks that increase/decrease variable and fixed times.

After lots of work and testing the system is finished. It handles everything like official pre-re and renewal servers (depending on the settings), uses a lot less coding, and minimizes the number of instructions to keep cpu and memory usage eco friendly. (Maybe not eco friendly, but its very well coded I think)

I think this system would be great to add to rAthena. Here's the code below as of 3CeAM r667. Let me know what you think. If it gets approved ill have to make a few minor adjustments before adding it so itl work properly. Remember that 3CeAM is a pre-re emulator.

This is the source code for skill.c

/*==========================================
* Does cast-time reductions based on dex, int (for renewal), status's, item bonuses, and config setting
*------------------------------------------*/
int skill_castfix (struct block_list *bl, int skill_id, int skill_lv)
{
int time = skill_get_cast(skill_id, skill_lv);//Used for regular and renewal variable cast time.
int fixed_time = skill_get_fixed_cast(skill_id, skill_lv);//Used for renewal fix time.
int final_time = 0;//Used for finalizing time calculations for pre-re and combining time and fixed_time for renewal.
int rate = 0;//Used to support the duel dex rates check through castrate_dex_scale and castrate_dex_scale_3rd.
int scale = 0;//Used to scale the regular and variable cast times.
struct map_session_data *sd;
struct status_change *sc;
nullpo_retr(0, bl);
sd = BL_CAST(BL_PC, bl);
sc = status_get_sc(bl);
// Calculates regular and variable cast time.
if( !(skill_get_castnodex(skill_id, skill_lv)&1) )
{ //If renewal casting is enabled, all renewal skills will follow the renewal cast formula.
 if (battle_config.renewal_cast_3rd_skills == 1 && skill_id >= RK_ENCHANTBLADE && skill_id <= ECLAGE_RECALL)
 {
  time -= time * (status_get_dex(bl) * 2 + status_get_int(bl)) / 530;
  if ( time < 0 ) time = 0;// No return of 0 since were adding the fixed_time later.
 }
 else
 {
  if (fixed_time < 0)//Prevents negeative values from affecting the variable below.
fixed_time = 0;
  //Adds variable and fixed cast times together to make a full variable time for renewal skills
  //if renewal_cast_enable is turned off. Non-renewal skills dont have fixed times, causing a
  //fixed cast value of 0 to be added and not affect the actural cast time.
  time = time + fixed_time;
  if ( sd && ((sd->class_&MAPID_UPPERMASK_THIRD) >= MAPID_SUPER_NOVICE_E || (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO ))
  rate = battle_config.castrate_dex_scale_3rd;
  else
  rate = battle_config.castrate_dex_scale;
  scale = rate - status_get_dex(bl);
  if( scale > 0 ) // Not instant cast
time = time * scale / rate;
  else return 0;// Instant cast
 }
}
// Calculate cast time reduced by item/card bonuses.
// Last condition checks if you have a cast or variable time after calculations to avoid additional processing.
if( !(skill_get_castnodex(skill_id, skill_lv)&4) && sd && time > 0)
{
 int i;
 if( sd->castrate != 100 )
  time = time * sd->castrate / 100;
 for( i = 0; i < ARRAYLENGTH(sd->skillcast) && sd->skillcast[i].id; i++ )
 {
  if( sd->skillcast[i].id == skill_id )
  {
time+= time * sd->skillcast[i].val / 100;
break;
  }
 }
}
//These status's only affect regular and variable cast times.
if (!(skill_get_castnodex(skill_id, skill_lv)&2) && sc && sc->count)
{
 if (sc->data[sC_SUFFRAGIUM]) {
  time -= time * sc->data[sC_SUFFRAGIUM]->val2 / 100;
  status_change_end(bl, SC_SUFFRAGIUM, -1);}
 if (sc->data[sC_POEMBRAGI])
  time -= time * sc->data[sC_POEMBRAGI]->val2 / 100;
 if (sc->data[sC_MEMORIZE]) {
  time -= time * 50 / 100;
  if ((sc->data[sC_MEMORIZE]->val2) <= 0)
status_change_end(bl, SC_MEMORIZE, -1);}
 if (sc->data[sC_SLOWCAST])
  time += time * sc->data[sC_SLOWCAST]->val2 / 100;
}
//These status's only affect fixed cast times.
if (sc && sc->count)
{
 if( sc->data[sC__LAZINESS] )
  fixed_time += fixed_time * sc->data[sC__LAZINESS]->val2 / 100;
 if( sc->data[sC_DANCEWITHWUG] )
  fixed_time -= fixed_time * sc->data[sC_DANCEWITHWUG]->val3 / 100;
 if( sc->data[sC_MANDRAGORA] )
  fixed_time += 500 * sc->data[sC_MANDRAGORA]->val1;
 if( sc->data[sC_SECRAMENT] )
  fixed_time -= fixed_time * sc->data[sC_SECRAMENT]->val2 / 100;
 if( sc->data[sC_GUST_OPTION] || sc->data[sC_BLAST_OPTION] || sc->data[sC_WILD_STORM_OPTION] )
  fixed_time -= 1000;
}
if( sd && pc_checkskill(sd, WL_RADIUS) && skill_id >= WL_WHITEIMPRISON && skill_id <= WL_FREEZE_SP )
 fixed_time -= fixed_time * (5 * pc_checkskill(sd, WL_RADIUS) + status_get_int(bl) / 15 + status_get_lv(bl) / 15) / 100;
//Check prevents fixed times from going below to a negeative value.
if (fixed_time < 0)
fixed_time = 0;
//Only add variable and fixed times when renewal casting for renewal skills are on. Without this check,
//it will add the 2 together during the above phase and then readd the fixed time.
if (battle_config.renewal_cast_3rd_skills == 1 && skill_id >= RK_ENCHANTBLADE && skill_id <= ECLAGE_RECALL)
final_time = time + fixed_time;
else
final_time = time;
// Config cast time multiplier.
if (battle_config.cast_rate != 100)
 final_time = final_time * battle_config.cast_rate / 100;
// Return final cast time.
return (final_time > 0) ? final_time : 0;
}

This is whats in the skill.conf battle file.

// At what dex does the cast time become zero (instacast)?
castrate_dex_scale: 150
// How much DEX is needed to instant cast 1st and 2nd job skills
// when the player is a 3rd job? This also includes Expanded Super Novice, Kagerou, and Oboro.
castrate_dex_scale_3rd: 150
// Enable renewal casting/cycling system for 3rd jobs skills and other skills released in renewal?
// This will make all 3rd job skills and other skills added since renewal use the renewal casting system.
// This means skill cast times will use a Variable/Fixed setup, variable cast times will be affected by INT/DEX.
// Disabling the system will make all these skills use the prenewal cast system where only DEX affects cast times
// and fixed times dont exist. Renewal skills thats 100% fixed will only be reduceable and fixed cast reduction methods.
// (Default: Yes)
renewal_cast_3rd_skills: yes

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  319
  • Reputation:   198
  • Joined:  11/14/11
  • Last Seen:  

I finally got the time to work on this today and I hit a dead end. If someone can figure out the issue it would help greatly. Plus I think it would be wise to let others look over the code and try it out first before I commit it later in the future. Here's the diff on the current work I did. Note that I didnt do any cleanup yet.

Recoded Cast System 1.patch

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

whats your status on this dear?

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

just a question where is the part in the code where this part in the formula happens...??

(1 - SQRT((DEX * 2 + INT) / 530)) * (1 - sum_castReduction/100%) * baseCast * 0.8 + (1 - max_fixedReduction/100%) * baseCast * 0.2

and why is that the sum_castReduction is not raw in the code it shows that the percentage is already apply in the base cast..

		if (sc->data[sC_SLOWCAST])
		time += time * sc->data[sC_SLOWCAST]->val2 / 100;
	if (sc->data[sC_SUFFRAGIUM]) {
		time -= time * sc->data[sC_SUFFRAGIUM]->val2 / 100;
		status_change_end(bl, SC_SUFFRAGIUM, INVALID_TIMER);
	}
	if (sc->data[sC_MEMORIZE]) {
		time>>=1;
		if ((--sc->data[sC_MEMORIZE]->val2) <= 0)
			status_change_end(bl, SC_MEMORIZE, INVALID_TIMER);
	}
	if (sc->data[sC_POEMBRAGI])
		time -= time * sc->data[sC_POEMBRAGI]->val2 / 100;

at least the fixed cast time formula is done correctly..

Link to comment
Share on other sites

  • 5 weeks later...

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

bumpy... B)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  319
  • Reputation:   198
  • Joined:  11/14/11
  • Last Seen:  

I totally forgot about this. I gave up not long after I posted that patch since the compiler was being a dick no matter how I coded it. Anyway....

@malufett

(1 - SQRT((DEX * 2 + INT) / 530)) * (1 - sum_castReduction/100%) * baseCast * 0.8 + (1 - max_fixedReduction/100%) * baseCast * 0.2

The heck is this? I fully tested the cast time formula in a official server and got a much simpler result. Not this complex thing. Here's what I got....

Variable Cast Time - Variable Cast Time * (DEX * 2 + INT) / 530

And what do you mean "and why is that the sum_castReduction is not raw in the code it shows that the percentage is already apply in the base cast" ?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

Variable Cast Time - Variable Cast Time * (DEX * 2 + INT) / 530

ohh I see...cause I think you are following the other formula...that is why I'm looking for the other part of it...can you post the full formula for this one???

And what do you mean "and why is that the sum_castReduction is not raw in the code it shows that the percentage is already apply in the base cast" ?

AFAIK in RE all the reduction is added as one before applying to the variable/base cast...and ATM it was done one by one per status change..

if (sc->data[SC_SLOWCAST])

time += time * sc->data[SC_SLOWCAST]->val2 / 100;

if (sc->data[SC_SUFFRAGIUM]) {

time -= time * sc->data[SC_SUFFRAGIUM]->val2 / 100;

status_change_end(bl, SC_SUFFRAGIUM, INVALID_TIMER);

}

if (sc->data[SC_MEMORIZE]) {

time>>=1;

if ((--sc->data[SC_MEMORIZE]->val2) <= 0)

status_change_end(bl, SC_MEMORIZE, INVALID_TIMER);

}

if (sc->data[SC_POEMBRAGI])

time -= time * sc->data[SC_POEMBRAGI]->val2 / 100;

anyways this will be clear if the complete formula is shown...^^,

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  319
  • Reputation:   198
  • Joined:  11/14/11
  • Last Seen:  

Strange. When I tested the cast times with a Sorcerer on official, Memorize halfed the variable cast after stat reductions every time. Why would it half cast times before stat reductions? It always been reduction from stats before anything else. Also that formula is the full formula for reduction from stats. As for reductions from items, equips, and status's im just assuming its the same order as in pre-renewal. Logic tells me it wouldn't make scene if they changed that order.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

so it means all cast reducing statuses doesn't stack??

had you tried Memorize + Suffragium

if yes how does it work??

reduce by 95%

eg. base of 5000ms = 5000 - 5000*.95 = 250ms

or (base 50%)45%???

eg. base of 5000ms = 5000 - 5000*.5 = 2500 - 2500*.45 = 1375ms

kindly check it please.. thanks... /no1

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

Hey guys..

can I take over with this one?? since about months that this topic started...and I wish to revamp the whole system and stick with the long formula since its the most accurate base on my test with iRO, kRO and Aegis..and by using Yommy's amazing tool where gathered data that I assure is accurate...(including Rytech idea about the configs)

can I? /kis2

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  427
  • Reputation:   123
  • Joined:  11/17/11
  • Last Seen:  

Feel free to work on it, and as long as it is tested against kRO, I will welcome any change.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

Hey guys..

can I take over with this one?? since about months that this topic started...and I wish to revamp the whole system and stick with the long formula since its the most accurate base on my test with iRO, kRO and Aegis..and by using Yommy's amazing tool where gathered data that I assure is accurate...(including Rytech idea about the configs)

can I? /kis2

please do

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  554
  • Reputation:   70
  • Joined:  04/04/12
  • Last Seen:  

Renewal Casting @ (r16661)

I hope the database be soon furnished..:)

:meow:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

awesome malufett *-*

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  427
  • Reputation:   123
  • Joined:  11/17/11
  • Last Seen:  

To the digest!

Link to comment
Share on other sites

×
×
  • Create New...