Folgendes habe ich bei mir damals auf dem PvP-Trainings-Server verwendet:
Code
class CustomMission: MissionServer
{
void SetRandomHealth(EntityAI itemEnt)
{
if ( itemEnt )
{
int rndHlt = Math.RandomInt(55,100);
itemEnt.SetHealth("","",rndHlt);
}
}
void addBaseGear(PlayerBase player)
{
EntityAI itemEnt;
EntityAI itemAtt;
EntityAI itemEgy;
ItemBase itemBs;
// Rucksack
itemEnt = player.GetInventory().CreateInInventory("AliceBag_Camo");
// Weste
itemEnt = player.GetInventory().CreateInInventory("SmershVest");
itemAtt = itemEnt.GetInventory().CreateAttachment("SmershBag");
itemAtt = ItemBase.Cast(itemEnt);
// Jacke
itemEnt = player.GetInventory().CreateInInventory("M65Jacket_Olive");
// Hosen
itemEnt = player.GetInventory().CreateInInventory("GorkaPants_Summer");
// Schuhe mit Messer
itemEnt = player.GetInventory().CreateInInventory("MilitaryBoots_Black");
itemAtt = itemEnt.GetInventory().CreateAttachment("CombatKnife");
itemAtt = ItemBase.Cast(itemEnt);
// Taktischer Helm mit Lampe und Nachtsicht
itemEnt = player.GetInventory().CreateInInventory("Mich2001Helmet");
itemAtt = itemEnt.GetInventory().CreateAttachment("NVGoggles");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
itemAtt = itemEnt.GetInventory().CreateAttachment("UniversalLight");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
// Taktische Brille
itemEnt = player.GetInventory().CreateInInventory("TacticalGoggles");
// Handschuhe
itemEnt = player.GetInventory().CreateInInventory("TacticalGloves_Green");
// Sturmhaube
itemEnt = player.GetInventory().CreateInInventory("Balaclava3Holes_Green");
// Gürtel
itemEnt = player.GetInventory().CreateInInventory("MilitaryBelt");
}
void addBaseWeapons(PlayerBase player)
{
EntityAI itemEnt;
EntityAI itemAtt;
EntityAI itemEgy;
ItemBase itemBs;
float rand;
// FNX-45 mit Attachments
itemEnt = player.GetInventory().CreateInInventory("FNX45");
itemAtt = itemEnt.GetInventory().CreateAttachment("PistolSuppressor");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_FNX45_15Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("FNP45_MRDSOptic");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
player.SetQuickBarEntityShortcut(itemEnt,0 ,true);
// UMP-45 mit Attachments
itemEnt = player.GetInventory().CreateInInventory("UMP45");
itemAtt = itemEnt.GetInventory().CreateAttachment("PistolSuppressor");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_UMP_25Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("ReflexOptic");
itemAtt = ItemBase.Cast(itemAtt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
player.SetQuickBarEntityShortcut(itemEnt,1 ,true);
rand = Math.RandomFloatInclusive(0.0, 1.0);
if (rand <= 0.2) {
// M4A1 mit Attachments
itemEnt = player.GetInventory().CreateInInventory("M9A1_Bayonet");
itemEnt = player.GetHumanInventory().CreateInHands("M4A1");
itemAtt = itemEnt.GetInventory().CreateAttachment("M4_CQBBttstck");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("M4_RISHndgrd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_STANAG_30Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("ACOGOptic");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("M4_Suppressor");
itemAtt = ItemBase.Cast(itemEnt);
} else if (rand > 0.2 && rand <= 0.4) {
// AKM mit Attachments
itemEnt = player.GetInventory().CreateInInventory("AK_Bayonet");
itemEnt = player.GetHumanInventory().CreateInHands("AKM");
itemAtt = itemEnt.GetInventory().CreateAttachment("AK_PlasticBttstck");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("AK_RailHndgrd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_AKM_30Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("PSO11Optic");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
itemAtt = itemEnt.GetInventory().CreateAttachment("AK_Suppressor");
itemAtt = ItemBase.Cast(itemEnt);
} else if (rand > 0.4 && rand <= 0.6) {
// FAL mit Attachments
itemEnt = player.GetHumanInventory().CreateInHands("FAL");
itemAtt = itemEnt.GetInventory().CreateAttachment("Fal_FoldingBttstck");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Fal_OeBttstck");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_FAL_20Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("ACOGOptic");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("ImprovisedSuppressor");
itemAtt = ItemBase.Cast(itemEnt);
} else if (rand > 0.6 && rand <= 0.8) {
// SVD mit Attachments
itemEnt = player.GetHumanInventory().CreateInHands("SVD");
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_SVD_10Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("PSO1Optic");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
itemAtt = itemEnt.GetInventory().CreateAttachment("ImprovisedSuppressor");
itemAtt = ItemBase.Cast(itemEnt);
} else if (rand > 0.8) {
// VSS mit Attachments
itemEnt = player.GetHumanInventory().CreateInHands("VSS");
itemAtt = itemEnt.GetInventory().CreateAttachment("Mag_VSS_10Rnd");
itemAtt = ItemBase.Cast(itemEnt);
itemAtt = itemEnt.GetInventory().CreateAttachment("PSO11Optic");
itemAtt = ItemBase.Cast(itemEnt);
itemEgy = itemAtt.GetInventory().CreateInInventory("Battery9V");
itemEgy = ItemBase.Cast(itemAtt);
}
player.SetQuickBarEntityShortcut(itemEnt,2 ,true);
}
void addBaseEquippment(PlayerBase player) {
EntityAI itemEnt;
ItemBase itemBs;
itemEnt = player.GetInventory().CreateInInventory("TacticalBaconCan_Opened");
itemEnt = player.GetInventory().CreateInInventory("Canteen");
itemEnt = player.GetInventory().CreateInInventory("BandageDressing");
itemEnt = player.GetInventory().CreateInInventory("Epinephrine");
itemEnt = player.GetInventory().CreateInInventory("Morphine");
itemEnt = player.GetInventory().CreateInInventory("BloodTestKit");
itemEnt = player.GetInventory().CreateInInventory("SalineBagIV");
itemEnt = player.GetInventory().CreateInInventory("KazuarOptic");
itemEnt = player.GetInventory().CreateInInventory("LandMineTrap");
}
override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
{
Entity playerEnt;
playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
Class.CastTo(m_player, playerEnt);
GetGame().SelectPlayer(identity, m_player);
return m_player;
}
override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
// Inventar leeren
player.RemoveAllItems();
// Ausrüstung
addBaseGear(player);
addBaseEquippment(player);
addBaseWeapons(player);
}
};
Alles anzeigen
Wichtig ist immer, dass du ein Haupt-Item hast, diesem gibst du Attachments wovon einige Attachments wiederum eigene Attachments besitzen können. Beispiel FNX:
* FNX
* Visier
Ich denke mal du kannst anhand dessen schon sehen, was als was verwendet wird. Relativ einfach Entwicklung ![]()
Hoffentlich besteht der oben beschiebene Bug mit den Magazinen nicht mehr, habe es noch nicht wieder getestet.