<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.thedarkmod.com/index.php?action=history&amp;feed=atom&amp;title=GUI_Scripting%3A_Flashbomb_Example</id>
	<title>GUI Scripting: Flashbomb Example - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.thedarkmod.com/index.php?action=history&amp;feed=atom&amp;title=GUI_Scripting%3A_Flashbomb_Example"/>
	<link rel="alternate" type="text/html" href="https://wiki.thedarkmod.com/index.php?title=GUI_Scripting:_Flashbomb_Example&amp;action=history"/>
	<updated>2026-04-18T05:41:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.thedarkmod.com/index.php?title=GUI_Scripting:_Flashbomb_Example&amp;diff=30086&amp;oldid=prev</id>
		<title>Geep: Add category tag</title>
		<link rel="alternate" type="text/html" href="https://wiki.thedarkmod.com/index.php?title=GUI_Scripting:_Flashbomb_Example&amp;diff=30086&amp;oldid=prev"/>
		<updated>2022-11-04T17:32:15Z</updated>

		<summary type="html">&lt;p&gt;Add category tag&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&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 17:32, 4 November 2022&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-l105&quot;&gt;Line 105:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 105:&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;     }&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;     }&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;  }&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;  }&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;&lt;/ins&gt;&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;{{GUI}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Geep</name></author>
	</entry>
	<entry>
		<id>https://wiki.thedarkmod.com/index.php?title=GUI_Scripting:_Flashbomb_Example&amp;diff=29625&amp;oldid=prev</id>
		<title>Geep: create this article</title>
		<link rel="alternate" type="text/html" href="https://wiki.thedarkmod.com/index.php?title=GUI_Scripting:_Flashbomb_Example&amp;diff=29625&amp;oldid=prev"/>
		<updated>2022-07-08T15:12:13Z</updated>

		<summary type="html">&lt;p&gt;create this article&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;This page is part of a series. See [[GUI Scripting Language]] for overview.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
A flashbomb is an evasive weapon. A player can throw one at enemy AI, hoping that when it explodes, the AI will be momentarily blinded. But if not careful, the player can be likewise blinded briefly, either wholly or in part. That blinding of the player is considered here. The example demonstrates:&lt;br /&gt;
* Using a &amp;quot;gui&amp;quot; spawnarg to select a GUI file, and create a player overlay from it.&lt;br /&gt;
* Use of CallGui with named events.&lt;br /&gt;
* Managing transitions with &amp;quot;if…else&amp;quot; statements and a gui:: parameter.&lt;br /&gt;
&lt;br /&gt;
==When a Flashbomb Explodes==&lt;br /&gt;
===Invocation===&lt;br /&gt;
A thrown flashbomb is a projectile, whose entityDef (namely atdm:projectile_flashbomb in tdm_playertools_flashbomb.def) includes these spawnargs and defaults:&lt;br /&gt;
 has_result		1&lt;br /&gt;
 def_result		atdm:result_flashbomb&lt;br /&gt;
&lt;br /&gt;
Those describe a &amp;quot;projectile result&amp;quot; helper entity that gets spawned on impact. In turn, the entityDef for atdm:result_flashbomb includes these spawnargs:&lt;br /&gt;
 scriptobject		result_flashbomb&lt;br /&gt;
 gui			guis/playertools/flashbomb.gui&lt;br /&gt;
&lt;br /&gt;
In general, a &amp;quot;projectile result&amp;quot; is handled by C++ code in ProjectileResult.cpp. At the end of complicated processing, there&amp;#039;s a call to run (in the case of flashbombs) the script object&amp;#039;s function &amp;quot;dud&amp;quot;. Flashbomb results are always internally categorized as &amp;quot;duds&amp;quot;, not &amp;quot;active&amp;quot;, because their explosions invoke no physics or permanent damage.&lt;br /&gt;
&lt;br /&gt;
===Within the Script Object&amp;#039;s &amp;quot;Dud&amp;quot; Function===&lt;br /&gt;
This script object, &amp;quot;result_flashbomb&amp;quot; is defined in tdm_weapon_flashbomb_result.script.&lt;br /&gt;
&lt;br /&gt;
====Preliminary Calculations to Decide What to Do====&lt;br /&gt;
&amp;#039;&amp;#039;Details of this are not shown in the code fragment below.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
If the bomb explosion is not within the player&amp;#039;s field of view, then no &amp;quot;blinded&amp;quot; overlay is created, just a momentary off-screen light source. But if it is seen and not too far away, then the player is either fully blinded  if very close (but not actually hit), or partially blinded otherwise. For partial blindness, the closeness will determine the transparency of the overlay. Specifically, a &amp;quot;transparency&amp;quot; float variable of range 0.0 to 1.0 is calculated.&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;full blind&amp;quot;, a particle emitter spawns at the explosion site first, before the overlay is created.&lt;br /&gt;
&lt;br /&gt;
====Creating the Blinding Overlay====&lt;br /&gt;
As the script object code fragment below shows, a full screen overlay is created. If &amp;quot;full blind&amp;quot;, the script object calls the GUI&amp;#039;s doFullblind event handler. If &amp;quot;half blind&amp;quot;, the transparency value is passed to the GUI through gui:: parameter &amp;quot;flashbomb_halfblind_enum&amp;quot;. Then doHalfblind is called. &lt;br /&gt;
 … &lt;br /&gt;
 string guiName = getKey(&amp;quot;gui&amp;quot;); // has default value &amp;quot;flashbomb.gui&amp;quot;&lt;br /&gt;
 float overlay = $player1.createOverlay(guiName, 10);&lt;br /&gt;
 if (fullBlind) {&lt;br /&gt;
   $player1.callGui(overlay, &amp;quot;doFullblind&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
 else {&lt;br /&gt;
   $player1.setGuiFloat(overlay, &amp;quot;flashbomb_halfblind_enum&amp;quot;, transparency);&lt;br /&gt;
   $player1.callGui(overlay, &amp;quot;doHalfblind&amp;quot;);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===The GUI===&lt;br /&gt;
The &amp;quot;flashbomb.gui&amp;quot; file, due to greebo, is shown below (lightly edited). There are two full screen child windowDefs, both hidden at first. Only one will be made visible.&lt;br /&gt;
&lt;br /&gt;
When onNamedEvent doFullblind is called, the overlay becomes opaque white for 1 second, then fades grayly away back to transparent over the next 4 seconds.&lt;br /&gt;
&lt;br /&gt;
When onNamedEvent doHalfblind is called, the transparency affects the initial white opaqueness, which immediately begins its gray fade-away over the next 4 seconds.&lt;br /&gt;
&lt;br /&gt;
The use of &amp;quot;gui::flashbomb_halfblind_enum&amp;quot; as a float, and paired with &amp;quot;if…else&amp;quot; statements, nicely shows how to avoid trying to pass a color vec4 as a gui::parameter into a transition statement.&lt;br /&gt;
 windowDef Desktop {&lt;br /&gt;
    rect      0, 0, 640, 480&lt;br /&gt;
    nocursor 1&lt;br /&gt;
 &lt;br /&gt;
    windowDef fullBlindEffect {&lt;br /&gt;
        rect      0, 0, 640, 480&lt;br /&gt;
        backcolor 1, 1, 1, 1&lt;br /&gt;
        visible 0&lt;br /&gt;
 		&lt;br /&gt;
        onTime 0 {&lt;br /&gt;
            transition backcolor &amp;quot;1 1 1 1&amp;quot; &amp;quot;0 0 0 1&amp;quot; &amp;quot;1000&amp;quot; ;&lt;br /&gt;
        }&lt;br /&gt;
 &lt;br /&gt;
        onTime 1000 {&lt;br /&gt;
            transition backcolor &amp;quot;0 0 0 1&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot; ;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    windowDef halfBlindEffect {&lt;br /&gt;
        rect      0, 0, 640, 480&lt;br /&gt;
        backcolor 1, 1, 1, 0.5&lt;br /&gt;
        visible 0&lt;br /&gt;
 	&lt;br /&gt;
        onTime 0 {&lt;br /&gt;
            if (&amp;quot;gui::flashbomb_halfblind_enum&amp;quot; &amp;gt;= 1) {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 1&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else if (&amp;quot;gui::flashbomb_halfblind_enum&amp;quot; &amp;gt;= 0.8) {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 0.8&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else if (&amp;quot;gui::flashbomb_halfblind_enum&amp;quot; &amp;gt;= 0.6) {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 0.6&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else if (&amp;quot;gui::flashbomb_halfblind_enum&amp;quot; &amp;gt;= 0.4) {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 0.4&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else if (&amp;quot;gui::flashbomb_halfblind_enum&amp;quot; &amp;gt;= 0.2) {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 0.2&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            else {&lt;br /&gt;
                transition backcolor &amp;quot;1 1 1 0.1&amp;quot; &amp;quot;0 0 0 0&amp;quot; &amp;quot;4000&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    onNamedEvent doFullblind {&lt;br /&gt;
        set &amp;quot;fullBlindEffect::visible&amp;quot; &amp;quot;1&amp;quot;;&lt;br /&gt;
        resetTime &amp;quot;fullBlindEffect&amp;quot; &amp;quot;0&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
 &lt;br /&gt;
    onNamedEvent doHalfblind {&lt;br /&gt;
        set &amp;quot;halfBlindEffect::visible&amp;quot; &amp;quot;1&amp;quot;;&lt;br /&gt;
        resetTime &amp;quot;halfBlindEffect&amp;quot; &amp;quot;0&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Geep</name></author>
	</entry>
</feed>