Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
  • 0
Piloto_Spyke

How to start (first steps) [SOLVED]

Question

torials I made while helping people in Arma Discord


First Steps
Video:

 

Generic

0. Print on console on player spawn

Spoiler

1. Create project "HowToStartProject".
2. Create folder "worlds" on my project folder.
3. Open World Editor
4. Load world: ArmaReforger/worlds/MP/MpTest/MpTest.ent (This is an almost empty world, useful for test).
5. File > Create New --> Select SubScene
6. Now you can save your world on the folder we created previously
-> At this point we have a world to work with!!!

7. Create a script named "SPK_MyFirstCodeComponent" on: scripts/Game/GameMode (all scripts must be inside scripts/Game or will not be compiled)
8. Add the code below (SPK_MyFirstCode.c).
7. Override {0F307326459A1395}Prefabs/MP/Modes/GameMode_Base.et
8. Add SPK_MyFirstCodeComponent.
9. Verify (F7)
10. Compile and reload scripts (Shift+F7)
11. Save.
12. Play world.
13. If you look on console you will see this:
SCRIPT       : [SPK] SPK_MyFirstCodeComponent.OnPlayerSpawnFinalize_S
SCRIPT       : [SPK] SCR_ChimeraCharacter<0x0000019D54CC8B20> @"ENTITY:4611686018427387917" ('SCR_ChimeraCharacter','Assets/Characters/Basebody/Bas

SPK_MyFirstCode.c


[EntityEditorProps(category: "GameScripted/", description: "")]
class SPK_MyFirstCodeComponentClass : SCR_BaseGameModeComponentClass
{
}

class SPK_MyFirstCodeComponent : SCR_BaseGameModeComponent
{
	override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
	{
		Print("[SPK] SPK_MyFirstCodeComponent.OnPlayerSpawnFinalize_S");
		Print("[SPK] "+entity);	
	}
}

 


1. Actions and Hints -https://discord.com/channels/105462288051380224/976155351999201390/980360446110494761

Spoiler

ScriptSetup

1. Create this folders: Scripts/Game/generated/UserAction/Modded.

2. In Modded folder create ScriptedUserAction.c

3. Inside this file put this:


class myScriptedUserAction: ScriptedUserAction
{        
    //------------------------------------------------------------------------------------------------
    override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) 
    {
        Print("myAction_PerformAction");    
        SCR_HintManagerComponent.ShowCustomHint("My test ground world - DONE", "TEST GROUND", 3.0);    
    }
    
    //------------------------------------------------------------------------------------------------
    override bool CanBeShownScript(IEntity user)
    {    
        return true;
    }
    
    //------------------------------------------------------------------------------------------------
    override bool CanBePerformedScript(IEntity user)
    {
        return true;
    }
    
    //------------------------------------------------------------------------------------------------
    override bool HasLocalEffectOnlyScript()
    {
        return true;
    }    
};

World/EntitySetup
1. If not present, add an ActionsManagerComponent (read wiky for minimum components present in order to work)

2. Add one ActionContext

3. In ActionContext, input some ContextName (myContext)

4. In ActionContext, set Position to PointInfo and move up the Y offset (you will se the point moving in the world editor)

5. Add one Additional Actions selecting your class inside ScriptedUserAction.c in my example myScriptedUserAction.

6. In Aditional Actions/myScriptedUserAction add one parent context list and select the ContextName created before (myContext).

7. In Aditional Actions/myScriptedUserAction Add UiInfo and input some Name to be shown.

8. In Aditional Actions/myScriptedUserAction set visibility range to some value (2)

9. In Aditional Actions/myScriptedUserAction set duration to some value (2)

2. How to Kill object -https://discord.com/channels/105462288051380224/976155351999201390/995759928838996099

Spoiler

// Getting object with name myObject_0 from world.
IEntity myEntity = GetGame().FindEntity("myObject_0");

if(!myEntity)
  return;

// Getting destruction component.
SCR_DestructionMultiPhaseComponent component = SCR_DestructionMultiPhaseComponent.Cast(myEntity.FindComponent(SCR_DestructionMultiPhaseComponent));
        
if(!component)
  return;

// Killing entity    
component.Kill();

 

3. Delete Vehicle - https://discord.com/channels/105462288051380224/976155351999201390/995762975006785607

Spoiler

// Getting object with name BTR1 from world.
IEntity myEntity2 = GetGame().FindEntity("BTR1");

if(!myEntity2)
  return;

// Deleting entity using SCR_EntityHelper.
SCR_EntityHelper.DeleteEntityAndChildren(myEntity2);

 

4. Get entities from world in area - https://discord.com/channels/105462288051380224/976155351999201390/1068605228653498398
5. Make a custom config -https://discord.com/channels/105462288051380224/976155351999201390/1069333335672885299
6. Hide item - https://discord.com/channels/105462288051380224/976155351999201390/1076409862101155850

Spoiler

IEntity myEntity = GetGame().FindEntity("helmet_0");
Print(myEntity.GetPrefabData().GetPrefabName());
ParametricMaterialInstanceComponent cloth = ParametricMaterialInstanceComponent.Cast(myEntity.FindComponent(ParametricMaterialInstanceComponent));
if (!cloth)
    return;
cloth.SetUserAlphaTestParam(255);
// NOTE: Some items like helmet and his attached entities are hidden when changint from Third person to First person.

 

7. Check if third person IsActive - https://discord.com/channels/105462288051380224/976155351999201390/1076470136632004618

Spoiler

// Option 1
CharacterControllerComponent::IsInThirdPersonView
  
