/// <summary> /// the battle was unfair if the player's gang had guns and the enemy gang hadn't /// in this case, there is a possibility of the defeated gang instantly getting pistols /// in order to at least not get decimated all the time /// </summary> void CheckIfBattleWasUnfair() { if (enemyGang.GetListedGunFromOwnedGuns(ModOptions.instance.driveByWeapons) == WeaponHash.Unarmed && GangManager.instance.PlayerGang.GetListedGunFromOwnedGuns(ModOptions.instance.driveByWeapons) != WeaponHash.Unarmed) { if (RandoMath.RandomBool()) { enemyGang.gangWeaponHashes.Add(RandoMath.GetRandomElementFromList(ModOptions.instance.driveByWeapons)); GangManager.instance.SaveGangData(false); } } }
void CheckIfBattleWasUnfair() { //the battle was unfair if the player's gang had guns and the enemy gang hadn't //in this case, there is a possibility of the defeated gang instantly getting pistols //in order to at least not get decimated all the time if (enemyGang.GetListedGunFromOwnedGuns(ModOptions.instance.driveByWeapons) == WeaponHash.Unarmed && GangManager.instance.PlayerGang.GetListedGunFromOwnedGuns(ModOptions.instance.driveByWeapons) != WeaponHash.Unarmed) { if (RandoMath.RandomBool()) { enemyGang.gangWeaponHashes.Add(RandoMath.GetRandomElementFromList(ModOptions.instance.driveByWeapons)); enemyGang.gangWeaponHashes.Sort(enemyGang.CompareGunsByPrice); GangManager.instance.SaveGangData(false); } } }
public SpawnedGangMember SpawnGangMember(Gang ownerGang, Vector3 spawnPos, SuccessfulMemberSpawnDelegate onSuccessfulMemberSpawn = null) { if (livingMembersCount >= ModOptions.instance.spawnedMemberLimit || spawnPos == Vector3.Zero || ownerGang.memberVariations == null) { //don't start spawning, we're on the limit already or we failed to find a good spawn point or we haven't started up our data properly yet return(null); } if (ownerGang.memberVariations.Count > 0) { Logger.Log("spawn member: begin"); PotentialGangMember chosenMember = RandoMath.GetRandomElementFromList(ownerGang.memberVariations); Ped newPed = World.CreatePed(chosenMember.modelHash, spawnPos); if (newPed != null) { chosenMember.SetPedAppearance(newPed); newPed.Accuracy = ownerGang.memberAccuracyLevel; newPed.MaxHealth = ownerGang.memberHealth; newPed.Health = ownerGang.memberHealth; newPed.Armor = ownerGang.memberArmor; newPed.Money = RandoMath.CachedRandom.Next(60); //set the blip, if enabled if (ModOptions.instance.showGangMemberBlips) { newPed.AddBlip(); newPed.CurrentBlip.IsShortRange = true; newPed.CurrentBlip.Scale = 0.65f; Function.Call(Hash.SET_BLIP_COLOUR, newPed.CurrentBlip, ownerGang.blipColor); //set blip name - got to use native, the c# blip.name returns error ingame Function.Call(Hash.BEGIN_TEXT_COMMAND_SET_BLIP_NAME, "STRING"); Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, ownerGang.name + " member"); Function.Call(Hash.END_TEXT_COMMAND_SET_BLIP_NAME, newPed.CurrentBlip); } bool hasDriveByGun = false; //used for when the member has to decide between staying inside a vehicle or not //give a weapon if (ownerGang.gangWeaponHashes.Count > 0) { //get one weap from each type... if possible AND we're not forcing melee only newPed.Weapons.Give(ownerGang.GetListedGunFromOwnedGuns(ModOptions.instance.meleeWeapons), 1000, false, true); if (!ModOptions.instance.membersSpawnWithMeleeOnly) { WeaponHash driveByGun = ownerGang.GetListedGunFromOwnedGuns(ModOptions.instance.driveByWeapons); hasDriveByGun = driveByGun != WeaponHash.Unarmed; newPed.Weapons.Give(driveByGun, 1000, false, true); newPed.Weapons.Give(ownerGang.GetListedGunFromOwnedGuns(ModOptions.instance.primaryWeapons), 1000, false, true); //and one extra newPed.Weapons.Give(RandoMath.GetRandomElementFromList(ownerGang.gangWeaponHashes), 1000, false, true); } } //set the relationship group newPed.RelationshipGroup = ownerGang.relationGroupIndex; newPed.NeverLeavesGroup = true; //newPed.BlockPermanentEvents = true; //newPed.StaysInVehicleWhenJacked = true; Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, newPed, false, false); //cannot attack friendlies Function.Call(Hash.SET_PED_COMBAT_ABILITY, newPed, 100); //average combat ability //Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, newPed, 0, 0); //clears the flee attributes? Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, newPed, 46, true); // alwaysFight = true and canFightArmedWhenNotArmed. which one is which is unknown Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, newPed, 5, true); Function.Call(Hash.SET_PED_COMBAT_RANGE, newPed, 2); //combatRange = far newPed.CanSwitchWeapons = true; newPed.CanWrithe = false; //no early dying //enlist this new gang member in the spawned list! SpawnedGangMember newMemberAI = null; bool couldEnlistWithoutAdding = false; for (int i = 0; i < livingMembers.Count; i++) { if (livingMembers[i].watchedPed == null) { livingMembers[i].AttachData(newPed, ownerGang, hasDriveByGun); newMemberAI = livingMembers[i]; couldEnlistWithoutAdding = true; break; } } if (!couldEnlistWithoutAdding) { if (livingMembers.Count < ModOptions.instance.spawnedMemberLimit) { newMemberAI = new SpawnedGangMember(newPed, ownerGang, hasDriveByGun); livingMembers.Add(newMemberAI); } } livingMembersCount++; onSuccessfulMemberSpawn?.Invoke(); Logger.Log("spawn member: end (success). livingMembers list size = " + livingMembers.Count); return(newMemberAI); } else { Logger.Log("spawn member: end with fail (world createped returned null)"); return(null); } } return(null); }