Onset 1.7.0-alpha (Protocol Compatibility 8)
Client changelog
Second half of the pine wood town added
Unreal Engine Lua Wrapper
While thinking about a good API naming for the new clothing system I came to the conclusion that there is only a single satisfying solution.
Onset will now wrap classes and functions from Unreal Engine into Lua!
What does that mean?
Onset will provide you a Lua API that directly maps to the classes and functions from the Unreal Engine. It means you can basically do whatever Unreal can do.
What are the advantages?
As for the new clothing system it means that I don't have to write dozens of generic Lua functions that basically all do the same like "SetPlayerHairModel", "SetPlayerShirtModel".
This also paves the way for endless possibilities on modding. For example you can now also replace materials/textures on vehicles.
Do I need to use this API?
No, it's optional and it works perfectly fine with the "old" API. In fact you can also directly use the Unreal functions on entities from the old API.
What about the "old" API?
You can see this Lua Wrapper as an addition to the current system. For example you can use GetPlayerSkeletalMeshComponent to get a reference to the players body mesh. Then you continue with the new API to load a new mesh and set it to the player.
Clothing system example. Clothing models are "Skeletal Meshes" in Unreal. You can directly load models by specifying their path. A list of models will be added to the wiki.
As you can see it uses OOP. This is the best way and also necessary due to Unreal's class inheritance.
What Unreal functions are available?
Starting with this version I have began to wrap some of Unreals "component" classes as well as loading textures and materials from the game's pak file system.
I will add a list of classes and their functions shortly.
Server changelog
Client changelog
- New Lua functions
- SetSound3DLocation(sound, x, y, z), GetSound3DLocation(sound)
- IsGameDevMode()
- GetPlayerEquippedWeaponSlot()
- GetObjectModelName(ModelId) (needs testing)
- GetPlayerForwardVector(player), GetPlayerRightVector(player), GetPlayerUpVector(player)
- GetPlayerName(player)
- AddPostProcessMaterial(SlotName, UMaterialInterface), RemovePostProcessMaterial(SlotName)
- SetControlRotation(pitch, yaw, roll)
- Add SetObjectTexture(object, texturefile, materialslot)
Path layout: "packagename/folder/T_MyTexture.png"
Image width and height should be a power of two (for GPU performance), 128x128, 256x256, 1024x1024, etc
Image width and height should be the same (for GPU performance)
Material slot depends per object mesh. But 0 should be the main slot most of the time. - Add SetObjectAnimatedTexture(object, texturefile, rows, columns, materialslot)
Path layout: "packagename/folder/T_MyFlipbookTexture.png" - Add SetObjectColor and SetObjectEmissiveColor
- GetPlayerWeapon(slot) now behaves the same way as on the server. As a third parameter it returns the rounds in the magazine.
- Add event OnSteamOverlayActivated(bActivated) (needs testing)
- Add event On*NetworkUpdatePropertyValue(id, PropertyName, NewPropertyValue)
- Add event OnPlayerSwitchCamera(bIsFirstPerson). With the new clothing system I can no longer detect what clothing parts to hide during first person. You will have to use the new API to do that yourself.
- Add bSpectateCamera to GetCameraLocation
- Get*PropertyValue will now return nil instead of false if a property value does not exist or the entity identifier does not exist.
- Add createtable_ex to create tables with metatables, replaces setmetatable. (@JanHolger) Due to the OOP in the new Lua Engine API I can no longer guarantee that setmetatable is safe.
- Further improve Discord Rich Presence. Showing the Onset logo and the server IP when you hover it. When started with -dev it will show "Developing" instead of "Playing". The details will show "servername_short" from the server config.
- SMG03 firing animation now also moves the charging handle.
- Play correct helicopter pilot animation for helicopter seat 1.
- Add Steam Rich Presence. Please test if the "Join" button on a players Steam profile works.
- Files downloaded from the server will stay in the same order as defined on the server (@JanHolger)
- Add crouch walk aim animations for handguns and rifles!
- Stop shooting when starting to fall.
- Stop aiming when EnableFirstPersonMode is called.
- Disable reload and equip while playing custom animation.
- Settings save game file name now contains version suffix to prevent crashes in future changes.
- Add body masks. Body parts will no longer leak from under the clothing items. See examples in the new API on how to use them.
- Add new policeman & hat outfit
- Add Taser (subject to improvement in the next update)
Second half of the pine wood town added
Unreal Engine Lua Wrapper
While thinking about a good API naming for the new clothing system I came to the conclusion that there is only a single satisfying solution.
Onset will now wrap classes and functions from Unreal Engine into Lua!
What does that mean?
Onset will provide you a Lua API that directly maps to the classes and functions from the Unreal Engine. It means you can basically do whatever Unreal can do.
What are the advantages?
As for the new clothing system it means that I don't have to write dozens of generic Lua functions that basically all do the same like "SetPlayerHairModel", "SetPlayerShirtModel".
This also paves the way for endless possibilities on modding. For example you can now also replace materials/textures on vehicles.
Do I need to use this API?
No, it's optional and it works perfectly fine with the "old" API. In fact you can also directly use the Unreal functions on entities from the old API.
What about the "old" API?
You can see this Lua Wrapper as an addition to the current system. For example you can use GetPlayerSkeletalMeshComponent to get a reference to the players body mesh. Then you continue with the new API to load a new mesh and set it to the player.
Clothing system example. Clothing models are "Skeletal Meshes" in Unreal. You can directly load models by specifying their path. A list of models will be added to the wiki.
Code:
local SkeletalMeshComponent = GetPlayerSkeletalMeshComponent(GetPlayerId(), "Body") SkeletalMeshComponent:SetSkeletalMesh(USkeletalMesh.LoadFromAsset("/Game/CharacterModels/SkeletalMesh/BodyMerged/HZN_CH3D_Normal03_LPR")) SkeletalMeshComponent:SetMaterial(3, UMaterialInterface.LoadFromAsset("/Game/CharacterModels/Materials/HZN_Materials/M_HZN_Body_NoShoesLegsTorso")) // Mask to hide feet, legs and torso. SkeletalMeshComponent:SetFloatParameterOnMaterials("PupilScale", 1.3) // Make the pupil size big so it looks like the player is on drugs SkeletalMeshComponent:SetColorParameterOnMaterials("Skin Color", FLinearColor(0.239583, 0.239583, 0.239583, 0.0)) // Set brownish color. SkeletalMeshComponent = GetPlayerSkeletalMeshComponent(GetPlayerId(), "Clothing0") SkeletalMeshComponent:SetSkeletalMesh(USkeletalMesh.LoadFromAsset("/Game/CharacterModels/SkeletalMesh/HZN_CH3D_Normal_Hair_03_LPR")) SkeletalMeshComponent:SetColorParameterOnMaterials("Hair Color", FLinearColor(2.0, 0.0, 0.0, 0.0)) SkeletalMeshComponent = GetPlayerSkeletalMeshComponent(GetPlayerId(), "Clothing1") SkeletalMeshComponent:SetSkeletalMesh(USkeletalMesh.LoadFromAsset("/Game/CharacterModels/SkeletalMesh/Outfits/HZN_CH3D_Prisoner_LPR")) SkeletalMeshComponent = GetPlayerSkeletalMeshComponent(GetPlayerId(), "Clothing4") SkeletalMeshComponent:SetSkeletalMesh(USkeletalMesh.LoadFromAsset("/Game/CharacterModels/SkeletalMesh/Outfits/HZN_Outfit_Piece_CargoPants_LPR")) local DynamicMaterialInstance = SkeletalMeshComponent:CreateDynamicMaterialInstance(0) DynamicMaterialInstance:SetColorParameter("Clothing Color", FLinearColor(0.786458, 0.103145, 0.0, 1.0)) SkeletalMeshComponent:SetRelativeScale3D(FVector(1.0, 1.01, 1.0)) SkeletalMeshComponent:SetRelativeRotation(FRotator(0.0, 0.0, 0.0)) SkeletalMeshComponent:SetRelativeLocation(FVector(0.0, 0.0, 0.0))
What Unreal functions are available?
Starting with this version I have began to wrap some of Unreals "component" classes as well as loading textures and materials from the game's pak file system.
I will add a list of classes and their functions shortly.
Server changelog
- SetPlayerWeapon has a new parameter "bLoaded" to have the magazine loaded.
- GetPlayerWeapon now returns from 1 instead of 0
- Add "servername_short" setting (length limit 128 chars) to server_config.json
- Remove SetObjectTexture, SetObjectAnimatedTexture, SetObjectColor (see client changelog)
- Remove Set/GetPlayerModel (see client changelog for new clothing system)
- Remove ResetPlayerCamera (use client function: SetCameraLocation(0.0, 0.0, 0.0, false))
- Get*PropertyValue will now return nil instead of false if a property value does not exist or the entity identifier does not exist.
- Dynamic loading of packages is now possible!
-> StartPackage, StopPackage, IsPackageStarted
-> Files will be downloaded automatically by the client
-> When stopping a package timers will be destroyed automatically and the respective events and C++ plugin functions will be called.
-> The server or client will not cleanup any entities that you have spawned. You got to handle that yourself in OnPackageStop.