private EquipmentItem GetDefaultWeapon() { OffensiveWeaponEquipmentItem result = new OffensiveWeaponEquipmentItem(); result.DisplayName = "Biro based Paperclip Rifle"; result.Classification = ItemClassification.OffsensiveWeapon; result.MakeExternalInstallsPermitted(); result.UniqueId = KnownEquipmentIds.WEAPONTYPE_RIFLE_INSTANCE_1; result.InitialAmmunition = 20; result.D10DamageRolls = 1; result.DamageModifier = 0; result.BaseHitChance = 50; return(result); }
private EquipmentUseResult PerformEquipmentUsage(EquipmentUseRequestContext ctxt) { var bot = GetMappedBotByPublicId(ctxt.OwningBotIdentity); var activeEquipmentInstance = GetActiveEquipmentByInstanceId(ctxt); var equipTemplate = equipment.GetEquipmentTypeById(activeEquipmentInstance.EquipmentId); activeEquipmentInstance.UseCount++; if (equipTemplate.Classification == ItemClassification.Scanner) { ScannerEquipmentItem sci = (ScannerEquipmentItem)equipTemplate; return(PerformScannerUsage(sci, activeEquipmentInstance, bot)); } if (equipTemplate.Classification == ItemClassification.OffsensiveWeapon) { OffensiveWeaponEquipmentItem owi = (OffensiveWeaponEquipmentItem)equipTemplate; return(PerformFireWeapon(owi, activeEquipmentInstance, bot, ctxt)); } b.Warning.Log("Unknown equipment usage type, result being returned is a dummy"); EquipmentUseResult result = new EquipmentUseResult(); result.State = UsageEndState.Success; return(result); }
private EquipmentUseResult PerformFireWeapon(OffensiveWeaponEquipmentItem owi, ActiveEquipment activeEquipmentInstance, MappedBot attacker, EquipmentUseRequestContext ctxt) { EquipmentUseResult result = new EquipmentUseResult(); if (activeEquipmentInstance.CooldownTicksRemaining > 0) { result.State = UsageEndState.Fail_CooldownActive; return(result); } MappedBot victim = ConvertTemporaryScanKeyToBot(attacker.EngineId, ctxt.IParam); if (victim == null) { result.State = UsageEndState.Fail_InvalidTarget; b.Warning.Log("The bot tried to target an invalid key. This shouldnt happen"); return(result); } b.Assert.True(attacker.EngineId != victim.EngineId, "You cant shoot at yourself."); activeEquipmentInstance.RoundsRemaining -= 1; if (activeEquipmentInstance.RoundsRemaining <= 0) { result.State = UsageEndState.Fail_NoAmmo; return(result); } if (!attacker.ConsumeCharge(owi.BaseChargeCost)) { result.State = UsageEndState.Fail_NoCharge; return(result); } CombatAttack ca = new CombatAttack(); ca.Attacker = attacker; ca.Victim = victim; ca.Weapon = owi; ca.WeaponInstance = activeEquipmentInstance; CombatResult cr = combatCore.ResolveAttack(ca); UICombatContext context = new UICombatContext(); context.AggressorId = attacker.EngineId; context.VictimId = victim.EngineId; context.WeaponTypeId = owi.UniqueId; context.DidHit = cr.DidHit; context.Damage = cr.TotalDamage; hub.Launch <Message_Ui>(new Message_Ui(MainMessageKind.UIMessage, KnownSubkinds.WeaponFire) { RequestContext = context }); if (cr.DidHit) { ApplyWeaponfireHit(victim, cr); } result.State = UsageEndState.Success; return(result); }