// Option 2
bool isThirdPerson(IEntity pUserEntity)
{
    CameraHandlerComponent cameraHandler = CameraHandlerComponent.Cast(pUserEntity.FindComponent(CameraHandlerComponent));
    if (!cameraHandler)
        return false;
    return cameraHandler.IsInThirdPerson();
}

 

8. How to get attributes from a component not spawned yet.

Spoiler

    static void GetPhysAttribitesFromItemResource(ResourceName resourceName, out float weight, out int sizeSetupStrategy, out vector itemDimensions, out float volume)
    {
        weight = 0.0;
        sizeSetupStrategy = 0.0;        
        itemDimensions = vector.Zero;
        volume = 0.0;
        
        IEntityComponentSource entComp = SCR_BaseContainerTools.FindComponentSource(Resource.Load(resourceName),InventoryItemComponent);
        if(!entComp)            
            return;
        BaseContainer baseContainerAttributes = entComp.GetObject("Attributes");    
        BaseContainer baseContainerPhysAttribites = baseContainerAttributes.GetObject("ItemPhysAttributes");        
        /*
        baseContainerPhysAttribites
        0 - Weight
        1 - SizeSetupStrategy
        2 - ItemDimensions
        3 - ItemVolume
        4 - DimensionScaler
        5 - RestingUP
        6 - RestingAdditiveRotationLS
        7 - PivotBoneName
        8 - RestingAdditiveOffsetLS
        9 - ActivePhysicalSimulation        
        
        
        for (int i; i < baseContainerPhysAttribites.GetNumVars(); i++)
        {
            PrintFormat("%1 - %2",i,baseContainerPhysAttribites.GetVarName(i));
        };
        */
        baseContainerPhysAttribites.Get("Weight",weight);
        baseContainerPhysAttribites.Get("SizeSetupStrategy",sizeSetupStrategy);
        baseContainerPhysAttribites.Get("ItemDimensions",itemDimensions);
        baseContainerPhysAttribites.Get("ItemVolume",volume);        
    }

 

9. Send notification (local client)

Spoiler

SCR_PopUpNotification.GetInstance().PopupMsg(title,subtitle)

 

10. How to use Virtual Arsenal (spawn only locally) functionality.

Spoiler

/*!
This action will print all arsenal item's names and specifically M16 item name. Using Virtual Arsenal functionallity.
Used as reference: SCR_InventoryOpenedStorageArsenalUI.c
*/
class SPK_UserAction2 : ARU_ScriptedUserAction
{
	//------------------------------------------------------------------------------------------------
	override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) 
	{
		protected ref map<ResourceName, IEntity> cachedEntities = new map<ResourceName, IEntity>();
		
		// Getting SCR_ArsenalComponent allowed/filtered items.
		SCR_ArsenalComponent arsenalComponent = SCR_ArsenalComponent.Cast(pOwnerEntity.FindComponent(SCR_ArsenalComponent));
		if(!arsenalComponent)
			return;
		
		array<ResourceName> prefabsToSpawn = new array<ResourceName>();
		arsenalComponent.GetAvailablePrefabs(prefabsToSpawn);		
		if(prefabsToSpawn.IsEmpty())
			return;

		// Creating VIRTUAL ENTITIES (spawning locally) while adding it to the map array.	
		foreach (ResourceName resourceName: prefabsToSpawn)
		{
			cachedEntities.Insert(resourceName,SCR_VirtualArsenalCacheManager.GetInstance().RegisterResource(Resource.Load(resourceName)));
		}
		
		// Using this items for any stuff we need
		Print("Searching for all items: "+cachedEntities.Count().ToString());
		foreach (ResourceName resourceName, IEntity entity: cachedEntities)
		{
			GetInventoryItemUIInfoName(entity);
		}	
		
		// Getting an specific item name.		
		ResourceName myResourceName = "{3E413771E1834D2F}Prefabs/Weapons/Rifles/M16/Rifle_M16A2.et";
		Print("Searching for specific item: "+myResourceName);
		IEntity ent = cachedEntities.Get(myResourceName);
		if(ent)
			GetInventoryItemUIInfoName(ent);
	}
	
	//------------------------------------------------------------------------------------------------
	string GetInventoryItemUIInfoName(IEntity ent)
	{
		string str = "";
		if(!ent)
			return str;
		
		InventoryItemComponent inventoryItemComponent = InventoryItemComponent.Cast(ent.FindComponent(InventoryItemComponent));
		if(inventoryItemComponent)
			str = inventoryItemComponent.GetUIInfo().GetName();
		else
			Print("No name: "+ent.GetPrefabData().GetPrefabName());
		
		Print(str);	
		return str;	
	}	
};

 

 

Edition

1. Change default loadout loaded when spawning on world editor (useful for test purposes). Change it on the Loadout Manager prefab that should be present on the world map.

 

Workbench
1. Connecting Script Editor Debuger to PeerTool Client  - https://discord.com/channels/105462288051380224/105465701543723008/998630810913607760


GUI
1. First steps - Button and Hint - https://discord.com/channels/105462288051380224/976159778965438494/980534472372019250
2. Lists - https://discord.com/channels/105462288051380224/976159778965438494/986701077846061066

 

GUI - Game master
1. Populating dropdown list getting the variables from a component placed in the edited entity (in his case the vehicle) - https://discord.com/channels/105462288051380224/976159778965438494/1030925491080802314
2.  Add new waypoint to GM - https://discord.com/channels/105462288051380224/976159778965438494/1038538873283805325

 

  • Like 2

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts


×