Exemplo n.º 1
0
    void ServerProc()
    {
        while (true)
        {
            if (!working)
            {
                break;
            }
            if (listener.Pending())
            {
                AddNewClient(listener.AcceptTcpClient());
            }

            foreach (var pair in clientDic)
            {
                if (!pair.Value.Connected)
                {
                    continue;
                }
                try
                {
                    stream = pair.Value.GetStream();
                    reader = new BinaryReader(stream);
                    short  length = reader.ReadInt16();
                    byte[] buffer = reader.ReadBytes(length);
                    string msg    = Encoding.UTF8.GetString(buffer);
                    GEvent.OnEvent(eEvent.AddMsg, string.Format("{0}:{1}", pair.Key, msg));
                }
                catch
                {
                }
            }
        }
    }
Exemplo n.º 2
0
 public void OnConnect()
 {
     TcpC.instance.ConnectTo(inputIP.text, int.Parse(inputPort.text), (ip) =>
     {
         GEvent.OnEvent(eEvent.AddMsg, string.Format("Connect to {0} success!", ip));
     });
     btnConnnect.gameObject.SetActive(false);
     btnStop.gameObject.SetActive(true);
     btnStart.gameObject.SetActive(false);
     SetControlEnable(false);
     cType = ClientType.TcpC;
 }
Exemplo n.º 3
0
    public void Receive()
    {
        udpListener = new UdpClient(NetUtils.broadcastPort);
        IPEndPoint ipe = new IPEndPoint(IPAddress.Any, 0);

        while (true)
        {
            byte[] buffer = udpListener.Receive(ref ipe);
            if (ipe.Address.ToString() != selfIP4Address)
            {
                GEvent.OnEvent(eEvent.AddMsg, string.Format("{0}({1}):{2}", ipe.Address, ipe.Port, Encoding.UTF8.GetString(buffer)));
            }
        }
    }
Exemplo n.º 4
0
 void ReceiveFromServer()
 {
     while (client.Connected)
     {
         try
         {
             short  length = reader.ReadInt16();
             byte[] buffer = new byte[length];
             reader.Read(buffer, 0, length);
             string msg = Encoding.UTF8.GetString(buffer);
             GEvent.OnEvent(eEvent.AddMsg, "Server:" + msg);
             stream.Flush();
         }
         catch { }
     }
 }
Exemplo n.º 5
0
    void AddNewClient(TcpClient client)
    {
        if (null == client)
        {
            return;
        }
        IPEndPoint ipe = client.Client.RemoteEndPoint as IPEndPoint;

        if (clientDic.ContainsKey(ipe.Address.ToString()))
        {
            clientDic[ipe.Address.ToString()].Close();
            clientDic.Remove(ipe.Address.ToString());
        }
        clientDic.Add(ipe.Address.ToString(), client);
        GEvent.OnEvent(eEvent.AddMsg, string.Format("{0}: client connected!", ipe.Address.ToString()));
    }
Exemplo n.º 6
0
        public static bool Prefix(int fatherId, int motherId, int setFather, int setMother, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }
            int mainActorId = DateFile.instance.MianActorID();

            // 启用功能并且是主角造孩子
            if (Main.settings.pregnant.Enabled && (fatherId == mainActorId || motherId == mainActorId))
            {
                Debug("主角尝试发生关系");
                int num2 = int.Parse(DateFile.instance.GetActorDate(fatherId, 24));
                int num3 = int.Parse(DateFile.instance.GetActorDate(motherId, 24));
                DateFile.instance.ChangeActorFeature(fatherId, 4001, 4002);
                DateFile.instance.ChangeActorFeature(motherId, 4001, 4002);
                GEvent.OnEvent(eEvents.Copulate, fatherId, motherId);
                if (Main.settings.pregnant.fecundity.setFather)
                {
                    num2 = Main.settings.pregnant.fecundity.valueFather;
                }
                if (Main.settings.pregnant.fecundity.setMother)
                {
                    num3 = Main.settings.pregnant.fecundity.valueMother;
                }
                Debug("父方生育能力: " + num2 + " 母方生育能力: " + num3);

                int num4 = num2 * num3; // 生育能力的结果
                if (Main.settings.pregnant.fecundity.setAll)
                {
                    num4 = Main.settings.pregnant.fecundity.valueAll;
                }

                // 生育能力判定
                if (num4 <= 0)
                {
                    Debug("不可能生育,因为父方或母方生育能力不为正数");
                    __result = false;
                    return(false);
                }
                if (int.Parse(DateFile.instance.GetActorDate(motherId, 14, applyBonus: false)) != 2)
                {
                    Debug("母方不是女性,终止怀孕尝试");
                    __result = false;
                    return(false);
                }
                int var1 = Random.Range(0, 15000);
                if (!DateFile.instance.HaveLifeDate(motherId, 901) && var1 < num4)
                {
                    Debug("生育能力判定通过,检定结果:" + num4 + "/" + var1);

                    int 怀孕概率             = 100;
                    int existChildWeight = 20; // 现存的子嗣对剩余能力的影响
                    怀孕概率 -= DateFile.instance.GetActorSocial(fatherId, 310).Count *existChildWeight;
                    怀孕概率 -= DateFile.instance.GetActorSocial(motherId, 310).Count *existChildWeight;
                    int var2 = Random.Range(0, 100);

                    int num5 = 怀孕概率;
                    if (Main.settings.pregnant.SpecifiedPossibility)
                    {
                        num5 = Main.settings.pregnant.Possibility;
                    }
                    // 怀孕概率判定
                    if (var2 < num5)
                    {
                        Debug("怀孕判定通过,检定结果:" + num5 + "/" + var2);
                        DateFile.instance.ChangeActorFeature(motherId, 4002, 4003);
                        int var3 = Random.Range(0, 100);
                        int num6 = (((DateFile.instance.getQuquTrun - 100) / 10)); // 异胎概率
                        if (Main.settings.pregnant.SpecifiedQuQu)
                        {
                            num6 = Main.settings.pregnant.QuQu;
                        }

                        if (var3 < num6)
                        {
                            Debug("异胎判定通过,检定结果:" + num6 + "/" + var3);
                            DateFile.instance.getQuquTrun = 0;
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                1042, fatherId, motherId, setFather, setMother
                            });
                        }
                        else
                        {
                            Debug("正常胎儿判定通过,异胎检定结果:" + num6 + "/" + var3);
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                Random.Range(7, 10), fatherId, motherId, setFather, setMother
                            });
                            DateFile.instance.pregnantFeature.Add(motherId, new string[2] {
                                Characters.GetCharProperty(fatherId, 101),
                                Characters.GetCharProperty(motherId, 101)
                            });
                        }
                        __result = true;
                    }
                    else // 怀孕概率判定失败
                    {
                        Debug("怀孕判定未通过,检定结果:" + num5 + "/" + var2);
                    }
                }
                else // 生育能力判定失败
                {
                    if (!DateFile.instance.HaveLifeDate(motherId, 901))
                    {
                        Debug("生育能力判定未通过,因为母方已怀孕。");
                    }
                    else
                    {
                        Debug("生育能力判定未通过,检定结果:" + num4 + "/" + var1);
                    }
                }
                return(false);
            }
            else
            {
                // 不拦截
                return(true);
            }
        }
Exemplo n.º 7
0
        public static bool Prefix(int fatherId, int motherId, int setFather, int setMother, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }
            int mainActorId = DateFile.instance.MianActorID();

            // 启用功能并且是主角造孩子
            if (Main.settings.启用指定怀孕功能 && (fatherId == mainActorId || motherId == mainActorId))
            {
                Debug("主角尝试发生关系");
                int num2 = int.Parse(DateFile.instance.GetActorDate(fatherId, 24));
                int num3 = int.Parse(DateFile.instance.GetActorDate(motherId, 24));
                DateFile.instance.ChangeActorFeature(fatherId, 4001, 4002);
                DateFile.instance.ChangeActorFeature(motherId, 4001, 4002);
                GEvent.OnEvent(eEvents.Copulate, fatherId, motherId);
                Debug("父方生育可能性: " + num2 + " 母方生育可能性: " + num3);
                if (Main.settings.指定生育可能性 ? (Main.settings.生育可能性 <= 0) : (num2 <= 0 || num3 <= 0))
                {
                    Debug("生育不可能,终止");
                    __result = false;
                    return(false);
                }
                if (int.Parse(DateFile.instance.GetActorDate(motherId, 14, applyBonus: false)) != 2)
                {
                    Debug("阿拉,母方不是女性,终止");
                    __result = false;
                    return(false);
                }
                int var1 = Random.Range(0, 15000);
                if (!DateFile.instance.HaveLifeDate(motherId, 901) && var1 < (Main.settings.指定生育可能性 ? Main.settings.生育可能性 : (num2 * num3)))
                {
                    Debug("生育可能性判定通过,需求 " + var1 + ",结果 " + (Main.settings.指定生育可能性 ? Main.settings.生育可能性 : (num2 * num3)));
                    bool flag = fatherId == mainActorId || motherId == mainActorId;
                    int  num4 = 100;
                    int  num5 = flag ? 20 : 50;
                    num4 -= DateFile.instance.GetActorSocial(fatherId, 310).Count *num5;
                    num4 -= DateFile.instance.GetActorSocial(motherId, 310).Count *num5;
                    int var2 = Random.Range(0, 100);
                    if (var2 < (Main.settings.指定怀孕概率 ? Main.settings.怀孕概率 : num4))
                    {
                        Debug("怀孕判定通过,需求 " + var2 + ",结果 " + (Main.settings.指定怀孕概率 ? Main.settings.怀孕概率 : num4));
                        DateFile.instance.ChangeActorFeature(motherId, 4002, 4003);
                        int var3 = Random.Range(0, 100);
                        if (var3 < (Main.settings.指定蛐蛐概率 ? Main.settings.蛐蛐概率 : ((DateFile.instance.getQuquTrun - 100) / 10)))
                        {
                            Debug("异胎判定通过,需求 " + var3 + ",结果 " + (Main.settings.指定蛐蛐概率 ? Main.settings.蛐蛐概率 : ((DateFile.instance.getQuquTrun - 100) / 10)));
                            DateFile.instance.getQuquTrun = 0;
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                1042, fatherId, motherId, setFather, setMother
                            });
                        }
                        else
                        {
                            Debug("正常胎儿判定通过");
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                Random.Range(7, 10), fatherId, motherId, setFather, setMother
                            });
                            DateFile.instance.pregnantFeature.Add(motherId, new string[2] {
                                Characters.GetCharProperty(fatherId, 101),
                                Characters.GetCharProperty(motherId, 101)
                            });
                        }
                        __result = true;
                    }
                    else
                    {
                        Debug("怀孕判定未通过,需求 " + var2 + ",结果 " + (Main.settings.指定怀孕概率 ? Main.settings.怀孕概率 : num4));
                    }
                }
                Debug("生育可能性判定未通过,需求 " + var1 + ",结果 " + (Main.settings.指定生育可能性 ? Main.settings.生育可能性 : (num2 * num3)));
                return(false);
            }
            else if (Main.settings.启用防绿功能)
            {
                bool 是否拦截 = false;
                if (!是否拦截 && Main.settings.和太吾之外的人都不能发生关系)
                {
                    是否拦截 = (fatherId == mainActorId || motherId == mainActorId);
                    if (是否拦截)
                    {
                        Debug("拦截发生关系,父方 " + DateFile.instance.GetActorName(fatherId) +
                              ",母方 " + DateFile.instance.GetActorName(motherId));
                    }
                }
                if (!是否拦截 && Main.settings.太吾爱慕的人不能与他人发生关系)
                {
                    List <int> 太吾爱慕的人 = new List <int>();
                    foreach (int k in Main.settings.爱慕关系.Keys)
                    {
                        if (Main.settings.爱慕关系[k])
                        {
                            太吾爱慕的人.AddRange(DateFile.instance.GetActorSocial(mainActorId, k));
                        }
                    }
                    是否拦截 = (太吾爱慕的人.Contains(fatherId) || 太吾爱慕的人.Contains(motherId));
                    if (是否拦截)
                    {
                        Debug("拦截太吾爱慕的人发生关系,父方 " + DateFile.instance.GetActorName(fatherId) +
                              ",母方 " + DateFile.instance.GetActorName(motherId));
                    }
                }
                if (!是否拦截 && Main.settings.爱慕太吾的人不能与他人发生关系)
                {
                    List <int> 这两人爱慕的人们 = new List <int>();
                    foreach (int k in Main.settings.爱慕关系.Keys)
                    {
                        if (Main.settings.爱慕关系[k])
                        {
                            这两人爱慕的人们.AddRange(DateFile.instance.GetActorSocial(fatherId, k));
                            这两人爱慕的人们.AddRange(DateFile.instance.GetActorSocial(motherId, k));
                        }
                    }
                    是否拦截 = (这两人爱慕的人们.Contains(mainActorId));
                    if (是否拦截)
                    {
                        Debug("拦截爱慕太吾的人发生关系,父方 " + DateFile.instance.GetActorName(fatherId) +
                              ",母方 " + DateFile.instance.GetActorName(motherId));
                    }
                }
                return(!是否拦截);
            }
            else
            {
                // 不拦截
                return(true);
            }
        }
Exemplo n.º 8
0
        public static bool Prefix(int mapId, int tileId, bool isTaiwuAtThisTile, Dictionary <int, int> righteousInfo, object disasterInfo, int worldId, int mainActorId, Dictionary <int, List <int> > mainActorItems, System.Random random)
        {
            if (!Main.enabled || !Main.settings.启用主动欺辱功能)
            {
                return(true);
            }
            if (!isTaiwuAtThisTile)
            {
                return(true);
            }
            int 角色立场 = DateFile.instance.GetActorGoodness(mainActorId);
            int 欺辱概率 = int.Parse(DateFile.instance.goodnessDate[角色立场][25]);
            int 战力评价 = int.Parse(DateFile.instance.GetActorDate(mainActorId, 993, applyBonus: false));
            int 性别   = int.Parse(DateFile.instance.GetActorDate(mainActorId, 14, applyBonus: false));

            PeopleLifeAI_Utils.GetTileCharacters(mapId, tileId, out int[] aliveChars);
            List <int> list = aliveChars.ToList();

            if (Main.settings.主动欺辱爱慕筛选)
            {
                list = list.Where((int id) => DateFile.instance.GetActorSocial(mainActorId, 312).Contains(id)).ToList();
            }
            if (Main.settings.主动欺辱人名筛选)
            {
                list = list.Where((int id) => DateFile.instance.GetActorName(id).IndexOf(Main.settings.人名字符串片段) != -1).ToList();
            }
            if (Main.settings.主动欺辱异性筛选)
            {
                list = list.Where((int id) => int.Parse(DateFile.instance.GetActorDate(id, 14, applyBonus: false)) != 性别).ToList();
            }

            Debug.Log(("目标名单:" + ((list.Count == 0) ? "None" : (DateFile.instance.GetActorName(list[0]) + " etc."))));
            if (Main.settings.指定主动欺辱概率)
            {
                欺辱概率 = Main.settings.主动欺辱概率;
            }
            if (list.Count > 0 && UnityEngine.Random.Range(0, 100) < 欺辱概率)
            {
                int num3 = list[UnityEngine.Random.Range(0, list.Count)];
                if (!Main.settings.跳过战力检定 && 战力评价 < int.Parse(DateFile.instance.GetActorDate(num3, 993, applyBonus: false)) + 10000)
                {
                    Debug.Log("欺辱打不过的人");
                    if (Main.settings.主动欺辱结仇)
                    {
                        DateFile.instance.AddSocial(num3, mainActorId, 401);
                    }
                    if (Main.settings.主动欺辱影响双方情绪)
                    {
                        PeopleLifeAI_Utils.AiMoodChange(mainActorId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(mainActorId)][102]));
                    }
                    PeopleLifeAI_Utils.AISetMassage(99, mainActorId, mapId, tileId, new int[1], num3);
                }
                else
                {
                    if (Main.settings.主动欺辱影响双方情绪)
                    {
                        PeopleLifeAI_Utils.AiMoodChange(mainActorId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(mainActorId)][102]) * 10);
                    }
                    if (DateFile.instance.GetActorSocial(num3, 312).Contains(mainActorId))
                    {
                        Debug.Log("欺辱成功,但是并无过多怨恨");
                        if (Main.settings.主动欺辱影响双方情绪)
                        {
                            PeopleLifeAI_Utils.AiMoodChange(num3, UnityEngine.Random.Range(-10, 11));
                        }
                        if (UnityEngine.Random.Range(0, 100) < 50 && Main.settings.主动欺辱结仇)
                        {
                            DateFile.instance.AddSocial(num3, mainActorId, 402);
                        }
                        PeopleLifeAI_Utils.AISetMassage(97, num3, mapId, tileId, new int[1], mainActorId);
                    }
                    else
                    {
                        Debug.Log("欺辱成功,对方伤心欲绝");
                        if (Main.settings.主动欺辱影响双方情绪)
                        {
                            PeopleLifeAI_Utils.AiMoodChange(num3, -50);
                        }
                        if (Main.settings.主动欺辱结仇)
                        {
                            DateFile.instance.AddSocial(num3, mainActorId, 402);
                        }
                        PeopleLifeAI_Utils.AISetMassage(96, num3, mapId, tileId, new int[1], mainActorId);
                    }
                    if (性别 != int.Parse(DateFile.instance.GetActorDate(num3, 14, applyBonus: false)))
                    {
                        Debug.Log("试图怀孕");
                        PeopleLifeAI_Utils.AISetChildren((性别 == 1) ? mainActorId : num3, (性别 == 1) ? num3 : mainActorId, Main.settings.主动欺辱的孩子有双亲 ? 1 : ((性别 != 1) ? 1 : 0), Main.settings.主动欺辱的孩子有双亲 ? 1 : ((性别 == 1) ? 1 : 0));
                    }
                    else
                    {
                        Debug.Log("同性不能怀孕");
                        DateFile.instance.ChangeActorFeature(mainActorId, 4001, 4002);
                        DateFile.instance.ChangeActorFeature(num3, 4001, 4002);
                        GEvent.OnEvent(eEvents.Copulate, mainActorId, num3);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 9
0
        public static bool Rape(int raperId, int victimId, int mapId, int tileId, bool skipBattle = false, bool moodChange = true, bool beHated = true, bool oneParent = true)
        {
            int BattleAbility = int.Parse(DateFile.instance.GetActorDate(raperId, 993, applyBonus: false));

            if (!skipBattle && BattleAbility < int.Parse(DateFile.instance.GetActorDate(victimId, 993, applyBonus: false)) + 10000)
            {
                if (beHated)
                {
                    DateFile.instance.AddSocial(victimId, raperId, 401);
                }
                if (moodChange)
                {
                    PeopleLifeAIHelper.AiMoodChange(raperId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(raperId)][102]));
                }
                PeopleLifeAIHelper.AISetMassage(99, raperId, mapId, tileId, new int[1], victimId);
                return(false);
            }

            if (moodChange)
            {
                PeopleLifeAIHelper.AiMoodChange(raperId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(raperId)][102]) * 10);
            }

            if (DateFile.instance.GetActorSocial(victimId, 312).Contains(raperId))
            {
                if (moodChange)
                {
                    PeopleLifeAIHelper.AiMoodChange(victimId, UnityEngine.Random.Range(-10, 11));
                }
                if (UnityEngine.Random.Range(0, 100) < 50)
                {
                    if (beHated)
                    {
                        DateFile.instance.AddSocial(victimId, raperId, 402);
                    }
                }
                PeopleLifeAIHelper.AISetMassage(97, victimId, mapId, tileId, new int[1], raperId);
            }
            else
            {
                if (moodChange)
                {
                    PeopleLifeAIHelper.AiMoodChange(victimId, -50);
                }
                if (beHated)
                {
                    DateFile.instance.AddSocial(victimId, raperId, 402);
                }
                PeopleLifeAIHelper.AISetMassage(96, victimId, mapId, tileId, new int[1], raperId);
            }

            int RaperSex = int.Parse(DateFile.instance.GetActorDate(raperId, 14, applyBonus: false));

            if (RaperSex != int.Parse(DateFile.instance.GetActorDate(victimId, 14, applyBonus: false)))
            {
                int setFather = (RaperSex != 1) ? 1 : 0;
                int setMother = (RaperSex == 1) ? 1 : 0;
                if (!oneParent)
                {
                    setFather = setMother = 1;
                }

                PeopleLifeAIHelper.AISetChildren((RaperSex == 1) ? raperId : victimId, (RaperSex == 1) ? victimId : raperId, setFather, setMother);
            }
            else
            {
                DateFile.instance.ChangeActorFeature(raperId, 4001, 4002);
                DateFile.instance.ChangeActorFeature(victimId, 4001, 4002);
                GEvent.OnEvent(eEvents.Copulate, raperId, victimId);
            }

            return(true);
        }
Exemplo n.º 10
0
        public static bool Prefix(int fatherId, int motherId, int setFather, int setMother, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }
            if (!Main.settings.启用指定怀孕功能)
            {
                return(true);
            }
            int num = DateFile.instance.MianActorID();

            if (fatherId != num && motherId != num)
            {
                return(true);
            }
            Debug.Log((object)"PrecisionShooting...");
            int num2 = int.Parse(DateFile.instance.GetActorDate(fatherId, 24));
            int num3 = int.Parse(DateFile.instance.GetActorDate(motherId, 24));

            DateFile.instance.ChangeActorFeature(fatherId, 4001, 4002);
            DateFile.instance.ChangeActorFeature(motherId, 4001, 4002);
            GEvent.OnEvent(eEvents.Copulate, fatherId, motherId);
            if (Main.settings.指定生育可能性 ? (Main.settings.生育可能性 <= 0) : (num2 <= 0 || num3 <= 0))
            {
                __result = false;
                return(false);
            }
            if (int.Parse(DateFile.instance.GetActorDate(motherId, 14, applyBonus: false)) != 2)
            {
                __result = false;
                return(false);
            }
            if (!DateFile.instance.HaveLifeDate(motherId, 901) && Random.Range(0, 15000) < (Main.settings.指定生育可能性 ? Main.settings.生育可能性 : (num2 * num3)))
            {
                Debug.Log((object)"生育可能性判定成功");
                bool flag = fatherId == num || motherId == num;
                int  num4 = 100;
                int  num5 = flag ? 20 : 50;
                num4 -= DateFile.instance.GetActorSocial(fatherId, 310).Count *num5;
                num4 -= DateFile.instance.GetActorSocial(motherId, 310).Count *num5;
                if (Random.Range(0, 100) < (Main.settings.指定怀孕概率 ? Main.settings.怀孕概率 : num4))
                {
                    Debug.Log((object)"怀孕判定成功");
                    DateFile.instance.ChangeActorFeature(motherId, 4002, 4003);
                    if (Random.Range(0, 100) < (Main.settings.指定蛐蛐概率 ? Main.settings.蛐蛐概率 : ((DateFile.instance.getQuquTrun - 100) / 10)))
                    {
                        Debug.Log((object)"异胎判定成功");
                        DateFile.instance.getQuquTrun = 0;
                        DateFile.instance.actorLife[motherId].Add(901, new List <int>
                        {
                            1042,
                            fatherId,
                            motherId,
                            setFather,
                            setMother
                        });
                    }
                    else
                    {
                        Debug.Log((object)"常胎判定成功");
                        DateFile.instance.actorLife[motherId].Add(901, new List <int>
                        {
                            Random.Range(7, 10),
                            fatherId,
                            motherId,
                            setFather,
                            setMother
                        });
                        DateFile.instance.pregnantFeature.Add(motherId, new string[2]
                        {
                            Characters.GetCharProperty(fatherId, 101),
                            Characters.GetCharProperty(motherId, 101)
                        });
                    }
                    __result = true;
                }
            }
            return(false);
        }
        public static bool Prefix(int mapId, int tileId, bool isTaiwuAtThisTile, Dictionary <int, int> righteousInfo, object disasterInfo, int worldId, int mainActorId, Dictionary <int, List <int> > mainActorItems, System.Random random)
        {
            if (!Main.enabled || !Main.settings.启用主动欺辱功能)
            {
                return(true);
            }

            if (!isTaiwuAtThisTile)
            {
                return(true);
            }

            Debug("开始试图欺辱");

            int 角色立场 = DateFile.instance.GetActorGoodness(mainActorId);
            int 欺辱概率 = int.Parse(DateFile.instance.goodnessDate[角色立场][25]);
            int 战力评价 = int.Parse(DateFile.instance.GetActorDate(mainActorId, 993, applyBonus: false));
            int 性别   = int.Parse(DateFile.instance.GetActorDate(mainActorId, 14, applyBonus: false));

            PeopleLifeAI_Utils.GetTileCharacters(mapId, tileId, out int[] aliveChars);
            List <int> list = aliveChars.ToList();

            if (Main.settings.主动欺辱爱慕筛选)
            {
                list = list.Where((int id) => DateFile.instance.GetActorSocial(mainActorId, 312).Contains(id)).ToList();
            }
            if (Main.settings.主动欺辱人名筛选)
            {
                list = list.Where((int id) => DateFile.instance.GetActorName(id).IndexOf(Main.settings.人名字符串片段) != -1).ToList();
            }
            if (Main.settings.主动欺辱异性筛选)
            {
                list = list.Where((int id) => int.Parse(DateFile.instance.GetActorDate(id, 14, applyBonus: false)) != 性别).ToList();
            }

            string names = "";

            foreach (int kid in list)
            {
                names += DateFile.instance.GetActorName(list[kid]) + " ";
            }

            Debug("主角想要欺辱的目标名单" + ((list.Count == 0) ? "为空" : (": " + names)));

            if (Main.settings.指定主动欺辱概率)
            {
                欺辱概率 = Main.settings.主动欺辱概率;
            }
            int var1 = UnityEngine.Random.Range(0, 100);

            if (list.Count > 0 && var1 < 欺辱概率)
            {
                Debug("欺辱概率判定通过,需求 " + var1 + ",结果 " + 欺辱概率);
                int num3 = list[UnityEngine.Random.Range(0, list.Count)];
                if (!Main.settings.跳过战力检定 && 战力评价 < int.Parse(DateFile.instance.GetActorDate(num3, 993, applyBonus: false)) + 10000)
                {
                    Debug("战力判定未通过,需求 " + (int.Parse(DateFile.instance.GetActorDate(num3, 993, applyBonus: false)) + 10000) +
                          ",结果 " + 战力评价);
                    if (Main.settings.主动欺辱结仇)
                    {
                        DateFile.instance.AddSocial(num3, mainActorId, 401);
                    }
                    if (Main.settings.主动欺辱影响双方情绪)
                    {
                        PeopleLifeAI_Utils.AiMoodChange(mainActorId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(mainActorId)][102]));
                    }
                    PeopleLifeAI_Utils.AISetMassage(99, mainActorId, mapId, tileId, new int[1], num3);
                }
                else
                {
                    Debug("战力判定通过,需求 " + (int.Parse(DateFile.instance.GetActorDate(num3, 993, applyBonus: false)) + 10000) +
                          ",结果 " + 战力评价);
                    if (Main.settings.主动欺辱影响双方情绪)
                    {
                        PeopleLifeAI_Utils.AiMoodChange(mainActorId, int.Parse(DateFile.instance.goodnessDate[DateFile.instance.GetActorGoodness(mainActorId)][102]) * 10);
                    }
                    if (DateFile.instance.GetActorSocial(num3, 312).Contains(mainActorId))
                    {
                        if (Main.settings.主动欺辱影响双方情绪)
                        {
                            PeopleLifeAI_Utils.AiMoodChange(num3, UnityEngine.Random.Range(-10, 11));
                        }
                        int var2 = UnityEngine.Random.Range(0, 100);
                        if (var2 < 50 && Main.settings.主动欺辱结仇)
                        {
                            DateFile.instance.AddSocial(num3, mainActorId, 402);
                        }
                        PeopleLifeAI_Utils.AISetMassage(97, num3, mapId, tileId, new int[1], mainActorId);
                        Debug("对方并无过多怨恨," + ((var2 < 50) ? "但是仍然结下仇怨" : "因此并未结下仇怨"));
                    }
                    else
                    {
                        if (Main.settings.主动欺辱影响双方情绪)
                        {
                            PeopleLifeAI_Utils.AiMoodChange(num3, -50);
                        }
                        if (Main.settings.主动欺辱结仇)
                        {
                            DateFile.instance.AddSocial(num3, mainActorId, 402);
                        }
                        PeopleLifeAI_Utils.AISetMassage(96, num3, mapId, tileId, new int[1], mainActorId);
                        Debug("对方伤心欲绝");
                    }
                    if (性别 != int.Parse(DateFile.instance.GetActorDate(num3, 14, applyBonus: false)))
                    {
                        Debug("由于性别不同,开始进行怀孕判定");
                        PeopleLifeAI_Utils.AISetChildren((性别 == 1) ? mainActorId : num3, (性别 == 1) ? num3 : mainActorId, Main.settings.主动欺辱的孩子有双亲 ? 1 : ((性别 != 1) ? 1 : 0), Main.settings.主动欺辱的孩子有双亲 ? 1 : ((性别 == 1) ? 1 : 0));
                    }
                    else
                    {
                        Debug("由于性别相同,无法进行怀孕判定");
                        DateFile.instance.ChangeActorFeature(mainActorId, 4001, 4002);
                        DateFile.instance.ChangeActorFeature(num3, 4001, 4002);
                        GEvent.OnEvent(eEvents.Copulate, mainActorId, num3);
                    }
                }
            }
            else
            {
                Debug("欺辱概率判定未通过,需求 " + var1 + ",结果 " + 欺辱概率);
            }
            return(true);
        }
Exemplo n.º 12
0
        public static bool Prefix(int fatherId, int motherId, int setFather, int setMother, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }
            int mainActorId = DateFile.instance.MianActorID();

            // 启用功能并且是主角造孩子
            if (Main.settings.pregnant.Enabled && (fatherId == mainActorId || motherId == mainActorId))
            {
                DebugPregnant("主角尝试发生关系");
                int num2 = int.Parse(DateFile.instance.GetActorDate(fatherId, 24));
                int num3 = int.Parse(DateFile.instance.GetActorDate(motherId, 24));
                DateFile.instance.ChangeActorFeature(fatherId, 4001, 4002);
                DateFile.instance.ChangeActorFeature(motherId, 4001, 4002);
                GEvent.OnEvent(eEvents.Copulate, fatherId, motherId);
                DebugPregnant("父方生育能力: " + num2 + " 母方生育能力: " + num3);
                if (Main.settings.pregnant.SpecifiedFecundity ? (Main.settings.pregnant.Fecundity <= 0) : (num2 <= 0 || num3 <= 0))
                {
                    DebugPregnant("生育不可能,终止");
                    __result = false;
                    return(false);
                }
                if (int.Parse(DateFile.instance.GetActorDate(motherId, 14, applyBonus: false)) != 2)
                {
                    DebugPregnant("阿拉,母方不是女性,终止");
                    __result = false;
                    return(false);
                }
                int var1 = Random.Range(0, 15000);
                if (!DateFile.instance.HaveLifeDate(motherId, 901) && var1 < (Main.settings.pregnant.SpecifiedFecundity ? Main.settings.pregnant.Fecundity : (num2 * num3)))
                {
                    DebugPregnant("生育能力判定通过,需求 " + var1 + ",结果 " + (Main.settings.pregnant.SpecifiedFecundity ? Main.settings.pregnant.Fecundity : (num2 * num3)));
                    bool flag = fatherId == mainActorId || motherId == mainActorId;
                    int  num4 = 100;
                    int  num5 = flag ? 20 : 50;
                    num4 -= DateFile.instance.GetActorSocial(fatherId, 310).Count *num5;
                    num4 -= DateFile.instance.GetActorSocial(motherId, 310).Count *num5;
                    int var2 = Random.Range(0, 100);
                    if (var2 < (Main.settings.pregnant.SpecifiedPossibility ? Main.settings.pregnant.Possibility : num4))
                    {
                        DebugPregnant("怀孕判定通过,需求 " + var2 + ",结果 " + (Main.settings.pregnant.SpecifiedPossibility ? Main.settings.pregnant.Possibility : num4));
                        DateFile.instance.ChangeActorFeature(motherId, 4002, 4003);
                        int var3 = Random.Range(0, 100);
                        if (var3 < (Main.settings.pregnant.SpecifiedQuQu ? Main.settings.pregnant.QuQu : ((DateFile.instance.getQuquTrun - 100) / 10)))
                        {
                            DebugPregnant("异胎判定通过,需求 " + var3 + ",结果 " + (Main.settings.pregnant.SpecifiedQuQu ? Main.settings.pregnant.QuQu : ((DateFile.instance.getQuquTrun - 100) / 10)));
                            DateFile.instance.getQuquTrun = 0;
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                1042, fatherId, motherId, setFather, setMother
                            });
                        }
                        else
                        {
                            DebugPregnant("正常胎儿判定通过");
                            DateFile.instance.actorLife[motherId].Add(901, new List <int> {
                                Random.Range(7, 10), fatherId, motherId, setFather, setMother
                            });
                            DateFile.instance.pregnantFeature.Add(motherId, new string[2] {
                                Characters.GetCharProperty(fatherId, 101),
                                Characters.GetCharProperty(motherId, 101)
                            });
                        }
                        __result = true;
                    }
                    else
                    {
                        DebugPregnant("怀孕判定未通过,需求 " + var2 + ",结果 " + (Main.settings.pregnant.SpecifiedPossibility ? Main.settings.pregnant.Possibility : num4));
                    }
                }
                DebugPregnant("生育能力判定未通过,需求 " + var1 + ",结果 " + (Main.settings.pregnant.SpecifiedFecundity ? Main.settings.pregnant.Fecundity : (num2 * num3)));
                return(false);
            }
            else if (Main.settings.nontr.Enabled)
            {
                bool 是否拦截 = false;

                if (Main.settings.nontr.PreventAll)
                {
                    是否拦截 = true;
                    // 允许配偶关系,并且确实是配偶,就不拦截
                    if (Main.settings.nontr.AllowCouple && DateFileHelper.HasSocial(fatherId, 309, motherId))
                    {
                        是否拦截 = false;
                    }

                    if (是否拦截)
                    {
                        DebugNontr(string.Format("拦截了 {0} 与 {1} 试图发生关系的行为", DateFile.instance.GetActorName(fatherId), DateFile.instance.GetActorName(motherId)));
                    }
                }
                else
                {
                    bool 在关系列表内 = false;

                    if (!在关系列表内 && DateFileHelper.HasAnySocial(mainActorId, Main.NoNtrSocialTypList, fatherId))
                    {
                        DebugNontr(string.Format("父方 {0} 在关系列表内", DateFile.instance.GetActorName(fatherId)));
                        在关系列表内 = true;
                    }

                    if (!在关系列表内 && DateFileHelper.HasAnySocial(mainActorId, Main.NoNtrSocialTypList, motherId))
                    {
                        DebugNontr(string.Format("母方 {0} 在关系列表内", DateFile.instance.GetActorName(motherId)));
                        在关系列表内 = true;
                    }

                    if (在关系列表内)
                    {
                        是否拦截 = true;
                        if (Main.settings.nontr.AllowCouple && DateFileHelper.HasSocial(fatherId, 309, motherId))
                        {
                            是否拦截 = false;
                        }

                        if (是否拦截)
                        {
                            DebugNontr(string.Format("拦截了 {0} 与 {1} 试图发生关系的行为", DateFile.instance.GetActorName(fatherId), DateFile.instance.GetActorName(motherId)));
                        }
                    }
                }
                return(!是否拦截);
            }
            else
            {
                // 不拦截
                return(true);
            }
        }
Exemplo n.º 13
0
            private static bool Prefix()
            {
                if (!Main.enabled || !Main.settings.fastBreak)
                {
                    return(true);
                }
                UIDate.instance.ChangeTime(false, 20);
                int   mianActorId = DateFile.instance.mianActorId;
                float num         = 1f;

                if (BuildingWindow.instance.studySkillTyp == 17)
                {
                    if (DateFile.instance.GetActorFeature(mianActorId, false).Contains(5002))
                    {
                        num += 0.2f;
                    }
                    int num2 = int.Parse(DateFile.instance.gongFaDate[BuildingWindow.instance.levelUPSkillId][3]);
                    if (num2 > 0)
                    {
                        int gangPartValue = DateFile.instance.GetGangPartValue(num2);
                        if (gangPartValue >= 600)
                        {
                            num += 0.2f;
                        }
                        if (gangPartValue >= 800)
                        {
                            num += 0.2f;
                        }
                    }
                    num += (float)DateFile.instance.addGongFaStudyValue / 100f;
                }
                else
                {
                    if (DateFile.instance.GetActorFeature(mianActorId, false).Contains(5001))
                    {
                        num += 0.2f;
                    }
                    num += (float)DateFile.instance.addSkillStudyValue / 100f;
                }
                int num3 = Main.BuildingWindow_StartStudyGongFa_Hook.MyGetMaxStudyTurn();

                if (Main.settings.dangerousBreak)
                {
                    num3 += 2;
                    float largeSize = BattleSystem.instance.largeSize;
                    BattleSystem.instance.SetRealDamage(true, 1, 15, 200, mianActorId, largeSize, false, 0);
                }
                int num4 = (int)((float)num3 * UnityEngine.Random.Range(num - 0.2f, num + 0.2f));

                DateFile.instance.ChangeGongfaExp(-BuildingWindow.instance.useValue, true);
                if (BuildingWindow.instance.studySkillTyp == 17)
                {
                    GEvent.OnEvent(eEvents.GongfaBreakthroughBuffChange, Array.Empty <object>());
                    DateFile.instance.ChangeActorGongFa(mianActorId, BuildingWindow.instance.levelUPSkillId, num4, 0, 0, false);
                }
                else
                {
                    GEvent.OnEvent(eEvents.SkillBreakthroughBuffChange, Array.Empty <object>());
                    DateFile.instance.ChangeMianSkill(BuildingWindow.instance.levelUPSkillId, num4, 0, false);
                }
                BuildingWindow.instance.UpdateStudySkillWindow();
                BuildingWindow.instance.UpdateLevelUPSkillWindow();
                BuildingWindow.instance.UpdateReadBookWindow();
                return(false);
            }