Skip to content

Commit

Permalink
UnLua v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chienluo committed Aug 13, 2019
0 parents commit 102b557
Show file tree
Hide file tree
Showing 229 changed files with 26,220 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Config/DefaultEditor.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


2 changes: 2 additions & 0 deletions Config/DefaultEditorSettings.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[/Script/UnrealEd.AnalyticsPrivacySettings]
bSendUsageData = false
131 changes: 131 additions & 0 deletions Config/DefaultEngine.ini

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions Config/DefaultGame.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=6EA8D66B479BD73FE99BE9B2084D9F14

[/Script/UnrealEd.ProjectPackagingSettings]
Build=IfProjectHasCode
BuildConfiguration=PPBC_Shipping
StagingDirectory=(Path="")
FullRebuild=False
ForDistribution=False
IncludeDebugFiles=False
BlueprintNativizationMethod=Disabled
bIncludeNativizedAssetsInProjectGeneration=False
bExcludeMonolithicEngineHeadersInNativizedCode=False
UsePakFile=True
bGenerateChunks=False
bGenerateNoChunks=False
bChunkHardReferencesOnly=False
bBuildHttpChunkInstallData=False
HttpChunkInstallDataDirectory=(Path="")
HttpChunkInstallDataVersion=
IncludePrerequisites=False
IncludeAppLocalPrerequisites=False
bShareMaterialShaderCode=False
bSharedMaterialNativeLibraries=False
ApplocalPrerequisitesDirectory=(Path="")
IncludeCrashReporter=False
InternationalizationPreset=English
-CulturesToStage=en
+CulturesToStage=en
bCookAll=True
bCookMapsOnly=False
bCompressed=True
bEncryptIniFiles=False
bEncryptPakIndex=False
bSkipEditorContent=True
bSkipMovies=False
+DirectoriesToAlwaysStageAsUFS=(Path="Script")
bNativizeBlueprintAssets=False
bNativizeOnlySelectedBlueprints=False

6 changes: 6 additions & 0 deletions Config/DefaultGameUserSettings.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[/Script/Engine.GameUserSettings]
ResolutionSizeX=1920
ResolutionSizeY=1080
FullscreenMode=2
bUseDesktopResolution=false
Version=5
90 changes: 90 additions & 0 deletions Config/DefaultInput.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@

[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_TriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip1Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Grip2Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Left_Thumbstick_Z",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MotionController_Right_Thumbstick_Z",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_FaceButton1",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_FaceButton2",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_IndexPointing",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_ThumbUp",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_FaceButton1",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_FaceButton2",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_IndexPointing",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_ThumbUp",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouchpad_Touchpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouchpad_Touchpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_HandGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_IndexGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_MiddleGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_RingGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Left_PinkyGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_HandGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_IndexGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_MiddleGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_RingGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="SteamVR_Knuckles_Right_PinkyGrip",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
bCaptureMouseOnLaunch=True
bDefaultViewportMouseLock=False
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False
bUseAutocorrect=False
DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
DefaultViewportMouseLockMode=LockOnCapture
FOVScale=0.011110
DoubleClickTime=0.200000
+ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="Aim",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
+ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton)
+ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom)
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W)
+AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D)
+AxisMappings=(AxisName="Turn",Scale=1.000000,Key=MouseX)
+AxisMappings=(AxisName="LookUp",Scale=-1.000000,Key=MouseY)
+AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S)
+AxisMappings=(AxisName="MoveRight",Scale=-1.000000,Key=A)
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Gamepad_LeftY)
+AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=Gamepad_LeftX)
+AxisMappings=(AxisName="LookUpRate",Scale=1.000000,Key=Gamepad_RightY)
+AxisMappings=(AxisName="TurnRate",Scale=1.000000,Key=Gamepad_RightX)
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
ConsoleKey=None
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde


Binary file added Content/AnimationAssets/Death_1.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Death_2.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Death_3.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Enemy_Idle.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Enemy_Walk.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Idle_Rifle_Hip.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Jog_Bwd_Rifle.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Jog_Fwd_Rifle.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Jog_Lt_Rifle.uasset
Binary file not shown.
Binary file added Content/AnimationAssets/Jog_Rt_Rifle.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/Animations/ABP_AICharacter.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/Animations/BS_EnemyMovement.uasset
Binary file not shown.
Binary file added Content/Core/Animations/BS_PlayerMovement.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/AI/BB_Enemy.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/AI/BP_AICharacter.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/AI/BP_AIController.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/Blueprints/AI/BT_Enemy.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/BPI_Interfaces.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/BP_CharacterBase.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/BP_DamageType.uasset
Binary file not shown.
Binary file added Content/Core/Blueprints/BP_Game.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/Maps/MainMap.umap
Binary file not shown.
Binary file added Content/Core/Materials/M_Base.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/Materials/M_Floor_Inst.uasset
Binary file not shown.
Binary file added Content/Core/Materials/M_UE4Man_Body_Inst.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/Core/UI/UMG_Main.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/FPWeapon/Materials/MI_FPGun.uasset
Binary file not shown.
Binary file added Content/FPWeapon/Materials/M_FPGun.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Content/FPWeapon/Mesh/SK_FPGun.uasset
Binary file not shown.
Binary file not shown.
Binary file added Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset
Binary file not shown.
Binary file added Content/FPWeapon/Textures/T_FPGun_AO.uasset
Binary file not shown.
Binary file added Content/FPWeapon/Textures/T_FPGun_M.uasset
Binary file not shown.
Binary file added Content/FPWeapon/Textures/T_FPGun_N.uasset
Binary file not shown.
Binary file added Content/FPWeapon/Textures/UE4_LOGO_CARD.uasset
Binary file not shown.
Binary file not shown.
40 changes: 40 additions & 0 deletions Content/Script/AI/BP_AICharacter_C.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require "UnLua"

local BP_AICharacter_C= Class("BP_CharacterBase_C")

function BP_AICharacter_C:Initialize(Initializer)
self.Super.Initialize(self)
self.Damage = 128.0
--self.DamageType = UE4.UClass.Load("/Script/Engine.DamageType")
self.DamageType = UE4.UClass.Load("UDamageType")
end

--function BP_AICharacter_C:UserConstructionScript()
--end

function BP_AICharacter_C:ReceiveBeginPlay()
self.Super.ReceiveBeginPlay(self)
self.Sphere.OnComponentBeginOverlap:Add(self, BP_AICharacter_C.OnComponentBeginOverlap_Sphere)
end

function BP_AICharacter_C:Died(DamageType)
self.Super.Died(self, DamageType)
self.Sphere:SetCollisionEnabled(UE4.ECollisionEnabled.NoCollision)
local NewLocation = UE4.FVector(0.0, 0.0, self.CapsuleComponent.CapsuleHalfHeight)
local SweepHitResult = UE4.FHitResult()
self.Mesh:K2_SetRelativeLocation(NewLocation, false, SweepHitResult, false)
self.Mesh:SetAllBodiesBelowSimulatePhysics(self.BoneName, true, true)
local GameMode = UE4.UGameplayStatics.GetGameMode(self)
UE4.UBPI_Interfaces_C.NotifyEnemyDied(GameMode)
--self.Sphere.OnComponentBeginOverlap:Remove(self, BP_AICharacter_C.OnComponentBeginOverlap_Sphere)
end

function BP_AICharacter_C:OnComponentBeginOverlap_Sphere(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult)
local PlayerCharacter = OtherActor:Cast(UE4.ABP_PlayerCharacter_C)
if PlayerCharacter then
local Controller = self:GetController()
UE4.UGameplayStatics.ApplyDamage(PlayerCharacter, self.Damage, Controller, self, self.DamageType)
end
end

return BP_AICharacter_C
13 changes: 13 additions & 0 deletions Content/Script/AI/BP_AIController_C.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require "UnLua"

local BP_AIController_C = Class()

--BP_AIController_C.BehaviorTree = UObject.Load("/Game/Core/Blueprints/AI/BT_Enemy")
BP_AIController_C.BehaviorTree = LoadObject("/Game/Core/Blueprints/AI/BT_Enemy")

function BP_AIController_C:ReceiveBeginPlay()
--local BehaviorTree = UObject.Load("/Game/Core/Blueprints/AI/BT_Enemy")
self:RunBehaviorTree(self.BehaviorTree)
end

return BP_AIController_C
33 changes: 33 additions & 0 deletions Content/Script/Animation/ABP_AICharacter_C.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "UnLua"

local ABP_AICharacter_C = Class()

function ABP_AICharacter_C:AnimNotify_NotifyPhysics()
UE4.UBPI_Interfaces_C.ChangeToRagdoll(self.Pawn)
end

function ABP_AICharacter_C:BlueprintBeginPlay()
self.Velocity = UE4.FVector()
self.Pawn = self:TryGetPawnOwner()
end

function ABP_AICharacter_C:BlueprintUpdateAnimation(DeltaTimeX)
local Pawn = self:TryGetPawnOwner(self.Pawn)
if not Pawn then
return
end
local Vel = Pawn:GetVelocity(self.Velocity)
if not Vel then
return
end
self.Speed = Vel:Size()
local Character = Pawn:Cast(UE4.ABP_CharacterBase_C)
if Character then
if Character.IsDead and not self.IsDead then
self.IsDead = true
self.DeathAnimIndex = UE4.UKismetMathLibrary.RandomIntegerInRange(0, 2)
end
end
end

return ABP_AICharacter_C
52 changes: 52 additions & 0 deletions Content/Script/Animation/ABP_PlayerCharacter_C.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require "UnLua"

local ABP_PlayerCharacter_C = Class()

function ABP_PlayerCharacter_C:AnimNotify_NotifyPhysics()
UE4.UBPI_Interfaces_C.ChangeToRagdoll(self.Pawn)
end

function ABP_PlayerCharacter_C:BlueprintBeginPlay()
self.Velocity = UE4.FVector()
self.ForwardVec = UE4.FVector()
self.RightVec = UE4.FVector()
self.ControlRot = UE4.FRotator()
self.Pawn = self:TryGetPawnOwner()
end

function ABP_PlayerCharacter_C:BlueprintUpdateAnimation(DeltaTimeX)
local Pawn = self:TryGetPawnOwner(self.Pawn)
if not Pawn then
return
end
local Vel = Pawn:GetVelocity(self.Velocity)
if not Vel then
return
end
local Character = Pawn:Cast(UE4.ABP_CharacterBase_C)
if Character then
if Character.IsDead and not self.IsDead then
self.IsDead = true
self.DeathAnimIndex = UE4.UKismetMathLibrary.RandomIntegerInRange(0, 2)
end
end
local Speed = Vel:Size()
self.Speed = Speed
if Speed > 0.0 then
Vel:Normalize()
local Rot = Pawn:GetControlRotation(self.ControlRot)
Rot:Set(0, Rot.Yaw, 0)
local ForwardVec = Rot:GetForwardVector(self.ForwardVec)
local RightVec = Rot:GetRightVector(self.RightVec)
local DP0 = Vel:Dot(RightVec)
local DP1 = Vel:Dot(ForwardVec)
local Angle = UE4.UKismetMathLibrary.Acos(DP1)
if DP0 > 0.0 then
self.Direction = Angle
else
self.Direction = -Angle
end
end
end

return ABP_PlayerCharacter_C
73 changes: 73 additions & 0 deletions Content/Script/BP_CharacterBase_C.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require "UnLua"

local BP_CharacterBase_C = Class()

function BP_CharacterBase_C:Initialize(Initializer)
self.IsDead = false
self.BodyDuration = 3.0
self.BoneName = nil
local Health = 100
self.Health = Health
self.MaxHealth = Health
end

--function BP_CharacterBase_C:UserConstructionScript()
--end

function BP_CharacterBase_C:ReceiveBeginPlay()
local Weapon = self:SpawnWeapon()
if Weapon then
Weapon:K2_AttachToComponent(self.WeaponPoint, nil, UE4.EAttachmentRule.SnapToTarget, UE4.EAttachmentRule.SnapToTarget, UE4.EAttachmentRule.SnapToTarget)
self.Weapon = Weapon
end
end

function BP_CharacterBase_C:SpawnWeapon()
return nil
end

function BP_CharacterBase_C:StartFire()
if self.Weapon then
self.Weapon:StartFire()
end
end

function BP_CharacterBase_C:StopFire()
if self.Weapon then
self.Weapon:StopFire()
end
end

function BP_CharacterBase_C:ReceiveAnyDamage(Damage, DamageType, InstigatedBy, DamageCauser)
if not self.IsDead then
local Health = self.Health - Damage
self.Health = math.max(Health, 0)
if Health <= 0.0 then
self:Died(DamageType)
local co = coroutine.create(BP_CharacterBase_C.Destroy)
coroutine.resume(co, self, self.BodyDuration)
end
end
end

function BP_CharacterBase_C:Died(DamageType)
self.IsDead = true
self.CapsuleComponent:SetCollisionEnabled(UE4.ECollisionEnabled.NoCollision)
self:StopFire()
local Controller = self:GetController()
Controller:UnPossess()
end

function BP_CharacterBase_C:Destroy(Duration)
UE4.UKismetSystemLibrary.Delay(self, Duration)
if self.Weapon then
self.Weapon:K2_DestroyActor()
end
self:K2_DestroyActor()
end

function BP_CharacterBase_C:ChangeToRagdoll()
self.Mesh:SetSimulatePhysics(true)
end

return BP_CharacterBase_C
Loading

0 comments on commit 102b557

Please sign in to comment.