| 1 |
Cellular Automata based wildfire for FlightGear/CVS |
| 2 |
--------------------------------------------------- |
| 3 |
|
| 4 |
Copyright (C) 2008 - 2009 Anders Gidenstam |
| 5 |
|
| 6 |
* These programs are free software; you can redistribute them and/or modify |
| 7 |
* them under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 |
|
| 20 |
Usage |
| 21 |
----- |
| 22 |
|
| 23 |
A fire is started by calling wild_fire.ignite(pos) where pos is a |
| 24 |
valid geo.Coord instance. |
| 25 |
|
| 26 |
Example: starting fires by ctrl+shift+click: |
| 27 |
|
| 28 |
Put this Nasal fragment somewhere where it is run at startup. |
| 29 |
(E.g. in a <nasal><MyStuff><script>...</script></MyStuff></nasal> |
| 30 |
block in preferences.xml.) |
| 31 |
|
| 32 |
setlistener("/sim/signals/click", func { |
| 33 |
if (__kbd.shift.getBoolValue()) { |
| 34 |
if (__kbd.ctrl.getBoolValue()) { |
| 35 |
var click_pos = geo.click_position(); |
| 36 |
wildfire.ignite(click_pos); |
| 37 |
} |
| 38 |
} |
| 39 |
}); |
| 40 |
|
| 41 |
|
| 42 |
Configuration properties |
| 43 |
----------------------- |
| 44 |
|
| 45 |
These properties can be set at runtime, in preferences.xml or in any |
| 46 |
other way supported by FlightGear. |
| 47 |
|
| 48 |
/environment/wildfire/enabled : bool |
| 49 |
Enables/disables the whole WildFire module. |
| 50 |
On disable the current state is lost. Can be used to reset WildFire. |
| 51 |
|
| 52 |
/environment/wildfire/share-events : bool |
| 53 |
Enables/disables sending and receiving of fire events over the |
| 54 |
multiplayer network. |
| 55 |
|
| 56 |
/environment/wildfire/fire-on-crash : bool |
| 57 |
If true a fire will start if the aircraft crashes. |
| 58 |
|
| 59 |
/environment/wildfire/report-score : bool |
| 60 |
Report the result of fire fighting. |
| 61 |
|
| 62 |
/environment/wildfire/models/enabled : bool |
| 63 |
Enables/disables rendering of the 3d models. |
| 64 |
(That is, fire, smoke, soot and foam.) |
| 65 |
|
| 66 |
/environment/wildfire/save-on-exit : bool |
| 67 |
If set the current log of Wildfire events is saved in |
| 68 |
~/.fgfs/Wildfire/fire_log.xml . |
| 69 |
|
| 70 |
/environment/wildfire/restore-on-startup : bool |
| 71 |
If set Wildfire will load and execute the events in |
| 72 |
~/.fgfs/Wildfire/fire_log.xml . This recreates the fire state |
| 73 |
as it where when the log was saved. |
| 74 |
NOTE: A long event log or one that covers a long period of time will take |
| 75 |
a a lot of time to recreate. |
| 76 |
Storing and reloading of the CA state, as opposed to the event log, is not |
| 77 |
supported yet. |
| 78 |
|
| 79 |
|
| 80 |
API |
| 81 |
--- |
| 82 |
|
| 83 |
ignite : func (pos, source=1) |
| 84 |
pos - fire location : geo.Coord |
| 85 |
source - broadcast event? : {0, 1} |
| 86 |
|
| 87 |
Start a fire. |
| 88 |
|
| 89 |
|
| 90 |
resolve_water_drop : func (pos, radius, volume, source=1) |
| 91 |
pos - drop location : geo.Coord |
| 92 |
radius - drop radius m : double |
| 93 |
volume - Not used : double |
| 94 |
source - broadcast event? : {0, 1} |
| 95 |
|
| 96 |
Extinguishes any fires in the cells within r of pos and |
| 97 |
makes the cells nonflammable. |
| 98 |
|
| 99 |
resolve_retardant_drop : func (pos, radius, volume, source=1) { |
| 100 |
pos - drop location : geo.Coord |
| 101 |
radius - drop radius m : double |
| 102 |
volume - Not used : double |
| 103 |
source - broadcast event? : {0, 1} |
| 104 |
|
| 105 |
Identical to resolve_water_drop. |
| 106 |
|
| 107 |
resolve_foam_drop : func (pos, radius, volume, source=1) { |
| 108 |
pos - drop location : geo.Coord |
| 109 |
radius - drop radius m : double |
| 110 |
volume - Not used : double |
| 111 |
source - broadcast? : {0, 1} |
| 112 |
|
| 113 |
Extinguishes any fires in the cells within r of pos and |
| 114 |
makes the cells nonflammable and foamy. |
| 115 |
|
| 116 |
load_event_log : func (filename, skip_ahead_until=-1) |
| 117 |
filename - getprop("/sim/fg-home") ~ "/Wildfire/" ~ filename |
| 118 |
skip_ahead_until - skip from last event to this time : double (epoch) |
| 119 |
fast forward from skip_ahead_until |
| 120 |
to current time. |
| 121 |
x < last event - fast forward all the way to current time (use 0). |
| 122 |
NOTE: Can be VERY time consuming. |
| 123 |
-1 - skip to current time. |
| 124 |
|
| 125 |
Loads an event log. |
| 126 |
The skip_ahead_until argument can be used for synchronizing a restored |
| 127 |
fire state among multiple players. |
| 128 |
|
| 129 |
save_event_log : func (filename) |
| 130 |
filename - getprop("/sim/fg-home") ~ "/Wildfire/" ~ filename |
| 131 |
|
| 132 |
Saves an event log. |
| 133 |
|
| 134 |
print_score = func |
| 135 |
Print a summary of the current wildfire state. |
| 136 |
|
| 137 |
|
| 138 |
/Anders |