• 个人简介

    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    #include <cstring>
    #include <windows.h>
    using namespace std;
    
    //=====系统工具 C++98兼容=====
    void setColor(int c){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);}
    void resetColor(){setColor(7);}
    void cls(){system("cls");}
    void wait(int ms){Sleep(ms);}
    void pauseSys(){cin.ignore();cin.get();}
    void line(){cout<<"=============================================\n";}
    void title(const char* s){
        cls(); line();
        setColor(11); cout<<"  "<<s<<"\n"; resetColor();
        line();
    }
    void gameOver(){
        cls(); setColor(4); line();
        cout<<"  灵魂归于灰烬,旅途就此终结\n";
        line(); resetColor();
        pauseSys(); exit(0);
    }
    
    //=====常量定义=====
    const int MAX_BUFF=6;
    const int MAX_SKILL=12;
    const int MAX_TALENT=12;
    const int MAX_ITEM=15;
    const int MAX_BOOK=10;
    const int MAX_EQUIP=8;
    const int MAX_MEM=8;
    const int MAX_STANCE=100;
    const int MON_NUM=15;
    
    //=====数据结构=====
    struct Buff{char name[16];int type,val,dur;};
    struct Fighter{
        char name[24];
        int hp,maxHp,atk,def,soul,stance,poise;
        Buff buf[MAX_BUFF];int bcnt;
        Fighter(){hp=maxHp=atk=def=soul=stance=poise=bcnt=0;memset(buf,0,sizeof(buf));}
    };
    struct Equip{
        char name[24];char desc[50];
        int atk,def,hp,soulAdd;
        int price;
        bool have;
        Equip(){memset(name,0,sizeof(name));memset(desc,0,sizeof(desc));atk=def=hp=soulAdd=price=0;have=false;}
    };
    struct Player: Fighter{
        int job,route,lv,exp,gold,fame;
        bool skill[MAX_SKILL],tal[MAX_TALENT];
        int storyCho[10];int itemCnt[MAX_ITEM];
        Equip equip[MAX_EQUIP];
        Player(){
            job=route=lv=exp=gold=fame=0;
            memset(skill,0,sizeof(skill));
            memset(tal,0,sizeof(tal));
            memset(itemCnt,0,sizeof(itemCnt));
        }
    };
    struct Skill{char name[20],desc[40];int cost,mode,val;};
    struct Talent{char name[24],info[60];int needLv,bindJob;};
    struct Item{char name[20],tip[30];int type,eff,price;bool hidden;};
    struct SkillBook{char name[24];int sid,cost;int limitChap;};
    struct Monster{char name[24];int hp,atk,def,poise;char warn[50];};
    struct Enemy:Fighter{int id,phase,warnAct,lastOp,rage;};
    struct NPC{char name[20];int favor;char mem[MAX_MEM][50];int mCnt;};
    
    //=====全局变量=====
    Skill skLib[MAX_SKILL];
    Talent talLib[MAX_TALENT];
    Item itemLib[MAX_ITEM];
    SkillBook bookLib[MAX_BOOK];
    Monster monLib[MON_NUM];
    Equip equipLib[MAX_EQUIP];
    NPC villager,merchant,hermit;
    Player hero;Enemy foe;
    int nowChap;
    bool hiddenEndCond = false;
    
    //=====提前声明函数=====
    void battle(int mid);
    void useItem();
    void levelUp();
    void foeAI();
    void updateBuff(Fighter& f);
    void addBuff(Fighter& f,Buff b);
    void shopSystem();
    
    //=====BUFF逻辑=====
    void addBuff(Fighter& f,Buff b){if(f.bcnt>=MAX_BUFF)return;f.buf[f.bcnt++]=b;}
    void updateBuff(Fighter& f){
        for(int i=0;i<f.bcnt;i++){
            if(f.buf[i].type==2)f.hp-=f.buf[i].val;
            if(f.buf[i].type==5)f.soul+=f.buf[i].val;
            f.buf[i].dur--;
            if(f.buf[i].dur<=0){
                for(int j=i;j<f.bcnt-1;j++)f.buf[j]=f.buf[j+1];
                f.bcnt--;i--;
            }
        }
    }
    
    //=====初始化全部资源=====
    void initAllData(){
        //基础技能
        strcpy(skLib[0].name,"平斩");strcpy(skLib[0].desc,"基础攻击");skLib[0].cost=8;skLib[0].mode=0;skLib[0].val=70;
        strcpy(skLib[1].name,"碎势斩");strcpy(skLib[1].desc,"大幅积攒架势");skLib[1].cost=22;skLib[1].mode=0;skLib[1].val=62;
        strcpy(skLib[2].name,"裁决行刑");strcpy(skLib[2].desc,"失衡低血处决");skLib[2].cost=35;skLib[2].mode=3;skLib[2].val=0;
        strcpy(skLib[3].name,"蚀骨毒刃");strcpy(skLib[3].desc,"附加持续流血");skLib[3].cost=18;skLib[3].mode=2;skLib[3].val=16;
        strcpy(skLib[4].name,"隐势规避");strcpy(skLib[4].desc,"减少自身架势上涨");skLib[4].cost=15;skLib[4].mode=1;skLib[4].val=0;
        strcpy(skLib[5].name,"魂界壁垒");strcpy(skLib[5].desc,"生成防护护盾");skLib[5].cost=28;skLib[5].mode=4;skLib[5].val=65;
        //新增法师专属技能
        strcpy(skLib[6].name,"灵火冲击");strcpy(skLib[6].desc,"魂力轰击敌人");skLib[6].cost=20;skLib[6].mode=0;skLib[6].val=85;
        strcpy(skLib[7].name,"魔力汲取");strcpy(skLib[7].desc,"攻击回复自身魂力");skLib[7].cost=12;skLib[7].mode=5;skLib[7].val=10;
        strcpy(skLib[8].name,"冰封禁锢");strcpy(skLib[8].desc,"冻结敌方行动一回合");skLib[8].cost=30;skLib[8].mode=6;skLib[8].val=0;
    
        //天赋 新增4号绑定秘术法师
        strcpy(talLib[0].name,"狂势追猎");strcpy(talLib[0].info,"残血状态打崩敌方架势更快");talLib[0].needLv=3;talLib[0].bindJob=0;
        strcpy(talLib[1].name,"绝对行刑");strcpy(talLib[1].info,"无需失衡即可触发处决");talLib[1].needLv=6;talLib[1].bindJob=0;
        strcpy(talLib[2].name,"毒势蔓延");strcpy(talLib[2].info,"流血效果可叠加增伤");talLib[2].needLv=3;talLib[2].bindJob=1;
        strcpy(talLib[3].name,"无声遁走");strcpy(talLib[3].info,"战斗可无惩罚撤离");talLib[3].needLv=6;talLib[3].bindJob=1;
        strcpy(talLib[4].name,"壁垒永续");strcpy(talLib[4].info,"持盾缓慢恢复魂力");talLib[4].needLv=3;talLib[4].bindJob=2;
        strcpy(talLib[5].name,"残魂反制");strcpy(talLib[5].info,"护盾破碎冻结敌人一回合");talLib[5].needLv=6;talLib[5].bindJob=2;
        //法师天赋
        strcpy(talLib[6].name,"灵能增幅");strcpy(talLib[6].info,"法术伤害提升20%");talLib[6].needLv=3;talLib[6].bindJob=3;
        strcpy(talLib[7].name,"神魂自愈");strcpy(talLib[7].info,"消耗魂力同步恢复生命");talLib[7].needLv=6;talLib[7].bindJob=3;
    
        //常规道具
        strcpy(itemLib[0].name,"生命药剂");strcpy(itemLib[0].tip,"恢复45点生命");itemLib[0].type=0;itemLib[0].eff=45;itemLib[0].price=45;itemLib[0].hidden=false;
        strcpy(itemLib[1].name,"魂力药剂");strcpy(itemLib[1].tip,"恢复35点魂力");itemLib[1].type=1;itemLib[1].eff=35;itemLib[1].price=38;itemLib[1].hidden=false;
        strcpy(itemLib[2].name,"高阶生命药剂");strcpy(itemLib[2].tip,"恢复120生命");itemLib[2].type=0;itemLib[2].eff=120;itemLib[2].price=100;itemLib[2].hidden=false;
        strcpy(itemLib[3].name,"高阶魂力药剂");strcpy(itemLib[3].tip,"恢复90魂力");itemLib[3].type=1;itemLib[3].eff=90;itemLib[3].price=85;itemLib[3].hidden=false;
        //章节专属道具
        strcpy(itemLib[4].name,"林地解毒散");strcpy(itemLib[4].tip,"第三章专属,免疫毒素伤害");itemLib[4].type=3;itemLib[4].eff=0;itemLib[4].price=60;itemLib[4].hidden=false;
        strcpy(itemLib[5].name,"祭坛护符");strcpy(itemLib[5].tip,"第五章专属,降低邪术伤害");itemLib[5].type=3;itemLib[5].eff=0;itemLib[5].price=80;itemLib[5].hidden=false;
        //隐藏结局道具
        strcpy(itemLib[6].name,"余烬本源碎片");strcpy(itemLib[6].tip,"集齐三件解锁隐藏真结局");itemLib[6].type=9;itemLib[6].eff=0;itemLib[6].price=200;itemLib[6].hidden=true;
        strcpy(itemLib[7].name,"远古魂晶");strcpy(itemLib[7].tip,"集齐三件解锁隐藏真结局");itemLib[7].type=9;itemLib[7].eff=0;itemLib[7].price=220;itemLib[7].hidden=true;
        strcpy(itemLib[8].name,"末世之心");strcpy(itemLib[8].tip,"集齐三件解锁隐藏真结局");itemLib[8].type=9;itemLib[8].eff=0;itemLib[8].price=260;itemLib[8].hidden=true;
    
        //技能书 绑定章节
        strcpy(bookLib[0].name,"碎势斩秘籍");bookLib[0].sid=1;bookLib[0].cost=110;bookLib[0].limitChap=2;
        strcpy(bookLib[1].name,"毒刃古书");bookLib[1].sid=3;bookLib[1].cost=130;bookLib[1].limitChap=3;
        strcpy(bookLib[2].name,"灵火术法典");bookLib[2].sid=6;bookLib[2].cost=160;bookLib[2].limitChap=4;
        strcpy(bookLib[3].name,"魔力汲取秘卷");bookLib[3].sid=7;bookLib[3].cost=140;bookLib[3].limitChap=6;
        strcpy(bookLib[4].name,"冰封禁术");bookLib[4].sid=8;bookLib[4].cost=190;bookLib[4].limitChap=8;
    
        //装备库
        strcpy(equipLib[0].name,"制式铁剑");strcpy(equipLib[0].desc,"基础近战武器");
        equipLib[0].atk=6;equipLib[0].def=0;equipLib[0].hp=0;equipLib[0].soulAdd=0;equipLib[0].price=50;
        strcpy(equipLib[1].name,"粗布护甲");strcpy(equipLib[1].desc,"小幅提升生存能力");
        equipLib[1].atk=0;equipLib[1].def=5;equipLib[1].hp=15;equipLib[1].soulAdd=0;equipLib[1].price=70;
        strcpy(equipLib[2].name,"灵能法袍");strcpy(equipLib[2].desc,"法师专属,增幅魂力");
        equipLib[2].atk=3;equipLib[2].def=3;equipLib[2].hp=10;equipLib[2].soulAdd=20;equipLib[2].price=120;
        strcpy(equipLib[3].name,"噬魂魔刃");strcpy(equipLib[3].desc,"高额攻击加成");
        equipLib[3].atk=14;equipLib[3].def=2;equipLib[3].hp=0;equipLib[3].soulAdd=0;equipLib[3].price=180;
    
        //怪物数据
        strcpy(monLib[0].name,"灰烬流民");monLib[0].hp=65;monLib[0].atk=13;monLib[0].def=3;monLib[0].poise=3;strcpy(monLib[0].warn,"流民挥起残破利刃");
        strcpy(monLib[1].name,"腐坏野鼠");monLib[1].hp=42;monLib[1].atk=15;monLib[1].def=2;monLib[1].poise=2;strcpy(monLib[1].warn,"鼠群疯狂聚拢扑袭");
        strcpy(monLib[2].name,"灰烬信徒");monLib[2].hp=80;monLib[2].atk=15;monLib[2].def=4;monLib[2].poise=5;strcpy(monLib[2].warn,"信徒发动疯狂挥砍");
        strcpy(monLib[3].name,"焦土狼");monLib[3].hp=90;monLib[3].atk=18;monLib[3].def=3;monLib[3].poise=6;strcpy(monLib[3].warn,"焦土狼猛扑撕咬");
        strcpy(monLib[4].name,"堕落哨兵");monLib[4].hp=110;monLib[4].atk=20;monLib[4].def=6;monLib[4].poise=8;strcpy(monLib[4].warn,"哨兵挥剑重击");
        strcpy(monLib[5].name,"毒化飞虫");monLib[5].hp=55;monLib[5].atk=14;monLib[5].def=2;monLib[5].poise=3;strcpy(monLib[5].warn,"飞虫喷射毒液");
        strcpy(monLib[6].name,"废墟拾荒者");monLib[6].hp=85;monLib[6].atk=17;monLib[6].def=4;monLib[6].poise=5;strcpy(monLib[6].warn,"拾荒者持刀突刺");
        strcpy(monLib[7].name,"灰烬戍卫");monLib[7].hp=175;monLib[7].atk=23;monLib[7].def=10;monLib[7].poise=13;strcpy(monLib[7].warn,"戍卫沉肩蓄力重劈");
        strcpy(monLib[8].name,"腐化猎犬");monLib[8].hp=140;monLib[8].atk=30;monLib[8].def=6;monLib[8].poise=8;strcpy(monLib[8].warn,"猎犬撕裂你的防御");
        strcpy(monLib[9].name,"腐坏祭司");monLib[9].hp=230;monLib[9].atk=25;monLib[9].def=12;monLib[9].poise=16;strcpy(monLib[9].warn,"祭司释放腐坏诅咒");
        strcpy(monLib[10].name,"幽影刺客");monLib[10].hp=160;monLib[10].atk=32;monLib[10].def=8;monLib[10].poise=10;strcpy(monLib[10].warn,"刺客从暗影突袭");
        strcpy(monLib[11].name,"魂火守卫");monLib[11].hp=210;monLib[11].atk=22;monLib[11].def=14;monLib[11].poise=18;strcpy(monLib[11].warn,"魂火爆发冲击");
        strcpy(monLib[12].name,"荒古守棺者");monLib[12].hp=410;monLib[12].atk=32;monLib[12].def=17;monLib[12].poise=21;strcpy(monLib[12].warn,"守棺者催动墓地之力");
        strcpy(monLib[13].name,"灰烬领主");monLib[13].hp=520;monLib[13].atk=40;monLib[13].def=22;monLib[13].poise=26;strcpy(monLib[13].warn,"领主释放灰烬风暴");
        strcpy(monLib[14].name,"终焉主宰");monLib[14].hp=650;monLib[14].atk=44;monLib[14].def=24;monLib[14].poise=29;strcpy(monLib[14].warn,"天地余烬尽数翻涌");
    
        //NPC初始化
        strcpy(villager.name,"村落居民");villager.favor=0;villager.mCnt=0;
        strcpy(merchant.name,"流浪商人");merchant.favor=0;merchant.mCnt=0;
        strcpy(hermit.name,"隐世贤者");hermit.favor=0;hermit.mCnt=0;
    }
    
    //=====玩家初始化=====
    void initHero(){
        strcpy(hero.name,"余烬行者");
        hero.maxHp=115;hero.hp=115;hero.atk=15;hero.def=6;hero.soul=100;
        hero.lv=1;hero.exp=0;hero.gold=55;hero.fame=0;
        hero.itemCnt[0]=2;hero.itemCnt[1]=1;
        memset(hero.skill,0,sizeof(hero.skill));
        memset(hero.tal,0,sizeof(hero.tal));
    }
    
    //=====等级提升=====
    void levelUp(){
        int need=hero.lv*55;
        if(hero.exp>=need){
            hero.exp-=need;hero.lv++;
            hero.maxHp+=18;hero.hp=hero.maxHp;
            hero.soul+=12;hero.poise+=4;
            setColor(10);cout<<"  等级提升!当前等级:"<<hero.lv<<"\n";resetColor();wait(600);
        }
    }
    
    //=====天赋解锁界面=====
    void talentMenu(){
        title("天赋树界面");
        for(int i=0;i<MAX_TALENT;i++){
            if(talLib[i].name[0]==0)continue;
            if(talLib[i].bindJob!=-1&&talLib[i].bindJob!=hero.job)continue;
            cout<<i+1<<"."<<talLib[i].name<<" 需求等级:"<<talLib[i].needLv;
            if(hero.tal[i])cout<<" 【已解锁】";
            else if(hero.lv>=talLib[i].needLv)cout<<" 【可解锁】";
            cout<<"\n    "<<talLib[i].info<<"\n\n";
        }
        cout<<"0.返回\n";
        int op;cin>>op;
        if(op==0)return;
        if(op-1>=0&&op-1<MAX_TALENT&&!hero.tal[op-1]&&hero.lv>=talLib[op-1].needLv){
            hero.tal[op-1]=1;
            setColor(10); cout<<"  天赋解锁成功!\n"; resetColor();
            wait(500);
        }
    }
    
    //=====丰富商店系统 章节专属+隐藏道具+装备买卖+变卖=====
    void shopSystem(){
        while(true){
            cls();
            line();
            setColor(14);
            cout<<"===== 流浪综合商铺 | 当前章节:"<<nowChap<<" ====="<<endl;
            cout<<"持有金币:"<<hero.gold<<"  | 自身等级:"<<hero.lv<<endl;
            resetColor();
            line();
            cout<<"1.消耗药品专区"<<endl;
            cout<<"2.限定武学秘籍"<<endl;
            cout<<"3.武器防具装备"<<endl;
            cout<<"4.出售闲置物品"<<endl;
            cout<<"5.隐秘稀有货物"<<endl;
            cout<<"0.离开商店"<<endl;
            line();
            int mainOp;
            cin>>mainOp;
            if(mainOp==0) break;
    
            //1药品
            if(mainOp==1){
                cls();line();setColor(10);cout<<"药品商店\n";resetColor();line();
                for(int i=0;i<6;i++){
                    if(itemLib[i].name[0]==0||itemLib[i].hidden)continue;
                    cout<<i+1<<"."<<itemLib[i].name<<" "<<itemLib[i].price<<"金币 存量:"<<hero.itemCnt[i]<<endl;
                    cout<<"   效果:"<<itemLib[i].tip<<"\n";
                }
                cout<<"0.返回\n";
                int op;cin>>op;
                int idx=op-1;
                if(op>=1&&op<=6&&hero.gold>=itemLib[idx].price&&!itemLib[idx].hidden){
                    hero.gold-=itemLib[idx].price;
                    hero.itemCnt[idx]++;
                    setColor(10);cout<<"购买成功!\n";resetColor();wait(400);
                }
            }
            //2章节限定技能书
            if(mainOp==2){
                cls();line();setColor(11);cout<<"章节限定武学\n";resetColor();line();
                for(int i=0;i<MAX_BOOK;i++){
                    if(bookLib[i].name[0]==0)continue;
                    if(bookLib[i].limitChap != nowChap)continue;
                    cout<<i+1<<"."<<bookLib[i].name<<" 售价:"<<bookLib[i].cost;
                    if(hero.skill[bookLib[i].sid])cout<<" 已习得";
                    cout<<endl;
                }
                cout<<"0.返回\n";
                int op;cin>>op;
                int idx=op-1;
                if(op>=1&&hero.gold>=bookLib[idx].cost&&!hero.skill[bookLib[idx].sid]&&bookLib[idx].limitChap==nowChap){
                    hero.gold-=bookLib[idx].cost;
                    hero.skill[bookLib[idx].sid]=true;
                    setColor(10);cout<<"习得新技能!\n";resetColor();wait(400);
                }
            }
            //3装备
            if(mainOp==3){
                cls();line();setColor(12);cout<<"武器防具铺\n";resetColor();line();
                for(int i=0;i<MAX_EQUIP;i++){
                    if(equipLib[i].name[0]==0||equipLib[i].have)continue;
                    cout<<i+1<<"."<<equipLib[i].name<<" 价格:"<<equipLib[i].price<<endl;
                    cout<<"   攻击+"<<equipLib[i].atk<<" 防御+"<<equipLib[i].def<<" 生命+"<<equipLib[i].hp<<" 魂力+"<<equipLib[i].soulAdd<<endl;
                }
                cout<<"0.返回\n";
                int op;cin>>op;
                int idx=op-1;
                if(op>=1&&hero.gold>=equipLib[idx].price&&!equipLib[idx].have){
                    hero.gold-=equipLib[idx].price;
                    equipLib[idx].have=true;
                    hero.atk+=equipLib[idx].atk;
                    hero.def+=equipLib[idx].def;
                    hero.maxHp+=equipLib[idx].hp;
                    hero.hp+=equipLib[idx].hp;
                    hero.soul+=equipLib[idx].soulAdd;
                    setColor(10);cout<<"穿戴装备,战力提升!\n";resetColor();wait(400);
                }
            }
            //4变卖
            if(mainOp==4){
                cls();line();setColor(9);cout<<"物品变卖回收\n";resetColor();line();
                bool hasGoods=false;
                for(int i=0;i<6;i++){
                    if(hero.itemCnt[i]>0&&!itemLib[i].hidden){
                        cout<<i+1<<"."<<itemLib[i].name<<" 库存:"<<hero.itemCnt[i]<<" 回收价:"<<itemLib[i].price/2<<endl;
                        hasGoods=true;
                    }
                }
                if(!hasGoods){cout<<"暂无可售卖物品\n";wait(400);continue;}
                cout<<"选择变卖序号,0返回\n";
                int op;cin>>op;
                int idx=op-1;
                if(op>=1&&hero.itemCnt[idx]>0){
                    int getCoin=itemLib[idx].price/2;
                    hero.itemCnt[idx]--;
                    hero.gold+=getCoin;
                    setColor(10);cout<<"变卖获得"<<getCoin<<"金币\n";resetColor();wait(400);
                }
            }
            //5隐藏结局道具
            if(mainOp==5){
                cls();line();setColor(13);cout<<"隐秘特殊货物\n";resetColor();line();
                for(int i=6;i<9;i++){
                    cout<<i-5<<"."<<itemLib[i].name<<" 售价:"<<itemLib[i].price<<endl;
                    cout<<"   说明:"<<itemLib[i].tip<<endl;
                }
                cout<<"0.返回\n";
                int op;cin>>op;
                int idx=op+5;
                if(op>=1&&op<=3&&hero.gold>=itemLib[idx].price){
                    hero.gold-=itemLib[idx].price;
                    hero.itemCnt[idx]++;
                    int cnt=0;
                    for(int i=6;i<9;i++)if(hero.itemCnt[i]>0)cnt++;
                    if(cnt>=3)hiddenEndCond=true;
                    setColor(13);cout<<"获得远古秘宝!集齐三件解锁隐藏结局\n";resetColor();wait(600);
                }
            }
        }
    }
    
    //=====道具使用界面=====
    void useItem(){
        title("随身道具");
        for(int i=0;i<9;i++){
            if(itemLib[i].name[0]==0||itemLib[i].hidden)continue;
            cout<<i+1<<"."<<itemLib[i].name<<"  数量:"<<hero.itemCnt[i]<<"\n";
        }
        cout<<"0.返回\n";
        int op;cin>>op;
        int idx=op-1;
        if(op<1||op>9||hero.itemCnt[idx]<=0)return;
        hero.itemCnt[idx]--;
        if(itemLib[idx].type==0){
            hero.hp+=itemLib[idx].eff;
            if(hero.hp>hero.maxHp)hero.hp=hero.maxHp;
            setColor(10); cout<<"生命恢复完毕!\n"; resetColor();
        }else if(itemLib[idx].type==1){
            hero.soul+=itemLib[idx].eff;
            setColor(10); cout<<"魂力恢复完毕!\n"; resetColor();
        }
        wait(500);
    }
    
    //=====NPC对话记忆系统=====
    void npcTalk(){
        title("村落居民");
        if(hero.storyCho[2]==1){
            strcpy(villager.mem[villager.mCnt++],"救助过村民");
            setColor(10); cout<<"  多谢你此前出手相助,村内物资可优先取用!\n"; resetColor();
            hero.fame+=10;
        }else if(hero.storyCho[2]==2){
            strcpy(villager.mem[villager.mCnt++],"漠视村民危难");
            setColor(12); cout<<"  你当初冷眼旁观,众人对你心存隔阂...\n"; resetColor();
        }
        pauseSys();
    }
    
    //=====支线任务系统=====
    void sideQuest(){
        title("支线委托:清理郊外怪物");
        cout<<"是否接受委托,清剿灰烬流民?\n";
        cout<<"1.接受  2.拒绝\n";
        int op;cin>>op;
        if(op==1){
            battle(0);
            hero.gold+=35;hero.exp+=30;
            setColor(10); cout<<"  委托完成!获得酬劳\n"; resetColor();
            pauseSys();
        }
    }
    
    //=====敌人AI行为预判+惩罚=====
    void foeAI(){
        if(foe.warnAct){
            setColor(12); cout<<"  "<<monLib[foe.id].warn<<"\n"; resetColor();
            int dmg=foe.atk*2-hero.def/2;
            hero.hp-=dmg;
            foe.warnAct=0;foe.lastOp=0;
            wait(700);
            if(hero.hp<=0)gameOver();
            return;
        }
        if(foe.lastOp==1){foe.warnAct=1;return;}
        if(foe.lastOp==3){foe.rage+=25;if(foe.rage>=50)foe.warnAct=1;return;}
        int rd=rand()%3;
        if(rd==0){
            int dmg=foe.atk-hero.def+rand()%7;if(dmg<0)dmg=0;hero.hp-=dmg;
            cout<<"  "<<foe.name<<"发起普通攻击\n";
        }else{
            foe.stance-=12;if(foe.stance<0)foe.stance=0;
            cout<<"  "<<foe.name<<"稳固自身架势\n";
        }
    }
    
    //=====核心战斗流程=====
    void battle(int mid){
        memset(&foe,0,sizeof(foe));
        foe.id=mid;Monster m=monLib[mid];
        strcpy(foe.name,m.name);foe.maxHp=m.hp;foe.hp=m.hp;
        foe.atk=m.atk;foe.def=m.def;foe.poise=m.poise;
        foe.phase=1;foe.warnAct=0;foe.lastOp=0;foe.rage=0;
        bool finishExe=0;
        bool spellUp=hero.tal[6]?true:false;
    
        while(hero.hp>0&&foe.hp>0){
            cls();
            setColor(10); cout<<"  HP:"<<hero.hp<<"/"<<hero.maxHp<<"   魂力:"<<hero.soul<<"\n"; resetColor();
            setColor(12); cout<<"  "<<foe.name<<" 生命:"<<foe.hp<<"   架势:"<<foe.stance<<"/"<<MAX_STANCE<<"\n"; resetColor();
            line();
            if(foe.warnAct){foeAI();continue;}
            cout<<" 1.强攻   2.技能   3.防御   4.道具\n";
            int opt;cin>>opt;foe.lastOp=opt;
    
            if(opt==1){
                int dmg=hero.atk+rand()%9;foe.hp-=dmg;
                int addSta=15-foe.poise/3;if(addSta<4)addSta=4;
                foe.stance+=addSta;
                cout<<"  挥击造成 "<<dmg<<" 点伤害!\n";
                if(foe.stance>=MAX_STANCE){
                    setColor(10); cout<<"  敌方姿态崩塌,陷入失衡!\n"; resetColor();
                    foe.def/=2;
                }
            }
            if(opt==2){
                cout<<"已习得技能:\n";
                for(int i=0;i<MAX_SKILL;i++)if(hero.skill[i])cout<<i+1<<"."<<skLib[i].name<<"\n";
                int s;cin>>s;s--;
                if(!hero.skill[s]||hero.soul<skLib[s].cost){cout<<"无法释放\n";wait(500);continue;}
                hero.soul-=skLib[s].cost;
                int hurt=skLib[s].val+hero.atk/2;
                if(spellUp&&(s>=6&&s<=8)) hurt*=1.2;
                if(skLib[s].mode==0){foe.hp-=hurt;foe.stance+=25;cout<<"技能命中造成"<<hurt<<"伤害\n";}
                if(skLib[s].mode==2){Buff bd={"流血",2,skLib[s].val,4};addBuff(foe,bd);cout<<"施加持续流血效果\n";}
                if(skLib[s].mode==3){if(foe.hp<=foe.maxHp*0.3&&foe.stance>=MAX_STANCE){foe.hp=0;finishExe=1;cout<<"处决完成!\n";}else cout<<"条件不足\n";}
                if(skLib[s].mode==5){foe.hp-=hurt;Buff soulRec{"回魂",5,skLib[s].val,2};addBuff(hero,soulRec);cout<<"攻击汲取魂力\n";}
                if(skLib[s].mode==6){foe.warnAct=0;foe.lastOp=99;cout<<"冰封禁锢,敌人无法行动\n";}
            }
            if(opt==3){cout<<"进入防御姿态,降低受到伤害\n";}
            if(opt==4){useItem();continue;}
            if(foe.hp>0&&!finishExe&&foe.lastOp!=99)foeAI();
            updateBuff(hero);updateBuff(foe);
            hero.soul+=5;if(hero.soul>100)hero.soul=100;
            if(hero.tal[7]&&hero.soul<20) hero.hp+=8;
            wait(600);
        }
        setColor(10); cout<<"\n  战斗胜利!\n"; resetColor();
        int getExp = 45 + mid*18;
        int getGold = 32 + mid*12;
        hero.exp += getExp;
        hero.gold += getGold;
        cout<<"  获得经验:"<<getExp<<"  获得金币:"<<getGold<<"\n";
        levelUp();
        pauseSys();
    }
    
    //=====12章完整主线剧情=====
    void mainStory(int chap){
        nowChap = chap;
        if(chap==1){
            title("第一章 余烬苏醒");
            cout<<"三百年天火焚世,文明覆灭。\n你从废墟中苏醒,前路迷茫,唯有寻找末世真相。\n";
            cout<<"选择职业:\n";
            cout<<"1.处刑武士 | 近战爆发,处决强敌\n";
            cout<<"2.幽影巡猎 | 剧毒潜行,灵活拉扯\n";
            cout<<"3.铸魂守御 | 高防续航,团队壁垒\n";
            cout<<"4.秘术法师 | 魂力法术,控场输出\n";
            int j;cin>>j;hero.job=j-1;
            hero.skill[0]=1;
            //四大职业初始属性与技能区分
            if(hero.job==0){hero.atk+=7;hero.skill[1]=hero.skill[2]=1;}
            if(hero.job==1){hero.poise+=5;hero.skill[3]=hero.skill[4]=1;}
            if(hero.job==2){hero.maxHp+=25;hero.hp=hero.maxHp;hero.skill[5]=1;}
            if(hero.job==3){hero.soul+=30;hero.atk+=3;hero.skill[6]=1;}
            setColor(10); cout<<"  职业确定,旅途开始!\n"; resetColor();
            pauseSys();
            battle(0);
            shopSystem();
        }
        if(chap==2){
            title("第二章 荒土独行");
            cout<<"穿行荒芜焦土,前方出现幸存者聚落。\n聚落遭魔物侵扰,是否出手相助?\n1.出手  2.离开\n";
            int c;cin>>c;hero.storyCho[2]=c;
            pauseSys();
            if(c==1)sideQuest();
            battle(1); battle(5);
            shopSystem();
        }
        if(chap==3){
            title("第三章 暗影林地");
            cout<<"踏入腐坏密林,暗影魔物潜藏四处,危机四伏。\n";
            pauseSys();
            battle(2); battle(3);
            npcTalk();
            shopSystem();
        }
        if(chap==4){
            title("第四章 行商驿站");
            cout<<"偶遇流浪商人,可交易物资与武学典籍。\n";
            pauseSys();
            shopSystem();
            battle(6); battle(4);
            shopSystem();
        }
        if(chap==5){
            title("第五章 古老祭坛");
            cout<<"废弃祭坛内,异端信徒举行邪异仪式。\n";
            pauseSys();
            battle(2); battle(7);
            shopSystem();
        }
        if(chap==6){
            title("第六章 天赋觉醒");
            cout<<"历经生死之战,潜藏力量逐渐觉醒。\n";
            pauseSys();
            talentMenu();
            battle(8); battle(10);
            shopSystem();
        }
        if(chap==7){
            title("第七章 古墓禁地");
            cout<<"远古墓葬深埋地下,守墓生灵死守此地。\n";
            pauseSys();
            battle(11); battle(12);
            shopSystem();
        }
        if(chap==8){
            title("第八章 残魂遗迹");
            cout<<"古老魂能遗迹浮现,强大魂兽镇守核心。\n";
            pauseSys();
            battle(9); battle(11);
            shopSystem();
        }
        if(chap==9){
            title("第九章 阵营抉择");
            cout<<"抵达权力交界,选择最终立场:\n1.杀伐平定乱世  2.隐忍守护众生\n";
            cin>>hero.route;
            setColor(10); cout<<"  立场已确定!\n"; resetColor();
            pauseSys();
            battle(8); battle(10);
            shopSystem();
        }
        if(chap==10){
            title("第十章 灰烬王城");
            cout<<"昔日王城沦为焦土,最终领主镇守核心。\n";
            pauseSys();
            battle(13);
            shopSystem();
        }
        if(chap==11){
            title("第十一章 终焉前兆");
            cout<<"灾祸源头气息弥漫,大地即将彻底崩坏。\n";
            pauseSys();
            battle(12); battle(13);
            shopSystem();
        }
        if(chap==12){
            title("终章 终焉对决");
            cout<<"一切灾祸源头现世,末世存亡之战开启!\n";
            pauseSys();
            battle(14);
            cls(); line();
            setColor(11);
            //隐藏结局判定
            if(hiddenEndCond){
                cout<<"★★★ 隐藏真结局:余烬创世 ★★★\n";
                cout<<"集齐末世本源碎片,你洞悉世界真相,重塑新生纪元\n";
            }else{
                //原有职业结局
                if(hero.job==0){
                    if(hero.route==1)cout<<"  【处刑武士·裁决结局】以战止戈,平定末世之乱\n";
                    else cout<<"  【处刑武士·沉沦结局】沉溺杀戮,化身新的灾祸\n";
                }
                if(hero.job==1){
                    if(hero.route==1)cout<<"  【幽影巡猎·守望结局】隐于暗影,守护世间余火\n";
                    else cout<<"  【幽影巡猎·孤行结局】断绝牵绊,独行永夜之中\n";
                }
                if(hero.job==2){
                    if(hero.route==1)cout<<"  【铸魂守御·救世结局】凝魂筑盾,撑起末世希望\n";
                    else cout<<"  【铸魂守御·魂灭结局】魂力失控,与灰烬一同消散\n";
                }
                if(hero.job==3){
                    if(hero.route==1)cout<<"  【秘术法师·灵界主宰】驾驭魂力,净化世间邪秽\n";
                    else cout<<"  【秘术法师·虚空迷途】魔力反噬,消散混沌之中\n";
                }
            }
            resetColor();
            line();
            pauseSys();
        }
    }
    
    //=====主函数=====
    int main(){
        srand((unsigned)time(NULL));
        initHero(); initAllData();
        for(int i=1;i<=12;i++) mainStory(i);
        title("暗黑灰烬·余烬裁决");
        setColor(11); cout<<"  旅途完结,感谢游玩\n"; resetColor();
        line();
        pauseSys();
        return 0;
    }
    
  • 最近活动