public void DeactivateRandomModule()
    {
        ShipModule shipModule = shipParts[(int)UnityEngine.Random.Range(0, shipParts.Count - 0.01f)];

        shipModule.DeactivateModule();
        disableShipParts.Add(shipModule);
    }
Exemple #2
0
 public ModuleJob(ShipModule parent, Jobtype type, int numSlots)
 {
     this.numSlots = numSlots;
     this.parent   = parent;
     this.type     = type;
     assignments   = new List <JobAssignment>(numSlots);
 }
Exemple #3
0
        protected override void GenerateModule(DropManager dropManager, ShipModelSlotType slotType)
        {
            //base.GenerateModule(dropManager, slotType);

            bool success = false;

            if (m_Data != null)
            {
                if (m_Data.moduleList.ContainsKey(slotType))
                {
                    ModuleGenList gen;
                    if (m_Data.moduleList.TryGetValue(slotType, out gen))
                    {
                        ShipModule prevModule;
                        ShipModule module = new ShipModule(gen);
                        shipModel.SetModule(module, out prevModule);
                        success = true;
                        s_Log.InfoFormat("Special Ship {0} generate success".Magenta(), slotType);
                    }
                }
                else
                {
                    s_Log.InfoFormat("Special Ship data module list invalid".Magenta());
                }
            }
            else
            {
                s_Log.Info("Special Ship data is null".Magenta());
            }
            if (!success)
            {
                base.GenerateModule(dropManager, slotType);
            }
        }
Exemple #4
0
        public JournalLoadout(JObject evt) : base(evt, JournalTypeEnum.Loadout)
        {
            Ship      = JournalFieldNaming.GetBetterShipName(evt["Ship"].Str());
            ShipFD    = JournalFieldNaming.NormaliseFDShipName(evt["Ship"].Str());
            ShipId    = evt["ShipID"].Int();
            ShipName  = evt["ShipName"].Str();
            ShipIdent = evt["ShipIdent"].Str();

            ShipModules = new List <ShipModule>();

            JArray jmodules = (JArray)evt["Modules"];

            if (jmodules != null)       // paranoia
            {
                foreach (JObject jo in jmodules)
                {
                    ShipModule module = new ShipModule(JournalFieldNaming.GetBetterSlotName(jo["Slot"].Str()),
                                                       JournalFieldNaming.NormaliseFDSlotName(jo["Slot"].Str()),
                                                       JournalFieldNaming.GetBetterItemNameLoadout(jo["Item"].Str()),
                                                       JournalFieldNaming.NormaliseFDItemName(jo["Item"].Str()),
                                                       jo["On"].BoolNull(),
                                                       jo["Priority"].IntNull(),
                                                       jo["AmmoInClip"].IntNull(),
                                                       jo["AmmoInHopper"].IntNull(),
                                                       jo["EngineerBlueprint"].Str().SplitCapsWordFull(),
                                                       jo["EngineerLevel"].IntNull(),
                                                       jo["Health"].DoubleNull(),
                                                       jo["Value"].IntNull());
                    ShipModules.Add(module);
                }

                ShipModules = ShipModules.OrderBy(x => x.Slot).ToList();            // sort for presentation..
            }
        }
    void ConnectModule(ModuleSlot slot)
    {
        Rigidbody rb = heldObject.GetComponent <Rigidbody>();

        SceneManager.instance.RemoveGravityBody(rb);
        Destroy(rb);

        heldObject.transform.SetParent(slot.transform);

        ShipModule currentModule = heldObject.GetComponent <ShipModule>();

        slot.connectedModule    = currentModule;
        currentModule.connected = true;

        slot.GetComponent <MeshRenderer>().enabled = false;
        assignedSlot = null;

        Ship ship = slot.GetComponentInParent <Ship>();

        if (ship)
        {
            ship.UpdateModuleStatus(currentModule, currentModule.moduleType, true);
            currentModule.shipRB = ship.GetComponent <Rigidbody>();
        }

        FindObjectOfType <Ship>().ToggleModuleSlots(false);

        heldObject = null;

        PlayerHUD.instance.ToggleCrosshair(true);
        PlayerCamera.instance.checkForUsable         = true;
        PlayerCamera.instance.checkForMaterializable = true;

        energyParticles.Stop();
    }
