?? archer.h
字號:
class Archer:public Player//弓箭手類和劍士類差不多,就是數值設定不同
{
public:
Archer(int i,char *cptr);
void isLevelUp();
bool attack(Player &p);
bool specialatt(Player &p);
};
Archer::Archer(int i,char *cptr)
{
role=ar;
for (int j=0;j<10;j++)
name[j]=cptr[j];
HP=180+6*(i-1);
HPmax=180+6*(i-1);
MP=75+8*(i-1);
MPmax=75+8*(i-1);
AP=30+3*(i-1);
DP=24+3*(i-1);
speed=30+10*(i-1);
LV=i;
death=0;
EXP=(LV-1)*(LV-1)*70;
bag.set(i*8,i*8);
}
void Archer::isLevelUp()
{
if (EXP>=LV*LV*70)
{
LV++;
AP=AP+3;
DP=DP+3;
HPmax=HPmax+6;
MPmax=MPmax+8;
speed=speed+10;
cout <<name <<"升級了!" <<endl;
cout <<"生命值增加了" <<6 <<"點" <<endl;
cout <<"魔法值增加了" <<8 <<"點" <<endl;
cout <<"速度增加了" <<10 <<"點" <<endl;
cout <<"攻擊力增加了" <<3 <<"點" <<endl;
cout <<"防御力增加了" <<3 <<"點" <<endl;
isLevelUp();
}
}
bool Archer::attack(Player &p)
{
double HPtemp=0,EXPtemp=0;
double hit=1;
srand(time(NULL));
if ((speed>p.speed) && (rand()%100<(speed-p.speed)))//Double Hit
{
HPtemp=(int)((1.0*AP/p.DP)*AP*2/(rand()%4+10));
cout <<name <<"先暗放一箭,不偏不倚正好打在" <<p.name <<"的胸口," <<p.name <<"生命值減少了" <<HPtemp <<endl;
p.HP=(int)(p.HP-HPtemp);
EXPtemp=(int)(HPtemp*1.2);
}
if (rand()%100<1)
{
cout <<name <<"射出一支歪歪扭扭的箭," <<p.name <<"很輕松地避開了。" <<endl;
system("pause");
return 1;
}
if (rand()%100<=10)
{
hit=1.5;
cout <<name <<"拉足了弓,發出會心一擊。";
}
HPtemp=(int)(hit*(1.0*AP/p.DP)*AP*30/(rand()%8+32));
cout <<name <<"射出一支長箭,“嗖”地一聲,插入了" <<p.name <<"的" <<(rand()%2==1?"胸膛,":"大腿,") <<p.name <<"生命值減少了" <<HPtemp <<endl;
EXPtemp=(int)(EXPtemp+HPtemp*1.2);
p.HP=(int)(p.HP-HPtemp);
cout <<name <<"獲得了" <<EXPtemp <<"點經驗值。" <<endl;
EXP=(int)(EXP+EXPtemp);
system("pause");
return 1;
}
bool Archer::specialatt(Player &p)
{
if (MP<40)
{
cout <<"您的魔法值不夠!" <<endl;
system("pause");
return 0;
}
else
{
MP=MP-40;
double HPtemp=0,EXPtemp=0;
srand(time(NULL));
HPtemp=(int)(AP*1.4+18);
EXPtemp=(int)(HPtemp*1.5);
cout <<name <<"拿出三把長箭,大叫一聲“流~~~~星~~~~箭~~~~!”三把長箭徑直向" <<p.name <<"飛去," <<p.name <<"無處閃躲……" <<endl;
cout <<p.name <<"生命值減少了" <<HPtemp <<"," <<name <<"獲得了" <<EXPtemp <<"點經驗值。" <<endl;
p.HP=(int)(p.HP-HPtemp);
EXP=(int)(EXP+EXPtemp);
system("pause");
}
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -