Can someone explain to me how to build a verse code making the chug cannon heal players for 100 health or any number greater than what it already does? like what devices do I use to make it work.
You can’t “directly” mess with weapon stuff BUT you can work your way around it.
Specifically subscribe to the HealedEvent, and then conditionalbutton check if the source of the heal was holding the chug cannon, then you can adjust the target player’s health accordingly
Keep in mind this method is not foolproof and can be abused since by the time the healing is applied (eg till the chug cannon projectile lands people could switch weapons, or even heal in some other way AND then switch to a chug cannon at the same time to benefit from bonus heals), Would heavily recommend to heavily test that whatever implementation you do it’s not abusable (unless you don’t mind that much)
Hello, as far as I know there is not a way to make it fully reliable or clean to detect this, because we can’t cast the weapons in healing result or damage result to a type like the cannon.
There is a “hacky” way of doing it with conditional button and a custom device. This implies that it would only work while the player is holding the cannon in hand.
Here is the script.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
chug_device := class(creative_device):
@editable
ExtraHeal : float = 50.0
@editable
#This conditional button is going to have a reference to the chug cannon
ConditionalButton : conditional_button_device = conditional_button_device{}
var SubscriptionsMap : [player]subscriptions_container = map{}
var HealCooldownsMap : [agent][]heal_cooldown_from_same_source = map{}
OnBegin<override>():void=
Playspace := GetPlayspace()
Playspace.PlayerAddedEvent().Subscribe(OnPlayerAdded)
Playspace.PlayerRemovedEvent().Subscribe(OnPlayerRemoved)
for(Player : Playspace.GetPlayers()):
OnPlayerAdded(Player)
OnPlayerAdded(Player:player):void=
if:
not SubscriptionsMap[Player]
FortCharacter := Player.GetFortCharacter[]
then:
Container := subscriptions_container{}
Container.AddSubscription(FortCharacter.HealedEvent().Subscribe(OnCharacterHealed))
if. set SubscriptionsMap[Player] = Container
OnPlayerRemoved(Player:player):void=
if(Container := SubscriptionsMap[Player]):
Container.CancelAllSubscriptions()
OnCharacterHealed(HealingResult:healing_result):void=
if(WasFromChugCannon[HealingResult], IsHealNotInCooldown[HealingResult]):
StartCooldown(HealingResult)#need to update first cooldown before healing to avoid multiple call
HealingResult.Target.Heal(ExtraHeal)
WasFromChugCannon(HealingResult:healing_result)<decides><transacts>:void=
if:
Instigator := HealingResult.Instigator?#Player who caused the heal
SourceValue := HealingResult.Source?# Player or weapon that caused the heal
FortCharacter := fort_character[Instigator]#Check if the instigator is a fort character
InstigatorAgent := FortCharacter.GetAgent[]#Get Agent
HasWeaponOnHand := ConditionalButton.IsHoldingItem[InstigatorAgent]#Check player is holding the correct item
then:
true?
else:
false?
IsHealNotInCooldown(HealingResult:healing_result)<decides><transacts>:void=
if:
TargetFortCharacter := fort_character[HealingResult.Target]
TargetAgent := TargetFortCharacter.GetAgent[]
Instigator := HealingResult.Instigator?
SourceFortCharacter := fort_character[Instigator]
SourceAgent := SourceFortCharacter.GetAgent[]
Cooldowns := HealCooldownsMap[TargetAgent]
CooldownIndex := FindCooldownIndex[Cooldowns, TargetAgent, SourceAgent]
Cooldown := Cooldowns[CooldownIndex]
CurrentTime := GetSecondsSinceEpoch()
CurrentTime < Cooldown.FinishTime
then:# this is the only case that could cause a fail because it's on cooldown.
false?
else:# if some of the conditions before failed means it's not in cooldown
true?
StartCooldown(HealingResult:healing_result):void=
CooldownsInSeconds := 1.0
if:
TargetFortCharacter := fort_character[HealingResult.Target]
TargetAgent := TargetFortCharacter.GetAgent[]
Instigator := HealingResult.Instigator?#Player who caused the heal
InstigatorFortCharacter := fort_character[Instigator]#Check if the instigator is a fort character
InstigatorAgent := InstigatorFortCharacter.GetAgent[]#Get Agent
then:
Cooldown := heal_cooldown_from_same_source
{
Target := TargetAgent
Source := InstigatorAgent
FinishTime := GetSecondsSinceEpoch() + CooldownsInSeconds
}
AddCooldown(TargetAgent, Cooldown)
AddCooldown(Target:agent, Cooldown:heal_cooldown_from_same_source):void=
if(not HealCooldownsMap[Target]):
if. set HealCooldownsMap[Target] = array{}
if:
Cooldowns := HealCooldownsMap[Target]
then:
if:
CooldownIndex := FindCooldownIndex[Cooldowns, Cooldown.Source, Cooldown.Target]
then:
if. set HealCooldownsMap[Target][CooldownIndex] = Cooldown
else:
if. set HealCooldownsMap[Target] += array{ Cooldown }
FindCooldownIndex(Cooldowns:[]heal_cooldown_from_same_source, Target:agent, Source:agent)<decides><transacts>:int=
var MaybeIndex : ?int = false
for(i := 0..Cooldowns.Length, Cooldown := Cooldowns[i], not MaybeIndex?):
if:
Cooldown.Source = Source
Cooldown.Target = Target
then:
Index := i
set MaybeIndex = option { Index }
return MaybeIndex?
heal_cooldown_from_same_source := class():
Target : agent
Source : agent
FinishTime : float
subscriptions_container := class():
var Subscriptions : []cancelable = array{}
AddSubscription(Cancelable:cancelable):void=
set Subscriptions += array{ Cancelable }
CancelAllSubscriptions():void=
for(Subscription : Subscriptions):
Subscription.Cancel()
You would need to add a conditional button, set the key item to the chug cannon and set the reference to this in the custom_device.