#enfusion_scripting
1 messages · Page 21 of 1
yeah but modding in WB you have pretty good control over load order (aside from nested dependencies). If a mod I depend on breaks due to that then it can be fixed, if a mod loaded after mine its overrides should take precedence right?
No
Scripts do not use that at all
Scripts is based on alphabetical order starting from their script module being compiled
Respecting dependency order in scripts is insanely troublesome because of the hoising behabior we have on it
ah right it's all based on FS paths forgot about that
Otherwise you would have to do includes yourself and so
complicating the thing even more
before you had to do includes, that is why .h (Header files) were supported a long time ago
You could create your inferface on a headfile, then the impl in a CPP way on .c files
A bit of script lore here
:p
Even before that
Yeah right considering that the dependency management / hoisting isn't deterministic makes a lot more sense why it would cause problems
it was very similar to c in style
no classes even
and even before that, it was just instructions just a bit higher level than assembly
Is there any possibility in the future of Enfusion getting deterministic dependency management like most popular runtimes / language toolchains do?
for scripts
?
Yeah
It's deterministic
just on alphabetical order
It will always be the same
But we do see the values of making it work with resource db dependency resolution
Issue is that the whole of scripts do not use that
That is why script files do not have meta files
Every time servers check for mod updates they update everything to latest version on workshop, so it makes using dependencies quite brittle if they update and introduce breaking changes before consuming mods are updated to support them.
Having a proper dependency manifest format like Rust's cargo.toml or Node's package.json that allows us to pin dependency versions would give a way to express dependencies deterministically and prevent core dependency updates (e.g. EPF) from breaking live servers while still allowing other stuff less likely to cause issues to auto-update
this is there
You can set on your server config which specific mod version to use
At the mod level?
No
Oh yeah I know about server config
that's not really ideal though, are we supposed to just wait for our mods to break then reach out to everyone running servers for them telling them to update their config and pin a dependency version?
and go into some dpendency hell and back to A2 days even when trying to get non savvy players to play something
So we prefer to force everyone to latest
even if it means archiving a mod
We also do not host all mod versions
only the last 30 versions of a mod
We have exp for this
There's gotta be a more proactive solution to it than just waiting for everything to explode and scrambling to help server owners fix their configs
experimental is really only relevant for vanilla changes, not dependency mod changes
Workshop is for final distribution of "a finalized product"
I'm talking about when a mod your mod depends on (e.g. EPF) makes breaking changes, right now the only real solution is tell server owners to fix their config
it's not for testing or so
So if you are a dev, using a mod and that matters. Workshop is to the platform for it
Mods are not designed to be used as libraries
So that is why it behaves like this
Yeah I understand that which is why I'm advocating for change 😄
Main problem we see, is deprecated lists point to unexistent mods at that some point
Or mods not updating for players, and still causing crashes because of that
So safest option, is to force everyone to update.
or players having to redownload a mod multiple times
I think an easy solution to that would be before installing a mod, resolve all it's dependencies and if any are unavailable, fail the mod install
(Just to clarify, we are not closed to it. We just see it risky player and modder wise)
THis is a never ending problem and why in many dev stacks there is infinite amount of package managers and dev environments that try to sort the same thing
We woudl like to avoid a Python sistuation for example
If my mod is depending on an ancient/unpublished/banned dependency then that's entirely on me to fix especially since I probably had tons of time to do it. But if my mod is depending on a mod that pushed a breaking update overnight and the previous version is still hosted I don't see why I shouldn't be able to point my mod to the previous compatible version so it at least still works out-of-the-box for everyone trying to play it until it's properly updated to support the new dep version
Because you have no control on the hosted versions
It might easily be purged
Yeah but I should at least be able to say my mod depends on version X of this dependency, if that version of the dependency fails to download then my mod should also fail to install
with no alternative on how to get inside workshop
and if the other mod broke
and updated
on game update. then probably is also broken / crashing the game
really it would function no different to how pinning mod versions the server config works, just from the mod .gproj level instead
When it comes to versioning I am of different mind, it's always going to be on server operators 
See it from player side
If mod A updated because it causes some crashes on new game update
and yours has specific mod A version
If your mod becomes somewhat popular
then you are forcing everyone to old broken version of mod A. Just so that yours compile
Then mod A dev, receives the issues and all because of outdated mod forced by yours
in many cases modders can't contact others, making the whole problem worse
THis is the risky part we see
Hmm yeah that's a fair point
Could maybe be avoided somewhat with good visibility on when a server is running an outdated mod like a popup warning when joining or something, then players already know when joining that it's using an outdated version of X mod
yeah for sure but I imagine in this kind of scenario it would be preferable to just release an update to your mod pinning prev dependency version than having server operators inundating your DMs with fry_fixit.gif and saying your mod broke their server 😅
But that last issue is the one that always creeps out on us on whatever idea we get for this
That's an easy fix, just turn off DM's. That's what I do.
Is there anyone here who can help me figure out how to spell out the values in SCR_EArsenalItamType?🥹
You mean like list out all the options? Loop over it and call .ToString() on each
Well, in Reforger 22 itself, the values are set for vanilla classes and their limit is 32 bits, but I need to add 22 classes. 22+22=44
the underlying values of an enum are just ints, so shouldn't be a problem unless you're trying to exceed 2147483647
or unless you add one that collides with an existing value
in general you can just add enum entries and let the compiler/VM generate its underlying value
there are already plenty of vanilla enums with wayyy more than 44 entries 😅
I just don't know why, but when I overrided EArsenalItemType and added more values to it, it skipped everything except the 32nd and beyond.
So I realized that there is a limit of 32 bits. Specifically in EArsenalItemMode - such as
Oh I see
bitwise
Since it's really 2^32, since they can be combined - why do you need so many types? They are meant to be combined
So there is no reason to have that
In short, I am trying to create arsenals for divisions by assigning them unique values.
That way the pattern is enforced and modding friendly
This is the wrong place probably to identify specific types to that level of granularity
Yeah
Fk
as (not an arsenal guy), this does not look like the place to separate types of weapons or uniforms, you already have item types for both of those.
Well arsenal item types, which seem to be meant to be very generic
I can see the intent though, because it would be pretty cool to just tell an arsenal it's X type and use that to spawn your items, but the better (and I mean you aren't losing more time than putting this definition on the items themselves), is making a bunch of arsenal configs with those items separated between each arsenal.
Sounds great, but I don't know how to do it so that unique items don't end up with everyone.
So you are kind of looking to allow/disallow players from using certain item types
Are players all in one faction?
For example, two teams are playing for the US, and one team has items that are not similar to the second team.
Yup, but in separate groups.
Yeah, not sure if there is anything in the base game that will not actively try to destroy you on this quest
Probably worht to mod the method that fills this in for arsenal
GetAllItems or something like that iirc
I haven't dealt with a similar issue at all, but the approach I would initially try is to create editable item component labels EEditableEntityLabel, then mod the arsenal logic to only return the items labeled with the label the player has.
Not sure if that's how the arsenal pulls items but that could be a pretty good start, and have the server track what players have what labels. The label search is pretty powerful (can use include/exclude for searching items).
Probably better to get all items available to faction, excluding the other team's label, that way unlabeled things can belong to both teams within the faction.
We have EnumBitFlag in script now whic hdoes this automatically for you btw https://enfusionengine.com/api/redirect?to=enfusion://ScriptEditor/scripts/Core/attributes.c;563
Yeah filtering by editable entity labels is probably a better approach
See SCR_EntityCatalog.GetFullFilteredEntityListWithLabels and usages of it for an idea
but in a nutshell you should be able to add all those things you were trying to add as arsenal modes as entity labels instead, then you can call GetFullFilteredEntityListWithLabels with the labels for whatever sets of gear you want to be available in a specific case
Im new to scripting and im getting this warning, howdo I fix it:
SCRIPT (W): @"Scripts/Game/HVK_MagRepack/Components/HVK_AmmoContainerComponent.c,17": Method not linked 'HVK_AmmoContainerComponent.GetMagazineWell'
You are trying to use a method that is not available anymore from CPP side
Or you moved your mod from Exp to Stable and the method is not available yet there
GetMagazineWell
Ah, thanks Mario, I found the culprit !🍻
Also new here with a question.
Is there a way to test multiplayer code in the workbench with multiple clients? Like if i wanna test that the replication correctly works for authority, owner and proxy. Or do i have to upload a possible fix and test it live?
World editor -> plugins -> peer tools
Thanks i will take a look at it
Is the MOB supply regeneration defined in the scripting or mission files? I'm looking to add fuel regeneration for fuel depots
resource component i would think, at least thats where it is for the classic supply depots in conflict
What controls the position of entities for JIPs
I am setting the transform on the client and server but JIPs don't see this change
I already do
droneComp.ForceNodeMovement(transform[3]);
Which works for the entity being streamed into connected players but it seems tho the position never updates for JIPs unless I am directly setting the position when they join
For example
JIP Client
Client that moved the drone
GenericEntity droneEntity = GenericEntity.Cast(drone);
droneEntity.SetTransform(transform);
droneEntity.Update();
droneEntity.OnTransformReset();
droneComp.ForceNodeMovement(prevTransform[3]);
The RplComponent was not set to runtime

