Example #1
0
    public override bool OnHeartbeat(GameObject attachee, GameObject triggerer)
    {
        var c_time = Council.council_time();

        if ((attachee.GetMap() == 5048 && ScriptDaemon.get_v(435) != 0 && c_time == 1))
        {
            // Townhall
            if (ScriptDaemon.get_v(435) == 1)
            {
                ScriptDaemon.set_v(435, 3);
                Council_Script(attachee, triggerer);
            }
        }

        if ((attachee.GetMap() == 5048))
        {
            // Townhall
            if ((ScriptDaemon.get_v(436) == 3 && ScriptDaemon.get_v(435) < 4))
            {
                // you've found the trap, initiate dialogue with rufus to GTFO
                foreach (var npc in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
                {
                    if ((npc.GetNameId() == 8071))
                    {
                        SelectedPartyLeader.BeginDialog(npc, 2000);
                    }
                }
            }
        }

        return(RunDefault);
    }
Example #2
0
        private static Council getCouncil <T>() where T : DatahubDataObj
        {
            string  name    = typeof(T).Name;
            Council council = new Council();

            switch (name)
            {
            case "DatahubDataAberdeen":
                council.referenceCode = "S12000033";
                council.name          = "Aberdeen City";
                council.entity        = new AberdeenSummary();
                break;

            case "DatahubDataGlasgow":
                council.referenceCode = "S12000046";
                council.name          = "Glasgow City";
                council.entity        = new GlasgowSummary();
                break;

            case "DatahubDataAberdeenshire":
                council.referenceCode = "S12000034";
                council.name          = "Aberdeenshire";
                council.entity        = new AberdeenshireSummary();
                break;

            default:
                council = null;
                break;
            }
            return(council);
        }
Example #3
0
        public IHttpActionResult PutCouncil(int id, Council council)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != council.Councils_id)
            {
                return(BadRequest());
            }

            db.Entry(council).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CouncilExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
        public static void initialPopulationForCouncil <T>(ISession session) where T : DatahubDataObj
        {
            Stopwatch stopwatch   = new Stopwatch();
            Stopwatch stopwatch_g = new Stopwatch();

            stopwatch.Start();
            stopwatch_g.Start();

            Council council = getCouncil <T>();

            Console.WriteLine("Initial population for {0}: Started", council.name);



            Console.WriteLine("Preparing data for all periods: Started");
            // Aberdeenshire

            IList <DatahubDataObj> studentDataAllPeriods = session.QueryOver <T>().Where(x => x.Current_Status != "Time Out to Travel" &&
                                                                                         x.Current_Status != "PSD (Social & Health)" && x.Current_Status != "PSD (Employability)" && x.Current_Status != "Get Ready for Work").List <DatahubDataObj>();
            // Aberdeen glasgow
            //IList<DatahubDataObj> studentDataAllPeriods = session.QueryOver<T>().List<DatahubDataObj>();

            var            monthYearList = studentDataAllPeriods.Select(x => new { x.Data_Month, x.Data_Year }).ToList().Distinct().ToList();
            IList <string> dataZonesList = session.QueryOver <DataZoneObj>().Where(x => x.Reference_Council == council.referenceCode).List().Select(x => x.Reference).ToList();
            IList <IntermediateZoneObj> intermediateZonesList = session.QueryOver <IntermediateZoneObj>().Where(x => x.Reference_Council == council.referenceCode).List();
            IList <AllSchools>          allSchoolsList        = session.QueryOver <AllSchools>().Where(x => x.referenceCouncil == council.referenceCode).List <AllSchools>();

            stopwatch.Stop();
            Console.WriteLine("Preparing data for all periods: Completed");
            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
            stopwatch.Reset();


            foreach (var period in monthYearList)
            {
                int currMonth             = period.Data_Month;
                int currYear              = period.Data_Year;
                var studentDataThisPeriod = getSubsetStudentsThisPeriod(studentDataAllPeriods, currMonth, currYear);

                switch (council.name)
                {
                case "Aberdeen City":
                    populateForSinglePeriod <T, AberdeenSummary>(session, studentDataThisPeriod, council, currMonth, currYear, intermediateZonesList, dataZonesList, allSchoolsList);
                    break;

                case "Glasgow City":
                    populateForSinglePeriod <T, GlasgowSummary>(session, studentDataThisPeriod, council, currMonth, currYear, intermediateZonesList, dataZonesList, allSchoolsList);
                    break;

                case "Aberdeenshire":
                    populateForSinglePeriod <T, AberdeenshireSummary>(session, studentDataThisPeriod, council, currMonth, currYear, intermediateZonesList, dataZonesList, allSchoolsList);
                    break;
                }
            }

            stopwatch_g.Stop();
            Console.WriteLine("Initial population for {0}: Finalized", council.name);
            Console.WriteLine("Total time elapsed: {0}", stopwatch_g.Elapsed);
        }
