<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://chronocrash.com/openbor/wiki/index.php?action=history&amp;feed=atom&amp;title=Player_Die_Scripts</id>
	<title>Player Die Scripts - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://chronocrash.com/openbor/wiki/index.php?action=history&amp;feed=atom&amp;title=Player_Die_Scripts"/>
	<link rel="alternate" type="text/html" href="https://chronocrash.com/openbor/wiki/index.php?title=Player_Die_Scripts&amp;action=history"/>
	<updated>2026-10-21T15:39:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://chronocrash.com/openbor/wiki/index.php?title=Player_Die_Scripts&amp;diff=1040&amp;oldid=prev</id>
		<title>Dcurrent at 01:42, 21 August 2026</title>
		<link rel="alternate" type="text/html" href="https://chronocrash.com/openbor/wiki/index.php?title=Player_Die_Scripts&amp;diff=1040&amp;oldid=prev"/>
		<updated>2026-08-21T01:42:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:42, 20 August 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Player]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Player]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Script]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Script]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Script Events]]&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Die scripts&amp;#039;&amp;#039;&amp;#039; are global player events that execute when OpenBOR processes a native player death and life loss. Numbered scripts provide slot-specific behavior, while &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; provides one shared listener for every player.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Die scripts&amp;#039;&amp;#039;&amp;#039; are global player events that execute when OpenBOR processes a native player death and life loss. Numbered scripts provide slot-specific behavior, while &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; provides one shared listener for every player.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l314&quot;&gt;Line 314:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 312:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Death]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Death]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Script Overview]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[Script Overview]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Openbor]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Dcurrent</name></author>
	</entry>
	<entry>
		<id>https://chronocrash.com/openbor/wiki/index.php?title=Player_Die_Scripts&amp;diff=1039&amp;oldid=prev</id>
		<title>Dcurrent: Created page with &quot;Category:Player Category:Script Category:Script Events  &#039;&#039;&#039;Die scripts&#039;&#039;&#039; are global player events that execute when OpenBOR processes a native player death and life loss. Numbered scripts provide slot-specific behavior, while &lt;code&gt;dieall.c&lt;/code&gt; provides one shared listener for every player.  The numbered series consists of:  * &lt;code&gt;data/scripts/die1.c&lt;/code&gt; * &lt;code&gt;data/scripts/die2.c&lt;/code&gt; * &lt;code&gt;data/scripts/die3.c&lt;/code&gt; * &lt;code&gt;data/scripts/die4.c...&quot;</title>
		<link rel="alternate" type="text/html" href="https://chronocrash.com/openbor/wiki/index.php?title=Player_Die_Scripts&amp;diff=1039&amp;oldid=prev"/>
		<updated>2026-08-21T01:41:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/openbor/wiki/index.php?title=Category:Player&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Category:Player (page does not exist)&quot;&gt;Category:Player&lt;/a&gt; &lt;a href=&quot;/openbor/wiki/index.php/Category:Script&quot; title=&quot;Category:Script&quot;&gt;Category:Script&lt;/a&gt; &lt;a href=&quot;/openbor/wiki/index.php/Category:Script_Events&quot; title=&quot;Category:Script Events&quot;&gt;Category:Script Events&lt;/a&gt;  &amp;#039;&amp;#039;&amp;#039;Die scripts&amp;#039;&amp;#039;&amp;#039; are global player events that execute when OpenBOR processes a native player death and life loss. Numbered scripts provide slot-specific behavior, while &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; provides one shared listener for every player.  The numbered series consists of:  * &amp;lt;code&amp;gt;data/scripts/die1.c&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;data/scripts/die2.c&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;data/scripts/die3.c&amp;lt;/code&amp;gt; * &amp;lt;code&amp;gt;data/scripts/die4.c...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Player]]&lt;br /&gt;
[[Category:Script]]&lt;br /&gt;
[[Category:Script Events]]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Die scripts&amp;#039;&amp;#039;&amp;#039; are global player events that execute when OpenBOR processes a native player death and life loss. Numbered scripts provide slot-specific behavior, while &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; provides one shared listener for every player.&lt;br /&gt;
&lt;br /&gt;
The numbered series consists of:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;data/scripts/die1.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;data/scripts/die2.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;data/scripts/die3.c&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;data/scripts/die4.c&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The shared listener is:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;data/scripts/dieall.c&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
OpenBOR distinguishes an entity entering a dead state, a player losing a life, and an entity being killed or removed from play. The Die series represents the player-life event. This makes it useful for life-loss penalties, cooperative defeat handling, continue systems, player-specific statistics, encounter adjustment, audiovisual feedback, and any other system that should respond when a player leaves active play through the native death routine.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Create any desired Die-script files in &amp;lt;code&amp;gt;data/scripts&amp;lt;/code&amp;gt;. OpenBOR loads them automatically, so no model, level, or project command is required.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;die#.c&amp;lt;/code&amp;gt; is documentation shorthand in which &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; represents the player number. Literal filenames use &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File&lt;br /&gt;
! Scope&lt;br /&gt;
! Player identification&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;data/scripts/die1.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 1&lt;br /&gt;
| Filename - index &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;data/scripts/die2.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 2&lt;br /&gt;
| Filename - index &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;data/scripts/die3.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 3&lt;br /&gt;
| Filename - index &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;data/scripts/die4.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 4&lt;br /&gt;
| Filename - index &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;data/scripts/dieall.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Every player&lt;br /&gt;
| Local variable &amp;lt;code&amp;gt;playerindex&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Projects may use only the numbered files, only &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt;, or both layers together.&lt;br /&gt;
&lt;br /&gt;
== Die Event ==&lt;br /&gt;
&lt;br /&gt;
The Die series executes when OpenBOR&amp;#039;s native player-death routine processes a player leaving active play. Common causes include completing a normal defeat sequence, falling into a pit, moving beyond the permitted off-screen boundary, or another condition routed through native player death handling.&lt;br /&gt;
&lt;br /&gt;
This event is not a general entity-death listener. It does not execute merely because an entity enters a dead state or because &amp;lt;code&amp;gt;killentity()&amp;lt;/code&amp;gt; removes an entity through an unrelated path. The event belongs specifically to player-slot life processing.&lt;br /&gt;
&lt;br /&gt;
Each native player death runs the applicable Die-script chain once. If the player has another life, OpenBOR later creates the replacement player entity and executes the [[Respawn Scripts|Respawn series]]. If no lives remain, the Respawn series does not follow.&lt;br /&gt;
&lt;br /&gt;
== Execution Order ==&lt;br /&gt;
&lt;br /&gt;
OpenBOR performs the relevant player-death sequence in this order:&lt;br /&gt;
&lt;br /&gt;
# OpenBOR identifies the dying entity&amp;#039;s player slot.&lt;br /&gt;
# The player&amp;#039;s life count is reduced when native life deduction is active.&lt;br /&gt;
# The corresponding numbered script, &amp;lt;code&amp;gt;die1.c&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;die4.c&amp;lt;/code&amp;gt;, executes when present.&lt;br /&gt;
# &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; executes when present and receives &amp;lt;code&amp;gt;playerindex&amp;lt;/code&amp;gt;.&lt;br /&gt;
# OpenBOR clears the player slot&amp;#039;s entity reference and stores health and magic values for a possible respawn.&lt;br /&gt;
# OpenBOR removes the old entity or leaves an inert corpse according to the model&amp;#039;s death configuration.&lt;br /&gt;
# If no lives remain, OpenBOR performs the applicable continue or game-over preparation and ends the death routine.&lt;br /&gt;
# If lives remain, OpenBOR creates the replacement player entity and executes the numbered and shared Respawn scripts.&lt;br /&gt;
# Native post-respawn enemy-drop, rumble, and timer-reset behavior continues as configured.&lt;br /&gt;
&lt;br /&gt;
The player&amp;#039;s remaining-life value is already current when either Die-script layer begins. The dying entity is also still assigned to the player slot and can be retrieved through the player property API during the event.&lt;br /&gt;
&lt;br /&gt;
The numbered script always executes before &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt;. Shared logic can consequently consume state established by the slot-specific script during the same death event.&lt;br /&gt;
&lt;br /&gt;
== Numbered Die Scripts ==&lt;br /&gt;
&lt;br /&gt;
Numbered Die scripts are tied to the player slot identified by their filename. They receive no automatic event variables because the player identity is already fixed by that filename.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    // die3.c always represents Player 3, player index 2.&lt;br /&gt;
    setglobalvar(&amp;quot;player_three_defeated&amp;quot;, 1);&lt;br /&gt;
    setglobalvar(&amp;quot;party_state_changed&amp;quot;, 1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Slot-specific files are convenient for asymmetric penalties, unique defeat effects, fixed cooperative roles, individual statistics, or other behavior tied to one player position.&lt;br /&gt;
&lt;br /&gt;
== Dieall ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; is the shared listener for every player slot. OpenBOR supplies one automatic local variable:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Variable&lt;br /&gt;
! Type&lt;br /&gt;
! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;playerindex&amp;lt;/code&amp;gt;&lt;br /&gt;
| Integer&lt;br /&gt;
| Zero-based index of the player whose native death routine is being processed. Values range from &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; through &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; for Players 1 through 4.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    int remaining_lives = getplayerproperty(playerindex, &amp;quot;lives&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    setglobalvar(&amp;quot;last_defeated_playerindex&amp;quot;, playerindex);&lt;br /&gt;
    setglobalvar(&amp;quot;last_defeat_remaining_lives&amp;quot;, remaining_lives);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The zero-based index matches OpenBOR&amp;#039;s player property and scripting conventions:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! &amp;lt;code&amp;gt;playerindex&amp;lt;/code&amp;gt;&lt;br /&gt;
! Player label&lt;br /&gt;
! Corresponding numbered script&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 1&lt;br /&gt;
| &amp;lt;code&amp;gt;die1.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 2&lt;br /&gt;
| &amp;lt;code&amp;gt;die2.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 3&lt;br /&gt;
| &amp;lt;code&amp;gt;die3.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;&lt;br /&gt;
| Player 4&lt;br /&gt;
| &amp;lt;code&amp;gt;die4.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; does not receive an automatic entity reference. The dying entity remains available from the player slot until both Die-script layers finish:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    void dying_entity = getplayerproperty(playerindex, &amp;quot;entity&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    if (dying_entity)&lt;br /&gt;
    {&lt;br /&gt;
        setglobalvar(&amp;quot;defeat_effect_playerindex&amp;quot;, playerindex);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creators can use &amp;lt;code&amp;gt;dying_entity&amp;lt;/code&amp;gt; immediately with entity properties, visual effects, audio ownership, bindings, or other systems that operate on an active entity reference. OpenBOR clears the player slot&amp;#039;s reference after &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; returns.&lt;br /&gt;
&lt;br /&gt;
== Life Count Timing ==&lt;br /&gt;
&lt;br /&gt;
Native life deduction occurs before the Die scripts. Reading the player&amp;#039;s &amp;lt;code&amp;gt;lives&amp;lt;/code&amp;gt; property therefore returns the remaining count rather than the count that existed before death.&lt;br /&gt;
&lt;br /&gt;
OpenBOR decides between exhausted-life handling and respawn only after both Die-script layers finish. Creators may therefore modify the remaining life count during the event to implement shared-life pools, revive tokens, insurance systems, checkpoint allowances, or other custom continuation rules.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    int remaining_lives = getplayerproperty(playerindex, &amp;quot;lives&amp;quot;);&lt;br /&gt;
    int revive_tokens = getglobalvar(&amp;quot;revive_tokens&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    if (remaining_lives &amp;lt;= 0 &amp;amp;&amp;amp; revive_tokens &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        changeplayerproperty(playerindex, &amp;quot;lives&amp;quot;, 1);&lt;br /&gt;
        setglobalvar(&amp;quot;revive_tokens&amp;quot;, revive_tokens - 1);&lt;br /&gt;
        setglobalvar(&amp;quot;revive_token_used&amp;quot;, playerindex);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The numbered script can apply slot-specific life rules first. &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; then receives the same event and can reconcile the resulting life count before OpenBOR chooses its next branch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot; line&amp;gt;&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
    int remaining_lives = getplayerproperty(playerindex, &amp;quot;lives&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    if (remaining_lives &amp;lt;= 0)&lt;br /&gt;
    {&lt;br /&gt;
        setglobalvar(&amp;quot;player_out_playerindex&amp;quot;, playerindex);&lt;br /&gt;
        setglobalvar(&amp;quot;check_continue_state&amp;quot;, 1);&lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
        setglobalvar(&amp;quot;prepare_respawn_playerindex&amp;quot;, playerindex);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This timing allows one listener to distinguish a death that will proceed to respawn from a death that exhausts the player&amp;#039;s current life supply. Native options that prevent life consumption naturally leave the life count unchanged.&lt;br /&gt;
&lt;br /&gt;
== Combining Numbered and Shared Logic ==&lt;br /&gt;
&lt;br /&gt;
Both layers may participate in the same death event. Their fixed execution order supports a useful division of responsibility:&lt;br /&gt;
&lt;br /&gt;
* Numbered &amp;lt;code&amp;gt;die#.c&amp;lt;/code&amp;gt; performs slot-specific defeat handling.&lt;br /&gt;
* Shared &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; performs project-wide reconciliation after that handling.&lt;br /&gt;
&lt;br /&gt;
For example, numbered scripts might apply different penalties to asymmetric cooperative roles while &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; updates a shared defeat counter, checks the remaining-life state, changes encounter intensity, and prepares common audiovisual feedback.&lt;br /&gt;
&lt;br /&gt;
== Die, Death, and Kill Hooks ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Hook&lt;br /&gt;
! Scope&lt;br /&gt;
! Event represented&lt;br /&gt;
! Entity availability&lt;br /&gt;
|-&lt;br /&gt;
| [[Ondeathscript]]&lt;br /&gt;
| Model&lt;br /&gt;
| Entity enters native death processing&lt;br /&gt;
| &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; is the dying entity&lt;br /&gt;
|-&lt;br /&gt;
| Numbered &amp;lt;code&amp;gt;die#.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| One player slot&lt;br /&gt;
| Native player life-loss routine&lt;br /&gt;
| Player slot still references the dying entity&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt;&lt;br /&gt;
| Every player slot&lt;br /&gt;
| Shared native player life-loss listener&lt;br /&gt;
| Retrieve the dying entity using &amp;lt;code&amp;gt;playerindex&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[Onkillscript]]&lt;br /&gt;
| Model&lt;br /&gt;
| Entity is being removed from play&lt;br /&gt;
| &amp;lt;code&amp;gt;self&amp;lt;/code&amp;gt; is available immediately before removal&lt;br /&gt;
|-&lt;br /&gt;
| [[Respawn Scripts]]&lt;br /&gt;
| Player&lt;br /&gt;
| Replacement player entity has been created after life loss&lt;br /&gt;
| Player slot references the new entity&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
These hooks represent different transitions and may all participate in one defeat sequence. Their separation allows entity-specific death behavior, player-life systems, removal cleanup, and replacement-player setup to remain independent.&lt;br /&gt;
&lt;br /&gt;
== Choosing a Die Script ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Need&lt;br /&gt;
! Recommended hook&lt;br /&gt;
|-&lt;br /&gt;
| Behavior unique to one fixed player slot&lt;br /&gt;
| Corresponding &amp;lt;code&amp;gt;die#.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| The same life-loss behavior for every player&lt;br /&gt;
| &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Fixed slot handling followed by common party reconciliation&lt;br /&gt;
| Numbered &amp;lt;code&amp;gt;die#.c&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;dieall.c&amp;lt;/code&amp;gt; together&lt;br /&gt;
|-&lt;br /&gt;
| Behavior for any entity entering death processing&lt;br /&gt;
| [[Ondeathscript]]&lt;br /&gt;
|-&lt;br /&gt;
| Cleanup immediately before an entity is removed from play&lt;br /&gt;
| [[Onkillscript]]&lt;br /&gt;
|-&lt;br /&gt;
| Setup for the newly created replacement player&lt;br /&gt;
| [[Respawn Scripts]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Other Uses ==&lt;br /&gt;
&lt;br /&gt;
Quick applications include:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Life-loss penalties&amp;#039;&amp;#039;&amp;#039; - Remove resources, reset streaks, alter score systems, or apply player-specific consequences.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cooperative defeat handling&amp;#039;&amp;#039;&amp;#039; - Update shared lives, revival opportunities, team resources, rescue systems, or remaining-party rules.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Encounter adjustment&amp;#039;&amp;#039;&amp;#039; - Reduce or increase pressure, redirect opponents, change hazards, or suspend objectives when a player falls.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Defeat presentation&amp;#039;&amp;#039;&amp;#039; - Trigger sounds, screen effects, announcements, portraits, controller feedback, or spectator transitions.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Continue systems&amp;#039;&amp;#039;&amp;#039; - Detect exhausted lives, prepare custom continue state, or coordinate project-specific game-over flow.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Statistics and achievements&amp;#039;&amp;#039;&amp;#039; - Record defeat counts, remaining lives, player order, survival milestones, or challenge failures.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Role management&amp;#039;&amp;#039;&amp;#039; - Release responsibilities, transfer shared ownership, select a new leader, or update cooperative formations.&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Development tools&amp;#039;&amp;#039;&amp;#039; - Log player-death order, verify remaining-life values, inspect the dying entity, or test corpse and respawn configurations.&lt;br /&gt;
&lt;br /&gt;
== Related Scripts ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Script&lt;br /&gt;
! Relationship&lt;br /&gt;
|-&lt;br /&gt;
| [[Respawn Scripts]]&lt;br /&gt;
| Execute after the replacement player entity is created when lives remain. The numbered script runs before &amp;lt;code&amp;gt;respawnall.c&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| [[Join Scripts]]&lt;br /&gt;
| Execute when a player completes an in-progress join rather than returning from death.&lt;br /&gt;
|-&lt;br /&gt;
| [[Ondeathscript]]&lt;br /&gt;
| Model-level hook for entity death processing.&lt;br /&gt;
|-&lt;br /&gt;
| [[Onkillscript]]&lt;br /&gt;
| Model-level hook that executes immediately before entity removal.&lt;br /&gt;
|-&lt;br /&gt;
| [[Onspawnscript]]&lt;br /&gt;
| Model-level creation hook that may execute for the replacement player entity before the Respawn series.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Respawn Scripts]]&lt;br /&gt;
* [[Join Scripts]]&lt;br /&gt;
* [[Ondeathscript]]&lt;br /&gt;
* [[Onkillscript]]&lt;br /&gt;
* [[Onspawnscript]]&lt;br /&gt;
* [[Player Properties]]&lt;br /&gt;
* [[Death]]&lt;br /&gt;
* [[Script Overview]]&lt;/div&gt;</summary>
		<author><name>Dcurrent</name></author>
	</entry>
</feed>