Scripting Guide
The syntax of variant of AngelScript used in Gothic 1 Remake can probably be best described as a mix between C# and C++. If you’ve used a C-family language before, it should feel somewhat familiar to you.
Object Nullchecks
Section titled “Object Nullchecks”Unreal AngelScript deliberately made the choice to not support this pattern:
if (!SomeObject) { ... } // Does not workif (SomeObject) { ... } // Does not workinstead, you’ll have to be explicit if you really want a nullcheck
if (SomeObject == nullptr) { ... }if (SomeObject != nullptr) { ... }however, in general, it is cleaner to just use IsValid instead:
if (!IsValid(SomeObject)) { ... }if (IsValid(SomeObject)) { ... }StaticClass
Section titled “StaticClass”All UObject-derived types have a ::StaticClass() static member function that returns the type’s UClass. To not have hundreds of ::StaticClass() sprinkled throughout the scripts, the class name itself
has been made to act as a global variable set to the class itself.
So these two are the same:
UClass Test1 = UMyObject; // New, shorter styleUClass Test1 = UMyObject::StaticClass(); // Old explicit styleThis was a feature that was added later during development, so you will still find ::StaticClass() being used in the scripts, but in general, prefer the shorter variant.
Automatic return type deduction
Section titled “Automatic return type deduction”Template support is limited to data-types, i.e. TArray<>, TSet<> etc. There is no function template support in the language at all. The odd one out is Cast<>, which is not really a function template but a language feature.
On many native bindings, the script engine can be instructed to change the return type of a function to match the type of a UObject or TSubclassOf, so that you don’t need to do another cast.
For example:
// Bad: Useless extra cast, GetTypedOuter already returns the right typeAActor OuterActor = Cast<AActor>(GetTypedOuter(AActor));AGothicCharacter OuterCharacter = Cast<AGothicCharacter>(GetTypedOuter(AGothicCharacter));UTextBlock TextBlock = Cast<UTextBlock>(NewObject(this, UTextBlock));
// Good: Return type is inherited from the passed classAActor OuterActor = GetTypedOuter(AActor);AGothicCharacter OuterCharacter = GetTypedOuter(AGothicCharacter);UTextBlock TextBlock = NewObject(this, UTextBlock);