Here is the code:
void ssj_drain(CHAR_DATA *ch)
{
int drain;
/* This is so when they sleep they don't lose energy trying to sustain the transformation or in the future gain skill */
if (ch->position <= POS_SLEEPING)
{
act( AT_RED, "Your hair flashes back to its original color as you lose conciseness.", ch, NULL, NULL, TO_CHAR );
act( AT_RED, "$n's hair flashes back to its original color as $e loses conciseness.", ch, NULL, NULL, TO_NOTVICT );
if (xIS_SET((ch)->affected_by, AFF_SSJ)
|| xIS_SET((ch)->affected_by, AFF_SSJ2)
|| xIS_SET((ch)->affected_by, AFF_SSJ3)
|| xIS_SET((ch)->affected_by, AFF_SSJ4))
{
if (xIS_SET((ch)->affected_by, AFF_USSJ))
xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
if (xIS_SET((ch)->affected_by, AFF_USSJ2))
xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
if (xIS_SET((ch)->affected_by, AFF_SSJ))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
if (xIS_SET((ch)->affected_by, AFF_SSJ2))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
if (xIS_SET((ch)->affected_by, AFF_SSJ3))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ3);
if (xIS_SET((ch)->affected_by, AFF_SSJ4))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ4);
ch->pl = ch->exp;
transStatRemove(ch);
if( !IS_NPC( ch ) )
{
ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
ch->pcdata->eyes = ch->pcdata->orignaleyes;
}
}
return;
}
/* 4 if checks one for each of the different levels of Super Saiyan Transformations to determine how much energy to drain */
if (xIS_SET(ch->affected_by, AFF_SSJ)
&& !xIS_SET(ch->affected_by, AFF_SSJ2)
&& !xIS_SET(ch->affected_by, AFF_SSJ3)
&& !xIS_SET(ch->affected_by, AFF_SSJ4))
{
if (( ch->pcdata->learned[gsn_ssj] > 0 ) && ( ch->pcdata->learned[gsn_ssj] < 20 ))
drain = 100;
else if (( ch->pcdata->learned[gsn_ssj] > 20 ) && ( ch->pcdata->learned[gsn_ssj] < 50 ))
drain = 80;
else if (( ch->pcdata->learned[gsn_ssj] > 50 ) && ( ch->pcdata->learned[gsn_ssj] < 70 ))
drain = 40;
else if (( ch->pcdata->learned[gsn_ssj] > 70 ) && ( ch->pcdata->learned[gsn_ssj] < 90 ))
drain = 20;
else if (( ch->pcdata->learned[gsn_ssj] > 90 )
drain = 0;
}
if (!xIS_SET(ch->affected_by, AFF_SSJ)
&& xIS_SET(ch->affected_by, AFF_SSJ2)
&& !xIS_SET(ch->affected_by, AFF_SSJ3)
&& !xIS_SET(ch->affected_by, AFF_SSJ4))
{
if (( ch->pcdata->learned[gsn_ssj2] > 0 ) && ( ch->pcdata->learned[gsn_ssj] < 20 ))
drain = 200;
else if (( ch->pcdata->learned[gsn_ssj2] > 20 ) && ( ch->pcdata->learned[gsn_ssj] < 50 ))
drain = 150;
else if (( ch->pcdata->learned[gsn_ssj2] > 50 ) && ( ch->pcdata->learned[gsn_ssj] < 70 ))
drain = 100;
else if (( ch->pcdata->learned[gsn_ssj2] > 70 ) && ( ch->pcdata->learned[gsn_ssj] < 90 ))
drain = 50;
else if (( ch->pcdata->learned[gsn_ssj2] > 90 )
drain = 0;
}
if (!xIS_SET(ch->affected_by, AFF_SSJ)
&& !xIS_SET(ch->affected_by, AFF_SSJ2)
&& xIS_SET(ch->affected_by, AFF_SSJ3)
&& !xIS_SET(ch->affected_by, AFF_SSJ4))
{
if (( ch->pcdata->learned[gsn_ssj3] > 0 ) && ( ch->pcdata->learned[gsn_ssj] < 20 ))
drain = 300;
else if (( ch->pcdata->learned[gsn_ssj3] > 20 ) && ( ch->pcdata->learned[gsn_ssj] < 50 ))
drain = 200;
else if (( ch->pcdata->learned[gsn_ssj3] > 50 ) && ( ch->pcdata->learned[gsn_ssj] < 70 ))
drain = 100;
else if (( ch->pcdata->learned[gsn_ssj3] > 70 ) && ( ch->pcdata->learned[gsn_ssj] < 90 ))
drain = 50;
else if (( ch->pcdata->learned[gsn_ssj3] > 90 )
drain = 0;
}
if (!xIS_SET(ch->affected_by, AFF_SSJ)
&& !xIS_SET(ch->affected_by, AFF_SSJ2)
&& !xIS_SET(ch->affected_by, AFF_SSJ3)
&& xIS_SET(ch->affected_by, AFF_SSJ4))
{
if (( ch->pcdata->learned[gsn_ssj4] > 0 ) && ( ch->pcdata->learned[gsn_ssj] < 20 ))
drain = 400;
else if (( ch->pcdata->learned[gsn_ssj4] > 20 ) && ( ch->pcdata->learned[gsn_ssj] < 50 ))
drain = 300;
else if (( ch->pcdata->learned[gsn_ssj4] > 50 ) && ( ch->pcdata->learned[gsn_ssj] < 70 ))
drain = 200;
else if (( ch->pcdata->learned[gsn_ssj4] > 70 ) && ( ch->pcdata->learned[gsn_ssj] < 90 ))
drain = 100;
else if (( ch->pcdata->learned[gsn_ssj4] > 90 )
drain = 0;
}
/* actual drain function, would like to add a possibilty for a skill increase in this if possible */
if (ch->mana - drain < 0)
{
drain = drain - ch->mana;
ch->mana = 0;
}
else
ch->mana -= drain;
if (drain != 0 && ch->mana == 0)
{
act( AT_RED, "Your hair and eyes return to their original color as you can no longer sustain your Super Saiyan state.", ch, NULL, NULL, TO_CHAR );
act( AT_RED, "$n's hair and eyes return to their original color as $e can no longer sustain the Super Saiyan state.", ch, NULL, NULL, TO_NOTVICT );
if (xIS_SET((ch)->affected_by, AFF_SSJ)
|| xIS_SET((ch)->affected_by, AFF_SSJ2)
|| xIS_SET((ch)->affected_by, AFF_SSJ3)
|| xIS_SET((ch)->affected_by, AFF_SSJ4))
{
if (xIS_SET((ch)->affected_by, AFF_USSJ))
xREMOVE_BIT((ch)->affected_by, AFF_USSJ);
if (xIS_SET((ch)->affected_by, AFF_USSJ2))
xREMOVE_BIT((ch)->affected_by, AFF_USSJ2);
if (xIS_SET((ch)->affected_by, AFF_SSJ))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ);
if (xIS_SET((ch)->affected_by, AFF_SSJ2))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ2);
if (xIS_SET((ch)->affected_by, AFF_SSJ3))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ3);
if (xIS_SET((ch)->affected_by, AFF_SSJ4))
xREMOVE_BIT((ch)->affected_by, AFF_SSJ4);
ch->pl = ch->exp;
transStatRemove(ch);
if( !IS_NPC( ch ) )
{
ch->pcdata->haircolor = ch->pcdata->orignalhaircolor;
ch->pcdata->eyes = ch->pcdata->orignaleyes;
}
}
}
return;
}
|