9 Commits
Author SHA1 Message Date
Luxferre 0c65598156 v0.6: compacted UI 2024-10-12 19:09:06 +03:00
Luxferre 3846afaf10 Fixed Health Crates Cure Poison choices, started some UI optimization 2024-10-12 18:49:14 +03:00
Luxferre 140a085ebe v0.5: fixed-point logic fixes 2024-10-12 18:14:52 +03:00
Luxferre 27c669f67f v0.4: fixed default value validation for v3 2024-10-12 17:05:16 +03:00
Luxferre b749722945 bumped version 2024-10-12 16:44:43 +03:00
Luxferre ec2c95ca07 Fixed v3 value scanning 2024-10-12 16:41:58 +03:00
Luxferre 2babede737 Implemented .WAgame import support 2024-10-12 15:29:51 +03:00
Luxferre d9ef9e5062 Version converter fix 2024-10-12 14:25:01 +03:00
Luxferre b6cf77b296 Version converter fix 2024-10-12 14:20:07 +03:00
2 changed files with 112 additions and 69 deletions
+4 -2
View File
@@ -2,11 +2,13 @@
ArmageDec (short for Armageddon Decoder) is a GUI scheme editor (written in Tcl/Tk 8.6) for Worms: Armageddon game scheme file format from version 1 to version 3. It was developed based on [this format description page](https://worms2d.info/Game_scheme_file) and supports all fields readable as of W:A v3.8.1, including those not present in some other external scheme editors.
Additionally, ArmageDec now supports importing schemes from Worms: Armageddon replay (.WAgame) files.
## Usage
ArmageDec is a fully GUI-based application, although you can pass the .wsc scheme file to open as the first command-line parameter to the script. You can modify all supported parameters, including the format version itself. If you supply an invalid version value, the program will assume and save version 3.
ArmageDec is a fully GUI-based application, although you can pass a .wsc scheme file (or a .WAgame replay file) to open as the first command-line parameter to the script. You can modify all supported parameters, including the format version itself. If you supply an invalid version value, the program will assume and save version 3.
Note that you can't create a fully new scheme as of now. You need to open an existing .wsc file and start by editing it.
Note that you can't create a fully new scheme as of now. You need to open an existing .wsc file or .WAgame and start by editing it. You can import schemes from .WAgame files but you can only save to .wsc files.
### How to use Mines & Barrels Calculator section
+104 -63
View File
@@ -7,7 +7,7 @@
package require Tk
set appversion 0.1
set appversion 0.6
set scriptpath [file normalize [info script]]
set appdir [file dirname $scriptpath]
# check if we're running from a starpack
@@ -54,11 +54,11 @@ set wa_opts {
{offset 0x1E name {Blood} val {bool}}
{offset 0x23 name {Upgraded Grenade} val {bool}}
{offset 0x24 name {Upgraded Shotgun} val {bool}}
{offset 0x25 name {Upgraded Clusters} val {bool}}
{offset 0x26 name {Upgraded Longbow} val {bool}}
{offset 0x0F name {Sudden Death Event} val {0 {Round ends} 1 {Nuclear strike} 2 {HP drops to 1} 3 {Nothing happens}}}
{offset 0x0D name {Stockpiling Mode} val {0 Replenish 1 Accumulate 2 Reduce}}
{offset 0x0E name {Worm Selection} val {0 Sequential 1 Manual 2 Random}}
{offset 0x25 name {Upgraded Clusters} val {bool}}
{offset 0x26 name {Upgraded Longbow} val {bool}}
}
# names of weapon properties
@@ -202,18 +202,16 @@ set wa_ext_opts {
{offset 0x150 size 1 name {Undetermined Crates} def 128 val {0 Off 1 On 128 Default}}
{offset 0x151 size 1 name {Undetermined Fuses} def 128 val {0 Off 1 On 128 Default}}
{offset 0x14A size 1 name {Rope-Roll Drops} def 0 val {0 {Disabled} 1 {As from rope only} 2 {As from rope or jump}}}
{offset 0x14B size 1 name {Horizontal Impact Loss of Control} def 0 val {0 {Lose control} 255 {No loss of control}}}
{offset 0x143 size 1 name {Phased Worms (Enemy)} def 0 val {
0 {Off}
1 {Worms move through each other}
2 {+ Move through enemy weapon objects}
3 {+ Don't take damage from enemy explosions}
}}
{offset 0x14D size 1 name {Keep Control After Skimming} def 0 val {0 {Lose control} 1 {Keep control} 2 {Keep control and rope}}}
{offset 0x183 size 1 name {RubberWorm Gravity Type} def 0 val {0 {Unmodified} 1 {Standard} 2 {Black hole (constant)} 3 {Black hole (linear)}}}
{offset 0x191 size 1 name {Health Crates Cure Poison} def 1 val {255 {Off} 0 {Cure the collector} 1 {Cure the collector's team} 2 {Cure all allied teams}}}
{offset 0x156 size 1 name {Pneumatic Drill Imparts Velocity} def 128 val {0 Off 1 On 128 Default}}
{offset 0x16D size 1 name {Indian Rope Glitch} def 128 val {0 Off 1 On 128 Default}}
{offset 0x16E size 1 name {Herd-Doubling Glitch} def 128 val {0 Off 1 On 128 Default}}
{offset 0x172 size 1 name {Skipwalking} def 0 val {255 Disabled 0 Possible 1 Facilitated}}
{offset 0x193 size 1 name {Sheep Heaven's Gate} def 7 val {
1 {1. Sheep explode out of all crates}
2 {2. Sheep weapon extended fuse time}
@@ -223,18 +221,20 @@ set wa_ext_opts {
6 {6. Option 2 + Option 4}
7 {7. All of the above}
}}
{offset 0x192 size 1 name {Kaos Mod Preset} def 0 val {
0 {20, 10, 15, 5, 10, 15, 10, 15, 5}
1 {20, 10, 10, 5, 10, 15, 10, 12, 5}
2 {20, 15, 10, 5, 10, 15, 10, 10, 0}
3 {25, 15, 5, 0, 20, 20, 10, 5, 0}
4 {25, 25, 0, 5, 20, 10, 10, 5, 0}
5 {25, 15, 5, 5, 25, 10, 10, 5, 0}
}}
{offset 0x16E size 1 name {Herd-Doubling Glitch} def 128 val {0 Off 1 On 128 Default}}
{offset 0x172 size 1 name {Skipwalking} def 0 val {255 Disabled 0 Possible 1 Facilitated}}
{offset 0x173 size 1 name {Roofing} def 0 val {0 {Allowed} 1 {Block above} 2 {Block everywhere}}}
{offset 0x18E size 1 name {Terrain Overlap Phasing Glitch} def 128 val {0 Off 1 On 128 Default}}
{offset 0x183 size 1 name {RubberWorm Gravity Type} def 0 val {0 {Unmodified} 1 {Standard} 2 {Black hole (constant)} 3 {Black hole (linear)}}}
{offset 0x191 size 1 name {Health Crates Cure Poison} def 1 val {255 {Off} 0 {Cure the collector} 2 {Cure the collector's team} 3 {Cure all allied teams}}}
{offset 0x192 size 1 name {Kaos Mod Preset} def 0 val {
0 {Preset 0}
1 {Preset 1}
2 {Preset 2}
3 {Preset 3}
4 {Preset 4}
5 {Preset 5}
}}
{offset 0x14B size 1 name {Horizontal Impact Loss of Control} def 0 val {0 {Lose control} 255 {No loss of control}}}
{offset 0x14D size 1 name {Keep Control After Skimming} def 0 val {0 {Lose control} 1 {Keep control} 2 {Keep control and rope}}}
}
# special setting processor section
@@ -293,21 +293,22 @@ proc wa_roundtime_write {num} {
# fixedpoint helpers
proc fixed2float {fpint} {
set whole [expr {int($fpint) >> 16}]
set frac [expr {int($fpint) & 65535}]
return [expr {$whole + ($frac / 65536)}]
set fpint [expr {int($fpint)}]
set whole [expr {$fpint >> 16}]
set frac [expr {$fpint % 65536}]
return [expr {$whole + ($frac / 65536.)}]
}
proc float2fixed {flt} {
set whole [expr {int(float($flt))}]
set frac [expr {float($flt) - $whole}]
return [expr {($whole << 16) | int($frac * 65536)}]
set whole [expr {int($flt)}]
set frac [expr {$flt - $whole}]
return [expr {($whole << 16) | int($frac * 65536.)}]
}
# v3-only spec functions
proc wa_petrolturndecay_read {raw} {return [fixed2float $raw]}
proc wa_petrolturndecay_write {num} {return [expr int($num * 65536)]}
proc wa_petrolturndecay_write {num} {return [expr int($num * 65536.)]}
# general logic
@@ -333,12 +334,16 @@ proc fullscanscheme {version} {
foreach weap $wa_weapons {
set offs [dict get $weap offset]
set offs [expr {int($offs)}]
# limit weapons for v1 schemes
if {($offs >= 0xDD) && ($version < 2)} {break}
set poweroffs [expr {$offs + 1}]
set delayoffs [expr {$offs + 2}]
set proboffs [expr {$offs + 3}]
binary scan [string range $rawschemedata $offs [expr {$offs + 4}]] cucucucu ammo power delay prob
set ammo 0
set power 0
set delay 0
set prob 0
catch {
binary scan [string range $rawschemedata $offs [expr {$offs + 3}]] cucucucu ammo power delay prob
}
set wsc_data($offs) $ammo
set wsc_data($poweroffs) $power
set wsc_data($delayoffs) $delay
@@ -355,9 +360,9 @@ proc fullscanscheme {version} {
if {$size eq 1} {set fmt cu}
if {$size eq 2} {set fmt s}
if {$size eq 4} {set fmt i}
catch {
binary scan [string range $rawschemedata [expr {$offs + $size}]] $fmt wscval
}
set newval ""
binary scan [string range $rawschemedata $offs [expr {$offs + $size - 1}]] $fmt newval
if {$newval ne ""} {set wscval $newval}
if {([llength $valopt] > 1) && ([lindex $valopt 0] eq "spec")} {
set readfunc "[lindex $valopt 1]_read"
set wscval [$readfunc $wscval]
@@ -371,13 +376,34 @@ proc fullscanscheme {version} {
# load a scheme file into the internal structure
proc loadscheme {fname} {
global rawschemedata wsc_data
if [string match *.wagame [string tolower $fname]] { # extract from the replay file
set fp [open $fname r]
fconfigure $fp -translation binary
set replaydata [read $fp]
close $fp
set schemestart [string first "SCHM" $replaydata]
if {$schemestart < 0} {
tk_messageBox -type ok -title "Scheme loading error" -icon error -message "No scheme found in the replay file!"
return
}
# read the version
set offs [expr {$schemestart + 4}]
set scanval [string index $replaydata $offs]
binary scan $scanval cu scmver
# set the target size based on the version
set datasize 221
if {$scmver eq 2} {set datasize 297}
if {$scmver eq 3} {set datasize 407}
set rawschemedata [string range $replaydata $schemestart [expr {$schemestart + $datasize - 1}]]
} else { # read raw scheme data directly
set fp [open $fname r]
fconfigure $fp -translation binary
set rawschemedata [read $fp]
close $fp
}
set hdr ""
set ver ""
binary scan $rawschemedata a4c hdr ver
binary scan $rawschemedata a4cu hdr ver
if {$hdr eq {SCHM} && ($ver eq 1 || $ver eq 2 || $ver eq 3)} {
# proceed with full scanning
fullscanscheme $ver
@@ -393,6 +419,20 @@ proc savescheme {fname} {
# guard the version
if {int($wsc_data(version)) < 1} {set wsc_data(version) 1}
if {int($wsc_data(version)) > 3} {set wsc_data(version) 3}
# detect the target size
set datasize 221
if {int($wsc_data(version)) eq 2} {set datasize 297}
if {int($wsc_data(version)) eq 3} {set datasize 407}
# expand/truncate rawschemedata according to the detected size
set diffbytes [expr {$datasize - [string length $rawschemedata]}]
if {$diffbytes > 0} { # expand with nulls
set rawschemedata [string cat $rawschemedata [binary format x$diffbytes]]
} else { # truncate
set rawschemedata [string range $rawschemedata 0 [expr {$datasize - 1}]]
}
# write the version itself
set binval [binary format cu $wsc_data(version)]
set rawschemedata [string replace $rawschemedata 4 4 $binval]
# write normal options
foreach opt $wa_opts {
set offs [dict get $opt offset]
@@ -435,13 +475,12 @@ proc savescheme {fname} {
if {$size eq 2} {set fmt s}
if {$size eq 4} {set fmt i}
if {([llength $valopt] > 1) && ([lindex $valopt 0] eq "spec")} {
set writefunc "[lindex $valopt 1]_read"
set writefunc "[lindex $valopt 1]_write"
set val [$writefunc $val]
} elseif {$valopt eq "fixp"} {
set val [float2fixed $val]
}
set binval [binary format $fmt $val]
set wsc_data($offs) $wscval
set rawschemedata [string replace $rawschemedata $offs [expr {$offs + $size - 1}] $binval]
}
}
@@ -454,14 +493,16 @@ proc savescheme {fname} {
}
# open a .wsc scheme file (get the target name)
# or a .WAgame replay file
proc openwsc {} {
global wscfile appdir
set startdir $appdir
if {$wscfile ne ""} {set startdir [file dirname $wscfile]}
set types {
{{Worms: Armageddon game scheme} {.wsc} BINA}
{{Worms: Armageddon replay} {.WAgame} BINA}
}
return [tk_getOpenFile -filetypes $types -initialdir $startdir -title {Open a Worms scheme file}]
return [tk_getOpenFile -filetypes $types -initialdir $startdir -title {Open a Worms scheme or replay file}]
}
# save a .wsc scheme file (get the target name)
@@ -530,7 +571,7 @@ grid .infoframe -row 1 -column 0 -sticky we
ttk::frame .tabbar.nopts
.tabbar add .tabbar.nopts -text "Options"
ttk::labelframe .tabbar.nopts.opts -text "General options"
grid .tabbar.nopts.opts -column 0 -row 0 -sticky nw -padx 5 -pady 5 -columnspan 6
grid .tabbar.nopts.opts -column 0 -row 0 -sticky nw -padx 5 -pady 5 -columnspan 4
set row 0
set col 0
@@ -550,7 +591,7 @@ foreach opt $wa_opts {
ttk::entry $txtid -width 8 -textvariable $boundvar
pack $lblid -side left -fill x -padx 5
pack $txtid -side right
grid $elpref -column $col -row $row -sticky nwe
grid $elpref -column $col -row $row -sticky nwe -pady 5
} elseif {([lindex $valopt 0] eq "bool")} { # create a checkbox entry
set chkid ".tabbar.nopts.opts.chk$offs"
ttk::checkbutton $chkid -text $name -variable $boundvar -onvalue 1 -offvalue 0
@@ -568,7 +609,7 @@ foreach opt $wa_opts {
grid $comboid -column $col -row $row -sticky news
}
incr col
if {$col > 4} {
if {$col > 3} {
set col 0
incr row
}
@@ -593,25 +634,25 @@ foreach weap $wa_weapons {
set boundvar_prob "wsc_data($proboffs)"
set groupid ".tabbar.weap.$offs"
ttk::labelframe $groupid -text $wname -labelanchor nw
ttk::label "$groupid.ammolbl" -text "Ammo"
ttk::label "$groupid.ammolbl" -text "A"
ttk::entry "$groupid.ammotxt" -textvariable $boundvar_ammo -width 4
grid "$groupid.ammolbl" -column 0 -row 0 -sticky nsw
grid "$groupid.ammotxt" -column 1 -row 0 -sticky nw
ttk::label "$groupid.powerlbl" -text "Power"
ttk::label "$groupid.powerlbl" -text "P"
ttk::entry "$groupid.powertxt" -textvariable $boundvar_power -width 4
grid "$groupid.powerlbl" -column 0 -row 1 -sticky nsw
grid "$groupid.powertxt" -column 1 -row 1 -sticky nw
ttk::label "$groupid.delaylbl" -text "Delay"
grid "$groupid.powerlbl" -column 2 -row 0 -sticky nsw
grid "$groupid.powertxt" -column 3 -row 0 -sticky nw
ttk::label "$groupid.delaylbl" -text "D"
ttk::entry "$groupid.delaytxt" -textvariable $boundvar_delay -width 4
grid "$groupid.delaylbl" -column 0 -row 2 -sticky nsw
grid "$groupid.delaytxt" -column 1 -row 2 -sticky nw
ttk::label "$groupid.problbl" -text "Probability"
grid "$groupid.delaylbl" -column 4 -row 0 -sticky nsw
grid "$groupid.delaytxt" -column 5 -row 0 -sticky nw
ttk::label "$groupid.problbl" -text "Pr"
ttk::entry "$groupid.probtxt" -textvariable $boundvar_prob -width 4
grid "$groupid.problbl" -column 0 -row 3 -sticky nsw
grid "$groupid.probtxt" -column 1 -row 3 -sticky nw
grid "$groupid.problbl" -column 6 -row 0 -sticky nsw
grid "$groupid.probtxt" -column 7 -row 0 -sticky nw
grid $groupid -column $col -row $row -sticky news -padx 5 -pady 3
incr col
if {$col > 10} {
if {$col > 4} {
set col 0
incr row
}
@@ -621,15 +662,14 @@ foreach weap $wa_weapons {
ttk::frame .tabbar.extopts
.tabbar add .tabbar.extopts -text "Extended options (v3)"
# Extended option checkboxes in the first tab
set eflpref ".tabbar.nopts.eflags"
ttk::labelframe $eflpref -text "Extended option flags (v3)"
grid $eflpref -row 1 -column 0 -sticky nw -padx 5 -pady 5 -columnspan 8
# Second extended options tabframe
ttk::frame .tabbar.extflags
.tabbar add .tabbar.extflags -text "Extended option flags (v3)"
# Extended option textboxes in the first tab
set etpref ".tabbar.nopts.etxts"
ttk::labelframe $etpref -text "Extended option parameters (v3)"
grid $etpref -row 2 -column 0 -sticky nw -padx 5 -pady 5 -columnspan 8
grid $etpref -row 2 -column 0 -sticky nw -padx 5 -pady 5 -columnspan 5
set row 0
set col 0
@@ -653,18 +693,18 @@ foreach opt $wa_ext_opts {
ttk::entry $txtid -width 8 -textvariable $boundvar
pack $lblid -side left -fill x -padx 5
pack $txtid -side right
grid $elpref -column $txtcol -row $txtrow -sticky nwe
grid $elpref -column $txtcol -row $txtrow -sticky nwe -pady 5
incr txtcol
if {$txtcol > 5} {
if {$txtcol > 4} {
set txtcol 0
incr txtrow
}
} elseif {([lindex $valopt 0] eq "bool")} { # create a checkbox entry
set chkid ".tabbar.nopts.eflags.chk$offs"
set chkid ".tabbar.extflags.chk$offs"
ttk::checkbutton $chkid -text $name -variable $boundvar -onvalue 1 -offvalue 0
grid $chkid -column $chkcol -row $chkrow -sticky nw
incr chkcol
if {$chkcol > 4} {
if {$chkcol > 3} {
set chkcol 0
incr chkrow
}
@@ -680,7 +720,7 @@ foreach opt $wa_ext_opts {
}
grid $comboid -column $col -row $row -sticky news -padx 5 -pady 3
incr col
if {$col > 5} {
if {$col > 4} {
set col 0
incr row
}
@@ -689,7 +729,7 @@ foreach opt $wa_ext_opts {
# right container of the first tab
ttk::frame .tabbar.nopts.right
grid .tabbar.nopts.right -column 6 -row 0 -sticky ne
grid .tabbar.nopts.right -column 4 -row 0 -sticky nwe
# Mines and barrels calc
set hcalc_mines 0
@@ -700,11 +740,11 @@ ttk::labelframe $calcpref -text "Mines & Barrels Calculator"
grid $calcpref -column 0 -row 0 -sticky nw -padx 5 -pady 5
ttk::label "$calcpref.minelbl" -text Mines
ttk::entry "$calcpref.minetxt" -width 3 -textvariable hcalc_mines
grid $calcpref.minelbl -column 0 -row 0 -sticky nw -padx 5 -pady 5
grid $calcpref.minelbl -column 0 -row 0 -sticky nsw -padx 5 -pady 5
grid $calcpref.minetxt -column 1 -row 0 -sticky nw -padx 5 -pady 5
ttk::label "$calcpref.barrlbl" -text Barrels
ttk::entry "$calcpref.barrtxt" -width 3 -textvariable hcalc_barrels
grid $calcpref.barrlbl -column 0 -row 1 -sticky nw -padx 5 -pady 5
grid $calcpref.barrlbl -column 0 -row 1 -sticky nsw -padx 5 -pady 5
grid $calcpref.barrtxt -column 1 -row 1 -sticky nw -padx 5 -pady 5
ttk::button "$calcpref.reset" -text Reset -command {
set hcalc_mines 0
@@ -800,9 +840,9 @@ ttk::button "$calcpref.docalc" -text Calculate -command {
}
grid $calcpref.docalc -column 2 -row 2 -sticky nw -padx 5 -pady 5
ttk::label "$calcpref.resultlbl" -text "Result:"
grid $calcpref.resultlbl -column 0 -row 2 -sticky nw -padx 5 -pady 5
grid $calcpref.resultlbl -column 0 -row 2 -sticky nsw -padx 5 -pady 5
ttk::label "$calcpref.result" -textvariable hcalc_result
grid $calcpref.result -column 1 -row 2 -sticky nw -padx 5 -pady 5
grid $calcpref.result -column 1 -row 2 -sticky nsw -padx 5 -pady 5
# Version overrider
set verpref ".tabbar.nopts.right.vers"
@@ -813,3 +853,4 @@ grid $verpref.verlbl -column 0 -row 1 -sticky nws -padx 5 -pady 5
grid $verpref.vertxt -column 1 -row 1 -sticky nw -padx 5 -pady 5
grid $verpref -column 0 -row 1 -sticky nw -padx 5 -pady 5