Exemple #6
0
    public void ReplaceIndexedBonus(ShipModule module, int boostPoints1, int boostPoints2, int idx)
    {
        ParameterBonus bonus = new ParameterBonus(module, boostPoints1, boostPoints2);

        indexedBonuses[idx] = bonus;
        CalculateParameters();
    }
    public void addModule(ShipModule mod)
    {
        mods = mods ?? new List <ShipModStatus>();
        ShipModStatus modstat = new ShipModStatus(mod);

        mods.Add(modstat);
    }
    void GrabObject(GameObject gameObject)
    {
        heldObject = gameObject;

        ShipModule currentModule = gameObject.GetComponent <ShipModule>();

        if (currentModule)
        {
            if (currentModule.connected)
            {
                DisconnectModule(gameObject.GetComponentInParent <ModuleSlot>());
                currentModule.shipRB = null;
                Ship ship = currentModule.GetComponentInParent <Ship>();
                if (ship)
                {
                    ship.UpdateModuleStatus(currentModule, currentModule.moduleType, false);
                }
            }

            FindObjectOfType <Ship>().ToggleModuleSlots(true);
        }

        gameObject.transform.parent = transform;

        gameObject.GetComponent <IMaterializeable>().Dematerialize(dematMaterial);

        PlayerHUD.instance.ToggleCrosshair(false);
        PlayerHUD.instance.ToggleUsePrompt(false);
        PlayerHUD.instance.ToggleDematPrompt(false);
        PlayerCamera.instance.checkForUsable         = false;
        PlayerCamera.instance.checkForMaterializable = false;

        energyParticles.Play();
    }
    public void Save()
    {
        string q;

        if (Id == 0)
        {
            if (ModuleCode == Guid.Empty)
            {
                q  = $@"
                INSERT INTO players_modules(player_id) VALUES(0)
                SELECT @@IDENTITY AS Result";
                Id = DataConnection.GetResultInt(q);
            }
            else
            {
                Id = ShipModule.ModuleIdByGuid(ModuleCode);
                if (Id == 0)
                {
                    return;
                }
            }
        }

        q = $@"UPDATE players_modules SET 
                player_id = {PlayerId},
                module_id = {ModuleTypeId},
                experience = {Experience},
                module_level = {ModuleLevel},
                rig_id = {RigSlotId},
                module_code = CAST('{ModuleCode.ToString()}' AS uniqueidentifier)
            WHERE
                id = {Id}";
        DataConnection.Execute(q);
    }
Exemple #10
0
        public void OnModuleCrafted(ShipModule module)
        {
            logger.Info($"{LOG_TAG}: module crafted {module.SlotType}");

            CraftedModule = new CraftedModule(module.SlotType, module.Level, module.Color);

            if (startedQuests.Count > 0)
            {
                bool needTryComplete = false;
                foreach (var quest in startedQuests)
                {
                    QuestConditionCollection conditions = null;
                    if (quest.Data.TryGetCompleteConditions(PlayerRace, out conditions))
                    {
                        if (conditions.HasCondition <ModuleCraftedQuestCondition>())
                        {
                            needTryComplete = true;
                        }
                    }
                }

                if (needTryComplete)
                {
                    TryCompleteQuest(sendUpdate: true);
                }
            }
        }
Exemple #11
0
    IEnumerator PrintPart(GameObject shipModule)
    {
        foreach (ParticleSystem particleSystem in printParticles)
        {
            particleSystem.Play();
        }
        yield return(new WaitForSeconds(0.2f));

        newPart = Instantiate(shipModule, printPoint.position, printPoint.rotation).GetComponent <ShipModule>();
        SceneManager.instance.AddGravityBody(newPart.GetComponent <Rigidbody>());
        newPart.Dematerialize(PartPrinterData.instance.printMaterial);
        meshRenderer = newPart.GetComponent <MeshRenderer>();
        SetPartOpacity(partOpacity);
        yield return(new WaitForSeconds(PartPrinterData.instance.printTime));

        foreach (ParticleSystem particleSystem in printParticles)
        {
            particleSystem.Stop();
        }
        yield return(new WaitForSeconds(0.2f));

        newPart.Materialize();
        newPart     = null;
        partOpacity = 0f;
    }
Exemple #12
0
 public ModuleService(ShipModule parent, Servicetype type, int numSlots)
 {
     this.numSlots = numSlots;
     this.parent   = parent;
     this.type     = type;
     assignments   = new List <ServiceAssignment>(numSlots);
 }
Exemple #13
0
        public void Rescan(JObject evt)
        {
            ShipModules = new List <ShipModule>();

            JArray jmodules = (JArray)evt["Modules"];

            if (jmodules != null)
            {
                foreach (JObject jo in jmodules)
                {
                    string slotfdname = JournalFieldNaming.NormaliseFDSlotName(jo["Slot"].Str());
                    string itemfdname = JournalFieldNaming.NormaliseFDItemName(jo["Item"].Str());

                    ShipModule module = new ShipModule(
                        JournalFieldNaming.GetBetterSlotName(slotfdname),
                        slotfdname,
                        JournalFieldNaming.GetBetterItemName(itemfdname),
                        itemfdname,
                        null,                                // unknown
                        jo["Priority"].IntNull(),
                        null,                                // aclip
                        null,                                // ahooper
                        null,                                // health
                        null,                                // Value
                        jo["Power"].DoubleNull(),
                        null                                 //engineering
                        );
                    ShipModules.Add(module);
                }

                ShipModules = ShipModules.OrderBy(x => x.Slot).ToList();            // sort for presentation..
            }
        }
Exemple #14
0
        }                                                          //

        public void Set(ShipModule baseModule)
        {
            if (baseModule == null)
            {
                return;
            }

            this.ModuleId     = baseModule.Id;
            this.SlotType     = baseModule.SlotType.toByte();
            this.Level        = baseModule.Level;
            this.Name         = baseModule.Name;
            this.Workshop     = baseModule.Workshop.toByte();
            this.TemplateId   = baseModule.TemplateModuleId;
            this.Prefab       = baseModule.Prefab;
            this.HP           = baseModule.HP;
            this.Hold         = baseModule.Hold;
            this.Resist       = baseModule.commonResist;
            this.rocketResist = baseModule.rocketResist;
            this.acidResist   = baseModule.acidResist;
            this.laserResist  = baseModule.laserResist;

            this.Speed          = baseModule.Speed;
            this.DamageBonus    = baseModule.DamageBonus;
            this.Color          = baseModule.Color.toByte();
            this.Skill          = baseModule.Skill;
            this.SetID          = baseModule.Set;
            this.CritChance     = baseModule.CritChance;
            this.CritDamage     = baseModule.CritDamage;
            this.CraftMaterials = baseModule.CraftMaterials;
            this.energyBonus    = baseModule.EnergyBonus;
            this.speedBonus     = baseModule.SpeedBonus;
            this.holdBonus      = baseModule.HoldBonus;
            this.difficulty     = (int)(byte)baseModule.Difficulty;
        }
Exemple #15
0
        public ShipModel SourceObject(IRes resource)
        {
            var        model      = new ShipModel(resource);
            ShipModule prevModule = null;

            try {
                if (this.ES != null)
                {
                    model.ES.SetModule(this.ES.SourceObject(), out prevModule);
                }
                if (this.CB != null)
                {
                    model.CB.SetModule(this.CB.SourceObject(), out prevModule);
                }
                if (this.DF != null)
                {
                    model.DF.SetModule(this.DF.SourceObject(), out prevModule);
                }
                if (this.CM != null)
                {
                    model.CM.SetModule(this.CM.SourceObject(), out prevModule);
                }
                if (this.DM != null)
                {
                    model.DM.SetModule(this.DM.SourceObject(), out prevModule);
                }
            } catch (Exception ex) {
                log.Error(ex);
                log.Error(ex.StackTrace);
            }
            return(model);
        }
 void ShipModule_OnModuleDestroyed(ShipModule module)
 {
     if (targets.Contains(module.gameObject))
     {
         targets.Remove(module.gameObject);
         OnTargetStatusChanged(module.gameObject, false);
     }
 }
Exemple #17
0
 void Awake()
 {
     MyModule = GetComponentInChildren <ShipModule> ();
     if (!UnityEditor.ArrayUtility.Contains(AllowedModules, MyModule.GetType().ToString()))
     {
         Debug.Log("Module mismatch: " + MyModule.GetType().ToString());
     }
 }
Exemple #18
0
            public bool Same(ShipModule other)      // ignore localisased item, it does not occur everywhere..
            {
                bool basics = (Slot == other.Slot && Item == other.Item && Enabled == other.Enabled &&
                               Priority == other.Priority && AmmoClip == other.AmmoClip && AmmoHopper == other.AmmoHopper &&
                               Health == other.Health && Value == other.Value);

                return(basics);  // Engineering is not needed, we have checked slots/items
            }
 public PlayerAsset(int playerId)
 {
     Rigs     = SpaceshipRig.PlayerRigs(playerId);
     Officers = Crew.CrewOfficer.OfficersForPlayer(playerId, false);
     Ships    = Ship.PlayerShips(playerId);
     Modules  = ShipModule.PlayerModules(playerId);
     //CreateModuleTypeDictionary();
 }
Exemple #20
0
    public void UpdateModuleStatus(ShipModule module, GameTypes.ModuleType type, bool connected)
    {
        switch (type)
        {
        case GameTypes.ModuleType.FuelPack:
            if (connected)
            {
                fuelPack = module.GetComponent <FuelPack>();
                Debug.Log("Ship: Fuel pack connected");
            }
            else
            {
                fuelPack = null;
                Debug.Log("Ship: Fuel pack disconnected");
            }
            break;

        case GameTypes.ModuleType.Thrusters:
            if (connected)
            {
                thrusters = module.GetComponent <Thrusters>();
                Debug.Log("Ship: Thrusters connected");
            }
            else
            {
                thrusters = null;
                Debug.Log("Ship: Thrusters disconnected");
            }
            break;

        case GameTypes.ModuleType.Boosters:
            if (connected)
            {
                boosters = module.GetComponent <Boosters>();
                Debug.Log("Ship: Boosters connected");
            }
            else
            {
                boosters = null;
                Debug.Log("Ship: Boosters disconnected");
            }
            break;

        case GameTypes.ModuleType.QuantumDrive:
            if (connected)
            {
                quantumDrive = module.GetComponent <QuantumDrive>();
                Debug.Log("Ship: Quantum Drive connected");
            }
            else
            {
                quantumDrive = null;
                Debug.Log("Ship: Quantum Drive disconnected");
            }
            break;
        }
    }
Exemple #21
0
    public void Build_Mount_Point_Drop_Panels()
    {
        //****************************
        //Get the list of mount points
        //****************************
        GameObject g = null;

        if (this.command_module == null)
        {
            //We need to hide all buttons and only show a command
            SetScreenNoCommandModule();
        }
        else
        {
            if (this.tmp_drop_panel)
            {
                Destroy(this.tmp_drop_panel);
            }
            if (drop_panels_loaded)
            {
                return;
            }
            GameObject mount_points = this.command_module.transform.Find("MountPoints").gameObject;
            ShipModule sys          = mount_points.GetComponentInParent <ShipModule>();
            mount_point_drop_zone_list = new GameObject[sys.mount_points.Count];

            foreach (MountPoint m in sys.mount_points)
            {
                if (m.zone == Enums.emun_zone.intern)
                {
                    g = Instantiate(mount_point_drop_zone_grid, mount_point_panels[(int)m.zone].gameObject.transform);
                }
                else
                {
                    g = Instantiate(mount_point_drop_zone, mount_point_panels[(int)m.zone].gameObject.transform);
                }

                mount_point_drop_zone_list[m.index] = g.transform.Find("DropZone").gameObject;
                MountPoint omp = g.GetComponent <MountPoint>();
                omp.SetValues(m);
                omp.SetSize(new Vector2(100 + (m.max_mounting * 50), 50));
                omp.mount_type_util_top  = m.mount_type_util_top;
                omp.mount_type_util_side = m.mount_type_util_side;
                omp.mount_type_thruster  = m.mount_type_thruster;
                omp.mount_type_engine    = m.mount_type_engine;

                omp.associated_mountpoint = m.gameObject;
                ItemDropHandler dh = g.GetComponentInChildren <ItemDropHandler>();
                dh.enforce_max = true;
                dh.max_items   = m.max_mounting;
            }
            DisableEnableButtons(true);
            Populate_Mount_Point_Drop_Panels();
            Build_Inventory_List_Items();
            drop_panels_loaded = true;
        }
    }
    public void SetShipPartToPlace(ShipModule shipModule)
    {
        if (shipPart != null)
        {
            Destroy(shipPart.gameObject);
        }

        shipPart = shipModule;
        shipPart.GetComponent <SpriteRenderer>().sortingOrder = 1;
    }
Exemple #23
0
        public HttpResponseMessage GetPlayerModules()
        {
            string            steamId           = User.Identity.Name;
            int               playerId          = PlayerDataSql.PlayerId(steamId);
            List <ShipModule> modules           = ShipModule.PlayerModules(playerId);
            string            serializedElement = JsonConvert.SerializeObject(modules);
            var               response          = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StringContent(serializedElement);
            return(response);
        }
        public JournalLoadout(JObject evt) : base(evt, JournalTypeEnum.Loadout)
        {
            ShipFD     = JournalFieldNaming.NormaliseFDShipName(evt["Ship"].Str());
            Ship       = JournalFieldNaming.GetBetterShipName(ShipFD);
            ShipId     = evt["ShipID"].Int();
            ShipName   = evt["ShipName"].Str();
            ShipIdent  = evt["ShipIdent"].Str();
            HullValue  = evt["HullValue"].LongNull();
            HullHealth = evt["HullHealth"].DoubleNull();
            if (HullHealth != null)
            {
                HullHealth *= 100.0;        // convert to 0-100
            }
            ModulesValue = evt["ModulesValue"].LongNull();
            Rebuy        = evt["Rebuy"].LongNull();
            Hot          = evt["Hot"].BoolNull(); // 3.3

            ShipModules = new List <ShipModule>();

            JArray jmodules = (JArray)evt["Modules"];

            if (jmodules != null)       // paranoia
            {
                foreach (JObject jo in jmodules)
                {
                    ShipModule.EngineeringData engineering = null;

                    JObject jeng = (JObject)jo["Engineering"];
                    if (jeng != null)
                    {
                        engineering = new ShipModule.EngineeringData(jeng);
                    }

                    string slotfdname = JournalFieldNaming.NormaliseFDSlotName(jo["Slot"].Str());
                    string itemfdname = JournalFieldNaming.NormaliseFDItemName(jo["Item"].Str());

                    ShipModule module = new ShipModule(JournalFieldNaming.GetBetterSlotName(slotfdname),
                                                       slotfdname,
                                                       JournalFieldNaming.GetBetterItemName(itemfdname),
                                                       itemfdname,
                                                       jo["On"].BoolNull(),
                                                       jo["Priority"].IntNull(),
                                                       jo["AmmoInClip"].IntNull(),
                                                       jo["AmmoInHopper"].IntNull(),
                                                       jo["Health"].DoubleNull(),
                                                       jo["Value"].IntNull(),
                                                       null,   //power not received here
                                                       engineering);
                    ShipModules.Add(module);
                }

                ShipModules = ShipModules.OrderBy(x => x.Slot).ToList();            // sort for presentation..
            }
        }
Exemple #25
0
        private void GenerateNewShipModel(DropManager dropManager)
        {
            if (StartModel == null)
            {
                SetStartModel(nebulaObject.Tag((byte)PlayerTags.Model) as Hashtable);
            }

            ShipModule prevModule = null;
            var        character  = GetComponent <CharacterObject>();

            Hashtable model = new Hashtable();

            foreach (DictionaryEntry entry in StartModel)
            {
                log.InfoFormat("start model {0} = {1}", entry.Key, entry.Value);
                model.Add(int.Parse(entry.Key.ToString()), entry.Value);
            }

            log.InfoFormat("Module: {0}", (string)model[(int)ShipModelSlotType.CB]);
            ModuleDropper.ModuleDropParams dpCB = new ModuleDropper.ModuleDropParams(nebulaObject.world.Resource(), (string)model[(int)ShipModelSlotType.CB],
                                                                                     character.level, Difficulty.none, this.GenerateStartModuleCraftMaterials(), ObjectColor.white, string.Empty);
            var module = dropManager.GetModuleDropper(dpCB).Drop() as ShipModule;

            SetModule(module, out prevModule);
            log.InfoFormat("Generate module with skill = {0}", module.Skill);

            log.InfoFormat("Module: {0}", (string)model[(int)ShipModelSlotType.CM]);
            ModuleDropper.ModuleDropParams dpCM = new ModuleDropper.ModuleDropParams(nebulaObject.world.Resource(), (string)model[(int)ShipModelSlotType.CM],
                                                                                     character.level, Difficulty.none, this.GenerateStartModuleCraftMaterials(), ObjectColor.white, string.Empty);
            module = dropManager.GetModuleDropper(dpCM).Drop() as ShipModule;
            SetModule(module, out prevModule);
            log.InfoFormat("Generate module with skill = {0}", module.Skill);

            log.InfoFormat("Module: {0}", (string)model[(int)ShipModelSlotType.DF]);
            ModuleDropper.ModuleDropParams dpDF = new ModuleDropper.ModuleDropParams(nebulaObject.world.Resource(), (string)model[(int)ShipModelSlotType.DF],
                                                                                     character.level, Difficulty.none, this.GenerateStartModuleCraftMaterials(), ObjectColor.white, string.Empty);
            module = dropManager.GetModuleDropper(dpDF).Drop() as ShipModule;
            SetModule(module, out prevModule);
            log.InfoFormat("Generate module with skill = {0}", module.Skill);

            log.InfoFormat("Module: {0}", (string)model[(int)ShipModelSlotType.DM]);
            ModuleDropper.ModuleDropParams dpDM = new ModuleDropper.ModuleDropParams(nebulaObject.world.Resource(), (string)model[(int)ShipModelSlotType.DM],
                                                                                     character.level, Difficulty.none, this.GenerateStartModuleCraftMaterials(), ObjectColor.white, string.Empty);
            module = dropManager.GetModuleDropper(dpDM).Drop() as ShipModule;
            SetModule(module, out prevModule);
            log.InfoFormat("Generate module with skill = {0}", module.Skill);

            log.InfoFormat("Module: {0}", (string)model[(int)ShipModelSlotType.ES]);
            ModuleDropper.ModuleDropParams dpES = new ModuleDropper.ModuleDropParams(nebulaObject.world.Resource(), (string)model[(int)ShipModelSlotType.ES],
                                                                                     character.level, Difficulty.none, this.GenerateStartModuleCraftMaterials(), ObjectColor.white, string.Empty);
            module = dropManager.GetModuleDropper(dpES).Drop() as ShipModule;
            SetModule(module, out prevModule);
            log.InfoFormat("Generate module with skill = {0}", module.Skill);
        }
Exemple #26
0
        public void SpawnRandomModule(int x, int y, int z)
        {
            ShipModule module = _wrapper.ShipModuleRepository.GetAll <ShipModule>(f => f.Id != null).OrderBy(o => Guid.NewGuid()).Take(1).First();
            SpaceLoot  loot   = new SpaceLoot();

            loot.X = x;
            loot.Y = y;
            loot.Z = z;
            loot.ShipModules.Add(module);
            _wrapper.SpaceLootRepository.AddOne(loot);
        }
Exemple #27
0
    public int AddIndexedBonus(ShipModule module, int boostPoints1, int boostPoints2)
    {
        ParameterBonus bonus = new ParameterBonus(module, boostPoints1, boostPoints2);

        if (indexedBonuses == null)
        {
            indexedBonuses = new List <ParameterBonus>();
        }
        indexedBonuses.Add(bonus);
        CalculateParameters();
        return(indexedBonuses.Count - 1);
    }
