Jump to content

Infinite buff


Umbrella

Recommended Posts

Hello,

 

I am trying to define a buff with infinite duration. I would like your feedback and thoughts on the following options:

 

A) Re-add buff on finish

	<buff name="AAA" remove_on_death="true"> 			
		<stack_type value="duration"/>
		<duration value="10"/>
		<update_rate value="9"/>
		<effect_group name="AAA" tiered="false">			
			<triggered_effect trigger="onSelfBuffFinish" action="AddBuff" target="self" buff="AAA"/>							
		</effect_group>
	</buff>

This seems to work partially only. After 9 renew (hitting the smallest common multiple of duration and update_rate), the renew fails.

 

B) Use a dedicated duration cvar

I think this is how the game proceeds for infinite buffs. Use a cvar buff_duration, and remove the buff when the cvar hits 0.

For performance, you probably want a local cvar and check for IsServer in the cvar check

 

With A and B, If you need both finite and infinite version of the buff, you end duplicating it in xml. C) tries to solve it by making the renew depends on a cvar

 

C) Renew optionnaly

		<effect_group name="renewable">
			<requirement name="RenewBuffRequirement, Mymod" target="self"/>
			<triggered_effect trigger="onSelfBuffFinish" action="AddBuff" target="self" buff="AAA"/>
		</effect_group>

RenewBuffRequirement receives the buff name as parameter (say it's "AAA"), and check for cvar "__isrenew__AAA" on target entity.

 

Benefits:

- Don't duplicate buffs.

- The cvars "__isrenew__{buff_name}" are most of the time left to their default value (better performance than B which requires a set cvar per target of the buff)

 

This fails : I can see the requirement called and return the proper value, but the buff still wears off. Moving the requirement in/out the <triggered> fails in both case.

I cannot understand why this does not work, while A works (almost identical xml). Do you have an explanation for this ?

 

 

How do you usually implement infinite buff ?

 

Thank you for your attention !

 

 

Link to comment
Share on other sites

I assume by infinite buff you mean an infinite duration? If so, just set the duration to 0. Obviously if you die, it will be cleared out because of remove_on_death, but besides that it will be active till removed.

 

If you mean infinite as in a loop so that it has a possibility of wearing off, the way I do it is have my master buff add a second buff (AAA in your case) on update. This update rate is .5. The second buff (AAA) would be set to a 1 second duration and the stack type to replace. Every .5 seconds, the master buff would replace the AAA with a new version of that buff. Should master buff fail (using requirements) to replace the AAA buff, the AAA buff will fall off the player after 1 second.

Link to comment
Share on other sites

  • 1 month later...

Thanks a lot Telric. Your design is very clean, and I am currently using it. Don't know how I missed the duration=0 convention...

 

Stil, I dislike having all "duplicates" buffs in the xml. In an ideal world, the buff should only be an argument of a single renew mechanism. I finally fixed my example above. I needed to use trigger onSelfBuffRemove, instead of Finish (and additionaly checking is dead status). So I may give it another try.

Edited by Umbrella (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...