i made this mainly because nearly every dm snippet out has multiple text events for each item and is generally quite large(1k lines+)
this snippet uses only one text event and the dm code itself is only around 60 lines. the cp is just an extra :p
to add weapons/food type /dmcp or right click in any channel and click 'DM Control Panel'
once the dialog opens you will see two sections, one for weapons and one for food.
too add an item fill out the respective editboxes and click add, an input request box will popup and ask you to enter a short, one word name for the item(this will be used as the trigger and for records). the three editboxes that you need to fill out should be quite self explanatory except for the uses box, this is the maximum amount of times a player can use that item per game, i.e. if you set it to 2 the item can only be used by each player twice. to allow the item to be used an unlimited amount of times enter '-1'
after you add an item it will be added to the appropriate listbox(where all item of their group are shown) which you can click on to see their details. if you made a mistake when creating the item or just want to change it click on the item and in the lower part of the dialog click the 'edit' button.
once you do that a small dialog will popup and show you all the different details for that item that there are, after you have finished editing it click 'save', or if you want to leave it how it is click 'close'
to start a game simply type !dm
the rest should be pretty easy to figure out
alias dmcp dialog $+(-,$iif($dialog(dmcp),v,md)) dmcp dmcp
dialog dmcp {
title "DM Control Panel"
size -1 -1 391 134
option dbu
box "Weapons List", 1, 1 0 133 102
list 2, 3 8 128 91, vsbar size sort
box "Manage Weapons", 3, 135 0 59 102
box "Weapon info", 4, 1 102 193 31
text "Weapon Name:", 5, 4 111 38 8
edit "", 6, 44 111 50 10, read autohs
text "Max Damage:", 7, 4 122 34 8
edit "", 8, 44 122 50 10, read autohs
text "Max number of uses:", 9, 95 111 51 8
edit "", 10, 150 111 38 10, read
button "Add new weapon", 11, 138 73 53 10
button "Delete weapon", 12, 138 86 53 10
text "Weapon Name", 13, 139 11 50 8, center
edit "", 14, 139 21 50 10, autohs
text "Max number of uses", 15, 139 31 50 8, center
edit "", 16, 139 41 50 10
text "Max Damage", 17, 139 51 50 8, center
edit "", 18, 139 61 50 10
box "Food List", 19, 196 0 133 102
list 20, 198 8 128 91, vsbar size sort
box "Manage Food", 21, 331 0 59 102
box "Food Info", 22, 196 102 194 31
text "Food Name:", 23, 200 111 31 8
text "Health bonus:", 24, 200 121 36 8
text "Max number of uses:", 25, 297 111 51 8
edit "", 26, 240 111 50 10, read autohs
edit "", 27, 240 122 50 10, read autohs
edit "", 28, 351 111 36 10, read
text "Food Name:", 29, 335 11 50 8, center
edit "", 30, 335 21 50 10
text "Max Number of uses", 31, 335 31 50 8, center
edit "", 32, 335 41 50 10
text "Health Bonus", 33, 335 51 50 8, center
edit "", 34, 335 61 50 10
button "Add new food", 35, 334 73 53 10
button "Delete food", 36, 334 86 53 10
button "Edit", 37, 118 121 40 10
button "Edit", 38, 314 121 40 10
}
dialog -l dm.edit {
title "DM Item's Manager"
size -1 -1 177 43
option dbu
text "Name:", 1, 11 5 18 8
edit "", 2, 33 5 50 10, autohs
text "Type:", 3, 11 20 18 8
edit "", 4, 33 20 50 10, autohs
text "Max number of uses:", 5, 86 5 51 8
edit "", 6, 140 5 34 10
text "Max Damage:", 7, 86 20 50 8
edit "", 8, 139 20 34 10
button "Save", 9, 51 32 30 10
button "Close", 10, 90 32 30 10,cancel
}
on *:dialog:dmcp:*:*: {
if ($devent == init) {
var %a = 1
while ($ini(dm.ini,%a)) {
var %wep = $v1,%id = $iif($readini(dm.ini,$v1,type) == Weapon,2,20)
did -a dmcp %id %wep
inc %a
}
}
elseif ($devent == sclick) {
if ($istok(2 20,$did,32) && $did($did).seltext) { dm.update $did $v1 | did -e dmcp $iif($did == 2,12,36) }
elseif ($istok(11 35,$did,32)) {
var %a = $iif($did == 11,14 16 18,30 32 34),%c = 1,%1,%2,%3,%4
while ($gettok(%a,%c,32)) { % [ $+ [ %c ] ] = $did($v1) | inc %c }
if (%1 && %2 && %3) {
%4 = $?="Enter a short, one word name for this item."
if (!%4) { halt }
elseif ($ini(dm.ini,%4)) { .noop $input(That item already exists!,o) | halt }
dm.make $+($iif($did == 11,2,20),|,$iif($did == 11,weapon,food),|,%1,|,%2,|,%3,|,%4)
}
else { .noop $input(You need to fill out all three editboxes before you can make a new item!,o) }
}
elseif ($istok(12 36,$did,32)) {
var %a = $iif($did == 12,2,20)
remini dm.ini $did(%a).seltext
did -d dmcp %a $did(%a).sel
did -r dmcp $replace($iif($did == 12,6 8 10,26 27 28),$chr(32),$chr(44))
}
elseif ($istok(37 38,$did,32)) {
dialog -mo dm.edit dm.edit
var %a = $iif($did == 37,1,0),%b = $iif(%a,1,0),%type = $iif(%a,Weapon,Food),%c = $iif(%a,6 %type 10 8,26 %type 28 27),%d = 2 4 6 8,%e = 1
if (!%a) { did -ra dm.edit 7 Health Bonus }
while ($gettok(%c,%e,32)) {
var %did = $v1
did -ra dm.edit $gettok(%d,%e,32) $iif(%did isnum,$did(%did),%did)
inc %e
}
}
}
}
on *:dialog:dm.edit:sclick:9: {
var %a = 2 4 6 8,%b = name type maxu $iif($did(7) != Max Damage,maxd,heal),%c = 1
while ($gettok(%a,%c,32)) {
var %did = $did($v1)
writeini dm.ini $did(dmcp,$iif($did(4) == Weapon,2,20)).seltext $gettok(%b,%c,32) %did
inc %c
}
}
on $*:text:/[!.@](\w*)/Si:#: {
var %a = DM $+ #
if ($regml(1) == dm) {
if (!$hget(%a)) {
.hadd -m %a player1 $nick
.timer $+ %a 1 30 dm.end #
msg # type !dm to accept $nick $+ 's DM request!
}
elseif (!$hget(%a,started) && $hget(%a)) {
var %b = .hadd %a,%c
%b player2 $nick
%c = $hget(%a,$+(player,$r(1,2)))
.msg # DM has started, for a list of available weapons and food, type !dmlist.
.msg # %c goes first!
.timer $+ %a off
%b started 1
%b turn %c
%b p1.hp 99
%b p2.hp 99
}
else { .msg # Sorry $nick $+ , but there is already a DM goin on. }
}
elseif ($regml(1) == enddm && $hget(%a) && $istok($regsubex(a,..,/./g,$hget(%a,player $+ \n) $chr(32)),$nick,32)) {
var %winner = $iif($nick != $hget(%a,player1),$v2,$hget(%a,player2))
.msg # DM has ended, %winner has won!
writeini dmstats.ini %winner Wins $calc($readini(dmstats.ini,%winner,Wins) +1)
.hfree %a
}
elseif ($dm.isitem($regml(1)) && $hget(%a,started)) {
var %item = $dm.isitem($regml(1)),%item1 = $regml(1)
if ($hget(%a,turn) == $nick) {
var %name = $readini(dm.ini,$regml(1),name),%damage = $r(0,$readini(dm.ini,$regml(1),maxd)),%heal = $readini(dm.ini,$regml(1),heal),%uses = $readini(dm.ini,$regml(1),maxu), $&
%nplayer = $iif($hget(%a,player1) !== $hget(%a,turn),$v1,$hget(%a,player2)),%cplayer,%pturn
if (%item == 1) { %cplayer = $+(p,$iif($hget(%a,player1) = $hget(%a,turn),1,2),.hp) | %pturn = $hget(%a,$+(player,$iif(%cplayer == p1.hp && %item == 1,2,1))) }
else { %cplayer = $+(p,$iif($hget(%a,player1) = $hget(%a,turn),2,1),.hp) | %pturn = $hget(%a,$+(player,$iif(%cplayer == p2.hp && %item == 1,2,1))) }
var %cplayer.hp = $iif($calc($hget(%a,%cplayer) - $iif(%damage,$v1,- %heal)) > 0,$v1,0)
if (%uses != -1 && %uses <= $hget(%a,%item1 $+ $nick)) { .msg # you dont have any more of that item left $nick $+ ! | halt }
.msg # $nick $iif(%item = 1,uses,eats) his %name and $iif(%item = 1,hits a %damage,gets healed by %heal HP) $+ ! $&
$iif(%item == 1,%pturn,$nick) $+ 's health is now at %cplayer.hp $dm.hpbar(%cplayer.hp)
.hadd %a %cplayer %cplayer.hp
.hadd %a turn %nplayer
if (%item != -1) { .hinc %a %item1 $+ $nick }
if (%cplayer.hp <= 0) {
var %winner = $iif($nick == $hget(%a,player1),$v1,$hget(%a,player2)),%wins = $calc($readini(dmstats.ini,%winner,Wins) +1)
.msg # $hget(%a,turn) lost the DM! %winner has won %wins $+(time,$iif(%wins != 1,s),!)
writeini dmstats.ini %winner Wins %wins
.hfree %a
}
}
else { .msg # its not your turn $nick $+ ! }
}
elseif ($regml(1) == dmlist) {
msg # my weapons are: $regsubex($str(.,$ini(dm.ini,0)),/(.)/g,$+($iif($readini(dm.ini,$ini(dm.ini,\n),type) == weapon,$+(!,$ini(dm.ini,\n))),$iif(\n != \0,$chr(32))))
msg # my foods are: $regsubex($str(.,$ini(dm.ini,0)),/(.)/g,$+($iif($readini(dm.ini,$ini(dm.ini,\n),type) == food,$+(!,$ini(dm.ini,\n))),$iif(\n != \0,$chr(32))))
}
}
alias -l dm.update {
var %did = $iif($1 == 2,1,0),%a = $iif(%did,maxd,heal),%ids = $iif(%did,6 8 10,26 27 28),%b = name %a maxu,%c = 1
while ($gettok(%ids,%c,32)) { did -ra dmcp $v1 $readini(dm.ini,$2,$gettok(%b,%c,32)) | inc %c }
}
alias -l dm.make {
did -a dmcp $gettok($1-,1,124) $gettok($1-,6,124)
var %a = $gettok($1-,2-5,124),%b = type name maxu $iif($gettok($1-,1,124) == 2,maxd,heal),%c = 1
while ($gettok(%a,%c,124)) { writeini dm.ini $gettok($1-,6,124) $gettok(%b,%c,32) $v1 | inc %c }
if ($dialog(dmcp)) { dialog -v dmcp }
}
alias -l dm.isitem return $iif($ini(dm.ini,$1),$iif($readini(dm.ini,$1,type) == weapon,1,2),0)
alias -l dm.end { msg $1 Noone answered $+($hget($+(DM,$1),player1),'s) DM Request... the game has been ended. | hfree DM $+ $1 }
alias -l dm.hpbar { return $+($str($+(09,$chr(44),09.),$ceil($calc($1 /10))),$str($+(04,$chr(44),04.),$ceil($calc((99- $1)/10)))) }
on *:load:if (!$isfile(DM.ini)) { write -c DM.ini } | if (!$isfile(dmstats.ini)) { write -c dmstats.ini }
menu channel {
DM Control Panel:dmcp
}