Exemple #28
0
        public static int moduleToDamage(ShipModule module, Ship Attacker, Ship Defender, int direction, CombatField combatField)
        {
            if (Attacker.energy < 0 || Attacker.crew < 0)
            {
                return(0);
            }

            var    damageMod = Combat.damageModificator(module.module.moduleGain.weaponType, direction, combatField);
            double Damage    = module.module.moduleGain.damageoutput;// +damageMod;



            /*
             * // Nice rules, but both aren't explained ingame :(
             * //Shield reduction (except if scout fights bigShips
             * if (Attacker.hullid == 1 &&
             *  (Defender.hullid == 7 || Defender.hullid == 8 || Defender.hullid == 201 || Defender.hullid == 202))
             * {
             *  //fight against a bigShip
             * }
             * else
             * {
             *  Damage = Damage * ((100.0 - Defender.damagereduction) / 100);
             * }
             *
             * //reduce if attacker has no movement points but is nevertheless attacking:
             * if (direction == 1)
             * {
             *  if ((combatField.SysXY == null  && Attacker.hyper == 0)
             || (combatField.SysXY != null && Attacker.impuls == 0))
             || {
             ||     Damage = Damage * 4.0 / 5.0;
             || }
             ||}
             */
            Damage = Damage * ((100.0 - Defender.damagereduction) / 100);
            //remove the above is the block is commented in again


            //reduce by damage of the shooting ship (but only half of it)
            // f = faktor... 1-(1-f)^1.5 oder sowas //marcgfx: so dass ein bisschen schaden weniger macht
            //double DamageRatio = 1.0 - ((1.0 - ((double)Attacker.CombatStartHitpoint / (double)Attacker.CombatMaxHitpoint)) / 2.0);
            //double DamageRatio = 1.0 - ((1.0 - ((double)Attacker.CombatStartHitpoint / (double)Attacker.CombatMaxHitpoint)) / 2.0);
            //(1-(1-f)^p) //p=1 bisherige rechnung
            var HullHitpoints     = Attacker.CombatMaxHitpoint - Core.Instance.ShipHulls[Attacker.hullid].ShipHullGain.hitpoints;
            var DamageRatio       = Math.Min((double)Attacker.hitpoints / (double)(Attacker.CombatMaxHitpoint - HullHitpoints), 1.0);
            var HalvedDamageRatio = 1.0 - ((1.0 - DamageRatio) / 2.0);


            Damage = Damage * HalvedDamageRatio;

            return((int)Math.Ceiling(Damage));
        }
Exemple #29
0
    public void SaveData(int rigId)
    {
        string q;

        if (Id == 0)
        {
            q       = $@"
                    INSERT INTO ss_rigs_slots(ss_rig_id) VALUES({rigId})
                    SELECT @@IDENTITY AS Result";
            this.Id = DataConnection.GetResultInt(q);
        }



        int slotId = 0;

        if (Slot != null)
        {
            slotId = Slot.Id;
        }
        int moduleTypeId = 0;

        if (ModuleType != null)
        {
            moduleTypeId = ModuleType.Id;
        }

        int moduleId = 0;

        if (Module != null)
        {
            Module.Id        = ShipModule.ModuleIdByGuid(Module.ModuleCode);
            moduleId         = Module.Id;
            Module.RigSlotId = Id;
            Module.Save();
        }


        q = $@"
            UPDATE ss_rigs_slots SET 
                slot_id = {slotId},
                module_type_id = {moduleTypeId},
                module_id = {moduleId},
                officer_ids = @str1
            WHERE
                id = {Id}";

        List <string> names = new List <string> {
            team.GetOfficerString()
        };

        DataConnection.Execute(q, names);
    }
Exemple #30
0
        void AddModuleLine(ShipModule sm, ShipInformation si = null)
        {
            string infoentry = "";

            if (si != null)
            {
                infoentry = si.ShipNameIdentType;
            }
            else if (sm.AmmoHopper.HasValue)
            {
                infoentry = sm.AmmoHopper.Value.ToString();
                if (sm.AmmoClip.HasValue)
                {
                    infoentry += "/" + sm.AmmoClip.ToString();
                }
            }

            string value = (sm.Value.HasValue && sm.Value.Value > 0) ? sm.Value.Value.ToString("N0") : "";

            string typename = sm.LocalisedItem;

            if (typename.IsEmpty())
            {
                typename = ShipModuleData.Instance.GetItemProperties(sm.ItemFD).ModType;
            }

            string eng = "";

            if (sm.Engineering != null)
            {
                eng = sm.Engineering.FriendlyBlueprintName + ":" + sm.Engineering.Level.ToStringInvariant();
            }

            object[] rowobj = { typename,
                                sm.Item,                                           sm.Slot, infoentry,
                                sm.Mass > 0 ? (sm.Mass.ToString("0.#") + "t") : "",
                                eng,
                                value,                                             sm.PE() };

            dataGridViewModules.Rows.Add(rowobj);

            if (sm.Engineering != null)
            {
                string text = sm.Engineering.ToString();
                EliteDangerousCalculations.FSDSpec spec = sm.GetFSDSpec();
                if (spec != null)
                {
                    text += spec.ToString();
                }

                dataGridViewModules.Rows[dataGridViewModules.Rows.Count - 1].Cells[5].ToolTipText = text;
            }
        }