Running Command Every Few Sim-Minutes
Jul 13, 2020 21:16:44 GMT -5
MizoreYukii and digivix like this
Post by boopidoop on Jul 13, 2020 21:16:44 GMT -5
Took a long time but I finally figured it out! It's a bit cheaty, but it works!
Make a buff, with any timer. I've set mine to be invisible as it's meant to run in the background. Give it a timer - this one'll take 10 in-game minutes - and a _loot_on_removal
For the loot, all you need is a "reaction". This is meant to be used for animations, ie. when a buff is removed, make a happy face, but it turns out you can run commands through it too!
The interaction can be set up to run any command, as usual. Here's the bit for commands for anyone reading this who's new to commands.
Then in a script, add the buff with the following lines of code:
The result is that once the Buff timer runs out, it runs the LootActions which runs the Interaction, which runs the command to re-add the buff. Then just add break-cases!
I'm gonna have a lie down now
Make a buff, with any timer. I've set mine to be invisible as it's meant to run in the background. Give it a timer - this one'll take 10 in-game minutes - and a _loot_on_removal
<I c="Buff" i="buff" m="buffs.buff" n="buff_name" s="123">
<T n="audio_sting_on_add" p="InGame\Audio\Stings\sting_buff_gain.propx">39b2aa4a:00000000:8af8b916cf64c646</T>
<T n="audio_sting_on_remove" p="InGame\Audio\Stings\sting_buff_loss.propx">39b2aa4a:00000000:3bf33216a25546ea</T>
<T n="buff_description">0xBC2C0BE9<!--Test--></T>
<T n="buff_name">0xBC2C0BE9<!--Test--></T>
<T n="icon" p="InGame\UI\Icons\Buffs\buffs_hadafight_neg.png">2f7d0004:00000000:176e1332791c1b01</T>
<T n="visible">False</T>
<V n="_temporary_commodity_info" t="enabled">
<U n="enabled">
<T n="max_duration">10</T>
</U>
</V>
<L n="_loot_on_removal">
<T>456</T>
</L>
</I>
For the loot, all you need is a "reaction". This is meant to be used for animations, ie. when a buff is removed, make a happy face, but it turns out you can run commands through it too!
<I c="LootActions" i="action" m="interactions.utils.loot" n="loot_name" s="456">
<L n="loot_actions">
<V t="reaction">
<U n="reaction">
<V n="mixer_reaction" t="enabled">
<U n="enabled">
<T n="affordance">5678</T>
</U>
</V>
</U>
</V>
</L>
</I>
The interaction can be set up to run any command, as usual. Here's the bit for commands for anyone reading this who's new to commands.
<V n="outcome" t="dual">
<U n="dual">
<U n="success_actions">
<L n="basic_extras">
<V t="do_command">
<U n="do_command">
<T n="command">command_name</T>
</U>
</V>
</L>
</U>
<U n="failure_actions">
<V t="enabled" n="animation_ref">
<U n="enabled">
<T n="factory">11870<!--AnimationElement: Soc_Friendly_T_Console_Fail_basic--></T>
</U>
</V>
<E n="outcome_result">FAILURE</E>
</U>
<U n="success_chance">
<T>50</T>
</U>
</U>
</V>
Then in a script, add the buff with the following lines of code:
sim_info = get_optional_target(opt_sim, target_type=OptionalSimInfoParam, _connection=_connection)
if sim_info is None:
return False
manager = services.get_instance_manager(Types.BUFF)
timer = manager.get(123)
sim_info.debug_add_buff_by_type(timer)
The result is that once the Buff timer runs out, it runs the LootActions which runs the Interaction, which runs the command to re-add the buff. Then just add break-cases!
I'm gonna have a lie down now