About two weeks ago, I started learning Verse. I got this code from the internet, but I modified it myself to apply damage to the fiends. Everything works perfectly, but I have a problem: I can’t get the tracker device to register the fiends’ eliminations. I’ve tried many things, one of them being that when a fiend is eliminated, it triggers an event, and that event would activate the tracker device. In my creative island, I need to eliminate a certain number of fiends to move on to the next round, but it’s impossible for me to make it work. I’m sure it’s because I’m not declaring some agent or something, as I’m not very good at programming.
Additional Info: When a creature from the Spawner Device is eliminated, it sends an event to the Tracker Device to increase the count.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Game }
custom_weapon_damage := class(creative_device):
@editable CustomDamageCB : conditional_button_device = conditional_button_device {}
@editable Spawner : []creature_spawner_device = array{}
@editable DamageMultiplierValue : float = 0.0
HandlePlayerHit(DamageResult : damage_result) : void =
if:
Target := DamageResult.Target
Amount := DamageResult.Amount
DamageMultiplier :float = DamageMultiplierValue
Instigator := DamageResult.Instigator?
InstigatorAgent := Instigator.GetInstigatorAgent[]
InstigatorPlayer := player[InstigatorAgent]
CharacterWhoWasHitFort := fort_character[Target]
CharacterWhoWasHitAgent := CharacterWhoWasHitFort.GetAgent[]
CharacterWhoWasHitPlayer := agent[CharacterWhoWasHitAgent]
then:
if (CustomDamageCB.IsHoldingItem[InstigatorPlayer]):
# Aplica daño con el multiplicador
CharacterWhoWasHitFort.Damage(Amount * DamageMultiplier)
Print("Holding item, Damage applied: {Amount * DamageMultiplier}")
else:
CharacterWhoWasHitFort.Damage(Amount)
Print("Not holding item, Damage applied: {Amount}")
FiendSpawned(Agent: agent):void=
if (FortCharacter := Agent.GetFortCharacter[]):
FortCharacter.DamagedEvent().Subscribe(HandlePlayerHit)
OnBegin<override>()<suspends>:void=
for (SpawnerDevice : Spawner):
SpawnerDevice.SpawnedEvent.Subscribe(FiendSpawned)