diff --git a/bin/_startup.def b/bin/_startup.def index aab3396..b73b489 100644 --- a/bin/_startup.def +++ b/bin/_startup.def @@ -6,6 +6,7 @@ LOG * DefScript StartUp [${@version_short}]... // first, load all scripts in patch 'scripts' with extension .def SET,fcount ?{LGETFILES,scriptlist,def scripts} +LSORT scriptlist LOGDETAIL * Loading ${fcount} scripts. // iterate over all files and load them; if counter i is equal to the amount of files we are done. SET,i 0 diff --git a/bin/conf/ScriptConfig.conf.default b/bin/conf/ScriptConfig.conf.default index 610ab77..b438b5e 100644 --- a/bin/conf/ScriptConfig.conf.default +++ b/bin/conf/ScriptConfig.conf.default @@ -9,9 +9,12 @@ [#noprefix] // special char that is used to trigger server commands (for example ".goname Player") // (WoWEmu="." MaNGOS="." or "!") -// other servers might be different +// other servers might be different cmdchar=. +// MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command! +other_cmd_chars=.! + [#normal] diff --git a/bin/scripts/__core_chat.def b/bin/scripts/__core_chat.def new file mode 100644 index 0000000..834a5dc --- /dev/null +++ b/bin/scripts/__core_chat.def @@ -0,0 +1,210 @@ + +//----------------------------------------------------------- +#script=chan +//----------------------------------------------------------- +// Script to write on channels +// Arguments: +// ========== +// @def: text to write +// @0: channel name +// @1: language name/number + +#permission=10 +SET,lang ${@1} +DEFAULT,lang 0 +SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}} +UNSET lang + + +//----------------------------------------------------------- +#script=cmd +#permission=255 +//----------------------------------------------------------- +// purpose: send a server command. +// args: +// @def: command to send + +SAY ${#CMDCHAR}${@def} + + +//----------------------------------------------------------- +#script=reply +#permission=255 +//----------------------------------------------------------- +// purpose: reply to the player that whispered last + +SET,player ${@thiswhisper_name} +SET,lang ${@0} +DEFAULT,lang 0 +SET,msg ${@def} + +WHISPER,{${player}},{${lang}} ${msg} + +UNSET player +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=s +#permission=0 +//----------------------------------------------------------- +// is the char equal to the char we use for commands? does the player have a permission lvl below 255? +IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} + // yes: say a warning and the command the player wanted to use + SAY ${@thiscmd_name}: no permission to use commands [${@def}] + RETURN false +ELSE + // no: say the text as usual. + SAY,{${@0}} ${@def} + RETURN true +ENDIF + + +//----------------------------------------------------------- +#script=say +#permission=255 +//----------------------------------------------------------- +// purpose: say something. @0: language ID or name, @def: text to say +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Saying '${msg}' in lang ${lang} + +SENDCHATMESSAGE,0,${lang},{${msg}} +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=sayguild +#permission=255 +//----------------------------------------------------------- +// purpose: say something to guild channel +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +LOGDEBUG * Saying '${msg}' in lang ${lang} to guild + +SENDCHATMESSAGE,3,${lang},{${msg}} +UNSET lang +UNSET msg + +//----------------------------------------------------------- +#script=sayitem +#permission=0 +//----------------------------------------------------------- +// example script to "say" a clickable item +SAY ?{getchatitem ${@def}} + + +//----------------------------------------------------------- +#script=sayparty +#permission=255 +//----------------------------------------------------------- +// purpose: say something to party channel +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +default,lang 0 + +LOGDEBUG * Saying '${msg}' in lang ${lang} to party + +SENDCHATMESSAGE,1,${lang},{${msg}} +UNSET lang +UNSET msg + +//----------------------------------------------------------- +#script=sayred +//----------------------------------------------------------- +// example script how to output colored text +#permission=0 +SAY,{${@0}} |cffFF0000${@def} + +//----------------------------------------------------------- +#script=sayv +#permission=0 +//----------------------------------------------------------- +// purpose: say the value of a variable +// args: @0: language ID or name, @def: var name +SET,vn #${@caller}::${@def} +SET,vl ${@0} +DEFAULT,vl 0 + +IF ?{NOT ?{ISSET ${vn}}} + SAY,{${vl}} * Var '${@def}' not defined. +ELSE + SET,vv ${${vn}} + SAY,{${vl}} * Var '${@def}' = '${vv}' +ENDIF + +UNSET vv +UNSET vn +UNSET vl + + +//----------------------------------------------------------- +#script=whisper +#permission=255 +//----------------------------------------------------------- +// purpose: whisper text to a player. +// args: @0: player name to whisper to; @1: language to use; @def: text + +// setup some default values +SET,msg ${@def} +SET,player ${@0} +SET,lang ${@1} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}' + +SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}} +UNSET lang +UNSET msg +UNSET player + + +//------------------------------------------------------------- +#script=yell +#permission=255 +//------------------------------------------------------------- +// purpose: SHOUT! + +// setup some default values +SET,lang ${@0} +SET,msg ${@def} + +DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} +DEFAULT,lang ${#DEFAULTLANG} + +LOGDEBUG * Yelling '${msg}' in lang ${lang} + +SENDCHATMESSAGE,5,${lang},{${msg}} +UNSET lang +UNSET msg + + +//----------------------------------------------------------- +#script=y +#permission=0 +//----------------------------------------------------------- +// is the char equal to the char we use for commands? does the player have a permission lvl below 255? +IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} + // yes: say a warning and the command the player wanted to use + YELL ${@thiscmd_name}: no permission to use commands [${@def}] + RETURN false +ELSE + // no: say the text as usual. + YELL,{${@0}} ${@def} + RETURN true +ENDIF \ No newline at end of file diff --git a/bin/scripts/__core_func.def b/bin/scripts/__core_func.def new file mode 100644 index 0000000..1594e5a --- /dev/null +++ b/bin/scripts/__core_func.def @@ -0,0 +1,123 @@ +// core functions. required by other scripts to run! +#onload + log * Loading core scripts... +#/onload + + +//-------------------------------------------------------- +#script=append +#permission=255 +//-------------------------------------------------------- +// usage: append text to a string. +// args: +// @def: text to append +// @0: variable to which the text should be appended + +// get the var name if the original variable +SET,v #${@caller}::${@0} +// if it has not been set before, init it now +DEFAULT,${v} +// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got. +SET,${v} ${${v}}${@def} +// remove the name placeholder +UNSET v + + +//-------------------------------------------------------- +#script=exloadscp +#permission=255 +//-------------------------------------------------------- +if ?{fileexists ${@def}} + loadscp,{${@0}} ${@def} +else + logdebug skipped loading of non-existent file '${@def}' +endif + + +//-------------------------------------------------------- +#script=loadallscp +#permission=255 +//-------------------------------------------------------- +LOG * Loading SCP data storages... + +// example: +// LOADSCP,test data/test.scp + +// load default databases +LOADSCP,class data/scp/class.scp +LOADSCP,gender data/scp/gender.scp +LOADSCP,language data/scp/language.scp +LOADSCP,map data/scp/map.scp +LOADSCP,race data/scp/race.scp + +// load extended databases if present. +EXLOADSCP,sound data/scp/sound.scp +EXLOADSCP,emote data/scp/emote.scp + +LOG * SCP loaded. + + +//------------------------------------------------- +#script=string_is_command +#permission=255 +//------------------------------------------------- +// purpose: detect if @def might be a server command. + +// split all chars we have set in the config files to a list. +lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS} + +// find out the first char of the string +SET,c ?{SUBSTR,1 ${@def}} + +// does the char list contain our first char? if yes it can trigger a server command. +if ?{lcontains,#CMDCHARLIST ${c}} + unset c + return true +endif +unset c +return false + + +//-------------------------------------------------------- +#script=normalize_name +#permission=255 +//-------------------------------------------------------- +// uppercases first char, lowercases rest +set,name ?{uppercase ?{substr,1 ${@def}}} +set,len ?{strlen ${@def}} +sub,len 1 +append,name ?{lowercase ?{substr,${len},1 ${@def}}} +return ${name} + +//--------------------------------------------------------- +#script=globname +#permission=255 +//--------------------------------------------------------- +// purpose: returns the global name of a variable +// args: @def: var name, @0 (optional): name of the intended parent func +set,c ?{substr,1 ${@def}} +// it is a global var if the varname starts with # or there is no caller script +if ?{or,?{equal,# ${c}} ?{not ${@caller}}} + return ${@def} +endif +set,top ${@0} +default,top ${@caller} +return #${top}::${@def} + + +//--------------------------------------------------------- +#script=getvar +#permission=255 +//--------------------------------------------------------- +// purpose: returns the value of a variable. if the variable hasnt been set return empty string. +set,top ${@caller} +default,top # +set,v ?{globname,${top} ${@def}} +unset top +out getvar: v=${v} -> ${${v}} +if ?{isset ${v}} + return ${${v}} +endif +return + + diff --git a/bin/scripts/toleet.def b/bin/scripts/__core_funstuff.def similarity index 57% rename from bin/scripts/toleet.def rename to bin/scripts/__core_funstuff.def index c301d24..312fb48 100644 --- a/bin/scripts/toleet.def +++ b/bin/scripts/__core_funstuff.def @@ -1,26 +1,55 @@ -// toleet.def -// ========== -// purpose: convert any text into leetspeak [1337sp34k] -// args: -// @def: the text to convert -// returns: leetspeak^^ -// call it from script only + +//------------------------------------------------- +#script=slap #permission=255 +//------------------------------------------------- +// purpose: let a player fly. (at least works on MaNGOS) +// args: @def: player name +// returns: guid of the targeted player, else false. empty string if we are not in the world. + +// we can use this script only if we are in the world +if ?{not ${@inworld}} + logerror Can't slap anything if i am not in the world! + return +endif + +// normalize player name. first char uppercased, rest lowercased. +set,name ?{normalize_name ${@def}} + +// target the player. if targeting was successful, cast spell "Knockback 500". +set,t ?{target ${name}} +if ${t} + logdebug slapping player '${name}' + castspell 11027 + target +else + logerror Can't target player '${name}' +endif + +unset name + +return ${t} + + + +//------------------------------------------------ +#script=toleet +#permission=255 +//------------------------------------------------ +// purpose: convert any text into leetspeak [1337sp34k] +// args: @def: the text to convert +// returns: leetspeak^^ #onload // this can be used by other scripts to check if we have loaded this script set,#HAVE_LEET true #endonload -// --- Begin of main function --- - // empty the string where the leet will be stored set,str - // total length of the string to convert set,l ?{strlen ${@def}} - // position counter set,x 0 @@ -93,3 +122,5 @@ unset c unset c2 return ${str} + + diff --git a/bin/scripts/__core_internal.def b/bin/scripts/__core_internal.def new file mode 100644 index 0000000..3c477da --- /dev/null +++ b/bin/scripts/__core_internal.def @@ -0,0 +1,94 @@ +// scripts used for configuration! DO NOT MODIFY unless you know what you do!! + +#onload + log * Loading core scripts (internal config)... +#/onload + +//-------------------------------------------------------- +#script=exit +#permission=255 +//-------------------------------------------------------- +// just a name alternative +QUIT + + +//-------------------------------------------------------- +#script=quit +#permission=255 +//-------------------------------------------------------- +// quit PseuWoW, say goodbye when logged in +IF ${@inworld} + SAY Terminating proc... +ENDIF +SHDN + + +//----------------------------------------------- +#script=cleanupvars +//----------------------------------------------- +// purpose: unset all variables that could be abused by someone +LOGDETAIL * Cleaning up variables... +UNSET #ACCPASS +UNSET #ACCNAME +LOGDETAIL * Dangerous variables removed. + + +//----------------------------------------------- +#script=config +#permission=255 +//----------------------------------------------- +// Load all conf files from directory /conf/ +// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount' +SET,fcount ?{LGETFILES,fl,conf conf} +// sort the list, load conf files alphabetically. +LSORT fl + +IF ?{NOT ${fcount}} + LOGERROR No conf file found! Can't load. + RETURN +ENDIF + +LOG * Loading ${fcount} conf files. +// iterate over all files and load them; if counter i is equal to the amount of files we are done. +SET,i 0 +LOOP + IF ?{EQUAL,${i} ${fcount}} + EXITLOOP + ENDIF + SET,fn ?{LINDEX,fl ${i}} + LOG * Loading conf file [ ${fn} ] + LOADCONF ${fn} + ADD,i 1 +ENDLOOP + +UNSET fcount +UNSET i +UNSET fn +LDELETE fl + +// Apply the configuration +APPLYCONF +LOG * Configuration applied. + +// Apply user permissions +APPLYPERMISSIONS + +// remove dangerous variables +CLEANUPVARS + +// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style) +DEFAULT,#CMDCHAR . + + +//-------------------------------------------------- +#script=internal_perm +#permission=255 +//-------------------------------------------------- +// purpose: set script permissions for internal functions that cant be set otherwise. +// if you don't set a permission for a script manually, it will have permission 255 (highest) + +LOG * Assigning permissions for internal functions... +// emotes are hard to abuse, allow for everyone +setscriptpermission,emote 0 +// ... set more permissions here ... + diff --git a/bin/scripts/__core_list_extensions.def b/bin/scripts/__core_list_extensions.def new file mode 100644 index 0000000..42de5d8 --- /dev/null +++ b/bin/scripts/__core_list_extensions.def @@ -0,0 +1,36 @@ + + +//-------------------------------------------- +#script=lcontains +#permission=255 +//-------------------------------------------- +// return true if any list element matches @def, else return false. +// @0: list name, @def: search string + +set,i 0 +set,l ?{globname ${@0}} + +out list: ${l} - len: ?{llen ${l}} + +if ?{not ?{llen ${l}}} + return +endif + +set,result false +loop + out eq:?{equal,${i} ?{llen ${l}}} i:${i} len:?{llen ${l}} + if ?{equal,${i} ?{llen ${l}}} + exitloop + endif + set,elem ?{lindex,{${l}} ${i}} + if ?{equal,{${elem}} ${@def}} + set,result true + exitloop + endif + add,i 1 +endloop +unset i +unset l +unset elem +return ${result} + diff --git a/bin/scripts/__core_misc.def b/bin/scripts/__core_misc.def new file mode 100644 index 0000000..8700586 --- /dev/null +++ b/bin/scripts/__core_misc.def @@ -0,0 +1,57 @@ + + +//----------------------------------------------- +#script=getchatitem +#permission=255 +//----------------------------------------------- +// expected args: +// @def: item id +// @0 (optional): color (in RGB hex format: 00FF00 = pure green) +// returns: clickable item link to use it chat messages + +SET,i ${@def} +SET,color ${@0} +DEFAULT,i 0 +TOINT,i ${i} +DEFAULT,color 6679FF +SET,link |cff${color}|Hitem:${i}:0:0:0|h[Item ${i}]|h|r + +UNSET i +UNSET color + +RETURN ${link} + + +//----------------------------------------------- +#script=makechatitem +#permission=255 +//----------------------------------------------- +// purpose: write the text of a clickable item link into a variable +// expected args: +// @def: item id +// @0: variable name to write into +// @1 (optional): color (in hex format: 00FF00 = pure green) +SET,v #${@caller}::${target} +SET,{${v}} ?{getchatitem,{${@1}} ${@def}} +UNSET v + + +//----------------------------------------------- +#script=outv +#permission=0 +//----------------------------------------------- +// purpose: output a variable's value to the console. +// usage: "outv x" + +SET,vn #${@caller}::${@def} + +IF ?{NOT ?{ISSET ${vn}}} + OUT * Var '${@def}' not defined. + RETURN +ENDIF + +SET,vv ${${vn}} +OUT * Var '${@def}' = '${vv}' + +UNSET vv +UNSET vn diff --git a/bin/scripts/__core_wrappers.def b/bin/scripts/__core_wrappers.def new file mode 100644 index 0000000..0b2a4d7 --- /dev/null +++ b/bin/scripts/__core_wrappers.def @@ -0,0 +1,39 @@ +// example file. wrap a few functions together. + +//------------------------------------------------ +#script=gc +//------------------------------------------------ +// example script to write into channel "generalchat" +// usage: "gc bla bla..." +chan,generalchat ${@def} + + +//------------------------------------------------ +#script=gcl +#permission=0 +//------------------------------------------------ +// write leetspeak to channel generalchat (see "gc" script) +// usage: "gcl moo, cow syndrome!" +gc ?{toleet ${@def}} + + +//------------------------------------------------ +#script=selfheal +#permission=0 +//------------------------------------------------ +// purpose: heal self with full hp. GM-ONLY!! +// be sure you have this spell in your spellbook! +// DO NOT USE THIS SCRIPT IF YOU ARE NO GM! + +// target self (the name we used to login) +TARGET ${#CHARNAME} +// 23965 = instant heal +CASTSPELL 23965 + +//------------------------------------------------ +#script=sl +#permission=0 +//------------------------------------------------ +// say leetspeak text. gm-commands can't be executed this way +s,{${@0}} ?{toleet ${@def}} + diff --git a/bin/scripts/append.def b/bin/scripts/append.def deleted file mode 100644 index 6221ab3..0000000 --- a/bin/scripts/append.def +++ /dev/null @@ -1,15 +0,0 @@ -#permission=255 - -// usage: append text to a string. -// args: -// @def: text to append -// @0: variable to which the text should be appended - -// get the var name if the original variable -SET,v #${@caller}::${@0} -// if it has not been set before, init it now -DEFAULT,${v} -// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got. -SET,${v} ${${v}}${@def} -// remove the name placeholder -UNSET v \ No newline at end of file diff --git a/bin/scripts/chan.def b/bin/scripts/chan.def deleted file mode 100644 index 2639286..0000000 --- a/bin/scripts/chan.def +++ /dev/null @@ -1,13 +0,0 @@ - -// Script to write on channels -// Arguments: -// ========== -// @def: text to write -// @0: channel name -// @1: language name/number - -#permission=10 -SET,lang ${@1} -DEFAULT,lang 0 -SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}} -UNSET lang \ No newline at end of file diff --git a/bin/scripts/cleanupvars.def b/bin/scripts/cleanupvars.def deleted file mode 100644 index 88ac96b..0000000 --- a/bin/scripts/cleanupvars.def +++ /dev/null @@ -1,6 +0,0 @@ - - -LOG * Cleaning up variables... -UNSET #ACCPASS -UNSET #ACCNAME -LOG * Dangerous variables removed. \ No newline at end of file diff --git a/bin/scripts/cmd.def b/bin/scripts/cmd.def deleted file mode 100644 index 4e866d9..0000000 --- a/bin/scripts/cmd.def +++ /dev/null @@ -1,7 +0,0 @@ -#permission=255 - -// purpose: send a server command. -// args: -// @def: command to send - -SAY ${#CMDCHAR}${@def} \ No newline at end of file diff --git a/bin/scripts/config.def b/bin/scripts/config.def deleted file mode 100644 index cd3790c..0000000 --- a/bin/scripts/config.def +++ /dev/null @@ -1,35 +0,0 @@ -#permission=255 - -// Load all conf files from directory /conf/ -// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount' -SET,fcount ?{LGETFILES,fl,conf conf} -LOGDETAIL * Loading ${fcount} conf files. -// iterate over all files and load them; if counter i is equal to the amount of files we are done. -SET,i 0 -LOOP - IF ?{EQUAL,${i} ${fcount}} - EXITLOOP - ENDIF - SET,fn ?{LINDEX,fl ${i}} - LOG * Loading conf file [ ${fn} ] - LOADCONF ${fn} - ADD,i 1 -ENDLOOP - -UNSET fcount -UNSET i -UNSET fn -LDELETE fl - -// Apply the configuration -APPLYCONF -LOG * Configuration applied. - -// Apply user permissions -APPLYPERMISSIONS - -// remove dangerous variables -CLEANUPVARS - -// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style) -DEFAULT,#CMDCHAR . diff --git a/bin/scripts/example_3xadd1.def b/bin/scripts/example_3xadd1.def deleted file mode 100644 index 969b8f2..0000000 --- a/bin/scripts/example_3xadd1.def +++ /dev/null @@ -1,19 +0,0 @@ -#permission=255 - -// EXAMPLE SCRIPT!!! -// expected args: -// @def: variable name -// purpose: multiply a given variable with 3 and add 1 - -// this line is the most important part: -// get the name of the function calling this script, -// and modify its variable. note that we treat this variable as global! -// example: script "foo" has a variable x and calls this script with x as default argument. -// result: the variable name will be: "#foo::x" -set,v #${@caller}::${@def} -// v now stores the variable name of the var we want to change. -// side note: the # marks the var as global. if we didnt do this, the var name would be "example_3xadd1::foo::x" - -// do some math -mul,{${v}} 3 -add,{${v}} 1 \ No newline at end of file diff --git a/bin/scripts/example_loop_if.def b/bin/scripts/example_loop_if.def deleted file mode 100644 index 59fc019..0000000 --- a/bin/scripts/example_loop_if.def +++ /dev/null @@ -1,22 +0,0 @@ -#permission=255 -// example script to explain how to use loops/ifs - -set,x 0 -loop - set,y 0 - add,x 1 - if ?{bigger,${x} 5} - exitloop - endif - loop - if ?{bigger,${y} 8} - exitloop - else - set,tmp ${x} - mul,tmp ${y} - out LOOP:${x}:${y} = ${tmp} - endif - add,y 1 - endloop -endloop -out end if/loop test script \ No newline at end of file diff --git a/bin/scripts/example_onload.def b/bin/scripts/example_onload.def deleted file mode 100644 index b07f558..0000000 --- a/bin/scripts/example_onload.def +++ /dev/null @@ -1,13 +0,0 @@ -// EXAMPLE SCRIPT!!! -// purpose: demonstrate the #onload part that gets executed everytime the script is loaded -// result: on the first call the number '1001' will be written, 2nd call '1002', etc. - -#permission=255 -#onload - out Loading "loadtest.def" --[[ - set,mytest 1000 - out finished ]]-- -#endonload - -add,mytest 1 -out ${mytest} \ No newline at end of file diff --git a/bin/scripts/exit.def b/bin/scripts/exit.def deleted file mode 100644 index 71be10a..0000000 --- a/bin/scripts/exit.def +++ /dev/null @@ -1,4 +0,0 @@ -#permission=255 -// just a name alternative - -QUIT \ No newline at end of file diff --git a/bin/scripts/exloadscp.def b/bin/scripts/exloadscp.def deleted file mode 100644 index 04dfbad..0000000 --- a/bin/scripts/exloadscp.def +++ /dev/null @@ -1,6 +0,0 @@ -#permission=255 -if ?{fileexists ${@def}} - loadscp,{${@0}} ${@def} -else - logdebug skipped loading of non-existent file '${@def}' -endif \ No newline at end of file diff --git a/bin/scripts/gc.def b/bin/scripts/gc.def deleted file mode 100644 index 85fc8c2..0000000 --- a/bin/scripts/gc.def +++ /dev/null @@ -1,4 +0,0 @@ -// example script to write into channel "generalchat" -// usage: "gc bla bla..." - -chan,generalchat ${@def} \ No newline at end of file diff --git a/bin/scripts/gcl.def b/bin/scripts/gcl.def deleted file mode 100644 index 078179a..0000000 --- a/bin/scripts/gcl.def +++ /dev/null @@ -1,3 +0,0 @@ -// write leetspeak to channel generalchat (see gc.def) -#permission=0 -gc ?{toleet ${@def}} \ No newline at end of file diff --git a/bin/scripts/getchatitem.def b/bin/scripts/getchatitem.def deleted file mode 100644 index 7423d75..0000000 --- a/bin/scripts/getchatitem.def +++ /dev/null @@ -1,18 +0,0 @@ -#permission=255 - -// expected args: -// @def: item id -// @0 (optional): color (in RGB hex format: 00FF00 = pure green) -// returns: clickable item link - -SET,i ${@def} -SET,color ${@0} -DEFAULT,i 0 -TOINT,i ${i} -DEFAULT,color 6679FF -SET,link |cff${color}|Hitem:${i}:0:0:0|h[Item ${i}]|h|r - -UNSET i -UNSET color - -RETURN ${link} \ No newline at end of file diff --git a/bin/scripts/internal_perm.def b/bin/scripts/internal_perm.def deleted file mode 100644 index 9bd8c2c..0000000 --- a/bin/scripts/internal_perm.def +++ /dev/null @@ -1,51 +0,0 @@ -#psermission=255 - -LOG * Assigning permissions for internal functions... - -// default permission level for all internal script commands -set,p 255 - -// this is important because players could reset permissions for dangerous functions -SETSCRIPTPERMISSION,setscriptpermission 255 - -SETSCRIPTPERMISSION,out ${p} -SETSCRIPTPERMISSION,set ${p} -SETSCRIPTPERMISSION,default ${p} -SETSCRIPTPERMISSION,unset ${p} -SETSCRIPTPERMISSION,shdn ${p} -SETSCRIPTPERMISSION,loaddef ${p} -SETSCRIPTPERMISSION,reloaddef ${p} - -SETSCRIPTPERMISSION,toint ${p} -SETSCRIPTPERMISSION,add ${p} -SETSCRIPTPERMISSION,sub ${p} -SETSCRIPTPERMISSION,mul ${p} -SETSCRIPTPERMISSION,div ${p} -SETSCRIPTPERMISSION,mod ${p} -SETSCRIPTPERMISSION,pow ${p} -SETSCRIPTPERMISSION,bitor ${p} -SETSCRIPTPERMISSION,bitand ${p} -SETSCRIPTPERMISSION,bitxor ${p} - -SETSCRIPTPERMISSION,pause ${p} -// emotes are not relly dangerous, allow for all users -SETSCRIPTPERMISSION,emote 0 -SETSCRIPTPERMISSION,savecache ${p} -SETSCRIPTPERMISSION,sendchatmessage ${p} -SETSCRIPTPERMISSION,joinchannel ${p} -SETSCRIPTPERMISSION,leavechannel ${p} -SETSCRIPTPERMISSION,loadconf ${p} -SETSCRIPTPERMISSION,applyconf ${p} -SETSCRIPTPERMISSION,applypermissions ${p} -SETSCRIPTPERMISSION,log ${p} -SETSCRIPTPERMISSION,logdetail ${p} -SETSCRIPTPERMISSION,logdebug ${p} -SETSCRIPTPERMISSION,target ${p} -SETSCRIPTPERMISSION,loadscp ${p} -SETSCRIPTPERMISSION,castspell ${p} - - -UNSET p - - -LOG * Permissions set. diff --git a/bin/scripts/loadall.def.obsoelete b/bin/scripts/loadall.def.obsoelete deleted file mode 100644 index 1aa5194..0000000 --- a/bin/scripts/loadall.def.obsoelete +++ /dev/null @@ -1,27 +0,0 @@ - -// preloads the most important scripts - -LOG * Loading DefScripts... - -RELOADDEF _enterworld -RELOADDEF _leaveworld -RELOADDEF _nopermission -RELOADDEF _onwhisper -RELOADDEF cleanupvars -RELOADDEF internal_perm -RELOADDEF chan -RELOADDEF quit -RELOADDEF reply -RELOADDEF say -RELOADDEF yell -RELOADDEF whisper -RELOADDEF makechatitem - -RELOADDEF gc -RELOADDEF sayred -RELOADDEF outv -RELOADDEF sayv -RELOADDEF s -RELOADDEF y - -LOG * DefScripts loaded. \ No newline at end of file diff --git a/bin/scripts/loadallscp.def b/bin/scripts/loadallscp.def deleted file mode 100644 index e05eac1..0000000 --- a/bin/scripts/loadallscp.def +++ /dev/null @@ -1,20 +0,0 @@ -#permission=255 - -LOG * Loading SCP data storages... - -// example: -// LOADSCP,test data/test.scp - -// load default databases -LOADSCP,class data/scp/class.scp -LOADSCP,gender data/scp/gender.scp -LOADSCP,language data/scp/language.scp -LOADSCP,map data/scp/map.scp -LOADSCP,race data/scp/race.scp - -// load extended databases if present. -EXLOADSCP,sound data/scp/sound.scp -EXLOADSCP,emote data/scp/emote.scp - -LOG * SCP loaded. - diff --git a/bin/scripts/makechatitem.def b/bin/scripts/makechatitem.def deleted file mode 100644 index cbb42ea..0000000 --- a/bin/scripts/makechatitem.def +++ /dev/null @@ -1,21 +0,0 @@ -#permission=255 - -// expected args: -// @def: item id -// @0: variable name to write into -// @1 (optional): color (in hex format: 00FF00 = pure green) - -SET,i ${@def} -SET,target ${@0} -SET,color ${@1} -DEFAULT,i 0 -TOINT,i ${i} -DEFAULT,target chatitem -DEFAULT,color 6679FF -SET,v #${@caller}::${target} -SET,${v} |cff${color}|Hitem:${i}:0:0:0|h[Item ${i}]|h|r - -UNSET i -UNSET v -UNSET color -UNSET target \ No newline at end of file diff --git a/bin/scripts/outv.def b/bin/scripts/outv.def deleted file mode 100644 index 08a494d..0000000 --- a/bin/scripts/outv.def +++ /dev/null @@ -1,14 +0,0 @@ -#permission=0 - -SET,vn #${@caller}::${@def} - -IF ?{NOT ?{ISSET ${vn}}} - OUT * Var '${@def}' not defined. - RETURN -ENDIF - -SET,vv ${${vn}} -OUT * Var '${@def}' = '${vv}' - -UNSET vv -UNSET vn diff --git a/bin/scripts/quit.def b/bin/scripts/quit.def deleted file mode 100644 index 4e00346..0000000 --- a/bin/scripts/quit.def +++ /dev/null @@ -1,5 +0,0 @@ -#permission=255 -IF ${@inworld} - SAY Terminating proc... -ENDIF -SHDN \ No newline at end of file diff --git a/bin/scripts/reply.def b/bin/scripts/reply.def deleted file mode 100644 index c456919..0000000 --- a/bin/scripts/reply.def +++ /dev/null @@ -1,12 +0,0 @@ -#permission=255 - -SET,player ${@thiswhisper_name} -SET,lang ${@0} -DEFAULT,lang 0 -SET,msg ${@def} - -WHISPER,{${player}},{${lang}} ${msg} - -UNSET player -UNSET lang -UNSET msg \ No newline at end of file diff --git a/bin/scripts/s.def b/bin/scripts/s.def deleted file mode 100644 index 0135e1b..0000000 --- a/bin/scripts/s.def +++ /dev/null @@ -1,20 +0,0 @@ -#permission=0 - -// purpose: easy way for any player to make pseuwow say text. -// if it thinks the player is trying to use a server command it will not say it. -// args are the same as say.def -// only players whose permission is = 255 can use this script to say commands - -// first find out the first char of the message string -SET,c ?{SUBSTR,1 ${@def}} - -// is the char equal to the char we use for commands? does the player have a permission lvl below 255? -IF ?{AND,?{EQUAL,${c} {${#CMDCHAR}}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} - // yes: say a warning and the command the player wanted to use - SAY ${@thiscmd_name}: no permission to use commands [${@def}] - RETURN false -ELSE - // no: say the text as usual. - SAY,{${@0}} ${@def} - RETURN true -ENDIF \ No newline at end of file diff --git a/bin/scripts/say.def b/bin/scripts/say.def deleted file mode 100644 index 4bf5db5..0000000 --- a/bin/scripts/say.def +++ /dev/null @@ -1,13 +0,0 @@ -#permission=255 -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Saying '${msg}' in lang ${lang} - -SENDCHATMESSAGE,0,${lang},{${msg}} -UNSET lang -UNSET msg \ No newline at end of file diff --git a/bin/scripts/sayguild.def b/bin/scripts/sayguild.def deleted file mode 100644 index 59c8777..0000000 --- a/bin/scripts/sayguild.def +++ /dev/null @@ -1,12 +0,0 @@ -#permission=255 -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -default,lang 0 - -LOGDEBUG * Saying '${msg}' in lang ${lang} - -SENDCHATMESSAGE,3,${lang},{${msg}} -UNSET lang -UNSET msg \ No newline at end of file diff --git a/bin/scripts/sayitem.def b/bin/scripts/sayitem.def deleted file mode 100644 index c069bf7..0000000 --- a/bin/scripts/sayitem.def +++ /dev/null @@ -1,8 +0,0 @@ -// example script to "say" a clickable item (in WoW) - -MAKECHATITEM,i ${@def} -SAY ${i} -UNSET i - -// we could also use the following: -// SAY ?{GETCHATITEM ${@def}} diff --git a/bin/scripts/sayparty.def b/bin/scripts/sayparty.def deleted file mode 100644 index caf37e3..0000000 --- a/bin/scripts/sayparty.def +++ /dev/null @@ -1,12 +0,0 @@ -#permission=255 -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -default,lang 0 - -LOGDEBUG * Saying '${msg}' in lang ${lang} - -SENDCHATMESSAGE,1,${lang},{${msg}} -UNSET lang -UNSET msg \ No newline at end of file diff --git a/bin/scripts/sayred.def b/bin/scripts/sayred.def deleted file mode 100644 index 2451bfd..0000000 --- a/bin/scripts/sayred.def +++ /dev/null @@ -1,4 +0,0 @@ -// example script how to output colored text - -#permission=0 -SAY,${@0} |cffFF0000 ${@def} \ No newline at end of file diff --git a/bin/scripts/sayv.def b/bin/scripts/sayv.def deleted file mode 100644 index a1c7ab6..0000000 --- a/bin/scripts/sayv.def +++ /dev/null @@ -1,17 +0,0 @@ -#permission=0 - -SET,vn #${@caller}::${@def} -SET,vl ${@0} -DEFAULT,vl 0 - -IF ?{NOT ?{ISSET ${vn}}} - SAY,{${vl}} * Var '${@def}' not defined. - RETURN -ENDIF - -SET,vv ${${vn}} -SAY,{${vl}} * Var '${@def}' = '${vv}' - -UNSET vv -UNSET vn -UNSET vl diff --git a/bin/scripts/selfheal.def b/bin/scripts/selfheal.def deleted file mode 100644 index 8b7455e..0000000 --- a/bin/scripts/selfheal.def +++ /dev/null @@ -1,11 +0,0 @@ -#permission=0 - -// purpose: heal self with full hp. GM-ONLY!! -// be sure you have this spell in your spellbook! -// DO NOT USE THIS SCRIPT IF YOU ARE NO GM! - -// target self (the name we used to login) -TARGET ${#CHARNAME} - -// 23965 = instant heal -CASTSPELL 23965 \ No newline at end of file diff --git a/bin/scripts/sl.def b/bin/scripts/sl.def deleted file mode 100644 index a0c9e88..0000000 --- a/bin/scripts/sl.def +++ /dev/null @@ -1,3 +0,0 @@ -// say leetspeak text. gmcommands can't be executed this way -#permission=0 -s,{${@0}} ?{toleet ${@def}} diff --git a/bin/scripts/slap.def b/bin/scripts/slap.def deleted file mode 100644 index 4c36261..0000000 --- a/bin/scripts/slap.def +++ /dev/null @@ -1,31 +0,0 @@ -// purpose: let a player fly. (at least works on MaNGOS) -// args: @def: player name -// returns: guid of the targeted player, else false. empty string if we are not in the world. -#permission=100 - -// we can use this script only if we are in the world -if ?{not ${@inworld}} - logerror Can't slap anything if i am not in the world! - return -endif - -// normalize player name. first char uppercased, rest lowercased. -set,name ?{uppercase ?{substr,1 ${@def}}} -set,len ?{strlen ${@def}} -sub,len 1 -append,name ?{lowercase ?{substr,${len},1 ${@def}}} - - -// target the player. if targeting was successful, cast spell "Knockback 500". -set,t ?{target ${name}} -if ${t} - logdebug slapping player '${name}' - castspell 11027 - target -else - logerror Can't target player '${name}' -endif - -unset name - -return ${t} diff --git a/bin/scripts/whisper.def b/bin/scripts/whisper.def deleted file mode 100644 index d9f6dde..0000000 --- a/bin/scripts/whisper.def +++ /dev/null @@ -1,16 +0,0 @@ -#permissionn=255 - -// setup some default values -SET,msg ${@def} -SET,player ${@0} -SET,lang ${@1} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}' - -SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}} -UNSET lang -UNSET msg -UNSET player \ No newline at end of file diff --git a/bin/scripts/y.def b/bin/scripts/y.def deleted file mode 100644 index 4cc9716..0000000 --- a/bin/scripts/y.def +++ /dev/null @@ -1,2 +0,0 @@ -#permission=0 -YELL,{${@0}} ${@def} \ No newline at end of file diff --git a/bin/scripts/yell.def b/bin/scripts/yell.def deleted file mode 100644 index f230e0f..0000000 --- a/bin/scripts/yell.def +++ /dev/null @@ -1,13 +0,0 @@ -#permission=255 -// setup some default values -SET,lang ${@0} -SET,msg ${@def} - -DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction} -DEFAULT,lang ${#DEFAULTLANG} - -LOGDEBUG * Yelling '${msg}' in lang ${lang} - -SENDCHATMESSAGE,5,${lang},{${msg}} -UNSET lang -UNSET msg diff --git a/src/Client/DefScript/DefScript.cpp b/src/Client/DefScript/DefScript.cpp index 3b0414b..cd7bf4f 100644 --- a/src/Client/DefScript/DefScript.cpp +++ b/src/Client/DefScript/DefScript.cpp @@ -107,6 +107,7 @@ void DefScriptPackage::_InitFunctions(void) AddFunc("lclean",&DefScriptPackage::func_lclean); AddFunc("lmclean",&DefScriptPackage::func_lmclean); AddFunc("lerase",&DefScriptPackage::func_lerase); + AddFunc("lsort",&DefScriptPackage::func_lsort); } void DefScriptPackage::AddFunc(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set)) @@ -895,7 +896,6 @@ std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string s global = true; while(true) { - if(vn.at(0)=='#') global = true; if(vn.at(0)=='#' || vn.at(0)==':') @@ -903,6 +903,7 @@ std::string DefScriptPackage::_NormalizeVarName(std::string vn_in, std::string s else break; } + if( (!global) && (vn.at(0)!='@') ) vn=sn+"::"+vn; diff --git a/src/Client/DefScript/DefScript.h b/src/Client/DefScript/DefScript.h index 1b03621..d59403e 100644 --- a/src/Client/DefScript/DefScript.h +++ b/src/Client/DefScript/DefScript.h @@ -202,6 +202,7 @@ private: DefReturnResult func_lclean(CmdSet&); DefReturnResult func_lmclean(CmdSet&); DefReturnResult func_lerase(CmdSet&); + DefReturnResult func_lsort(CmdSet&); // setup own function declarations here # include "DefScriptInterfaceInclude.h" diff --git a/src/Client/DefScript/DefScriptListFunctions.cpp b/src/Client/DefScript/DefScriptListFunctions.cpp index 72944c3..60394b4 100644 --- a/src/Client/DefScript/DefScriptListFunctions.cpp +++ b/src/Client/DefScript/DefScriptListFunctions.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "DefScript.h" #include "DefScriptTools.h" @@ -254,6 +255,16 @@ DefReturnResult DefScriptPackage::func_lerase(CmdSet& Set) return r; } +DefReturnResult DefScriptPackage::func_lsort(CmdSet& Set) +{ + DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname)); + if(!l) + return false; + sort(l->begin(),l->end()); + return true; +} + + diff --git a/src/shared/tools.cpp b/src/shared/tools.cpp index 018e674..42af2f9 100644 --- a/src/shared/tools.cpp +++ b/src/shared/tools.cpp @@ -139,7 +139,6 @@ std::deque GetFileList(std::string path) while(files.size() && (files.front()=="." || files.front()=="..")) files.pop_front(); - return files; }