📄 fight1.cpp
字号:
void Fighter_count()
{
int i,n=0,m=0;
for (i=0;i<3;i++) if (en[i].flag) n++;
for (i=0;i<4;i++) {
if (ac[i].flag&&ac[i].hp<=0) ac[i].flag=99;
if (ac[i].flag&&ac[i].flag!=99) m++;
}
fenemy_num=n;
factor_num=m;
}
////////////////////////////////////////////////////////////////////////////
void Actor_HMP()
{
int i,hp_y,mp_y;
double a_hp,a_mhp,a_mp,a_mmp;
for (i=0;i<4;i++) if (ac[i].flag) {
a_hp=ac[i].hp;
a_mhp=ac[i].mhp;
hp_y=((a_hp/a_mhp)*43);
if (hp_y<1&&ac[i].hp>=1) hp_y=1;
if (hp_y>42) if (ac[i].hp<=ac[i].mhp-1) hp_y=42;
if (hp_y>43) hp_y=43;
if (hp_y>20) lsetColor(202);
if (hp_y<=20) lsetColor(25);
if (ac[i].hp>0) lbar(fa_x[ac[i].id]-1,235-hp_y,fa_x[ac[i].id],239-4);
}
for (i=0;i<4;i++) if (ac[i].flag) {
a_mp=ac[i].mp;
a_mmp=ac[i].mmp;
mp_y=((a_mp/a_mmp)*43);
if (mp_y<1&&ac[i].mp>0) mp_y=1;
if (mp_y>42) if (ac[i].mp<=ac[i].mmp-1) hp_y=42;
if (mp_y>43) mp_y=43;
lsetColor(90);
if (ac[i].mp>0) lbar(fa_x[ac[i].id]+41,235-mp_y,fa_x[ac[i].id]+42,239-4);
}
}
///////////////////////////////////////////////////////////////////////////
void Fighter_View()
{ int i;
lActiveSurface(&ls);
for (i=0;i<4;i++) if (en[i].flag)
lputSpirit(fe_x[en[i].seat],130,fepic.LpcImage[en[i].id]);
for (i=0;i<4;i++) if (ac[i].flag)
if (ac[i].flag==99) {
lputSpirit(fa_x[ac[i].id],239,fapic.LpcImage[ac[i].id]);
lsetColor(240);louttextxy(fa_x[i]+1,196,"死亡");
lsetColor(22);louttextxy(fa_x[i],195,"死亡");
}
else lputSpirit(fa_x[ac[i].id],239,fapic.LpcImage[ac[i].id]);
Actor_HMP();
}
////////////////////////////////////////////////////////////////////////////
void Fight_Scr_View()
{
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
lActiveSurface(&ls);
Fight_Menu();
lOutToScr(&ls,0,0,0,0,319,239);
}
///////////////////////////////////////////////////////////////////////////
void Fight_Menu()
{
switch (mode_mf) {
case 2:
switch (menu) {
case 0:lputImage(54,12,menu_p.LpcImage[1]);
lputImage(93,44,menu_p.LpcImage[2]);
lputImage(54,78,menu_p.LpcImage[4]);
lputImage(15,44,menu_p.LpcImage[6]);break;
case 1:lputImage(54,10,menu_p.LpcImage[0]);
lputImage(93,46,menu_p.LpcImage[3]);
lputImage(54,78,menu_p.LpcImage[4]);
lputImage(15,44,menu_p.LpcImage[6]);break;
case 2:lputImage(54,10,menu_p.LpcImage[0]);
lputImage(93,44,menu_p.LpcImage[2]);
lputImage(54,80,menu_p.LpcImage[5]);
lputImage(15,44,menu_p.LpcImage[6]);break;
case 3:lputImage(54,10,menu_p.LpcImage[0]);
lputImage(93,44,menu_p.LpcImage[2]);
lputImage(54,78,menu_p.LpcImage[4]);
lputImage(15,46,menu_p.LpcImage[7]);break;
}break;
case 3:
switch (menu) {
case 0: lputImage(25,64,menu_p.LpcImage[1]);
lputImage(104,64,menu_p.LpcImage[8]);break;
case 1: lputImage(25,64,menu_p.LpcImage[0]);
lputImage(104,64,menu_p.LpcImage[9]);break;
} break;
case 5:
switch (menu) {
case 0: lputImage(25,64,menu_p.LpcImage[11]);
lputImage(104,64,menu_p.LpcImage[12]);break;
case 1: lputImage(25,64,menu_p.LpcImage[10]);
lputImage(104,64,menu_p.LpcImage[13]);break;
}
break;
}
}
///////////////////////////////////////////////////////////////////////////
void change_color()
{ static int c=60,inc=-3;
c+=inc;
if (c>60||c<30) inc*=(-1);
lsetPal(255,c,c,6);
}
////////////////////////////////////////////////////////////////////////////
int Choice_Enemy()
{
int m[5],temp[5],press,n,max_n,i,j,k,l,newi,flag,flag01,flag02;
short key;
press=n=flag02=0;
Fighter_count();
for (k=0;k<4;k++) temp[k]=-1,m[k]=-1;
for (k=0;k<3;k++) if (en[k].flag) temp[en[k].seat]=k;
for (k=0,i=0,max_n=0;k<3;k++)
if (temp[k]>=0) m[i++]=temp[k],max_n++;
n=0;
for (k=0;(k<4)&&(!press);k++) if (ac[k].flag&&ac[k].flag!=99) {
while (!press){
lActiveSurface(&ls);
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
lputImage(fe_x[en[m[n]].seat],30,jt);
lputImage(fa_x[f_i]+14,175,jt);
lOutToScr(&ls,0,0,0,0,319,239);
lkgetch(&key);
switch (key) {
case KEY_LEFT: if (--n<0) n=0;
break;
case KEY_RIGHT: if (++n>=max_n) n=max_n-1;
break;
case KEY_ENTER:
case KEY_CTRL:
case KEY_SPACE: if (mode_mf==10) {
if (ac[f_i].flag!=99&&ac[f_i].flag) {
flag=0;
for (newi=0;(newi<factor_num+fenemy_num)&&(flag!=1);newi++)
if (st[newi].mode<0) {
for (i=0,j=0;i<4;i++) {
st[newi].obj=m[n];
st[newi].atf=1;
st[newi].sm=ac[f_i].sm;
st[newi].source=f_i;
st[newi].mode=0;
flag=1;
flag01++;
mode_mf=2,menu=0;
press_count=-1;
press=-1;
debug++;
}
return 1;
}
}
if (ac[f_i].flag==99){
mode_mf=2,menu=0;
press_count=-1;
press=-1;
return 1;
}
}
if (mode_mf==11) {
flag01=0;
for (newi=0;newi<factor_num;newi++) if (ac[newi].flag&&ac[newi].flag!=99) {
flag02++;
if (flag02>flag01) {
if (st[newi].mode<0) {
for (i=0;i<4;i++) {
st[newi].obj=m[n];
st[newi].atf=1;
st[newi].source=newi;
st[newi].mode=0;
st[newi].sm=ac[newi].sm;
press=-1;
}
}
}
}
return 0;
}
break;
case KEY_ALT:
case KEY_ESC: press=2,mode_mf=3,menu=0;
return 0;
break;
}
}
}
return 0;
}
////////////////////////////////////////////////////////////////////////////
void Dead(int ID,int actor_mode)
{
if (!actor_mode) {
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
lActiveSurface(&ls);
lputImage(fe_x[en[ID].seat],10,menu_p.LpcImage[14]);
lsetColor(240);
louttextxy(fe_x[en[ID].seat]+14,27,"死亡");
lsetColor(22);
louttextxy(fe_x[en[ID].seat]+13,26,"死亡");
lOutToScr(&ls,0,0,0,0,319,239);
en[ID].flag=0;
en[ID].id=-1;
en[ID].seat=-1;
en[ID].hp=0;
en[ID].mp=0;
en[ID].at=0;
en[ID].df=0;
en[ID].sm=0;
Noop(fight_delay*30);
}
else {ac[ID].flag=99;
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
lsetColor(240);
louttextxy(fa_x[st[ID].obj]+1,196,"死亡");
lsetColor(22);
louttextxy(fa_x[st[ID].obj],195,"死亡");
lOutToScr(&ls,0,0,0,0,319,239);
Noop(fight_delay*30);
}
}
///////////////////////////////////////////////////////////////////////////
int Fight()
{ int i,j,s,t,min_hp,at_obj,n,a,newflag,y;
char hp[80];
STOR temp;
at_obj=-1,min_hp=0;
for (n=0;n<4;n++)
if (en[n].flag) {
newflag=0;
Fighter_count();
for (i=0;i<factor_num+fenemy_num&&st[i].mode>=0;i++);
if (i<factor_num+fenemy_num) {
newflag=1;
st[i].mode=1;
st[i].source=n;
st[i].sm=en[n].sm;
for (min_hp=9999,at_obj=0,s=0;s<4;s++)
if (ac[s].flag!=99&&ac[s].flag&&ac[s].hp<=min_hp)
min_hp=ac[s].hp, at_obj=s;
//if ((rand()%2)==0) st[i].obj=at_obj;
if (random2(2)==0) st[i].obj=at_obj;
if (st[i].obj<0) {
for (s=0;s<4&&(ac[s].flag==0||ac[s].flag==99);s++);
st[i].obj=s;
}
/* if (en[st[i].source].mp>mg[en[st[i].source].mg1].point&&en[st[i].source].mg1!=-1) {
//if ((rand()%1)!=0) st[i].atf=2;
if (random2(1)!=0) st[i].atf=2;
else st[i].atf=1;
}
if (en[st[i].source].mp>mg[en[st[i].source].mg2].point&&en[st[i].source].mg2!=-1) {
//if ((rand()%1)!=0) st[i].atf=2;
if (random2(1)!=0) st[i].atf=2;
else st[i].atf=1;
}*/
if (st[i].atf<=0) st[i].atf=1;
}
}
for (s=0;s<factor_num+fenemy_num;s++)
for (t=s+1;t<factor_num+fenemy_num;t++)
if (st[s].sm<st[t].sm) {
memcpy(&temp,&st[s],sizeof(temp));
memcpy(&st[s],&st[t],sizeof(temp));
memcpy(&st[t],&temp,sizeof(temp));
}
Fighter_count();
for (i=0,newflag=0;i<factor_num+fenemy_num&&newflag!=1;i++)
{ switch (st[i].mode){
case 0: if (ac[st[i].source].flag==0||ac[st[i].source].flag==99) break;
if (en[st[i].obj].flag==0||en[st[i].obj].flag==99) {
for (j=0;j<3;j++) if (en[j].flag==1) st[i].obj=j;
if (en[st[i].obj].flag==0||en[st[i].obj].flag==99) break;
}
if (st[i].atf==1) {
en[st[i].obj].hp=en[st[i].obj].hp-(ac[st[i].source].at*2)/en[st[i].obj].df;
if (en[st[i].obj].hp<=0) en[st[i].obj].hp=0;
sprintf(hp,"%d",(ac[st[i].source].at*2)/en[st[i].obj].df);
for(a=0;a<2;a++) {
lActiveSurface(&ls);
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
lputSpirit(fe_x[en[st[i].obj].seat],239,act1_fight.LpcImage[act1_fight.pageList[st[i].source]+a]);
lOutToScr(&ls,0,0,0,0,319,239);
if (a==1) Noop(fight_delay*15);
else Noop(fight_delay*7);
for(y=0;y<20&&a==1;y++){
lBlitFast(&ls,0,0,0,240,319,479,&ls,0);
Fighter_View();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -