DayZ
DayZ Class-Selection
CuppaJOE 8. sep. 2020 kl. 8:27
Example of Setup
My files for my Testbox to compare with yours, if you are having trouble
look to end for GetClassSelection. Needs to be in. Also have an example for custom class further down. No guarantees to work, just good to reference. this one is Expansion. There is little change for vanilla mpmission init.c.
/**
* init.c
*
* DayZ Expansion Mod
* www.dayzexpansion.com
* © 2020 DayZ Expansion Mod Team
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
*
*/
#include "$CurrentDir:\\mpmissions\\expansion.enoch\\expansion\\ExpansionObjectSpawnTools.c"
#include "$CurrentDir:\\mpmissions\\expansion.enoch\\expansion\\missions\\MissionConstructor.c"

void main()
{
bool loadTraderObjects = false;
bool loadTraderNPCs = false;

string MissionWorldName = "empty";
GetGame().GetWorldName(MissionWorldName);

if (MissionWorldName != "empty")
{
//! Spawn mission objects and traders
// FindMissionFiles(MissionWorldName, loadTraderObjects, loadTraderNPCs);
}

//INIT WEATHER BEFORE ECONOMY INIT------------------------
Weather weather = g_Game.GetWeather();

weather.MissionWeather(false); // false = use weather controller from Weather.c

weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
weather.GetRain().Set( 0, 1, 0);
weather.GetFog().Set( 0, 1, 0);

//INIT ECONOMY--------------------------------------
Hive ce = CreateHive();
if ( ce )
ce.InitOffline();

//GetCEApi().ExportProxyData( "6500 0 6500", 16000 );

//DATE RESET AFTER ECONOMY INIT-------------------------
int year, month, day, hour, minute;
int reset_month = 8, reset_day = 10;
GetGame().GetWorld().GetDate(year, month, day, hour, minute);

if ((month == reset_month) && (day < reset_day))
{
GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
}
else
{
if ((month == reset_month + 1) && (day > reset_day))
{
GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
}
else
{
if ((month < reset_month) || (month > reset_month + 1))
{
GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
}
}
}
}

class CustomMission: MissionServer
{
void SetRandomHealth(EntityAI itemEnt)
{
if ( itemEnt )
{
int rndHlt = Math.RandomInt(55,100);
itemEnt.SetHealth("","",rndHlt);
}
}

override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
{
Entity playerEnt;
playerEnt = GetGame().CreatePlayer(identity, characterName, "12537.2 353.294 1076.2", 0, "NONE");//Creates random player
Class.CastTo(m_player, playerEnt);

GetGame().SelectPlayer(identity, m_player);

return m_player;
}
////PLACE THIS AFTER THE ABOVE LINE STATING return m_player; and closing brace
////BELOW IS WHERE TO EDIT STARTING GEAR

override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
TStringArray tops = {"ParamedicJacket_Crimson","HuntingJacket_Summer","PoliceJacketOrel","Raincoat_Pink","M65Jacket_Tan","BDUJacket"};
TStringArray pants = {"HunterPants_Winter","Breeches_Pink","GorkaPants_Summer","Jeans_Grey","BDUPants","PolicePantsOrel"};
TStringArray shoes = {"JoggingShoes_Red","Wellies_Green","WorkingBoots_Yellow","MilitaryBoots_Redpunk"};
TStringArray tool = {"DC_FastTravelTicket"};
TStringArray medic = {"BandageDressing"};
TStringArray drink = {"WaterBottle","Canteen","SodaCan_Kvass","SodaCan_Spite"};
TStringArray food = {"BakedBeansCan","sandwich_mung"};
TStringArray hat = {"PumpkinHelmet","BandanaHead_PolkaPattern","CowboyHat_black","TankerHelmet"};
TStringArray melee = {"SawedoffIzh43Shotgun","Pitchfork","Machete"};
TStringArray vest = {"HuntingVest"};
TStringArray backpack = {"LeatherSack_Black","WaterproofBag_Orange","FurImprovisedBag"};
player.RemoveAllItems();

EntityAI itemEnt;
EntityAI itemIn;
ItemBase itemBs;

EntityAI item = player.GetInventory().CreateInInventory(tops.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetHealth(itemEnt, 20);

EntityAI item2 = player.GetInventory().CreateInInventory(pants.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetHealth(itemEnt, 20);

EntityAI item3 = player.GetInventory().CreateInInventory(shoes.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetHealth(itemEnt, 20);

itemEnt = player.GetInventory().CreateInInventory(tool.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(medic.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(drink.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(food.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(hat.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(melee.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(vest.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory(backpack.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
// SetRandomHealth(itemEnt);
GetClassSelection().GiveClassEquipment(m_player);
// GetClassSelection().GiveClassEquipment(m_player)
}
};

---------CUSTOM CLASS information to compare to yours.
Experiment with any appropriate item for that position.
Also can add rifle to backpack(if you have a mod that packs have a weapon slot).
i.e.
( "clothes": [
{
"top": "BDUJacket",
"pants": "BDUPants",
"shoes": "CombatBoots_Black",
"backpack": "MVS_Radio_Pack_Tan",
"vest": "ChestHolster",
"gloves": "TacticalGloves_Black",
"belt": "CivilianBelt",
"hat": "MVS_WarriorHelmet_ERDL",
"glasses": "TacticalGoggles",
"mask": "BalaclavaMask_Green",
"armband": "poncho_camo_mung",
"backpackAttachments": [
"Mosin9130"
],
"beltAttachments": []
}
]
}

------------PARAMEDIC CLASS BELOW
{
"className": "Paramedic",
"selected": 0,
"primaryItems": [
{
"name": "Machete",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
},
{
"name": "BrassKnuckles_Shiny",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
},
{
"name": "LandMineTrap",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
}
],
"secondaryItems": [
{
"name": "Glock19",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": [
{
"name": "Mag_Glock_15Rnd",
"quantity": 1
}
]
}
],
"utilities": [
{
"name": "TetracyclineAntibiotics",
"selected": 0,
"quantity": 1,
"attachments": [],
"cargo": [],
"magazines": []
},
{
"name": "VitaminBottle",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
},
{
"name": "DisinfectantAlcohol",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
}
],
"generalItems": [
{
"name": "MassMedical_Bag_Blue",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [
{
"name": "BloodBagEmpty",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
},
{
"name": "StartKitIV",
"selected": 0,
"quantity": 0,
"attachments": [],
"cargo": [],
"magazines": []
}
],
"magazines": []
}
],
"clothes": [
{
"top": "ParamedicJacket_Crimson",
"pants": "ParamedicPants_Crimson",
"shoes": "MilitaryBoots_Black",
"backpack": "Massmedbag",
"vest": "Mass_WW2Vest",
"gloves": "SurgicalGloves_Blue",
"belt": "fannypack_black_mung",
"glasses": "AviatorGlasses",
"mask": "NioshFaceMask",
"armband": "MassArmbandDouble_Smiley",
"vestAttachments": [],
"backpackAttachments": [
"Chemlight_Blue"
],
"beltAttachments": []
}
]
}
Mission CreateCustomMission(string path)
{
return new CustomMission();
}