📄 fight.cpp
字号:
}
sound_Magic.LoadSoundFX(hWnd,CMagic::MAGIC[Command[i].lAccessory].SoundFileName);
}
else
Role_Temp=Role_Move[i].ReadText("设置","continue");
kill_count=0; //从第一个主角开始
break;
}
Account_Attack();
}
else if(FightRole[command_count].use==0)
{
command_count++;
if(FightRole[command_count].use==0)
command_count=0;
}
break;
}
}
}
break;
/////////////////////////////////////////////////////////////////////
// 进行攻击的动作------------------------------------------------
/////////////////////////////////////////////////////////////////////
case ROLE_KILL_ENEMY:
{
for(i=0; i<3; i++) //遍历主角,执行战斗指令
{
if(kill_count==i && FightRole[kill_count].use==1
&& Command[kill_count].lCommand == ATTACK) //轮到该主角攻击了
{
bShowMagicPic = false;
// 测试要攻击的对象是否存在,如果不存在则换人
if(Command[kill_count].kill_who!=Test_Enemy(Command[kill_count].kill_who))
{
Command[kill_count].kill_who=Test_Enemy(Command[kill_count].kill_who);
Account_Attack();
}
//进攻动作
FightRole[kill_count].stop_temp=10;
Sleep(Role_Move[i].ReadInt("设置","延时"));
//读取位图的大小数据
RMove_Pic.left=Role_Move[i].ReadInt(Role_Temp,"left");
RMove_Pic.top=Role_Move[i].ReadInt(Role_Temp,"top");
RMove_Pic.right=Role_Move[i].ReadInt(Role_Temp,"right");
RMove_Pic.bottom=Role_Move[i].ReadInt(Role_Temp,"bottom");
//循环动作
//从开始攻击到敌人受伤到主角复位
if(Role_Move[i].ReadInt(Role_Temp,"对比")==1)
{
//得到现在应该出现的位置
FightRole[kill_count].x1=FightRole[kill_count].x+Role_Move[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=FightRole[kill_count].y+Role_Move[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
//下一次的数据
Role_Temp=Role_Move[i].ReadText(Role_Temp,"continue");
free(str);
}
else if(Role_Move[i].ReadInt(Role_Temp,"对比")==2) //移动
{
FightRole[kill_count].x1=EnemyRole[Command[kill_count].kill_who].x+Role_Move[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=EnemyRole[Command[kill_count].kill_who].y+Role_Move[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
Role_Temp=Role_Move[i].ReadText(Role_Temp,"continue");
free(str);
}
else if(Role_Move[i].ReadInt(Role_Temp,"对比")==3) //敌人受伤
{
FightRole[kill_count].x1=EnemyRole[Command[kill_count].kill_who].x+Role_Move[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=EnemyRole[Command[kill_count].kill_who].y+Role_Move[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
Role_Temp=Role_Move[i].ReadText(Role_Temp,"continue");
free(str);
//敌人动作变成受伤的动作
EnemyRole[Command[kill_count].kill_who].stop_temp=11;
}
else if(Role_Move[i].ReadInt(Role_Temp,"对比")==4) //攻击
{
FightRole[kill_count].sound_Fight.Play(); //攻击声
FightRole[kill_count].x1=EnemyRole[Command[kill_count].kill_who].x+Role_Move[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=EnemyRole[Command[kill_count].kill_who].y+Role_Move[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
Role_Temp=Role_Move[i].ReadText(Role_Temp,"continue");
free(str);
//敌人动作变成后退动作
EnemyRole[Command[kill_count].kill_who].stop_temp=10;
}
else if(Role_Move[i].ReadInt(Role_Temp,"对比")==5) //敌人惨叫
{
FightRole[kill_count].x1=EnemyRole[Command[kill_count].kill_who].x+Role_Move[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=EnemyRole[Command[kill_count].kill_who].y+Role_Move[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
Role_Temp=Role_Move[i].ReadText(Role_Temp,"continue");
free(str);
//敌人动作复位成受伤动作
//---------
//整个过程是
//敌人先被攻击
//然后后退
//然后复位到被攻击的动作
//-------------
EnemyRole[Command[kill_count].kill_who].stop_temp=11;
EnemyRole[Command[kill_count].kill_who].sound_Defend.Play(); //叫喊声
}
else
{
//主角回到原位置
FightRole[kill_count].stop_temp=1;
//如果胜利了,就直接跳出进攻部分
if( Account_Loss()==1 )
goto _Next;
//计算攻击力
Account_Attack();
for(int j=i+1; j<3; j++)
if(FightRole[j].use==1) // 用来判断下一个角色是哪个角色
{
char* str = FightRoleInit.ReadText(Hero[j]->Fight_Ini_Name,"Move_Ini");
Role_Move[j].Open(str);
free(str);
_FREE(Role_Temp);
Role_Temp=Role_Move[j].ReadText("设置","continue");
kill_count=j; //切换到下一个主角
goto _Next;
}
//没有下个主角了,就换敌人攻击
Enemy_AI(); //为敌人攻击做好准备
main_count=ENEMY_KILL_ROLE; //进入敌人进攻部分
m_nRoundCount ++; //增加回合计数
Account_Attack();
}
_Next:;
}
//使用物品
else if(kill_count==i && FightRole[kill_count].use==1
&& Command[kill_count].lCommand == TOOLS)
{
bShowMagicPic = false;
//该位置不存在,换人
if(Command[kill_count].kill_who!=Test_Role(Command[kill_count].kill_who)) // 测试要攻击的对象是否存在,如果不存在则换人
{
Command[kill_count].kill_who=Test_Role(Command[kill_count].kill_who);
Account_Attack();
}
//如果这个物品可以使用,就进入使用模式
if(m_fightgoods.IsCanUse((int)Command[kill_count].lAccessory))
FightRole[kill_count].stop_temp=10;
//不能使用的话,就保持常态
else
FightRole[kill_count].stop_temp = 1;
Sleep(Role_Tool[i].ReadInt("设置","延时"));
//读取位图的大小数据
RMove_Pic.left=Role_Tool[i].ReadInt(Role_Temp,"left");
RMove_Pic.top=Role_Tool[i].ReadInt(Role_Temp,"top");
RMove_Pic.right=Role_Tool[i].ReadInt(Role_Temp,"right");
RMove_Pic.bottom=Role_Tool[i].ReadInt(Role_Temp,"bottom");
if(Role_Tool[i].ReadInt(Role_Temp,"对比")==1)
{
//位置数据
FightRole[kill_count].x1=FightRole[kill_count].x+Role_Tool[i].ReadInt(Role_Temp,"x");
FightRole[kill_count].y1=FightRole[kill_count].y+Role_Tool[i].ReadInt(Role_Temp,"y");
char *str = Role_Temp;
//下一个数据
Role_Temp=Role_Tool[i].ReadText(Role_Temp,"continue");
free(str);
}
else
{
//恢复原状态
FightRole[kill_count].stop_temp=1;
//使用物品
if(FightRole[kill_count].use==1)
{
if(m_fightgoods.IsCanUse((int)Command[kill_count].lAccessory))
{
//产生效果
m_fightgoods.GoodEffect((int)Command[kill_count].lAccessory, Hero[Command[kill_count].kill_who],Command[kill_count].kill_who);
//更新血槽数据
FightRole[Command[kill_count].kill_who].BroodLong=Hero[Command[kill_count].kill_who]->Hp * 100 / Hero[Command[kill_count].kill_who]->MaxHp;
}
else
{
//不能使用的时候,显示提示
GameMessage.DoMenu(lpDDSBack, "物品使用光了!");
}
}
for(int j=i+1; j<3; j++)
if(FightRole[j].use==1) // 用来判断下一个角色是哪个角色
{
if(Command[j].lCommand == ATTACK)
{
char* str = FightRoleInit.ReadText(Hero[j]->Fight_Ini_Name,"Move_Ini");
Role_Move[j].Open(str);
free(str);
_FREE(Role_Temp);
Role_Temp=Role_Move[j].ReadText("设置","continue");
}
else if(Command[j].lCommand == TOOLS)
{
char* str = FightRoleInit.ReadText(Hero[j]->Fight_Ini_Name,"Tool_Ini");
Role_Tool[j].Open(str);
free(str);
_FREE(Role_Temp);
Role_Temp=Role_Tool[j].ReadText("设置","continue");
}
kill_count=j;
goto _GoodsNext;
}
//没有下一个主角了就换敌人攻击
Enemy_AI();
main_count=ENEMY_KILL_ROLE;
m_nRoundCount ++; //增加回合计数
Account_Attack();
}
_GoodsNext:;
} //使用魔法
else if(kill_count==i && FightRole[kill_count].use==1
&& Command[kill_count].lCommand == MAGIC)
{
if(Command[kill_count].Class==1) //对自己的
{
if(Command[kill_count].kill_who!=Test_Role(Command[kill_count].kill_who)) // 测试要攻击的对象是否存在,如果不存在则换人
{
//重新计算
Command[kill_count].kill_who=Test_Role(Command[kill_count].kill_who);
Account_Attack();
if(Role_Magic[Command[kill_count].lAccessory].ReadInt("设置","相对"))
{
fightmagic.x = Role_Magic[Command[kill_count].lAccessory].ReadInt("设置","startx")+FightRole[kill_count].x;
fightmagic.y = Role_Magic[Command[kill_count].lAccessory].ReadInt("设置","starty")+FightRole[kill_count].y;
}
else
{
fightmagic.x = Role_Magic[Command[kill_count].lAccessory].ReadInt("设置","startx")+FightRole[Command[kill_count].kill_who].x;
fightmagic.y = Role_Magic[Command[kill_count].lAccessory].ReadInt("设置","starty")+FightRole[Command[kill_count].kill_who].y;
}
}
//如果这个魔法可以使用,就进入使用模式
if(m_fightmagic.IsCanUse((int)Command[kill_count].lAccessory))
{
//进入使用模式
FightRole[kill_count].stop_temp=10;
//显示魔法效果图片
bShowMagicPic = true;
int temp = Command[kill_count].lAccessory;
//休眠
Sleep(Role_Magic[temp].ReadInt("设置","延时"));
//读取人物动作位图的数据
RMove_Pic.left=Role_Magic[temp].ReadInt(Role_Temp,"left");
RMove_Pic.top=Role_Magic[temp].ReadInt(Role_Temp,"top");
RMove_Pic.right=Role_Magic[temp].ReadInt(Role_Temp,"right");
RMove_Pic.bottom=Role_Magic[temp].ReadInt(Role_Temp,"bottom");
//魔法图片的数据
fightmagic.RMagicPic.left = Role_Magic[temp].ReadInt(Role_Temp,"picleft");
fightmagic.RMagicPic.top = Role_Magic[temp].ReadInt(Role_Temp,"pictop");
fightmagic.RMagicPic.right=Role_Magic[temp].ReadInt(Role_Temp,"picright");
fightmagic.RMagicPic.bottom=Role_Magic[temp].ReadInt(Role_Temp,"picbottom");
if(Role_Magic[temp].ReadInt(Role_Temp,"对比")==1) //魔法开始
{
//播放魔法效果声音
char * soundtemp;
soundtemp=Role_Magic[temp].ReadText(Role_Temp,"SoundFileName");
if(soundtemp[0])
{
sound_Magic.Stop();
sound_Magic.LoadSoundFX(hWnd,soundtemp);
}
sound_Magic.Play();
//位置数据
int rolex=Role_Magic[temp].ReadInt(Role_Temp,"x");
int roley=Role_Magic[temp].ReadInt(Role_Temp,"y");
if(Role_Magic[temp].ReadInt(Role_Temp,"人物相对"))
{
FightRole[kill_count].x1=FightRole[kill_count].x+rolex;
FightRole[kill_count].y1=FightRole[kill_count].y+roley;
}
else
{
FightRole[kill_count].x1=FightRole[Command[kill_count].kill_who].x+rolex;
FightRole[kill_count].y1=FightRole[Command[kill_count].kill_who].y+roley;
}
int picx = Role_Magic[temp].ReadInt(Role_Temp,"picx");
int picy = Role_Magic[temp].ReadInt(Role_Temp,"picy");
if(Role_Magic[temp].ReadInt(Role_Temp,"图片相对"))
{
fightmagic.x = FightRole[kill_count].x + picx;
fightmagic.y = FightRole[kill_count].y + picy;
}
else
{
fightmagic.x = FightRole[Command[kill_count].kill_who].x + picx;
fightmagic.y = FightRole[Command[kill_count].kill_who].y + picy;
}
char *str = Role_Temp;
//下一个数据
Role_Temp=Role_Magic[temp].ReadText(Role_Temp,"continue");
free(str);
}
else if(Role_Magic[temp].ReadInt(Role_Temp,"对比")==2) //普通状态
{
//位置数据
int rolex=Role_Magic[temp].ReadInt(Role_Temp,"x");
int roley=Role_Magic[temp].ReadInt(Role_Temp,"y");
if(Role_Magic[temp].ReadInt(Role_Temp,"人物相对"))
{
FightRole[kill_count].x1=FightRole[kill_count].x+rolex;
FightRole[kill_count].y1=FightRole[kill_count].y+roley;
}
else
{
FightRole[kill_count].x1=FightRole[Command[kill_count].kill_who].x+rolex;
FightRole[kill_count].y1=FightRole[Command[kill_count].kill_who].y+roley;
}
int picx = Role_Magic[temp].ReadInt(Role_Temp,"picx");
int picy = Role_Magic[temp].ReadInt(Role_Temp,"picy");
if(Role_Magic[temp].ReadInt(Role_Temp,"图片相对"))
{
fightmagic.x = FightRole[kill_count].x + picx;
fightmagic.y = FightRole[kill_count].y + picy;
}
else
{
fightmagic.x = FightRole[Command[kill_count].kill_who].x + picx;
fightmagic.y = FightRole[Command[kill_count].kill_who].y + picy;
}
char *str = Role_Temp;
//下一个数据
Role_Temp=Role_Magic[temp].ReadText(Role_Temp,"continue");
free(str);
}
else //结束魔法
{
//不显示图片
bShowMagicPic = false;
//恢复原状态
FightRole[kill_count].stop_temp=1;
//使用魔法
if(FightRole[kill_count].use==1)
{
//产生效果
//使用者少魔法,接受者变化魔法设定的值
m_fightmagic.MagicEffect((int)Command[kill_count].lAccessory,Hero[kill_count], Hero[Command[kill_count].kill_who]);
//更新魔法槽数据
FightRole[kill_count].MagicLong=Hero[kill_count]->Mp * 100 / Hero[kill_count]->MaxMp;
//更新血槽数据
FightRole[Command[kill_count].kill_who].BroodLong=Hero[Command[kill_count].kill_who]->Hp * 100 / Hero[Command[kill_count].kill_who]->MaxHp;
//停止音乐
sound_Magic.Stop();
//要显示加血
m_nLifeupCountLife = 3;
m_nLifeupCountMove = 0;
FightRole[Command[kill_count].kill_who].Lifeup = CMagic::MAGIC[Command[kill_count].lAccessory].Hp;
}
for(int j=i+1; j<3; j++)
if(FightRole[j].use==1) // 用来判断下一个角色是哪个角色
{
if(Command[j].lCommand == ATTACK)
{
char* str = FightRoleInit.ReadText(Hero[j]->Fight_Ini_Name,"Move_Ini");
Role_Move[j].Open(str);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -