I need help with timers please!

I’m able to get a damage over time effect to last the right amount of time, but I want to make it so that if I melee someone, the timer is reset but I don’t know how. I’m just adding more time to it.

So normally, I melee and they get afflicted with damage over time for 3 seconds. I want to make it so if they get hit with my melee again before the 3 seconds is up, the duration goes back up to 3 seconds (basically resetting the timer).

Any help appreciated!

With this particular case you store total time elapsed in a player variable comfortably for the attacker using melde, after you apply the DOT, i Hope you use any damage rule. If so after you srored the time you check with the wait until action if the difference of the total time elapsed minus the variable is less or equal 3 and if Event ability is equal Button melde. The wait time should be set to 3 and lastly you just reuse the DOT Action afterwards. Unfortunately i cant Go in detail rn.

1 Like

Damage/Heal Over Time, have an associated id that you should be storing to a player variable when its created, it can only be accessed by the Last Damage Over Time ID so if another one is made before it tries to store it you cant do anything, which is why its best to do it the action immediately after its created.

now that you’ve stored the id of the DOT, all you need to do to remove that instance of DOT is to use Stop Damage Over Time with the input of the variable storing its ID. you can put that right before the code to create the DOT and nothing will happen if no ID is stored.

in general when working with DOT or HOT you want the creation structure to look like;

  • Stop Damage Over Time(Player.DamageID)
  • Start Damage Over Time( [settings] )
  • Player.DamageID = Last Damage Over Time ID
1 Like

Here would be a code sample:

{
	global:
		0: DOTTimer
		1: DOTReferenceContainer
		2: DOTDamage

	player:
		0: DOTAttacker
		1: Delta
		2: DOT_IDIndex
		3: Victims
}

rule("Init DOT properties")
{
	event
	{
		Ongoing - Global;
	}

	actions
	{
		Global.DOTTimer = Workshop Setting Integer(Custom String("Damage Over Time"), Custom String("Duration in seconds"), 3, 1, 999, 0);
		Global.DOTDamage = Workshop Setting Integer(Custom String("Damage Over Time"), Custom String("Damage per second"), 25, 1, 999, 1);
		Global.DOTReferenceContainer = Array();
	}
}

rule("Apply DOT on single target")
{
	event
	{
		Player Dealt Damage;
		All;
		Freja;
	}

	conditions
	{
		Event Ability == Button(Secondary Fire);
		Victim.DOTAttacker == Null;
		Attacker.Delta == Null;
	}

	actions
	{
		Victim.DOTAttacker = Attacker;
		Victim.DOT_IDIndex = Random Integer(0, 999);
		Start Damage Over Time(Victim, Victim.DOTAttacker, Global.DOTDamage, Global.DOTTimer);
		Global.DOTReferenceContainer[Victim.DOT_IDIndex] = Last Damage Over Time ID;
		Attacker.Delta = Total Time Elapsed;
	}
}

rule("Reapply DOT on target")
{
	event
	{
		Player Took Damage;
		All;
		All;
	}

	conditions
	{
		Event Ability == Button(Secondary Fire);
		Victim.DOTAttacker == Attacker;
		Round To Integer(Total Time Elapsed - Attacker.Delta, To Nearest) <= Global.DOTTimer;
	}

	actions
	{
		Stop Damage Over Time(Global.DOTReferenceContainer[Victim.DOT_IDIndex]);
		Global.DOTReferenceContainer[Victim.DOT_IDIndex] = Null;
		Victim.DOT_IDIndex = Random Integer(0, 999);
		Start Damage Over Time(Victim, Victim.DOTAttacker, Global.DOTDamage, Global.DOTTimer);
		Global.DOTReferenceContainer[Victim.DOT_IDIndex] = Last Damage Over Time ID;
		Attacker.Delta = Total Time Elapsed;
		Wait(Global.DOTTimer, Restart When True);
		Stop Damage Over Time(Global.DOTReferenceContainer[Victim.DOT_IDIndex]);
		Global.DOTReferenceContainer[Victim.DOT_IDIndex] = Null;
		Victim.DOT_IDIndex = Null;
		Attacker.Delta = Null;
		Victim.DOTAttacker = Null;
	}
}

rule("Reset DOT")
{
	event
	{
		Ongoing - Each Player;
		All;
		Freja;
	}

	conditions
	{
		Is True For Any(All Players(Opposite Team Of(Team Of(Event Player))), Current Array Element.DOTAttacker == Event Player) == True;
		Round To Integer(Total Time Elapsed - Event Player.Delta, To Nearest) == Global.DOTTimer;
	}

	actions
	{
		Event Player.Victims = Filtered Array(All Players(Opposite Team Of(Team Of(Event Player))),
			Current Array Element.DOTAttacker == Event Player);
		For Player Variable(Event Player, I, 0, Count Of(Event Player.Victims), 1);
			Stop Damage Over Time(Global.DOTReferenceContainer[Event Player.Victims[Event Player.I].DOT_IDIndex]);
			Global.DOTReferenceContainer[Event Player.Victims[Event Player.I].DOT_IDIndex] = Null;
			Event Player.Victims[Event Player.I].DOT_IDIndex = Null;
			Event Player.Victims[Event Player.I].DOTAttacker = Null;
			Wait(0.016, Ignore Condition);
		End;
		Event Player.Delta = Null;
		Event Player.Victims = Empty Array;
	}
}
1 Like

i don’t get why you’ve done so much unnecessary stuff there, only an ID variable & the simple 3 actions in order that i listed above, as the start of the DOT… are needed, and that’ll reapply it automatically.

also why are 2/3 of your rules only for Freja? not only is that inconsistent but the OP didn’t mention Freja at all… only mentions melee

your comment is just confusing & overcomplicated, I’m not commenting this to sound rude or anything… its just I’m genuinely baffled by it.

1 Like

I hope that explains your confusion, it was just brain storming

1 Like