Previous Question.
If a screen appears after a player is killed and your team occupies an area, you want to select a spawnable location (including the initial spawn) and spawn there.
I have written the code and I would like you to judge whether it is correct or not.
Please let me know if I’m missing something or if I’m doing something wrong.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Teams }
using { /Verse.org/Simulation }
using { /Verse.org/Simulation/Tags }
# リスポーンタグ定義
DominationSpawnTags<public> := module:
Tag_SpawnGroup<public> := class(tag){}
Tag_SpawnGroup_Initial<public> := class(Tag_SpawnGroup){}
Tag_SpawnGroup_GroupA<public> := class(Tag_SpawnGroup){}
Tag_SpawnGroup_GroupB<public> := class(Tag_SpawnGroup){}
Tag_SpawnGroup_GroupC<public> := class(Tag_SpawnGroup){}
Tag_TeamOwnership<public> := class(tag){}
Tag_TeamOwnership_Team1<public> := class(Tag_TeamOwnership){}
Tag_TeamOwnership_Team2<public> := class(Tag_TeamOwnership){}
# リスポーン管理クラス
respawn_manager := class(creative_device):
var SpawnPointGroupInitial:[]player_spawner_device = array{}
var SpawnPointGroupsCapPoint:[][]player_spawner_device = array{array{}, array{}, array{}}
var SelectedSpawnIndex:int = 0 # プレイヤーが選択したリスポーン地点のインデックス
@editable
CapturePoints:[]capture_area_device = {array{}}
# 初期リスポーンの無効化時間(秒)
InitialGroupDisableTime:float = 5.0
# 初期化処理
OnBegin<override>()<suspends>:void=
FindAndCacheSpawnDevices()
DisableInitialSpawnGroup()
# スポーンデバイスを取得
FindAndCacheSpawnDevices<private>():void=
InitialSpawnPoints:[]creative_object_interface = GetCreativeObjectsWithTag(DominationSpawnTags.Tag_SpawnGroup_Initial{})
for (FoundDevice : InitialSpawnPoints, DeviceAsSpawner := player_spawner_device[FoundDevice]):
set SpawnPointGroupInitial = SpawnPointGroupInitial + array{DeviceAsSpawner}
GroupTags:[]tag = array:
DominationSpawnTags.Tag_SpawnGroup_GroupA{}
DominationSpawnTags.Tag_SpawnGroup_GroupB{}
DominationSpawnTags.Tag_SpawnGroup_GroupC{}
for (I -> GroupTag:GroupTags):
FoundSpawnGroup:[]creative_object_interface := GetCreativeObjectsWithTag(GroupTag)
for (FoundDevice : FoundSpawnGroup, DeviceAsSpawner := player_spawner_device[FoundDevice]):
if:
set SpawnPointGroupsCapPoint[I] = SpawnPointGroupsCapPoint[I] + array{DeviceAsSpawner}
# 初期リスポーン地点の無効化処理
DisableInitialSpawnGroup<private>()<suspends>:void=
Sleep(InitialGroupDisableTime)
for (SpawnPoint : SpawnPointGroupInitial):
SpawnPoint.Disable()
# プレイヤーが倒された時のUI表示
OnPlayerEliminated(EliminatedPlayer:agent):void=
DisplaySpawnSelectionUI(EliminatedPlayer)
# リスポーン選択UIを表示
DisplaySpawnSelectionUI(TargetPlayer:agent):void= {}
# UIコードをここに実装(取得済エリアA, B, Cの選択肢を表示)
# プレイヤーの選択をトリガーするボタン設定なども含む
# リスポーン地点に応じた処理
RespawnPlayerAtSelectedPoint(TargetPlayer:agent):void=
if (SelectedSpawnIndex >= 0 and SelectedSpawnIndex < SpawnPointGroupsCapPoint.Length):
SelectedGroup := SpawnPointGroupsCapPoint[SelectedSpawnIndex]
for (SpawnDevice : SelectedGroup):
if (SpawnDevice.IsEnabled()):
SpawnDevice.SpawnPlayer(TargetPlayer)
return # スポーン完了後に終了