Hello
SCR_ScriptedUserAction -> CanBeShownScript is running on client or server side?
client
Thanks
I have a prefab. In prefab I have ScriptedAction and ScriptComponent
Component stores few variables, like isEnabled
ScriptedAction has CanBeShownScript and CanBePerformed. In both methods, i'm getting this entity, find my ScriptComponent and get var, for example component.GetIsEnabled()
In workbench it works fine, but on server i can see that both methods CanBeShownScript and CanBePerformed didnt executed. Why? I'm looking on entity, its spawned, but methods are not executed to verify can I see action or not (I added logs to see it)
class EvacuationDriverToBaseUserAction : SCR_ScriptedUserAction
{
string evacKey;
protected EvacuationUserActionComponent comp;
void SetEvacKey(string key)
{
evacKey = key;
}
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
{
comp = EvacuationUserActionComponent.Cast(pOwnerEntity.FindComponent(EvacuationUserActionComponent));
}
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
{
EvacuationToBaseHandler.GetInstance().StartEvacuation(evacKey, playerId);
comp.SetIsStarted(true);
}
override bool CanBeShownScript(IEntity user)
{
string playerGuid = GetGame().GetBackendApi().GetPlayerIdentityId(GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user));
bool result = playerGuid == comp.GetRequestor() && !comp.GetIsStarted();
Print("SteelPath >> Script result: " + result);
return result;
}
override bool CanBePerformedScript(IEntity user)
{
string playerGuid = GetGame().GetBackendApi().GetPlayerIdentityId(GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(user));
bool result = playerGuid == comp.GetRequestor() && !comp.GetIsStarted();
Print("SteelPath >> Script result: " + result);
return result;
}
}```
Ah, there is easier way to get player id
GetGame().GetPlayerController().GetPlayerId()
Player manager will exist only on server. Think of these actions as two simultaneous actions. One executes locally, the other on the server. So unexpected things like this are common especially with component properties. Because the action might execute correctly on server, but the client side doesn't know because your local component didn't do anything. The easiest way to sync state from server and client is via RplProp variable on the component, the action would read the component and that variable
Also CanBePerformedScript and CanBeShownScript are client side functions, And GetBackendApi is a server only function.
Replied to wrong person.
whats the best way to register chat commands which send something to the server and then back to the client? i have a faction whitelist script ive made. it works, but i cant seem to figure out how to make it so when a user types in /facadd it will add a user to the whitelist. but it seems i am having issue registering the command. does anyone know the function to use and what rpc call i should make?
Look into ScrServerCommand
It lets you create custom chat commands (which can also be executed via rcon as well) on the server.
Yeah but good luck using RCON in Reforger with how broken it is
It will do things like randomly adding 5 seconds of delay to your command, and doesnt follow the protocol it supposedly should (BattlEye RCON)
@fringe prairie @river imp Thaks for your answers.
In this case, how I can execute server code, or get server data from client? Rpc() is a void return type, i cant return validation result from server to client.
I have a client method, CanBeShownScript for example. From this method I need to call few server functions and get data from this functions, how I can do that?
Does anyone know how to fix the constant change of base positions in “Conflict” mode?
I have already set the “Affiliation Component” keys, but the bases still change from one another.
This used to work for me pre 1.6
Give it a shot
Thx ill try
I tried, seems like it's work somehow, but I'll keep testing it.
So... how tf I can get player UID "modernly"?
[Obsolete()]
proto external string GetPlayerIdentityId(int iPlayerId);
Ive got my command working, but it still says error despite it working. Is there a call I need to make to not do that
Never ran into that, are you returning EServerCmdResultType.OK 🤨
I assume it's eventually going to be SCR_PlayerIdentityUtils::GetPlayerIdentityId but right now it just does what we've been doing. But I assume that'll change over to the newer method when its introduced.
if (!mgr.IsPlayerAdmin(playerId))
{
FAC_SendCmdResponse(playerId, "Error: Admin required");
return null;
}
This is a snippet, where return null;
I had put ServerCmdResultType.OK() and it was giving me errors. Ive looked on the API docs and I cant see what value to use to return a success
So In this case id get the error for not being an admin, and an error that the cmd doesnt exist
which it does
helpful
Yes that should be used. It will change internally some time but the method continues to exist
Some weird issues like seemingly content of my static array is available after exiting and entering play mode lol
🤨
class TAG_MyCustomChatCommand : ScrServerCommand
{
override string GetKeyword() { return "echo"; }
override bool IsServerSide() { return true; }
override int RequiredRCONPermission() { return ERCONPermissions.PERMISSIONS_NONE; }
override int RequiredChatPermission() { return EPlayerRole.ADMINISTRATOR; }
override ref ScrServerCmdResult OnChatServerExecution(array<string> argv, int playerId)
{
if (argv.Count() < 2)
return ScrServerCmdResult("Expected another parameter like #echo hello", EServerCmdResultType.PARAMETERS);
string message;
for (int i = 1; i < argv.Count(); i++)
message += argv[i] + " ";
return ScrServerCmdResult(string.Format("You said: %1", message), EServerCmdResultType.OK);
}
override ref ScrServerCmdResult OnChatClientExecution(array<string> argv, int playerId)
{
return ScrServerCmdResult(string.Empty, EServerCmdResultType.OK);
}
override ref ScrServerCmdResult OnRCONExecution(array<string> argv)
{
return ScrServerCmdResult(string.Empty, EServerCmdResultType.OK);
}
override ref ScrServerCmdResult OnUpdate()
{
return ScrServerCmdResult(string.Empty, EServerCmdResultType.OK);
}
}
ah i think i was missing ScrServerCmdResult(string.Empty, EServerCmdResultType.OK);
Yeah... that's what I was referring to.. The kick/ban command is probably the easiest to look at and see how it should be setup for server actions
thanks, looks like its working
whats the difference between StaticArray and static array?
first one is for fixed size arrays looks like
Hello, I'm trying to dynamically retrieve the content present in a player's inventory.
To do this, I get the list of clothes the player is wearing using SCR_CharacterInventoryStorageComponent.
I then iterate through the clothing items to check whether they contain items. For outfits / backpacks / pants, I can cast the entity to SCR_UniversalInventoryStorageComponent to get the contents. But this doesn't work for vests.
So I cast using ClothNodeStorageComponent but this storage isn’t updated over time and it always gives me the player's starting equipment.
Do you have another class to recommend for dynamically retrieving the content ? Or is my method flawed ?
By chance are you looking for a specific item
Search predicates can help find specific items based on components or other things. I don’t have a search pattern easily accessible to me, I think you’d want to look at loadout areas?
No I'm not looking for a specific item. I need to retrieve the full content of the vest not search for a particular component or item. I'm trying to get the dynamic inventory stored inside the vest just like I can for outfits / backpacks or pants
Yeah loadout areas
ChimeraCharacter character = ChimeraCharacter.Cast(playerEntity);
if (character)
{
EquipedLoadoutStorageComponent loadoutStorage =
EquipedLoadoutStorageComponent.Cast(character.FindComponent(EquipedLoadoutStorageComponent));
if (loadoutStorage)
{
array<typename> equipmentAreas = {
LoadoutHeadCoverArea, LoadoutArmoredVestSlotArea,
LoadoutVestArea, LoadoutJacketArea, LoadoutBackpackArea
};
foreach (typename area : equipmentAreas)
{
IEntity container = loadoutStorage.GetClothFromArea(area);
if (!container) continue;
ClothNodeStorageComponent clothStorage = ClothNodeStorageComponent.Cast(
container.FindComponent(ClothNodeStorageComponent));
if (!clothStorage) continue;
array<IEntity> clothItems = {};
clothStorage.GetAll(clothItems);
foreach (IEntity clothItem : clothItems)
{
AG0_TDLDeviceComponent deviceComp = AG0_TDLDeviceComponent.Cast(
clothItem.FindComponent(AG0_TDLDeviceComponent));
if (deviceComp)
allDevices.Insert(deviceComp);
}
}
}
}```
This should get you closer to what you need
Thanks, but with your code I'm having the same problem. When I remove the items from my vest and run the code, it still tells me I have 8 items even though I have nothing https://gyazo.com/609b070cf7a2fbb2ee6d27e0e04af1f7 / https://gyazo.com/3bdee5344f4ae328cfed97dceb620b94
Heyo, please tell me I'm being stupid somehow: I've got the following script, to be attached to an entity as a component. I've attached it to an Entity, I can see it, edit properties etc. However I cannot get the Init function to work. I've got this code:
class SCR_MyComponent : ScriptComponent
{
override void EOnInit(IEntity owner)
{
Print("Hello I'm a test");
}
};
Anyone have any idea what I'm doing wrong?
Can I not use the ScriptComponent/EOnInit like this? I've been trying to diagnos this for an hour but I just can't get it to run
Hello try this : ```cs
[ComponentEditorProps(category: "Tutorial/Component", description: "TODO")]
class SCR_MyComponentClass : ScriptComponentClass
{
}
class SCR_MyComponent : ScriptComponent
{
override void OnPostInit(IEntity owner)
{
Print("Hello I'm a test");
}
}```
I stand corrected, I missed that you changed EOnInit to OnPostInit. Works now. Thanks!
Also another weird question: I noticed OnPostInit()is being called both after Init, and also after I exit the game. Anyone know why ti's doing that?
Any method with EOn... in a ScriptComponent has to have it's entity event set in OnPostInit to actually fire
For example,
[ComponentEditorProps(category: "Tutorial/Component", description: "TODO")]
class SCR_MyComponentClass : ScriptComponentClass
{
}
class SCR_MyComponent : ScriptComponent
{
override void OnPostInit(IEntity owner)
{
SetEventMask(owner, EntityEvent.INIT);
}
override void EOnInit(IEntity owner)
{
Print("Hello I'm a test");
}
}```
Here kind of shows you where each event fits into the entity life cycle
Thank you, I guess that makes sense
Because world editor loads scripts, so it runs, you can do IsEditor check or something to return and not run
Is the JsonApiStruct broken or am I using it incorrectly?
JsonApiStruct obj = new JsonApiStruct();
obj.StartObject("hello_world");
obj.StoreString("message", "Hello from Reforger!");
obj.EndObject();
obj.Pack();
string json = obj.AsString();
Print(json);
Returns:
{}
Use SCR_JsonSaveContext and SCR_JsonLoadContext
SCR_JsonSaveContext obj = new SCR_JsonSaveContext();
obj.StartObject("hello_world");
obj.WriteValue("message", "Hello from Reforger!");
obj.EndObject();
Print(obj.ExportToString());
Thanks
When i use api structs i use it like that :
Class definition
class SDS_ConnectUserJson : JsonApiStruct
{
string player_name;
string player_uid;
string platform;
void SDS_ConnectUserJson()
{
RegAll();
}
}
And that's how i use it :
private void ProcessConnection(int playerId)
{
string uid = KE_Helper.GetPlayerUID(playerId);
PlayerManager pm = GetGame().GetPlayerManager();
string username = pm.GetPlayerName(playerId);
PlatformKind platform = GetGame().GetBackendApi().GetPlayerPlatformKind(playerId);
SDS_ConnectUserJson connectInfo = new SDS_ConnectUserJson();
connectInfo.player_uid = uid;
connectInfo.player_name = username;
connectInfo.platform = SCR_Enum.GetEnumName(PlatformKind, platform);
m_backend.ConnectUser(connectInfo, playerId);
}
void ConnectUser(notnull SDS_ConnectUserJson connectInfo, int playerId)
{
if(!m_isBackendReady) {return;}
ref SDS_ConnectUserCallBack callback = new SDS_ConnectUserCallBack();
callback.SetPlayerId(playerId);
connectInfo.Pack();
m_callbackPendingDeletion.Set(connectInfo.player_uid, callback);
m_context.POST(callback,ENDPOINT_CONNECT_USER, connectInfo.AsString());
}
i like this approach more than load and save context even tho it's apparently way less optimal
In a way it looks more appropriate, I'll give it a try as well. The next question is how to attach a GET to a player on spawn. I've just put down a crate and added my RestAPI component to it and it's working but I doubt that's how it's done
can always use the OnPlayerSpawnFinalize_S method
I had a game mode running in which i synchronized the data after every respawn ->
override void OnPlayerSpawnFinalize_S(SCR_SpawnRequestComponent requestComponent, SCR_SpawnHandlerComponent handlerComponent, SCR_SpawnData data, IEntity entity)
{
PlayerController pc = requestComponent.GetPlayerController();
ToW_PlayerProfileComponent playerProfile = ToW_PlayerProfileComponent.Cast(
pc.FindComponent(ToW_PlayerProfileComponent)
);
playerProfile.RequestClientValueUpdate(); // send a POST request to my backend
}
Is ToW_PlayerProfileComponent you're player profile struct?
no but in some way it is linked to the api struct, it is a component which has function related to data stored in my backend.
So player xp, level, balance, kill death counter etc and then i have a class when i request an update it will turn those into a json api struct and return it.
But those two code sample come each from different projects
also when setting headers just note that setting a header will erase all previously set headers, so include every single header every time you call SetHeaders
Here's what I have so far, I haven't touched it since last night: https://pastebin.com/GP050Ffp
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i get that it is a test to learn how to use http calls but remember to keep the context instance, much more handy to keep authorization headers saved or base urls
Not only that, it drastically increases performance to not re-create a context each time
Is this correct: ```c
ctx.setHeaders("Content-Type: application/json");
No,
ctx.setHeaders("Content-Type,application/json,otherkey,othervalue");
Just so I'm understanding the syntax otherkey would be charset and othervalue would be utf-8?
No need to indicate the charset but it could be any other header.
Authorization, token, user-agent etc etc
I assumed that it was quite light to generate those comtexts but i guess i'm glad i did it right the first time then
How do I pass a reference to an array containing instances of my class to a method?
Without defining the type in the parameter that is
managed class, then using dynamic coding to retrieve the data. i do it in EDF code to handle any array for filtering of the query expression
Man I hope passing methods as parameters gets implemented, such a pain in the butt
Is that something that's on the table? I feel like it'd require too many compiler & runtime changes to be worth implementing
ctrl + click doesnt work anymore
doesnt go to definition
hm
ok it sometimes works
It's been a while since I've opened the script editor. Did something happen to the creation wizard? It used let you choose a template.
I guess I fill from template now
So, can RplProps and Attributes be stacked? Like if my game mode has an attribute configured at prefab level, but I also want to change it and replicate that variable, can this work?
[Attribute("1", UIWidgets.CheckBox, "Enable feature", category: "Freemode"), RplProp()]
It compiles but I'm scared haha
I think it works, at least it did for us before I noticed it in our github and got rid of it
its uh, interesting but I personally like to just separate the behaviours
Yes
Decorators can be stacked
[...] is called decorator list
Is there any downside to it or is it just a personal preference kind of thing?
it's compile time thing
Mixing an RplProp and Attribute
Yeah decorator, was the word I was looking for, I assumed as much with the [], that it should be fine. I think it makes sense to use for situations with a default attribute that can change over time
So it does not affect runtime perf
No issues
Hmm tmyk
We've instances of that in vanilla
Like for my gamemode I'm adding scenario properties and by default the world can have a default set up, but admins could go into scenario properties and change them.
Felt kind of silly having a variable for the attribute, and another for replication, and trying to figure out the difference
Anyone know what I'm doing wrong? External clients are not receiving these animation commands at the same time:
void ExecuteCustomCommand(){ // Only initiated from local player
Rpc(RPC_ExecuteCustomCommand);
}
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
protected void RPC_ExecuteCustomCommand() {
Rpc(RPC_DoExecuteCustomCommand);
}
[RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
protected void RPC_DoExecuteCustomCommand() {
MyWeaponAnimationComponent myWeaponAnimComp = GetMyWeaponAnimationComponent();
m_CharacterAnimComp.CallCommand(CMD_MyCustomCMD, 0, 0.0); // This gets executed second (long delay)
myWeaponAnimComp.CallCommand(CMD_MyCustomCMD, 0, 0.0); // This gets executed first
}
The character is getting the command like 200ms after the weapon, so they get really out of sync. Idk if it makes any difference here, but the character'sCallCommand is natively replicated already, but WeaponAnimationComponent's is not
Does anyone know which script or config file controls the Arsenal refund system?
Define same time
Like the character animation starts way after the weapon animation
Yeah are you waiting to start the weapon animation until the client recieves the character animation?
Nvm I see now, trying to line this up might be difficult, for you what happens locally? It executes instantly in some other logic?
yeah locally everything is at the same time. Just on MP, the anims are out of sync from another player's POV
So callcommand is being used locally as well? And it happens simultaneously?
for the original player that is
Or is callcommand being used as an analog for other players to see the animation which is already playing for your player, if that is the case, the game might be taking full control of the character animation, and waiting until it's own process replicates it
So basically your command isn't even firing, maybe, haven't messed with this yet, but it would make sense the game won't trigger it on an already replicated process. A good test would be doing call command on the server for the character anim comp in the RPC to server, then broadcast just the weapon, and see if that way it lines up?
since ideally the server is already replicating character, and when you do that, the weapon call would arrive at pretty much the same time?
void ExecuteCustomCommand(){ // Only initiated from local player
Rpc(RPC_ExecuteCustomCommand);
}
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
protected void RPC_ExecuteCustomCommand() {
Rpc(RPC_DoExecuteCustomCommand);
m_CharacterAnimComp.CallCommand(CMD_MyCustomCMD, 0, 0.0);
}
[RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
protected void RPC_DoExecuteCustomCommand() {
MyWeaponAnimationComponent myWeaponAnimComp = GetMyWeaponAnimationComponent();
myWeaponAnimComp.CallCommand(CMD_MyCustomCMD, 0, 0.0); // This gets executed first
}
see if this works? ¯_(ツ)_/¯
Yeah the server doesn't send out the CallCommand in that case. Only the weapon gets it (for both parties)
I think I have tried just about every combination so far lol
Yeah reminds me of the pain I had with joints.
Damn. Well thanks for trying to help. I really think it's some native engine constraint because the client is definitely getting these at the same time, just the character's isn't getting called right away for some reason.
Not too familiar with commands but is there any way to check when the character command is active and then do the weapon command
As a hack if you can figure out the delay, delay the weapon command trigger lol
I don’t see anything in the code directly. Maybe a really hacky way to do it through the animation graph
@mild quarry NEVER call anim graph stuff on NON OWNERS or NON AUTHORITY
You will desycn the whole simulation
The anim graph can replicate itself
Hande it on auth, let it replicate on clients
But the weapon graph commands do not replicate on their own
Is there a way I can sync them together?
They do, you just have to set them to be
it's on both graph config and component
The graph and anim system won't replicate and sync things it does not need to
You need to tell it what to sync
Where do I do that though? The "Synchronized" box is checked in both player_main and the weapon graph. I also have Auto Command Bind set to true in the weapon component
In fact, none of my Anim variables are replicated either (despite being "Synchronized"). I have been replicating those manually too
Can someone please tell me how I can assign access to items from the arsenal only to players with a certain role?
By writing your own budget value to check role
No one has done this yet, as far as I know
I've been working on this. I think it would be a nice feature to have in vanilla but maybe when we have more variety of weapons / gear
Hello folks,
Could anyone tell me why ApplyImpulse() does not work in multiplayer (it works ok in singleplayer)?
I'm trying to make a character fly around.
Any help is appreciated :)
I made this "debug script" for simplicity sake, when on dedicated server as peer in workbench, character doesn't fly up.
[ComponentEditorProps(category: "Movement/Character", description: "script component for flying")]
class REAB_TestComponentClass : ScriptComponentClass {}
class REAB_TestComponent : ScriptComponent
{
void Fly(vector movementInput, IEntity e)
{
if (!movementInput)
return;
Physics charPhysics = e.GetPhysics();
if (!charPhysics)
return;
charPhysics.ApplyImpulse(movementInput * 10);
}
override void OnPostInit(IEntity owner)
{
SetEventMask(owner, EntityEvent.FRAME);
}
override void EOnFrame(IEntity owner, float timeSlice)
{
Fly(vector.Up, owner);
}
}
@minor agate Hope I am not bothering you.
Is it possible that we could get entity type component params for the world editor?
To explain what I mean:
Have a component with an entity param (a parameter that takes a entity object) that can be set in the component,
place an object with that component in the world,
place a another object down,
and put the second object into the first object's component entity param.
I think of an example where I might is with door keypads. I have a keypad, and it has a parameter that takes a door object, and that I would reference the door to the building that the keypad is on.
Sorry but I got confused by your request/question. I am not sure what you meant.
Do you want to link entities together for some logic?
Annoying that autocomplete doesnt work most of the time, ctrl+click also doesnt work a lot of the time
this was fixed iirc. Just not in AR Enf yet
what is this
No changes
Probably
Is there anything else I need to do to get my commands to replicate to the weapons? I have them marked as Synchronized in both graphs, but still only the character commands get replicated natively.
This is why I invented my own animation system
I do hope they'll rework the animation system at least for A4 to be easier to interface with scripts and also more modding friendly...
Though I think Mario already mentioned something about improvements to the editor for modding graphs 😎
Attach keypad to door, get door component, get owner(The door), set param on keypad to door.
If you wanna do something like that in world editor write a plugin.
Are devs aware of thermal shader being very busted on Xbox/PlayStation? I understand it's an experimental feature, but it would be good if PC didn't have an inherit advantage when mods implement this wide spread. I submitted a feedback ticket for this during experimental. https://feedback.bistudio.com/T195448
so I'm primarily a modeler and animator, but I was wondering how difficult it would be to create a functioning ammo counter on a weapon, like you would see in halo
a number on a screen that ticks down from 32-0 and then returns to 32 when you reload
So the HUD component on Character_base.et has the weapon info display, but that's heads up display. But you could make a custom extended info display which gets the weapon from the weapon component that the hud manager gets, can do some searching to find the slot with the mesh to display the UI on, and use SetRenderTarget on the layout to put it on there when starting, and RemoveRenderTarget when stopping display
HUD manager is probably the cleanest way to do it imo
No HALO mods are allowed unless it's inspired and 100% your creation
ah thanks. I was looking for somewhere to start. How difficult do you see this being for someone who really has like no coding experience?
?
wdym
So don't call it Halo, abide by Microsoft game usage agreement
HALO IP is not allowed unless it is fan fic and 100% your creation
No rips, no lore copy, etc
Making sure, you mentioned halo, said you are working on that and have a HALO banner on your profile. So just making sure before you waste ton of time and get banned
They also have to be on player's iirc
left a comment on it.
I have them marked as synchronized in player_main and the weapon graph. There must be another step, right?
Unless this is a bug or something. Because from my understanding, these commands/variables should be automatically replicating without me having to replicate them manually
Any update on this
It seems I forgot about it, sorry
Can you share to me your project?. I will have a look at it over the weekend.
Thanks! I’ll clean it up a bit and share the repo
@torn bane please see your dm
How can I debug clients being kicked with this error? Happens when they stream in some common city building prefab
00:43:44.868 RPL : rpl::Pip::ProcessNetToGame
00:43:44.868 RPL (E): RplCreationError: Number of items mismatch. expected=2, created=3, nodeId=0x4000F7F3, node='Assets/Structures/BuildingsParts/Windows/Glass_122x42/Glass_01_122x42.xob'
00:43:44.868 RPL (E): created items:
00:43:44.868 RPL (E): name='RplComponent', layoutName='script::Game::RplComponent'
00:43:44.868 RPL (E): name='DamageManagerComponent', layoutName='script::Game::SCR_DestructionMultiPhaseComponent'
00:43:44.868 RPL (E): name='DamageManagerComponent', layoutName='script::Game::SCR_DestructionMultiPhaseComponent'
considering the double up on the DamageManagerComponent item, maybe you have 2 of the components on that specific object, or the RplComponent config is slightly off causing parent/child issues.
Did you set on your prefabs AutoHierarchy (On or Off) on RplComponent?
Ahhh I think I switched AutoHierarchy on on one of my entities when I was trying to work out some RPL issue and forgot to turn it off, removing any references to it in my stuff fixed it, thanks Mario!
yeah turns out it was the 2nd one, RplComponent had AutoHierarchy enabled on some things that shouldn't
The reference in error to a building window glass mesh was a bit of a red herring, it seems issue was caused by one of my entities with AutoHierarchy being child of a building or something
How to I get ResourceNames for materials assigned to MeshObject of entity?
I've found this bit of code posted here by @river imp
IEntityComponentSource ClothComponentSource = SCR_BaseContainerTools.FindComponentSource(PrefabResource, "BaseLoadoutClothComponent");
TResourceNameArray WornOverrides = new TResourceNameArray();
ClothComponentSource.Get("WornMaterialsOverride", WornOverrides);
How could I do this for Materials of MeshObject? Currently by doing it for "Materials" gives me a null
I had a way a while ago but it can’t get original materials on a mesh object
I don’t think I ever found a way
You can theoretically read them on workbench instance via file read
And parsing start of xob
Now you can get it if the materials are overridden, but an override can’t be the same as the original so it’s useless for most items. I put in a feedback ticket for it IIRC
Yeah, In the workbench I can read them from IEntitySource using GetDefaultAsString but it doesnt seem to work when packed and used in-game
void Vehicle(IEntitySource src, IEntity parent)
{
int compCount = src.GetComponentCount();
for (int x = 0; x < compCount; x++)
{
if(src.GetComponent(x).GetClassName() == "MeshObject")
{
BaseContainer mesh = src.GetComponent(x);
string mats;
mesh.GetDefaultAsString("Materials", mats);
array<string> resources = {};
mats.Split(",", resources, true);
foreach(string resource: resources)
{
if (resource.Contains(".emat"))
{
assignedMaterials.Insert(resource);
}
}
}
}
}
Can you use Rpcs inside game system? I see 2 uses in vanilla scripts but does it actually work? Can't get mine to run.
What kind of Rpcs? Broadcast Rpcs should work since 1.6, but others would need world controllers, which seem to be WIP atm.
Rpc function calls of RplRpc decorated methods
Ofc, but what do you have as RplRcver?
Tried it all, nothing
Can you post what you tried?
Some simple system
Again broadcast is the only one that makes sense.
Could also be that you tried to early when replication isn't ready yet.
And depending on what you do, a RplProp might make more sense.
class TestestSystem : BaseSystem
{
override static void InitInfo(WorldSystemInfo outInfo)
{
outInfo
.SetAbstract(false)
.SetLocation(ESystemLocation.Client)
.AddPoint(ESystemPoint.Frame);
}
[RplRpc(RplChannel.Reliable, RplRcver.Owner)]
void RpcTest1()
{
Print("RpcTest 1");
}
[RplRpc(RplChannel.Reliable, RplRcver.Server)]
void RpcTest2()
{
Print("RpcTest 2");
}
[RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
void RpcTest3()
{
Print("RpcTest 3");
}
int cnt = 0;
override void OnUpdate(ESystemPoint point)
{
super.OnUpdate(point);
cnt += 1;
if(cnt == 100)
{
Print(cnt);
Rpc(RpcTest1);
Rpc(RpcTest2);
Rpc(RpcTest3);
}
}
}
Testing as listen server in workshop
System location should be Both, not Client.
wat, it does work with Both
Having it as Client on server still runs the system and updates, but why not Rpcs?
Systems without Both are not registered in replication since it can not exist on one side
Broadcast RPCs on systems always worked
I mean there was a time when it didn't
but that was waaay before 1.6
even way before this year
But as Niirozz mentioned, it would not work unless you have the system on both sides
Could be. Can't really tell when tried last time before 1.6 😅
This a new bug in 1.6
It should not tick on server if set as client
And on DS
He's on a listen server, where it should tick though...
I found the issue internally on DS
But maybe it is fixed now in the hotfix perhaps
I need to test again
According to relevant enf dev, it was tied to some define mishap
What about WorldController? Are they fixed too for next version?
idk
I will need to check
According to relevant enf dev, it was also tied to some define mishap
😅
Ah, I guess try and see then 😅
Last part where I left it is when I reported it internally when I found it
After that I got busy and did not track it
It's easy to test
Just create a system on client only
and see if it exists and ticks on server in DS
I was messing with a mod I was working on, and that messed me up for a while until I debugged it
Network stuff is always fun to debug. The worst was by far finding the bandage bug that got fixed meanwhile 😅
Yeah, depending on what it is an adventure
I think I saved this guy some pain with this one recently
#enfusion_scripting message
😅
Oh and bad codecs
I think it's intentional at least for listening
At least I know now how you can stall replication yourself 🙈
Definitely, but it also makes sense that it isn't registered in the replication, unless you got both locations specified.
Nope
It's wrong to behave like that
But the table literally has yes for listen server
if set to client, on DS it should not even exist on server
Listen server is for example WB game with peertool
DS (Actual server)
Should never have it created even if set to Client
listen server has both, because it is both a server and client
Very random but I've got a couple of mods that I will probably never do anything with if anyone's interested in the code. Both were developed I think 2 releases ago? So may not work as-is on the latest version.
One was a scoreboard including kills/deaths/supplies delivered/supplies spent that you could see only at the command tent (ignore mod name it started off as something different).
https://github.com/landaire/arma-mods/tree/main/ReforgerEventsApi
Another one was a radio triangulation mod which would in theory allow command posts to detect radio transmissions and triangulate position. Kind of a cool concept that was unfortunately incomplete, just needs to port the logic to the map using logic similar to the game master/arma vision camera cone.
https://github.com/landaire/arma-mods/tree/main/RadioDirectionalFinding
Just to be clear, I'm not asking for help on these mods but I thought someone may find the code possibly useful for interacting with the radio system or stats.
@fringe prairie@quaint basalt
static void PrintOriginalMaterials(IEntity Entity)
{
EntityPrefabData PrefabData = Entity.GetPrefabData();
if (PrefabData)
{
IEntitySource EntitySource = PrefabData.GetPrefab().ToEntitySource();
if (EntitySource)
{
BaseContainer MeshObjectContainer = SCR_BaseContainerTools.FindComponentSource(EntitySource, "MeshObject");
if (MeshObjectContainer)
{
ResourceName MeshResourceName;
MeshObjectContainer.Get("Object", MeshResourceName);
MeshResourceName.Replace(string.Format("{%1}",SCR_ResourceNameUtils.GetPrefabGUID(MeshResourceName)),"");
Resource MetaResource = BaseContainerTools.LoadContainer(MeshResourceName + ".meta");
if(!MetaResource.IsValid())
return;
BaseContainer MetaContainer = MetaResource.GetResource().ToBaseContainer();
BaseContainerList MaterialAssignsList = MetaContainer.GetObjectArray("Configurations").Get(0).GetObjectArray("MaterialAssigns");
for (int i = 0; i < MaterialAssignsList.Count(); i++)
{
//string MaterialSlot;
//MaterialAssignsList[i].Get("SourceMaterial",MaterialSlot);
//Print(MaterialSlot);
ResourceName MaterialResourceName;
MaterialAssignsList[i].Get("AssignedMaterial",MaterialResourceName);
Print(MaterialResourceName);
}
}
}
}
}
This works in Workbench but, it complains about line 16.
SCRIPT : GetResourceName 'Scripts/Game/aaa.c,16'
SCRIPT : ResourceName MaterialResourceName = '{A906D0A0D856AE02}Assets/Props/SodaMachine/Data/left_panel.emat'
SCRIPT : ResourceName MaterialResourceName = '{E962A29EA375CBA9}Assets/Props/SodaMachine/Data/right_panel.emat'
SCRIPT : ResourceName MaterialResourceName = '{D9DDA98077894464}Assets/Props/SodaMachine/Data/frame.emat'
SCRIPT : ResourceName MaterialResourceName = '{B71109E7A519E50B}Assets/Props/SodaMachine/Data/card_reader.emat'
SCRIPT : ResourceName MaterialResourceName = '{4967C3DA48DE41EA}Assets/Props/SodaMachine/Data/buttons.emat'
SCRIPT : ResourceName MaterialResourceName = '{D090FF036EB9E7B7}Assets/Props/SodaMachine/Data/front_panel.emat'
Odd thing is, it doesn't complain about the same call in SCR_Global::GetResourceName
Going further with this test, with ESystemLocation set to Both, now listen server calls RplRcver.Owner and RplRcver.Server on itself, while joined client calls RplRcver.Broadcast again only on itself, never calling the function on each other. Why is that?
Server is owner of system, and client can't broadcast anything except to yourself
Server can't broadcast to clients either, what's the point of Rpcs in systems then?
Server should be able to do this
Welp, it works now, no idea why it didn't before 
RplRcver.Broadcast call reaches client when called from server
What are the main issues with WC that I need to be aware of?
or anybody who knows
Only auth can do broadcast
Proxies and proxies with owner modifier cant
FindController is broken
Ty
@minor agate any comment on this?
Why does my script complain and GetResourceName doesn't?
What exactly does it complain about?
It seems you clamped the error
SCRIPT : GetResourceName 'Scripts/Game/aaa.c,16'
That's all it ever prints
Getting this error when trying to use a Game master spawnpoint of my custom faction. Not sure where to turn to. I have a factionmanager and loadoutmanager already set up with the proper prefabs and affiliated faction on it.
Reason: NULL pointer to instance
Class: 'SCR_LoadoutRequestUIComponent'
Function: 'CreatePlayerLoadoutButton'
Stack trace:
scripts/Game/UI/Menu/DeployMenu/SCR_LoadoutRequestUIComponent.c:364 Function CreatePlayerLoadoutButton
scripts/Game/UI/Menu/DeployMenu/SCR_LoadoutRequestUIComponent.c:325 Function ShowPlayerLoadouts
scripts/Game/UI/Menu/DeployMenu/SCR_RoleSelectionMenu.c:383 Function OnPlayerGroupJoined
scripts/Game/UI/Menu/DeployMenu/SCR_RoleSelectionMenu.c:395 Function OnLocalGroupJoined
scripts/Game/UI/Menu/DeployMenu/SCR_GroupRequestUIComponent.c:168 Function UpdateLocalPlayerGroup
scripts/Game/Groups/SCR_PlayerControllerGroupComponent.c:796 Function OnGroupChangedDelayed
scripts/Game/game.c:914 Function OnUpdate```
Did you just create a tornado in Enfusion at the end? 😅
I tried seeing if physics joints were being destroyed or not upon entering a vehicle so I forced created the physics joints again when entering. This is the result lol.
This is the progress so far though where i ended off at. Still lots of testing to do
Hey, is there an easy way to create a unique ID (GUID) in enfusion?
Maybe this first one I found with a quick search🤷♂️ , i made my own solution that should be good enough (the second one)
//string guid = Workbench.GenerateGloballyUniqueID64();
//string randomUID = System.GetUnixTime().ToString()+"$"+Math.RandomInt(100,999);
Better, since 1.6 you have UUID class
oh cool UUID uuid = UUID.GenV4();
Nice! Is there an event or method that is triggered when an entity is created or edited in the workbench?
My first thought was to use a modified GenericEntity, but this is not possible, and I could not find anything on the WorldEditorAPI.
The only other option I can think of is to perform some checks every frame, but that just seems too contrived to be the best solution for this.
Shouldn't Math3D.PointLineSegmentDistanceSqr be able to handle a situation where v0 and v1 are the same? Feels unnecessary to check outside if v0 and v1 are same ..
You get the assert with float v = Math3D.PointLineSegmentDistanceSqr("5.0 5.0 5.0", "1.0 1.0 1.0", "1.0 1.0 1.0"); after you've started WB and run your code.
_WB_* methods on entities/components class
Yeah, but I want to know when any entity inherting from GenericEntity gets changed. So for that, I would have to mod the GenericEntity class which is not allowed. Or am I missing something?
If you need it globally - you doing something wrong
For other cases - add component on it, or replace entity class without your own in prefab
How do you mean I am doing something wrong?
To clearify: My goal is to make a little tool to record objects placed and modified in the editor so I can visualize map building progress. The visualization can be handled outside enfusion, so I just need a hook for when any entity is created, changed or deleted. I know it is not a "normal" use case ^^
I don't think it's currently possible without brut-force cycle
Ok, good to know I wasn't missing anything obvious. ^^
Not sure about diffing data changes but for tracking creation and deletion you can make your own component, attach it to an override of common base prefabs used by most entities e.g. most props inherit fromPrefabs/Props/Core/DestructibleMultiPhase_Props_Base.et, most buildings from Prefabs/Structures/Core/Building_Base.et etc
You can then use the _WB and lifecycle methods in your component since your component will be getting created/deleted automatically when any prefabs it's attached to are
What you're talking about sounds like the kind of thing I think WB plugins were intended for, I haven't looked into that stuff much myself yet but looking at how any of the scripted WB plugins were made might give you some direction
Can we control how far PIP will cull the entities? Currently at 1000 vehicles/soldiers just disappear
if im understanding you correctly, just use what the comment above the method says to use
how do i check if a player is an admin?
I think there is a method SCR_Global.IsAdmin iirc
I could be wrong but there was definitely an IsAmin method
How do you edit a locked script?
For any camera, handled in script or on the render target settings, setnearplane or setfarplane with the camera index desired
SetNearPlane will cull anything close than X (so like if there is geo like camera lens you want to hide, and far plane is how far it renders), but this camera is quite limited if it's not player camera as it will not render additional GEO or higher LOD levels than the player camera already sees, so direction of player camera and distance from what you are looking at can never be ignored as factors for distant viewing of objects.
Then you have RPL bubble, and distances at which things appear/disappear on network side. AR limitation that hopefully will be improved with A4
You create a modded class
I noticed another thing
Objects culling is also based on those two params in MeshObject:
Yeah, though with low enough FOV (high enough zoom), this should be mitigatable.
I guess nice to have ProjectileMoveComponent.GetProjectileSimulationResultnow, but is there a way to get the projectile simulation itself? To change mass, speed etc... at runtime? GetPhysics() returns nothing
You could modify the values in the prefab at runtime though.
GetPhysics doesn't work, as projectiles have a distinct simulation handled by ProjectileMoveComponent and ProjectileSimulationSystem afaik.
There is an update code for prefab when i edit something by code? its never worked for me, i tried enable LSD differential at runtime, but only next vehcle spawn used that
but can't modify anything during the simulation of a trajectory
Related ticket: https://feedback.bistudio.com/T188592
Are you trying to modify values for something you already spawned? That won't work, as once you spawned an instance, it's no longer tied to the prefab's values.
At least those that are not defined in *Class, which are shared accross all instances.
i get spawned vehicle by cursortarget and tried modify veh simulation things but not found update for it
As I said, you have to modify the prefab before you spawn the vehicle.
No other solution afaik.
What class(es) records what buildings are built by any faction player at bases? Trying to keep track if a player has built a helipad at a base such as Montignac.
What does a system failure kick result exactly entail
After this hotfix we are getting them constantly
Server does not crash, kicks a majority of the population with the system failure
Nothing in the logs
Can I use the remote console to pull things from my 3D viewport session? Trying to get live data
this is coppy and paste bc im to lazy to retype it,
well if anybody keeps crashing on pc they can deleted any of the banned mods and updated all of the mods and some of the mods I did update them sum the dependencies were also banned so you have to delete them too and every since I done that I haven't crashed yet
Is there a reason why PeerTool client doesn't get prefab entity with changes? For example I adjusted rotor offset in slot manager component but the change isn't there for PeerTool client. What am I missing?
Clients read from the prefab not the instance.
Apply changes to the prefab and it will be visible for the client.
Otherwise change on server and broadcast the change to clients.
Also if client doesn't pick up (non-runtime) changes to prefab files themselves it could be a problem of your peertool loading published mod over local source mod if you have it reading your game client add-ons dir
If you do not want to do this manually, you can add NwkMovementSimpleComponent and it will sync it for you (Along with RplComponent)
@craggy jolt
On the entity you expect to do the changes
Just don't use it everywhere, be smart about it
I know that EPF is deprecated but I'm still using it until I can fully implement the new Persistence System.
If there a way for me to make spawnpoints persistent?
I have a movable spawn that moves to player position with a ScriptedUserAction, I keep getting an VME when trying to implement EPF Persistence.
Any help will be greatly appreciated.
Any way to mark things to leave out of the build?
Dev only documentation in this case
How do i fix WB freezing for 10 secconds when switching between script editor and world editor?
mb disabling auto recompilation in settings?
No it's not auto recompilation, it just freezes
Ive noticed that when im working on a mod that uses a bunch of my mods in its dependencies it causes the script editor to buffer alot longer
Removing them from the workbench menu where you select them seemed to help
When you punlisha mod, scripts are published as source
Published mods scripts do not get distributed as bytecode
So, no
Okay thank you
quick question for my Enfusion workbench, Am i supposed to have a workbench tab? Is so why do i not have one Ive tried to get it to show but nothing works.
No they changed it to the file menu in 1.6
ok thank you i was extremely confused why i wasnt seeing it.
Im currently working on an AI Vehicle patrol addon that was similar to how exile would spawn vehicles and drive around, Is there a way to pull vehicles from different loaded addon within a server to add to the pool or do i have to hard code the Vehicles in?
How would I detect if an entity is getting deleted so I can do something before its deleted? Do I need to check IsDeleted() in EOnFrame()? Seems like that would be pretty expensive
Read from entity catalogs, look at usages of entitycatalogmanager for examples
Add component with your code in OnDelete to prefab of this entity
Thanks, apparently Im not modding the right action for the conflict building menu. Trying to do something to a vehicle when a player spawns it in. Anyone know what action that is?
Hello. I can't figure out how to intercept the moment a shot is fired? I need to implement weapon wear, but I don't understand how to detect the player's weapon and when it fires.
@scarlet iris
Hi
Sorry for disturbing u.
I wanted to ask - do u have same script for radios?
The sometimes are not spawning when im launching scenario
Hi guys just joined in, I'm sorta of a modder, I need a little help
I have this component which works great, it has member variables which works okay but I'm using a custom class data type in a variable, and that custom data type variable just doesn't seem to update , I'm using a custom plugin to update the variable, but it doesn't seem to update in the properties
I have tried looking through docs, serialization, AI
no luck
right below is the variable called 'm_savedObjects'
the custom class:
P.S: forgot to mention I'm updating this variable through a plugin
Still new to moding in Reforger not new to coding. Is there a script or properties int the game already that will let my make the item's mesh when in the players hand not be visible or is that something I will have to figure out and make?
not sure if this relevant to ur question but here's a https://www.youtube.com/watch?v=dUNN_KeyjkQ video of a guy showing how to add a custom helmet
Follow along with our guide here: https://reforger.armaplatform.com/news/modding-boot-camp-3-modeling
Bohemia Interactive Community Wiki (BIKI) Tutorial: https://community.bistudio.com/wiki/Arma_Reforger:Character_Gear_Creation/Headgear
This Modding Boot Camp seminar was originally held on the Arma Discord Server on December 18th, 2024.
Artis...
if his modeling a helmet and gettin it equipped, maybe you can make it appear on hand or something
If you write a gadget component, theres a function you can override for "ModeSwitch" , you can make an Option for "hideWhenHeld" or something and do..
if(hideWhenHeld){
ent.ClearFlags(EntityFlags.VISIBLE,false);
}
}```
The question is how to make the rendering of the item not appear when in hand.
not sure I'm not that familiar with enfusion yet
So "EGadgetMode" is the class name that handles this or you just gave it a made up name as example?
EGadetMode is an enum
I think this 'ent.ClearFlags(EntityFlags.VISIBLE,false);' sets the visibility to false
that is what I'm looking to do.
I think it has to be done in a gadget component, b/c you still want it visible when its not held
Can I just have it update to true when not in hand.
if (mode == EGadgetMode.IN_HAND) {
if(hideWhenHeld){
ent.ClearFlags(EntityFlags.VISIBLE,false);
}
} elseif {ent.ClearFlags(EntityFlags.VISIBLE,true);}
yea, just have another check for when it leaves the hand..in the same function there
yea..prettymuch that 👍 else*
Thanks bro!
is any of u guys familiar with this error?
error shows up when I hit plus/add button to add a new item for my array, the array's data type is a custom class
chat gpt thinks you should declare it like this 😅
ref array<ref SavedObject> SavedObjects = new array<ref SavedObject>();
yea I have been trying out AI as well but not chatGPT though, just the default google search
chatGPT didn't declare it that way though, if I recall I saw a ingame code declared like that so I gave it a try
Use Claude for best results, but really the power is in understanding why it works. Really it’s a teaching tool (why does C# declare objects this way? What are pros and cons?)
I know ref is 4 strong reference but it sorta confuses me since it doesn't work on components but seems to work on other classes
Really you shouldn’t need it to be declared like that, if it’s a base container object
I don't really copy paste code from AI, just use it 4 information
Need to see code for that attribute to be sure
If you want your custom class to be a config
But if it’s not a native class, your class needs decorators to tell the engine it’s a config thing
Then you need to decorate it tiwth the BaseContainerProps attribute
Otherwise it will just be a regular script class
What he said haha
Then you need to expose each variable you want in the config interface with the Attribute decorator
Also
BaseContainerProps?, I did look into that, gave that a try but it throwed an error
NEVER initialize attribute variables like how you did there with = {}
[BaseContainerProps()]
class AG0_PostProcessEffect
{
[Attribute("0", UIWidgets.ComboBox, "", "", ParamEnumArray.FromEnum(PostProcessEffectType))]
PostProcessEffectType m_eEffectType;
[Attribute("0", UIWidgets.Slider, "Priority (0-19)", "0 19 1")]
int m_iPriority;
[Attribute("", UIWidgets.ResourceNamePicker, "Material", "emat")]
ResourceName m_sMaterialPath;
}
Example
Then in attribute:
also I don't think my custom class is 4 config not sure, I'm using my custom class to hold some basic information like the object's health, prefab, position etc...
[Attribute("", UIWidgets.Auto, category: "Video Source Config")]
protected ref array<ref AG0_PostProcessEffect> m_aCameraEffects;```
I see, didn't know
But that is not your issue tho
I know there is a defvalue, but thought it would be okay
It's just waste of perf
You are overwriting as well whatever the default value is supposed to be
And creates some issues with debugging (why doesn’t it work!)
yo the attributes are working fine except 4 the custom class one
Read what I said about it
the custom class one I'm using a plugin to update the variable
But why a plugin?
My example should work if you and to try adapting it, but not sure how a plugin plays with that stuff.
yea I'm changing it now
its a bit complicated xD, have my reasons
Did you use AI for this? 😅
lmao no
AI is really bad for programming in general, it's even worse on our custom language, and our csutom engine
yea mate I already know that, I told ya b4 I use it 4 information though it sometimes throws errors
What are the reasons?
It sounds super wrong, that is why I ask
But it depends on what the reason is
It might be valid
I mostly use the default google search one, if I type a question it will answer and also show the topics and I mostly navigate those topics
I have this project that I made in Arma 3, all gud no AI
its called SandboxLib which has some features called sites, pawns, etc..., atm
I'm trying to create a existing feature which you might already be familiar with
in workbench
areas with spawning & despawning
Did you get a chance to look at it? Sent it in DM
From your snippet above it looks like you should be inheriting from one of the trigger entities as opposed to making your own component
Not ringing a bell, can you explain?
Components | Area #2
We continue with Area and demonstrate using the trigger and some actions applied to the area.
That just got me more confused
Explain it as if I do not know anything about your feature, because that is the case
I do not have context so idk how to even help or how to give advice about it
so basically if u played any game, u know that when you enter a area, it spawn some things and when you leave it despawns right?
arma reforger already has a feature like that called areas
yeah
actually the area component sorta provides that feature
Dynamic Spawn Despawn | Dynamic Spawn Despawn
Discussion and demonstration of the Dynamic Spawn and Despawn system of the Area and Layer.
Those are trigger entities
I'm trying to create something similar, and this is something I already made in Arma 3
yep
well I sorta tried to implement a button in a component's properties panel but I couldn't figure that out so I sorta ended up using a plugin to execute a code
so to summarize
I have some attributes defined, they all work good except for the 'ref array<SB_ObjectInfo> m_savedObjects', since 'SB_ObjectInfo' its a custom class
I'm using a code to update that array, but it doesn't get updated, I'm not sure why
Yeah, because as I said before. In order to make a custom class a config. You need to decorate it with the BaseContainerProps
It will then become a config class, which then means it will be able to be used in configs
Not sure why you need a plugin when you can just change the values on the prefab?
That is why I still do not understand this whole problem as well
Sounds like you're living in the past, this isn't the Eden Editor that you love so much.
yea ik
not good at vc xD
also the code basically grabs nearby objects and stores information about them in the array, I can't manually change hundreds of variables
You definitely shouldn't be storing information about hundreds of objects
especially not in numerous entities across the map
its just basic info, not much, + BI already made something similar though it only takes prefabs/resource names
When they store hundreds of things they do it in a prefab, meaning the data never has to rpc across the network
Regardless
Give a more clear example of EXACTLY what you're trying to do
yea ik, but still the prefab spawns in a position with a rotation right?, I'm pretty sure those are stored somewhere, and + my code just happened to take a prefab, and 2 vectors for rotation and position
clear example?, dude just watch the video I already told you I'm planning to create a system similar to BI's area spawning & despawning system
It's not the "what" only the thing we need context
it's the what and how
Please, write properly what you are trying to do and how. Otherwise we are wasting time here. We want to help you but we are going in circles
You are giving context in bits, which confuses us more and more
If it's all just for finding nearby objects, then why not to do this on init by script, instead of adding something into attributes and stay it in sync?
lol O_o?, I did explain, you knew and asked me about BaseContainerProps, so I'm looking into that atm, yea Im giving bits of stuff because you told to me explain it all though I already showed you a video of the system and how it works
I know that init executes on both workbench and simulation but still I prefer plugin since I don't wanna fetch nearby objects every time the workbench load the entities
currently looking into BaseContainerProps, it might be the solution 2 myp roblem
Just don't run script in WB, only in play session 🤷♂️
that won't do with what I'm making lol
If the functionality already exists then just use it. No need to reinvent the wheel.
I'm not reinventing anything though, BI uses a prefab to spawn it which is a pain 4 me sinceI have to manually each time assign a prefab
Im sorta using a different approach
which I used in Arma 3
This isn't Arma 3. The faster you stop making the comparisons the better off you'll be
And performance and mantainability will suffer as well
If you come from A3, then it's better to start from scratch and just learn to use the new tech
You might do some insane work for steering it on A3 way, for us to then later break it for you beause we do not intent those usages
And you will not get support on that part if that happens
I know this isn't arma 3 because its a different engine, yea ik, but it just happens so reforger already has something similar I made and I'm trying to bring that into reforger
and it just happens so the reforger already has that system but just one thing seems to be off and this way seems to be much easier so I'm making that way
lool got it working
also guys the doc examples aren't updated, had to make a few adjustments to make it work
Yeah a lot of them need updates
so I managed to get this kinda working using BaseContainerProps, also it turns out I did have 2 use two refs to make it work
Because I wanted to reference some other post.
||Pun intended||
Is there a way to get the location for the roads on any map and use it to set locations for spawn points?
yes
I think roads are entites since I used a query to debug and accidently fetch one
so try find a way to get that road and use GetOrigin(), P.S: i used GetGame().GetWorld().QuerySphere to get the road
i seen that they are RoadEntities but my issues is the there are different things attached to that like flower beds and what not, i originally started with a hand picked table but that isnt really clean and would only work for one map
Get the RoadNetworkManager from SCR_AIWorld, get the worlds bounds pass those bounds to RoadNetworkManager::GetRoadsInAABB and pass in an array of BaseRoads
Then you can get all the points from any of those BaseRoads and use those as spawn points.
thank you
Extra credit if you can spawn an item at each road point facing the direction of the road
Idk, I use it for spawning vehicles on roads, by default everything spawns facing the same direction. For vehicles that would mean, depending on the road point, that it could spawn perpendicular to the road. Which is something I don't want in most cases.
So I did it and now it will not let me equip the item in the grenade slot. The other thing is it only allows me to have it in the hand slot and when it is in the hand slot it is shown at my feet and moves with me. Maybe using the wrong script???
What are you trying to do?
I moded a M112 with a different object and it is now in the FPV. I'm trying to get the object to not be seen when it is equipped in the right hand.
so wanting to either swap out object or make it invisible while it is in hand so it is easier to place it.
What is it? Is it so big that you can't see with it in your hand?
yes
Sounds like you should be using a different animation instance
how would I do that?
Still will be in the way.
Plus when I tried to do it it didn't change the animation.
you know that is a good point, I should probably look into that
Update I could probably take the direction of the vehicle where it spawns and point it towards the closest move marker
Asking once again, what action is used to place a vehicle from the conflict building menu, like from a vehicle depot?
Not 100% sure but when looking around GameMaster scripts I swear I've seen functions for teleporting/placing at cursor. Might atleast give you an idea on where to look. That part of the code base seems to be inheritance city
look in SCR_BaseSupportStationComponent.c and see if that would have your answer?
@spark otter
SCR_PlacingEditorComponent::CreateEntity
Though if you want to override the behavior, you should do it on SCR_CampaignBuildingPlacingEditorComponent.
Unless you want the altered behavior for GM too.
how do i move the position of a component?
I assume you mean an entity since components don't have a position but are attached to entities which do. Usually people use .SetOrigin() or .SetTransform()
Or if you mean order of the component in the list, I don't think we have much control over that as half the time when I add a component it gets re-ordered somewhere else in the list next time I open prefab
no i mean how do i move an entity attached to another entity
sorry i could have made that more clear
ok yeah then you want to call set origin or transform on the entity you want to move
is there a way i can do that outside of a script?
depends on the prefab setup, look at the relevant prefab and see how the child you're interested in moving gets attached and how it can be positioned
ok ty
I have tried looking into this, but can't find a way, is it possible to use threading in simulation similar to arma 3 spawn command?
which allows sleeps
I know there is a threading that only works for workbench plugins but I'm looking for a PIE solution
Answer is: No.
But you have other ways to schedule things, or run things periodically.
Depending on what you want to do, one option might be best over the other.
What kind of logic do you want to do with that?
optimization reasons, will go with CallLater 4 now
CallLater does not run in another thread btw
Nor anything in the scripts do
So for optimization purposes, the only thing you can do is batching
Yea already learned that
Just do not use the Game CallQueue
it already causes freezes because of misusage
Make your own, and tick it on a system or the game loop
By making your own, I mean creating and storing your own CallQueue instance
works great 4 me though + the wiki suggests that
Yeah biki should have many things removed
Thanks, we will correct whatever it is suggesting regarding this
though I didn't have any issue with the method, it worked with the duration set to 0 and above
Mario is the Arma Reforger modding supervisor, so if he tells us to do something or avoid something, I guess the sensible move is to follow his direction. 
really?, but the guy joked about having 2 refs in a variable while both in game & wiki code shows variables using it that way so I didn't know
Why would multiple queues perform better than a single though?
@Kex if you run a heavy operation like spawning alot of objects in a single code it can cause stutter or freeze, but if you divide it into queues like adding delays for each object spawn
it might reduce the stutter and make things run smoothly
though there is going 2 be some delays if ur spawning objects
that way
That has nothing to do with my question...
CallQueue itself can't handle too many things on itself. At some point when you have many calls on it, it "explodes" in how long it takes it to process when to call something
So, using a global one for everything causes this to happen
- There is extra benefit that when having it alone, you can control when your stuff actually gets called. While the global one is unorganized.
We see it internally many times being cause when seeing insane modded performance issues. And because this gets processed on main thread, other secondary threads that require scripts also get stalled. Like for instance the replication threads.
So suddenly you could cause a kick because of this, not to mention the performance decrease
What I recommend usually, is to create a single callqueue if you need it global, for your whole mod
That way you diminish the possibility of this to happen
GetPlayerControlledEntity when used inside an rpc call is not returning an entity, any suggestions?
Did you use this in Authority?
(Server, listen server)
Couldn't this be avoided by changing the internal structure into multiple "buckets" to keep the processing in manageable size? Though it would increase the complexity of removals, but from what you said, the ticks are the main problem.
It would make it slower
The thing is that it is was never planned to be abused like that
Fair enough
on closing of a dialog, when a button is pressed the parameters are collected and then sent to the Rpc
And allowing that abuse, will just slow it down more on normal case
How did you get the PlayerID that you sent through the Rpc?
I cache the last interacted entity
Can you show me how?
It seems you just sent the wrong thing as PlayerID
I use the RPPhone functions to get the last entity
GetPlayerIdFromControlledEntity should be used with the player character entity
As it will check the player id of the character/entity the player is controlling
It's why it is called PlayerID
it does, might have confused it a bit, I was referring to a situation like where you might use a single queue to spawn alot of objects and that would cause stutter or freeze but you can use multiple queues with delays to spawn those objects so tons of objects won't spawn instantly saving u from lag issues
usually for stuff like that in Arma 3 I use the spawn command
No point in it, you probably didn't understand my question, but Mario answerd it properly already.
but ur question was
doesn't this sorta explain why multiple queues would perform better than using a single queue?
anyone knows how to set up keybinds for items that you have made?
No, especially with the anology of Arma 3. I would think the scheduled environment where your spawns get scheduled is also a single callqueue.
I'm not talking about Arma 3 atm though
You still misuse the word queue. Your point probably is to spawn all objects in a single call instead of breaking it into multiple ones and schedule them in a queue.
Whether you do it with a single or multiple queues won't make much difference, unless one of the queues is already overloaded like the main one, as Mario said.
ahh I might be wrong but shouldn't calling alot of queues with delays to spawn objects make the stutter lower? instead of spawning it all in one queue
I know queue runs on the main thread but I thought adding delays would still minimize the lag and make performance better*
The entire point of queues is to delay calls to begin with. You put something on a call queue to be called later instead of right now.
I could be wrong, but wasn't that I was refering to?, using delays to spawn objects
damn
I just looked up into spawn command in Arma 3, it doesn't run on a separate CPU thread, dang, I guess I got confused how threading works
my bad xD
I thought the spawn command ran on different CPU threads since you can use functions like sleep, but it seems even Unity and UE methods doesn't use multi-threading
guess I need to revise my programming skills as I was self taught mostly starting from Arma 1
Is there a way to await the spawning of a prefab client side?
(Without using callqueues / frames events)
Await in what regard?
Also wait for it where?
Detect on server that it spawned on client?
I'm more interested in the client side
Just detect when a vehicle has spawned for the client without using callqueues, idk if there is some kind of event i can listen to by giving it the entity id?
So
Detect if an entity spawned on a client, on the client itself?
You can just use EOnInit on the client
How would I go about adding a deliver task to a specific player with the new task system?
do we have event from garbage system or IEntity when entity is despawned\deleted?
Better ask here: https://discord.com/channels/105462288051380224/976159829628444682
Since this is not really scripting related
I want to assign it all via script though
Guys, I really need help if someone could offer some insight or point me in the right direction. Our server keeps crashing, a few times or more a day. At first I thought the below crash log was result of CRX AI causing this, but I cannot for the life of me find the mod that is causing the below crash log. I have crash logs, multiple times a day, with only the below log. Is this vanilla, is it a mod, and most importantly how do I stop this?
"09.12 2025 16:03:28
Virtual Machine Exception
Reason: NULL pointer to instance
Class: 'SCR_AIGroupCohesionComponent'
Function: 'AwardXPToGroup'
Stack trace:
scripts/Game/AI/Components/SCR_AIGroupCohesionComponent.c:206 Function AwardXPToGroup
scripts/Game/AI/Components/SCR_AIGroupCohesionComponent.c:224 Function CheckGroupCohesion
scripts/Game/game.c:866 Function OnUpdate"
Thanks in advance.
This is not a crash log, but yet another VME (in vanilla script in this case, but it might be caused by some mods).
Btw server crashes feels kinda normal since 1.6
Check last messages in console.log right before crash, this might help (not really, never helped me in 1.6)
Thanks for the reply! What is a VME?
oh virtual machine exception I assume. I am going to look at the console now
Here is my console.log about 30 seconds leading into the crash
Nothing really useful as always. I experience the same for past month.
Does this always show up in the crash log?
18:05:27.443 RPL : rpl::Pip::ProcessNetToGame 18:05:27.443 ENTITY : SpawnEntityPrefab @"{9430B94B5ED63B3C}Prefabs/Weapons/Rifles/HK416/VRT_Rifle_HK416_BLK.et" 18:05:27.443 ENTITY : Create entity @"ENTITY:4611686018427630110" ('GenericEntity','Prefabs/Weapons/Rifles/HK416/HK416.xob') at <1951.729980 59.000000 504.459991> @"{9430B94B5ED63B3C}Prefabs/Weapons/Rifles/HK416/VRT_Rifle_HK416_BLK.et" 18:05:27.443 ENTITY : SpawnEntityPrefab @"{613FC21D99F14DC5}Prefabs/Weapons/Attachments/Lasers/anpeq15/Laser_NGAL_BLK.et" 18:05:27.443 ENTITY : Create entity @"ENTITY:4611686018427630111" ('GameEntity','Prefabs/Weapons/Attachments/Lasers/anpeq15/NGAL.xob') at <1951.729980 59.000000 504.459991> @"{613FC21D99F14DC5}Prefabs/Weapons/Attachments/Lasers/anpeq15/Laser_NGAL_BLK.et" 18:05:27.443 DEFAULT (W): Provided entity is not valid for procedural animation. ()
Is there a way to filter Land vehicles from Air and sea, right now im having this issue where boats are spawning on land and AI cannot fly helicopters
the destructor of the entity?
No
We don't have access to ping via script right?
I was just trying to make it show their ping when they hover over a widget on menu UI
Is the logic for what counts as getting an XP reward in the engine? eg I want to give XP to players that dance a lot so the psuedo code would be like:
if duration(player.action(Dance_Mod)) > 5 minutes:
XPReward(500);
XPAlert(Dancing());
Yo Im kinda new to workbench and enfusion and modding. working on my first project right now. Im having trouble getting Workbench to recognize my scripts The script is written and it compiled with 0 errors. Now I'm trying to Add Component to en Entity in World Editor but my script does not show up in the search. Feels like I've tried everything - makling sure class designation is correct. making sure file path through 'Addons' 'Scripts' and 'Game' is correct - restarting enfusion. Nothing workls. If anybody has any advice id greatly appreciate it. I can send screenshots etc if seeing what iI have would help
for context, what you should see here in the screenshots is my file path leading to script, my search for the script in the Add Component part of World Editor which does not work - search comes up empty, cant find the script (im trying to add it to the prefab ANPRC radio) . and the code for the script itself in script editor
YourAddon/Scripts/Game/.../file.c
structure should be like that iirc
YourAddon being the existing addon folder
okay so its "YourAddon" instead of "Addons" ?
no
in your case its e.g. RadioBat/Scripts/Game/RadioBatComponent/SCR_RadioBatComponent.c
also dont use SCR make your own tag like LBL or something else
okay, ill try that. thought it had to SCR for it to work
no its just a "per author" tag
SCR is vanilla stuff for example
will it still technically work with SCR thEN?
i think having a tag matters for some script editor plugins or other things though, not too sure
yes
Is there some way to set default values for array editor attributes?
Doing something like
[Attribute("{921A76C90C54CDE3}PrefabsEditable/Auto/Compositions/Misc/CustomEntities/InteractionPoints/E_MO_Stash.et", uiwidget: UIWidgets.ResourcePickerThumbnail)]
ref array<ResourceName> propWhitelist;
causes that entry to be populated by default when adding a value to the array, but doesn't make the array have that value by default. Is there some special syntax I can use for the default for WB to parse it as expected?
It's from Bohemia code, looks like cast for SCR_XPHandlerComponent fails and returns returns a null ptr that errors when trying to access a method on it. There's no error checking for the cast.
There's no other code in the function that can throw this error. Maybe a dev should look at it.
Dunno if it's possibly caused by an AI mod but you could try to remove and see.
You could probably yourself stop the crashing by overriding the AwardXPToGroupmethod in SCR_AIGroupCohesionComponent and adding a null ptr check, if you wanted
It's funny that the code example for Cast has the error check but in practice the implemented method does not
Though I will admit it doesn't make sense to me that it can return null in a real gamestate somehow
The AI mods could be doing funny things with the XP component. If you don't want to remove mods, overriding the method is easy
how would I go about doing this?
also I removed the only AI mod I had given I thought it was potentially the AI mod as well. However, this started after I removed it for whatever reason
All you have to do is make a script override for that class in the Workbench. Copy paste the original source method into your overrided method. Then just add a couple lines of error check. Then build your mod and put the packaged mod files in the addons directory of your server. Edit the serverconfig.json file to add your mod's information.
If you have no coding or modding experience maybe it's a bit daunting
If you are just a server owner or hoster and don't really understand what I'm talking about it's ok. Just say so and I or someone else can give more in depth advice.
Especially as I am about to go to sleep and won't be able to respond soon. Maybe someone else will show up and give their advice and opinion on the matter. And maybe a dev can explain how the Cast can fail and why there is no error check
Casting to something that is not of the target type on cast will return null
And casting of a null to anything will return null
It gets the base from some Get functions and FindComponent call
I don't enough to know if it those can return null or the original reference freed or w/e
it is from Bohemia script maybe you can look and see? I don't see any other way to get null instance reference
I'm spawning AIs to vehicles (cars, helicopters, ..). I find a free compartment slot and then use GetInVehicle. I forceTeleport and performWhenPaused. Most of the time all works nicely, but sometimes the AI are left where they were spawned on the map. They've done the sit down animation but exist in the world. See the AIs in the image just sitting there and not reacting.
Is there a better way or am I doing smth wrong?
Why does the OnMagazineChanged event handler fire twice when reloading? Am I misunderstanding something? 🤔
Here's how I do it: ```cs
// Get vehicle compartments
BaseCompartmentManagerComponent slotCompMan = BaseCompartmentManagerComponent.Cast(spawnedVehicle.FindComponent(BaseCompartmentManagerComponent));
array<BaseCompartmentSlot> vehicleCompartments = new array<BaseCompartmentSlot>;
slotCompMan.GetCompartments(vehicleCompartments);
// Loop through all group members
for(int j = 0; j < agents.Count(); j++)
{
AIAgent member = agents[j];
if(member)
{
SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(member.GetControlledEntity());
CompartmentAccessComponent CAComp = CompartmentAccessComponent.Cast(character.FindComponent(CompartmentAccessComponent));
// If not in vehicle, put in an open seat
if(CAComp && character && !character.IsInVehicle() && j < vehicleCompartments.Count())
{
BaseCompartmentSlot slot = vehicleCompartments[j];
if(slot)
CAComp.GetInVehicle(spawnedVehicle, slot, true, -1, ECloseDoorAfterActions.INVALID, false);
}
// If no more seats open, remove the member from the group and delete
else
{
group.RemoveAgent(member);
RplComponent.DeleteRplEntity(member.GetControlledEntity().GetRootParent(), false);
}
}
}
Maybe the "change" is to no magazine, then when you put the new one in it changes again? 🤷♂️
You can spawn characters directly within the compartment, there is a function for that
BaseCompartmentSlot::SpawnCharacterInCompartment()
It takes a resource name and optionally an inout AI group, you can e. g. iterate over all slots and call the function with an AIGroup variable initially set to null
I didn't think much of it at the time but I noticed when running your missions mod my DS occasionally gets a bunch of warnings related to GetInVehicle, so I would guess there is some predicate for it to work not being met sometimes. The method Til mentioned to spawn them directly in compartment might avoid it completely
this actually seems to the be the case, so adding a check like so seems to prevent it from firing twice, and only once if needed like so (all this for reference for others):
//------------------------------------------------------------------------------------------------
protected void OnMagazineChanged(BaseWeaponComponent weapon, BaseMagazineComponent magazine, BaseMagazineComponent prevMagazine)
{
if (magazine)
{
<perform code here>
}
}```
Has anyone had any weird issues with SCR_UniversalInventoryStorageComponent.ShouldHideInVicinity() result seeming to get cached for other entities?
I have the following override so that my loot containers are hidden from vicinity:
modded class SCR_UniversalInventoryStorageComponent : UniversalInventoryStorageComponent
{
override bool ShouldHideInVicinity()
{
IEntity owner = GetOwner();
bool isLootSpawn = DL_LootSpawn.Cast(owner);
PrintFormat("DL: ShouldHideInVicinity(): %1 = %2", owner, isLootSpawn);
if (isLootSpawn)
return true;
return super.ShouldHideInVicinity();
}
}
When this override is enabled, the hidden loot containers will cause other storages which should not be impacted to become hidden in vicinity such as vehicles and backpacks. I can confirm from logs that the method is returning false for these entities, yet they remain hidden.
For some weird reason, dropping an equipped weapon seems to magically fix it ??? 
@torn bane I remember you mentioning that now in 1.6 dedicated server clients that close and relaunch will retain their player IDs, I cannot for the life of me get that to work however, everytime I close the client and reopen it, it connects as a brand new player
Seems to be an actual Reforger bug, ticket opened: https://feedback.bistudio.com/T196429
Is there anyway to see if a prefab inherits another prefab
For example if an object inherits Bush_Base
There should be an option to "find references" with the right click menu, the log console might show where it's used
i dont think ive ever heard anyone use trees to make something work 
My current goal is for owner/authority to know transformation from proxies of an entity. As there is no way to replicate properties or rpc call from proxy to owner/authority, what would be a good way to do this?
My current guess would be making a player controller component that would pull needed entities proxy data?
Yeah you would have something player-owned (playercontroller or a custom component attached to it) RPC the local data.
I think I remember someone saying GameSystem WorldControllers can also be useful for client->server requests, that might be a cleaner way of doing it w/o cramming extra stuff into playercontroller class
Looking at how the edit mode building placement is done might give you some direction, IIRC it essentially does a similar thing to what you're going for where client sends local transform of placed preview in a request to server asking it to spawn the entity with that transform
It's for reconnection, so after timeout. Kill the process via task manager details tab. Exiting in-game or any other way will result in graceful disconnect and shutdown. Then they will not get back their identity next time
Hello in RestContext the FILE and FILE_NOW functions are currently marked as obsolete with “Not supported, will be removed!”. Do you plan to update them or integrate a similar feature in the future ?
No, they will be removed without replacement
Any word on FindController fix?
It's kind of got me at a standstill.
Are we looking at 1.7 or before?
Thanks, I was looking for this but in the wrong place. Seems to work nicely!
Pretty much the same as I do/did. I'm prioritizing pilot and then gunner to fill in the seats. Before selecting the slot, I check that it is not occupied, it's accessible and it's not reserved. Seems that adding an AI to a compartment, does not immediately make it reserved. Now, if you immediately try to add another AI there, it will "succeed". Eventually when the AI is set in the seat, there might be another AI already sitting there -> AI sits outside. This seems to be my issue. Doing a .SetReserved() for the compartment after assigning the AI to it, seems to solve my issue.
Using GetOwnerPlayerID is also busted
Next big release probably
Just use modded player controller
Good to know. I rebuilt everything on world systems and world controllers and now I can't finish my new spawn system.Therefore I can't spawn and test mechanics either.
Yeah I did that too
Damn
Then had to undo it all
I ain't undoing anything lol
Guess you are waiting
The systems are fine (despite running on both server and client regardless of init info)
All my systems are running fine.I just can't get the player controller to attach a camera to when I spawn
Just need to make sure to check rpl role
It should be on both but I will have to double check when I get home.Thanks
If you see these issues still, please DM me details. Thanks.
Yeah I'll try to pay attention to logs and see what missions are spawned when it happens
That's interesting, I've never had that issue
I just tracked which compartments I used for mine
Had the same issue and this was the solution I came up with lmao
Good that I'm not the only one. I was thinking about the approach you have, but decided to dig deeper to find the reason. 🙂
is there anything that exists in the game to detect elevation and set off a trigger, or will i have to create this myself?
the best i can think of now is offsetting the projectile's collisiontriggercomp by my desired distance, but that seems very wack and has a chance of detecting things i don't want it to even with an arming distance.
Is there a reliable way to determine the type of terrain an entity is sitting upon? For example, to determine if a entity is on dirt versus being on a rock/road/etc
Maybe by getting the game material of the collider..?
//------------------------------------------------------------------------------------------------
//! Is the buriable entity sitting on top of a buriable material?
protected bool IsOnSoil(IEntity buriableEntity)
{
TraceParam paramGround = new TraceParam();
paramGround.Start = buriableEntity.GetOrigin() + (vector.Up * 0.1);
paramGround.End = paramGround.Start - vector.Up;
paramGround.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
paramGround.Exclude = buriableEntity;
paramGround.LayerMask = EPhysicsLayerPresets.Terrain;
buriableEntity.GetWorld().TraceMove(paramGround);
GameMaterial material = paramGround.SurfaceProps;
if (material.GetResourceName().Contains("soil")
|| material.GetResourceName().Contains("dirt")
|| material.GetResourceName().Contains("grass")
|| material.GetResourceName().Contains("gravel")
|| material.GetResourceName().Contains("sand")
|| material.GetResourceName().Contains("pebbles"))
return true;
return false;
}
``` seems to work how I want, reference to others in the future
Probably weird question
Can we dynamically cast Managed object to some class, knowing its typename?
Huh?
I mean what i a correlation between typename and class
for example
SomeComponent.Cast(entity.FindComponent(SomeComponent))
is basically
Class.Cast(entity.FindComponent(typename))
Now I have typename, and I can get entity.FindComponent(typename) but I still have to cast it to original component
Yes you can do a switch statement on the object type string
Also you don't need to cast it to original component that is wrong, it can be downcast or upcast
from what i understand 'managed' is the 'lowest class' an object can have so ye from that you can try any cast to it
What do you mean? I have to cast it to the original component to be able to use methods available in that component (FindComponent always returns Managed)
Yeah I know, I am just wondering whether I can retrieve dynamicly original class for that component (for example I have array of different components)
Class is the lowest
Managed inherits from Class
You can cast it to anything in its inheritance line
The Cast is a form of reflection since it either returns null or succeed, but I believe there is something like a GetTypeName() method
But technicalyl speaking, there are multiple lowests
pointer class has null as parent
and Class has null as parent
etc
There is no Null type class
Well yes I can get type but compiler won't let me cast to type, only to Class
by null I mena that it has nothing o n cpp side
You can just call the method through the little reflection you have
But it will be considerably slower, so do not use it for hot areas
Enforce Script is compile time, so it can't "figure out" the class type to be compiled after compilation. It does not make sense
So you have to do it at runtime
Got it.
Thank you again
Are GameSystems not automatically paused on GameTimePaused?
Oh nvm, its false on default 
override bool ShouldBePaused()
{
return true;
}
how to angle decal same with player.GetYawPitchRoll();
I use CreateDecal and angle param little bit confusing
T196480
You're just doing it wrong.
yaw* Math.DEG2RAD
Hey guys I've been learning this from scratch just a couple questions.
Are base game functions pre scripted?
If I want to create a standard area capture game mode do I have to manually script in every area and score for each side or is that pre-scripted ?
Lastly any pointers or tutorials for beginners?
Take a look at https://enfusionengine.com/api/redirect?to=enfusion://ResourceManager/~ArmaReforger:worlds/CaptureAndHold/CAH_Arland1.ent
or one of the other CAH worlds to get an understanding of how it all works.
I would also suggest to read everything on both of these pages, in order.
https://community.bohemia.net/wiki/Category:Arma_Reforger/Modding/Scripting/Guidelines?useskin=vector&useskin=darkvector
https://community.bohemia.net/wiki/Category:Arma_Reforger/Modding/Scripting/Tutorials?useskin=vector&useskin=darkvector
Someone with little to no experience with Object Oriented Programming and the Entity/Component System is gonna have a rough time writing scripts until they at least have a basic understanding of both.
Thank you so much, yeah I'm not familiar with the class or call functions so far it mostly looks like typescript.
don't get confused by "Entity/Component System"; Google that and you will read about an architecture popularised by Unity that is not used in this game. There are entities, components, and systems, but not an "Entity Component System"
Hello, in my server while we are with GM no matter what it shows this in console, spamming all time
You can still play but it accumulates in logs
Does anyone know how to patch the wcs_loadouteditor issue?
anybody know how can I retrieve the spawned units of a SCR_AIGroup?
nvm found it xD
also I just realized intellisense auto completion doesn't show all methods when you type it like this
not sure if its a bug or not
I guess its a bug
guys how can I add a component to an entity through code?, have been exploring wiki and intellisense auto completion I don't see something like adding a component through code
ping me @ if u have a answer
I don't believe it's possible. I think at most, you could pre-apply it to the prefab, and enable it through script potentially?
oh I see, its not like Unity
it is simply
IEntity someEntity;
someEntity.AddComponent(someComponentType)
Don't know that means, it's there. You need an actual entity object to use the method
it doesn't exist, not sure where chance is coming up with that
there isn't a method defined addcomponent
is it possible to store a custom variable in an entity similar to Arma 3 setvariable u guys?
if there is a way then I don't need to add a component in runtime
oh wait I guess u could make a dictionary
What's the thing against adding a component to it?
well storing the SCI_AIGroup entity as a key and for a value storing the information I want, kinda stupid but works
I think will
you are right
No their isn't. Not sure why people, like to spread false information.
If you need a component to exist on all entities of one type just add it to the base prefab that they all inherit from.
the base prefab is SCR_AIGroup so I don't think thats gonna happen, trying to store some info but already figured you could use dictionaries 4 that
I thought I saw it reading in the code on Workbench. Prob had it mixed up with FindComponent and my memory of AddComponent in Unity
I don't think you can modify a base prefab part of the engine or provided by BI not sure and also it wouldn't be a good idea
yea but what if another mod happens to modify that same prefab?
The modification stack
Cool
I call the anim commands from the SCR_CharacterCommandHandlerComponent like:
override event bool HandleWeaponReloading(CharacterInputContext pInputCtx, float pDt, int pCurrentCommandID) {
// if(!rplComp.IsOwner()) return; // This is where I filtermy rpl ownership checks
if (condition) {
charAnimComp.CallCommand(myCharCommand, 1, 0.0);
weapAnimComp.CallCommand(myWeapCommand, 1, 0.0);
}
}
On multiplayer, if I call from this rpl perspective, the proxies see the anim on:
Anyone:
- Char: Yes (but buggy)
- Weapon: No
Owner: - Char: Yes
- Weapon: No
Authority: - Char: No
- Weapon: No
I have only been able to get the weapon anims to show if I Rpc and broadcast it to proxies, but it's way out of sync. All commands are synchronized and all commands are bound. Where am I going wrong?
You can modify any prefab, for your task - just create your own component and add it to base prefab override, that's all
It would be smart for every mod developer to not just stack all their components on the same overrided prefab, and instead use their own derived/duplicated class as a new base for their mod
But it depends if you want to add a component that truly affects all child classes of that base, and not just your own mod's stuff