Example #5
0
        public IHttpActionResult GetCouncil(int id)
        {
            Council council = db.Councils.Find(id);

            if (council == null)
            {
                return(NotFound());
            }

            return(Ok(council));
        }
Example #6
0
        public IActionResult GetBadges(
            [FromHeader(Name = "conference_id")] int conference_id,
            [FromHeader(Name = "jwttoken")] string jwttoken,
            [FromQuery] string apikey)
        {
            // Permission Level Admin
            if (this.jwtService.PermissionLevelValid(jwttoken, "user") && this.auth.KeyIsValid(apikey, conference_id))
            {
                List <BadgeExport> badgeExport = new List <BadgeExport>();

                List <Conference_Application> attendees = this._context.Conference_Application.Where(ca => ca.ConferenceID == conference_id &&
                                                                                                     ca.Status == "IsAttendee" &&
                                                                                                     ca.Invalid == false).ToList();
                foreach (Conference_Application attendee in attendees)
                {
                    User    currUser    = this._context.User.FindAsync(attendee.ApplicantUID).Result;
                    Council currCouncil = this._context.Council.FindAsync(currUser.CouncilID).Result;
                    List <Workshop_Application> currWorkshops = this._context.Workshop_Application.Where(wa => wa.ApplicantUID == currUser.UID && wa.Status == "IsAttendee").ToList();
                    List <WorkshopExport>       workshops     = new List <WorkshopExport>();
                    foreach (Workshop_Application currWorkshop in currWorkshops)
                    {
                        Workshop       ws = this._context.Workshop.Find(currWorkshop.WorkshopID);
                        WorkshopExport we = new WorkshopExport
                        {
                            Workshop_ID = currWorkshop.WorkshopID,
                            Name        = ws.NameShort,
                            Start       = ws.Start,
                            Place       = ws.Place
                        };
                        workshops.Add(we);
                    }

                    BadgeExport be = new BadgeExport
                    {
                        UID            = currUser.UID,
                        Name           = currUser.Name,
                        Surname        = currUser.Surname,
                        CouncilID      = currCouncil.CouncilID,
                        CouncilName    = currCouncil.NameShort,
                        University     = currCouncil.UniversityShort,
                        IsHelper       = attendee.IsHelper,
                        IsBuFaKCouncil = attendee.IsBuFaKCouncil,
                        IsAlumnus      = attendee.IsAlumnus,
                        Workshops      = workshops != null ? workshops : null
                    };
                    badgeExport.Add(be);
                }

                return(this.Ok(badgeExport));
            }

            return(this.Unauthorized());
        }
Example #7
0
        public IHttpActionResult DeleteCouncil(int id)
        {
            Council council = db.Councils.Find(id);

            if (council == null)
            {
                return(NotFound());
            }

            db.Councils.Remove(council);
            db.SaveChanges();

            return(Ok(council));
        }
Example #8
0
        public Professional(int code, string name, string photo, DateTime?hiringDate, DateTime?firingDate,
                            Council council, IList <Phone> phones, IList <Procedure> procedures, bool active = true)
        {
            Code       = code;
            Name       = name;
            Photo      = photo;
            HiringDate = hiringDate;
            FiringDate = firingDate;
            Council    = council;
            Phones     = phones ?? new List <Phone>();
            Procedures = procedures ?? new List <Procedure>();
            Active     = active;

            Validate();
        }
Example #9
0
        public IActionResult AddNewCouncil([FromBody] Council council)
        {
            if (!council.Id.HasValue)
            {
                council.Id = Guid.NewGuid();

                _bucket.Upsert(council.Id.ToString(), new
                {
                    council.UserId,
                    council.Name,
                    council.PhysicalAddress,
                    council.DateCreated,
                    Type = "Council"
                });
            }
            return(Ok(council));
        }
Example #10
0
        public async Task <IActionResult> PutCouncil(
            [FromRoute] int id,
            [FromBody] Council council,
            [FromQuery] string apikey,
            [FromHeader] string jwttoken)
        {
            // Permission Level SuperAdmin
            if (this.jwtService.PermissionLevelValid(jwttoken, "superadmin") && this.auth.KeyIsValid(apikey))
            {
                if (!this.ModelState.IsValid)
                {
                    return(this.BadRequest(this.ModelState));
                }

                if (id != council.CouncilID)
                {
                    return(this.BadRequest());
                }

                this._context.Entry(council).State = EntityState.Modified;

                try
                {
                    await this._context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!this.CouncilExists(id))
                    {
                        return(this.NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(this.NoContent());
            }

            return(this.Unauthorized());
        }
Example #11
0
            public void SetCouncil(ChainType chainType, uint chainIndex, Council council)
            {
                if (chainType == ChainType.Core || chainType == ChainType.Service)
                {
                    _serviceCouncil = council;
                    return;
                }
                else if (chainType == ChainType.Data)
                {
                    _dataCouncils[chainIndex] = council;
                    return;
                }
                else if (chainType == ChainType.Maintain)
                {
                    _maintainCouncil = council;
                    return;
                }

                throw new ArgumentException("Invalid chain type", nameof(chainType));
            }
Example #12
0
        public async Task <IActionResult> PostCouncil(
            [FromBody] Council council,
            [FromQuery] string apikey,
            [FromHeader] string jwttoken)
        {
            // Permission Level SuperAdmin
            if (this.jwtService.PermissionLevelValid(jwttoken, "superadmin") && this.auth.KeyIsValid(apikey))
            {
                if (!this.ModelState.IsValid)
                {
                    return(this.BadRequest(this.ModelState));
                }

                this._context.Council.Add(council);
                await this._context.SaveChangesAsync();

                return(this.CreatedAtAction("GetCouncil", new { id = council.CouncilID }, council));
            }

            return(this.Unauthorized());
        }
Example #13
0
        public static void populateForSinglePeriod <T, U>(ISession session, IList <DatahubDataObj> studentDataThisPeriod, Council council, int currMonth, int currYear, IList <IntermediateZoneObj> intermediateZonesList, IList <string> dataZonesList, IList <AllSchools> schoolsList)
            where T : DatahubDataObj
            where U : SummaryData, new()
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            Console.WriteLine("Populating data for {0}: Current period: {1},{2}", council.name, currMonth, currYear);
            Console.WriteLine("Generating summary data and saving to session for whole council: Started", council.name);
            U entity = CalculateSummaryData <U>(new U(), studentDataThisPeriod, council.referenceCode, council.name, "Council", currMonth, currYear);

            session.Save(entity);

            stopwatch.Stop();
            Console.WriteLine("Generating summary data and saving to session for whole council: Completed");
            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
            stopwatch.Reset();

            // Calculate intermediate zones summary
            stopwatch.Start();
            Console.WriteLine("Generating summary data and saving to session for {0} intermediate zones: Started", intermediateZonesList.Count());
            foreach (IntermediateZoneObj intZone in intermediateZonesList)
            {
                var allIntermediateZoneStudentsThisPeriod = getSubsetStudentsByZone(session, studentDataThisPeriod, "Intermediate Zone", intZone.Reference);
                U   currSummary = CalculateSummaryData <U>(new U(), allIntermediateZoneStudentsThisPeriod, intZone.Reference, intZone.Name, "Intermediate Zone", currMonth, currYear);
                session.Save(currSummary);
            }

            stopwatch.Stop();
            Console.WriteLine("Generating summary data and saving to session for intermediate zones: Completed");
            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
            stopwatch.Reset();

            // Calculate data zones summary
            stopwatch.Start();
            Console.WriteLine("Generating summary data and saving to session for {0} data zones: Started", dataZonesList.Count);
            foreach (string zonecode in dataZonesList)
            {
                var allIntermediateZoneStudentsThisPeriod = getSubsetStudentsByZone(session, studentDataThisPeriod, "Data Zone", zonecode);
                U   currSummary = CalculateSummaryData <U>(new U(), allIntermediateZoneStudentsThisPeriod, zonecode, zonecode, "Data Zone", currMonth, currYear);
                session.Save(currSummary);
            }

            stopwatch.Stop();
            Console.WriteLine("Generating summary data and saving to session for data zones: Completed");
            Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
            stopwatch.Reset();

            // Calculate all schools summary
            stopwatch.Start();
            Console.WriteLine("Generating summary data and saving to session for {0} schools: Started", schoolsList.Count());
            foreach (AllSchools school in schoolsList)
            {
                var allSchoolStudentsThisPeriod = getSubsetStudentsBySchool(studentDataThisPeriod, school.seedCode);
                U   currSummary = CalculateSummaryData <U>(new U(), allSchoolStudentsThisPeriod, school.seedCode, school.name, "School", currMonth, currYear);
                session.Save(currSummary);
            }
            //    stopwatch.Stop();
            //    Console.WriteLine("Generating summary data and saving to session for schools: Completed");
            //    Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed);
            //    stopwatch.Reset();
        }
    // EVERYTHING BELOW HAS TO DO WITH SITRA'S RANNOS AND GREMAG MOD AS FAR AS I KNOW #

    public static int council_heartbeat(GameObject attachee)
    {
        var c_time = Council.council_time();

        // 1 - between 22:00 and 22:30 on council day
        // 2 - between 22:30 and 23:00
        // 3 - between 19:00 and 22:00
        // 4 - after council events ( >23:00 and beyond that day), but without ordinary council
        // 5 - ordinary council time
        // 0 - otherwise
        if (Council.traders_awol() == 1)
        {
            ScriptDaemon.set_v(435, 6);
        }

        if (c_time == 5)
        {
            ScriptDaemon.set_v(440, 1);
        }
        else if (c_time == 1)
        {
            if (ScriptDaemon.get_v(435) == 1)
            {
                ScriptDaemon.set_v(435, 3);
            }
            else if (ScriptDaemon.get_v(435) >= 5 || ScriptDaemon.get_v(435) == 0 && ScriptDaemon.get_v(440) == 0)
            {
                ScriptDaemon.set_v(440, 1);
            }
            else if (ScriptDaemon.get_v(435) == 4)
            {
                // council_events()
                var dummy = 1;
            }
        }
        else if (c_time == 2)
        {
            if (ScriptDaemon.get_v(435) == 3 || ScriptDaemon.get_v(435) == 1)
            {
                ScriptDaemon.set_v(435, 4);
                ScriptDaemon.set_v(436, 1);
                SetGlobalFlag(432, true);
            }
        }
        // council_events()
        else if (c_time == 3)
        {
            if (ScriptDaemon.get_v(435) == 2)
            {
                ScriptDaemon.set_v(435, 5);
                ScriptDaemon.set_v(436, 5);
                SetGlobalVar(750, 3);
                SetGlobalVar(751, 3);
                if ((!PartyLeader.HasReputation(23) && (!GetGlobalFlag(814) || !GetGlobalFlag(815))))
                {
                    PartyLeader.AddReputation(23);
                }
            }
        }
        else if ((c_time == 0 || c_time == 4))
        {
            if (c_time == 0 && GetGlobalFlag(336) && (ScriptDaemon.get_v(435) == 1 || ScriptDaemon.get_v(435) == 2))
            {
                ScriptDaemon.set_v(435, 0);
            }
            else if (ScriptDaemon.get_v(435) == 3 || ScriptDaemon.get_v(435) == 4 || (ScriptDaemon.get_v(435) == 1 && c_time == 4))
            {
                // chiefly used for the case where the whole thing played out without you
                if (ScriptDaemon.get_v(436) == 0)
                {
                    ScriptDaemon.set_v(436, 1);
                }

                ScriptDaemon.set_v(435, 5);
                if ((!PartyLeader.HasReputation(23) && (!GetGlobalFlag(814) || !GetGlobalFlag(815))))
                {
                    PartyLeader.AddReputation(23);
                }
            }

            if (!ScriptDaemon.npc_get(attachee, 10) && attachee.GetMap() == 5001 && c_time == 4)
            {
                hommletans_go_home();
                ScriptDaemon.npc_set(attachee, 10);
            }

            if (ScriptDaemon.get_v(435) == 2 && c_time == 4)
            {
                ScriptDaemon.set_v(435, 5);
                ScriptDaemon.set_v(436, 5);
                SetGlobalVar(750, 3);
                SetGlobalVar(751, 3);
                if ((!PartyLeader.HasReputation(23) && (!GetGlobalFlag(814) || !GetGlobalFlag(815))))
                {
                    PartyLeader.AddReputation(23);
                }
            }

            ScriptDaemon.set_v(440, 0);
        }

        return(1);
    }
    public override bool OnFirstHeartbeat(GameObject attachee, GameObject triggerer)
    {
        if ((attachee.GetMap() == 5049))
        {
            // stonemason
            var a = attachee.GetInt(obj_f.npc_pad_i_5);
            if ((ScriptDaemon.get_v(435) == 5 && ScriptDaemon.get_v(436) != 5 && ScriptDaemon.get_v(436) != 8))
            {
                foreach (var npc in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
                {
                    if (((npc.GetNameId() == 14801 || npc.GetNameId() == 14039) && npc.GetLeader() == null))
                    {
                        npc.Destroy();
                    }
                }
            }
            else if ((ScriptDaemon.get_v(435) == 4 && a == 0))
            {
                attachee.SetInt(obj_f.npc_pad_i_5, 1);
                GameObject gister = null;
                foreach (var npc in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_NPC))
                {
                    if (npc.GetNameId() == 14039)
                    {
                        gister = npc;
                    }
                }

                var bad1 = GameSystems.MapObject.CreateObject(14801, new locXY(471, 485));
                bad1.Move(new locXY(471, 485), 0f, 0f);
                bad1.Rotation = 4;
                var bad2 = GameSystems.MapObject.CreateObject(14801, new locXY(474, 481));
                bad2.Move(new locXY(474, 481), 0f, 0f);
                bad2.Rotation = 3.5f;
                var bad3 = GameSystems.MapObject.CreateObject(14801, new locXY(473, 483));
                bad3.Move(new locXY(473, 483), 7f, 0f);
                bad3.Rotation = 3.9f;
                heavily_damage(gister);
                StartTimer(200, () => proactivity(bad3, 400));
            }
        }
        else if (attachee.GetMap() == 5009)
        {
            // traders' barn
            var ggv435 = ScriptDaemon.get_v(435);
            AttachParticles("sp-Bless Water", attachee);
            Council.council_heartbeat();
            var a = attachee.GetInt(obj_f.npc_pad_i_3);
            if ((ggv435 >= 3 || (ggv435 == 2 && Council.council_time() == 3)) && (a & 1) == 0)
            {
                a = a | 1;
                ScriptDaemon.npc_set(attachee, 1);
                var courier = Utilities.find_npc_near(attachee, 14063);
                courier.Destroy();
                if (GetQuestState(17) == QuestState.Mentioned || GetQuestState(17) == QuestState.Accepted)
                {
                    SetQuestState(17, QuestState.Botched);
                }
            }

            if ((a & 2) == 0 && (GetGlobalFlag(438)) && !(GetGlobalFlag(814) && GetGlobalFlag(815)))
            {
                a = a | 2;
                ScriptDaemon.npc_set(attachee, 2);
                var        badger = GameSystems.MapObject.CreateObject(14371, new locXY(493, 487));
                GameObject pc     = null;
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((obj.DistanceTo(badger) <= 25 && !Utilities.critter_is_unconscious(obj)))
                    {
                        pc = obj;
                    }
                }

                pc?.BeginDialog(badger, 5000);
            }
        }
        else if (attachee.GetMap() == 5051 && ScriptDaemon.get_v(437) == 100)
        {
            // Nulb exterior
            AttachParticles("sp-Bless Water", attachee);
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
            {
                if ((obj.DistanceTo(attachee) <= 25 && !Utilities.critter_is_unconscious(obj)))
                {
                    DetachScript();
                    obj.BeginDialog(attachee, 2000);
                }
            }
        }
        else if (attachee.GetMap() == 5007)
        {
            // Inn, first floor
            var ggv435 = ScriptDaemon.get_v(435);
            var c      = attachee.GetInt(obj_f.npc_pad_i_3);
            // c & 1 - spawned mickey
            // c & 2 - Glora, the new innkeeper
            // c & 4 - switched gundigoot off
            // c & 8 - destroyed gundigoot
            // c & 16 - switched Turuko off (since you killed him)
            // c & 32 - switched Kobort off (since you killed him)
            AttachParticles("sp-Bless Water", attachee);
            var c_time = Council.council_time();
            Council.council_heartbeat();
            if (GetGlobalFlag(45) && (c & 16) == 0)
            {
                c = c | 16;
                ScriptDaemon.npc_set(attachee, 5);
                var turuko = Utilities.find_npc_near(attachee, 8004);
                if (turuko != null)
                {
                    turuko.Destroy();
                }
            }

            if (GetGlobalFlag(44) && (c & 32) == 0)
            {
                c = c | 32;
                ScriptDaemon.npc_set(attachee, 6);
                var kobort = Utilities.find_npc_near(attachee, 8005);
                if (kobort != null)
                {
                    kobort.Destroy();
                    AttachParticles("orb-summon-water-elemental", GameSystems.Party.GetPartyGroupMemberN(1));
                }
            }

            if ((c & 1) == 0)
            {
                c = c | 1;
                ScriptDaemon.npc_set(attachee, 1);
                var mecr = GameSystems.MapObject.CreateObject(14637, new locXY(475, 475));
                mecr.Rotation = 2.5f;
                mecr.SetObjectFlag(ObjectFlag.OFF);
            }

            if ((c & 2) == 0 && (GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7))
            {
                c = c | 2;
                ScriptDaemon.npc_set(attachee, 2);
                var glora = Utilities.find_npc_near(attachee, 14100);
                if (glora != null)
                {
                    glora.SetStandpoint(StandPointType.Day, 340);
                    glora.SetStandpoint(StandPointType.Night, 340);
                    glora.Rotation = 5f;
                }
            }

            if ((c_time == 1 || c_time == 2 || c_time == 5) && ((c & 4) == 0 || Utilities.find_npc_near(attachee, 8008) != null) && (c & 8) == 0)
            {
                c = c | 4;
                ScriptDaemon.npc_set(attachee, 3);
                var gundi = Utilities.find_npc_near(attachee, 8008);
                if (GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7)
                {
                    gundi.Destroy();
                    c = c | 8;
                    ScriptDaemon.npc_set(attachee, 4);
                }
                else
                {
                    // gundi.move(location_from_axis(476,445),0.0,0.0)
                    gundi.SetScriptId(ObjScriptEvent.FirstHeartbeat, 73);
                    gundi.SetScriptId(ObjScriptEvent.Heartbeat, 73);
                    gundi.SetObjectFlag(ObjectFlag.OFF);
                }
            }
            else if ((c & 4) == 4 && (c & 8) == 0 && c_time != 1 && c_time != 2 && c_time != 5)
            {
                var gundi = Utilities.find_npc_near(attachee, 8008);
                if ((GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7) && gundi != null)
                {
                    gundi.Destroy();
                    c = c | 8;
                    c = c - 4;
                    attachee.SetInt(obj_f.npc_pad_i_3, c);
                }
                else if (gundi != null)
                {
                    gundi.RemoveScript(ObjScriptEvent.FirstHeartbeat);
                    gundi.RemoveScript(ObjScriptEvent.Heartbeat);
                }
            }
        }
        else if (attachee.GetMap() == 5063)
        {
            // The Renton Residence (village militia captain)
            AttachParticles("orb-summon-water-elemental", attachee);
            var c_time = Council.council_time();
            Council.council_heartbeat();
            if ((c_time == 1 || c_time == 2 || c_time == 5) && Utilities.find_npc_near(attachee, 20007) != null)
            {
                var renton = Utilities.find_npc_near(attachee, 20007);
                renton.SetScriptId(ObjScriptEvent.FirstHeartbeat, 6);
                renton.SetScriptId(ObjScriptEvent.Heartbeat, 6);
                renton.SetObjectFlag(ObjectFlag.OFF);
            }
        }

        return(SkipDefault);
    }
    public override bool OnHeartbeat(GameObject attachee, GameObject triggerer)
    {
        var c = attachee.GetInt(obj_f.npc_pad_i_3);

        if (attachee.GetMap() == 5001)
        {
            // Hommlet exterior
            AttachParticles("sp-Bless Water", attachee);
            if ((c & 1) == 0 && GetGlobalVar(435) == 4)
            {
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((obj.DistanceTo(attachee) <= 25 && !Utilities.critter_is_unconscious(obj)))
                    {
                        c = c | 1;
                        attachee.SetInt(obj_f.npc_pad_i_3, c);
                        var a = trail_check();
                        SetGlobalVar(437, a);
                        if ((a == 1))
                        {
                            obj.BeginDialog(attachee, 1);
                        }
                        else if ((a == 2))
                        {
                            obj.BeginDialog(attachee, 100);
                        }
                        else if ((a == 3))
                        {
                            obj.BeginDialog(attachee, 200);
                        }
                        else if ((a == 50))
                        {
                            obj.BeginDialog(attachee, 500);
                        }
                        else if ((a == 60))
                        {
                            obj.BeginDialog(attachee, 600);
                        }
                        else if ((a == 65))
                        {
                            obj.BeginDialog(attachee, 650);
                        }
                        else
                        {
                            obj.BeginDialog(attachee, 700);
                        }
                    }
                }
            }
            else if ((c & 2) == 2)
            {
                c = c - 2;
                attachee.SetInt(obj_f.npc_pad_i_3, c);
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((obj.DistanceTo(attachee) <= 25 && !Utilities.critter_is_unconscious(obj)))
                    {
                        obj.BeginDialog(attachee, 710);
                    }
                }
            }
            else if ((c & 4) == 4)
            {
                c = c - 4;
                attachee.SetInt(obj_f.npc_pad_i_3, c);
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((obj.DistanceTo(attachee) <= 25 && !Utilities.critter_is_unconscious(obj)))
                    {
                        obj.BeginDialog(attachee, 620);
                    }
                }
            }
        }
        else if (attachee.GetMap() == 5007)
        {
            // Inn, first floor
            // c & 1 - spawned mickey
            // c & 2 - Glora, the new innkeeper
            // c & 4 - switched gundigoot off
            AttachParticles("sp-Bless Water", attachee);
            var c_time = Council.council_time();
            Council.council_heartbeat();
            if ((c & 2) == 0 && (GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7))
            {
                c = c | 2;
                attachee.SetInt(obj_f.npc_pad_i_3, c);
                var glora = Utilities.find_npc_near(attachee, 14100);
                if (glora != null)
                {
                    glora.SetStandpoint(StandPointType.Day, 340);
                    glora.SetStandpoint(StandPointType.Night, 340);
                    glora.Rotation = 5f;
                }
            }
            else if ((c_time == 1 || c_time == 2 || c_time == 5) && ((c & 4) == 0 || Utilities.find_npc_near(attachee, 8008) != null) && (c & 8) == 0)
            {
                c = c | 4;
                attachee.SetInt(obj_f.npc_pad_i_3, c);
                var gundi = Utilities.find_npc_near(attachee, 8008);
                if (GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7)
                {
                    gundi.Destroy();
                    c = c | 8;
                    attachee.SetInt(obj_f.npc_pad_i_3, c);
                }
                else
                {
                    // gundi.move(location_from_axis(476,445),0.0,0.0)
                    gundi.SetScriptId(ObjScriptEvent.FirstHeartbeat, 73);
                    gundi.SetScriptId(ObjScriptEvent.Heartbeat, 73);
                    gundi.SetObjectFlag(ObjectFlag.OFF);
                }
            }
            else if ((c & 4) == 4 && (c & 8) == 0 && c_time != 1 && c_time != 2 && c_time != 5)
            {
                var gundi = Utilities.find_npc_near(attachee, 8008);
                if ((GetGlobalVar(436) == 6 || GetGlobalVar(436) == 7) && gundi != null)
                {
                    gundi.Destroy();
                    c = c | 8;
                    c = c - 4;
                    attachee.SetInt(obj_f.npc_pad_i_3, c);
                }
                else if (gundi != null)
                {
                    gundi.RemoveScript(ObjScriptEvent.FirstHeartbeat);
                    gundi.RemoveScript(ObjScriptEvent.Heartbeat);
                }
            }
        }
        else if (attachee.GetMap() == 5051 && GetGlobalVar(437) == 100)
        {
            // Nulb exterior
            AttachParticles("sp-Bless Water", attachee);
            foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
            {
                if ((obj.DistanceTo(attachee) <= 25 && !Utilities.critter_is_unconscious(obj)))
                {
                    DetachScript();
                    obj.BeginDialog(attachee, 2000);
                }
            }
        }
        else if (attachee.GetMap() == 5009)
        {
            // traders' barn
            AttachParticles("sp-Bless Water", attachee);
            Council.council_heartbeat();
            var a = attachee.GetInt(obj_f.npc_pad_i_3);
            if ((GetGlobalVar(435) >= 3 || (GetGlobalVar(435) == 2 && Council.council_time() == 3)) && (a & 1) == 0)
            {
                a = a | 1;
                ScriptDaemon.npc_set(attachee, 1);
                var courier = Utilities.find_npc_near(attachee, 14063);
                courier.Destroy();
                if (GetQuestState(17) == QuestState.Mentioned || GetQuestState(17) == QuestState.Accepted)
                {
                    SetQuestState(17, QuestState.Botched);
                }
            }

            if ((a & 2) == 0 && (GetGlobalFlag(438)) && !(GetGlobalFlag(814) && GetGlobalFlag(815)))
            {
                a = a | 2;
                ScriptDaemon.npc_set(attachee, 2);
                var        badger = GameSystems.MapObject.CreateObject(14371, new locXY(493, 487));
                GameObject pc     = null;
                foreach (var obj in ObjList.ListVicinity(attachee.GetLocation(), ObjectListFilter.OLC_PC))
                {
                    if ((obj.DistanceTo(badger) <= 25 && !Utilities.critter_is_unconscious(obj)))
                    {
                        pc = obj;
                    }
                }

                pc?.BeginDialog(badger, 5000);
            }
        }
        else if (attachee.GetMap() == 5063)
        {
            // The Renton Residence (village militia captain)
            AttachParticles("orb-summon-water-elemental", attachee);
            var c_time = Council.council_time();
            Council.council_heartbeat();
            if ((c_time == 1 || c_time == 2 || c_time == 5) && Utilities.find_npc_near(attachee, 20007) != null)
            {
                var renton = Utilities.find_npc_near(attachee, 20007);
                renton.SetScriptId(ObjScriptEvent.FirstHeartbeat, 6);
                renton.SetScriptId(ObjScriptEvent.Heartbeat, 6);
                renton.SetObjectFlag(ObjectFlag.OFF);
            }
        }

        return(RunDefault);
    }