crossfire

Play with your Puppy.
Post Reply
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

crossfire

#1 Post by Karl Godt »

Homepage : http://crossfire.real-time.com/server/linux/index.html

1) crossfire-client :

1.0)
crossfire-client-gtk2

Compiled on Macpup-529 with the current devx_precise_5.2.60.sfs .

Small binary with 12 glade configuration files that take up most of the space .
Glade is gtk-2 syntax .

./configure --disable-sound because a) the server does not send sound tags to the client ; b) claims the whole soundsystem .

SDL was not installed at compile time and seems not to do anything if enabled . GL is also not compiled into it .

Will attach other configurations too and other Puppy versions .

*

2) crossfire-server :

Somewhere they have added a root exit to the source . Will have to figure out things. Older crossfire-server without root check run also .


************************************************************************************

So here first the client :
Description :
Lauching from the menu should give a main GUI and a Box to select the internet server . Just follow the instructions . Difficult to explain somehow for me . Encountered the game back at Debian Sarge times and had forgotten about it's name .

The gtk1 GUI is not bad either . Gtk1 was missing today . Will attach a X11 and a GTK-1 client also .
There is also a JAVA-XCLIENT that troubled me in JWM-492 much . In e17 this jxclient was somewhat OK for me .
Attachments
crossfire-client-dungeon.jpg
(43.71 KiB) Downloaded 1239 times

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

crossfire client scripting

#2 Post by Karl Godt »

This is nothing that is of interest to Puppy in general .

Scripting for the client is found here : http://wiki.metalforge.net/doku.php/cli ... asic_howto

http://wiki.metalforge.net/doku.php/cli ... ripts:bash
has no examples until now .

I wanted to post it to http://forum.metalforge.net , but that is down since a few days ( White Page ) ,
to have some scripts in the cloud to work on further if time and will are permitting.
So I post it here on the murga forum .

This is the most sophisticated script until now .
It creates Balm of First Aid .
It does a lot of failsafe/security checking .
It checks if on cauldron, cauldron empty, place to move, fails in executing commads.
Therfore its pretty huge ( 500 lines ) . Without these checks it would be less then 100 lines.

Code: Select all

#!/bin/ash

# *** Here begins program *** #
echo draw 2 "$0 is started.."

# *** PARAMETERS *** #

DIRB=west  # direction back to go

case $DIRB in
west)  DIRF=east;;
east)  DIRF=west;;
north) DIRF=south;;
south) DIRF=north;;
esac


# *** Check for parameters *** #
echo drawnifo 5 "Checking the parameters ($*)..."

[ "$*" ] && {
PARAM_1="$1"

# *** implementing 'help' option *** #
test "$PARAM_1" = "help" && {

echo draw 5 "Script to produce water of the wise."
echo draw 7 "Syntax:"
echo draw 7 "$0 NUMBER"
echo draw 5 "Allowed NUMBER will loop for"
echo draw 5 "NUMBER times to produce NUMBER of"
echo draw 5 "Balm of First Aid ."

        exit 0
        }

PARAM_1test="${PARAM_1//[[:digit:]]/}"
test "$PARAM_1test" && {
echo draw 3 "Only :digit: numbers as option allowed."
        exit 1 #exit if other input than numbers
        }

NUMBER=$PARAM_1

} || {
echo draw 3 "Script needs number of alchemy attempts as argument."
        exit 1
}

test "$1" || {
echo draw 3 "Need <number> ie: script $0 4 ."
        exit 1
}

echo drawinfo 7 "OK."
# *** Check if standing on a cauldron *** #

echo drawinfo 5 "Checking if on a cauldron..."

UNDER_ME='';
echo request items on

while [ 1 ]; do
read -t 1 UNDER_ME
#echo "$UNDER_ME" >>/tmp/cf_script.ion
UNDER_ME_LIST="$UNDER_ME
$UNDER_ME_LIST"
test "$UNDER_ME" = "request items on end" && break
test "$UNDER_ME" = "scripttell break" && break
test "$UNDER_ME" = "scripttell exit" && exit 1
sleep 0.1s
done

test "`echo "$UNDER_ME_LIST" | grep 'cauldron$'`" || {
echo draw 3 "Need to stand upon cauldron!"
exit 1
}

echo drawinfo 7 "OK."

# *** EXIT FUNCTIONS *** #
f_exit(){
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"
sleep ${SLEEP}s
echo draw 3 "Exiting $0."
#echo unmonitor
#echo unwatch monitor
#echo unwatch monitor issue
echo unwatch
echo unwatch drawinfo
exit $1
}

f_emergency_exit(){
echo "issue 1 1 apply rod of word of recall"
echo "issue 1 1 fire center"
echo draw 3 "Emergency Exit $0 !"
echo unwatch drawinfo
echo "issue 1 1 fire_stop"
exit $1
}

f_exit_no_space(){
echo draw 3 "On position $nr $DIRB there is Something ($IS_WALL)!"
echo draw 3 "Remove that Item and try again."
echo draw 3 "If this is a Wall, try another place."
exit $1
}

rm -f /tmp/cf_script.rpl   # empty old log file

# *** Check for 4 empty space to DIRB ***#

echo drawinfo 5 "Checking for space to move..."

echo request map pos

echo watch request

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

echo unwatch request


PL_POS_X=`echo "$REPLY" | awk '{print $4}'`
PL_POS_Y=`echo "$REPLY" | awk '{print $5}'`

if test "$PL_POS_X" -a "$PL_POS_Y"; then

if test ! "${PL_POS_X//[[:digit:]]/}" -a ! "${PL_POS_Y//[[:digit:]]/}"; then

for nr in `seq 1 1 4`; do

case $DIRB in
west)
R_X=$((PL_POS_X-nr))
R_Y=$PL_POS_Y
;;
east)
R_X=$((PL_POS_X+nr))
R_Y=$PL_POS_Y
;;
north)
R_X=$PL_POS_X
R_Y=$((PL_POS_Y-nr))
;;
south)
R_X=$PL_POS_X
R_Y=$((PL_POS_Y+nr))
;;
esac

echo request map $R_X $R_Y

echo watch request

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl

IS_WALL=`echo "$REPLY" | awk '{print $16}'`
echo "$IS_WALL" >>/tmp/cf_script.rpl
test "$IS_WALL" = 0 || f_exit_no_space 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

echo unwatch request

done

else

echo drawinfo 3 "Received Incorrect X Y parameters from server"
exit 1

fi

else

echo drawinfo 3 "Could not get X and Y position of player."
exit 1

fi

echo drawinfo 7 "OK."


# *** Monitoring function *** #
# *** Todo ...            *** #
f_monitor_malfunction(){

while [ 1 ]; do
read -t 1 ERRORMSGS

sleep 0.1s
done
}



# *** Actual script to alch the desired balm of first aid *** #
test $NUMBER -ge 1 || NUMBER=1 #paranoid precaution

# *** Lets loop - hope you have the needed amount of ingredients    *** #
# *** in the inventory of the character and unlocked !              *** #
# *** Make sure similar items are not in the inventory --           *** #
# *** eg. staff of summon water elemental and such ...              *** #
# *** So do a 'drop water' and                                      *** #
# *** drop mandrake root   before beginning to alch.                *** #

# *** Then if some items are locked, unlock these and drop again.   *** #
# *** Now get the number of desired water and mandrake root --      *** #
# *** only one inventory line with water(s) and                     *** #
# *** mandrake root are allowed !!                                  *** #

# *** Now get the number of desired water of the wise and           *** #
# *** same times the number of mandrake root .                      *** #

# *** Now walk onto the cauldron and make sure there are 4 tiles    *** #
# *** west of the cauldron.                                         *** #
# *** Do not open the cauldron - this script does it.               *** #
# *** HAPPY ALCHING !!!                                             *** #

echo "issue 0 1 pickup 0"  # precaution otherwise might pick up cauldron


# *** Readying rod of word of recall - just in case *** #

echo drawinfo 5 "Preparing for recall if monsters come forth..."

RECALL=0
OLD_REPLY="";
REPLY="";

echo request items actv

echo watch request

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep '.* rod of word of recall'`" && RECALL=1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

if test "$RECALL" = 1; then # unapply it now , f_emergency_exit applies again
echo "issue 1 1 apply rod of word of recall"
fi

echo unwatch request

echo drawinfo 6 "Done."


# *** Check if cauldron is empty *** #

echo drawinfo 5 "Checking for empty cauldron..."

echo "issue 1 1 apply"


OLD_REPLY="";
REPLY_ALL='';
REPLY="";

echo "issue 1 1 get"

echo watch drawinfo

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
REPLY_ALL="$REPLY
$REPLY_ALL"
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

test "`echo "$REPLY_ALL" | grep '.*Nothing to take!'`" || {
echo drawinfo 3 "Cauldron NOT empty !!"
echo drawinfo 3 "Please empty the cauldron and try again."
f_exit 1
}

echo unwatch drawinfo

echo drawinfo 7 "OK ! Cauldron IS empty."

echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"


# *** Getting Player's Speed *** #

echo drawinfo 5 "Processing Player's speed..."

SLEEP=3           # setting defaults
DELAY_DRAWINFO=6

ANSWER=
OLD_ANSWER=

echo request stat cmbt

echo watch request

while [ 1 ]; do
read -t 1 ANSWER
echo "$ANSWER" >>/tmp/cf_request.log
test "$ANSWER" || break
test "$ANSWER" = "$OLD_ANSWER" && break
OLD_ANSWER="$ANSWER"
sleep 0.1
done

echo unwatch request

#PL_SPEED=`awk '{print $7}' <<<"$ANSWER"`    # *** bash
PL_SPEED=`echo "$ANSWER" | awk '{print $7}'` # *** ash + bash
PL_SPEED="0.${PL_SPEED:0:2}"

echo drawinfo 7 "Player speed is $PL_SPEED"

PL_SPEED="${PL_SPEED:2:2}"
echo drawinfo 7 "Player speed is $PL_SPEED"

if test $PL_SPEED -gt 35; then
SLEEP=1; DELAY_DRAWINFO=2
elif test $PL_SPEED -gt 25; then
SLEEP=2; DELAY_DRAWINFO=4
fi

echo drawinfo 6 "Done."


# *** Now LOOPING *** #

for one in `seq 1 1 $NUMBER`
do

echo "issue 1 1 apply"

echo watch drawinfo

echo "issue 1 1 drop 1 water of the wise"

OLD_REPLY="";
REPLY="";

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep '.*Nothing to drop\.'`" && f_exit 1
test "`echo "$REPLY" | grep '.*There are only.*'`"  && f_exit 1
test "`echo "$REPLY" | grep '.*There is only.*'`"   && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

sleep ${SLEEP}s

echo "issue 1 1 drop 1 mandrake root"

OLD_REPLY="";
REPLY="";

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep '.*Nothing to drop\.'`" && f_exit 1
test "`echo "$REPLY" | grep '.*There are only.*'`"  && f_exit 1
test "`echo "$REPLY" | grep '.*There is only.*'`"   && f_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

echo unwatch drawinfo

sleep ${SLEEP}s

echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"
sleep ${SLEEP}s

echo watch drawinfo

echo "issue 1 1 use_skill alchemy"

OLD_REPLY="";
REPLY="";

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep '.*pours forth monsters\!'`" && f_emergency_exit 1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

echo unwatch drawinfo

echo "issue 1 1 apply"

echo watch drawinfo

echo "issue 1 1 get"

OLD_REPLY="";
REPLY="";
NOTHING=0
SLAG=0

while [ 1 ]; do
read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_script.rpl
test "`echo "$REPLY" | grep '.*Nothing to take\!'`" && NOTHING=1
test "`echo "$REPLY" | grep '.*You pick up the slag\.'`" && SLAG=1
test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"
sleep 0.1s
done

echo unwatch drawinfo


sleep ${SLEEP}s

echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
echo "issue 1 1 $DIRB"
sleep ${SLEEP}s

if test $NOTHING = 0; then
        if test $SLAG = 0; then
        echo "issue 1 1 use_skill sense curse"
        echo "issue 1 1 use_skill sense magic"
        echo "issue 1 1 use_skill alchemy"
        sleep ${SLEEP}s

        echo "issue 0 1 drop balm"
        else
        echo "issue 0 1 drop slag"
        fi
fi

sleep ${DELAY_DRAWINFO}s

echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"
echo "issue 1 1 $DIRF"
sleep ${SLEEP}s

UNDER_ME='';
UNDER_ME_LIST='';

echo request items on

while [ 1 ]; do
read -t 1 UNDER_ME
#echo "$UNDER_ME" >>/tmp/cf_script.ion
UNDER_ME_LIST="$UNDER_ME
$UNDER_ME_LIST"
test "$UNDER_ME" = "request items on end" && break
test "$UNDER_ME" = "scripttell break" && break
test "$UNDER_ME" = "scripttell exit" && exit 1
sleep 0.1s
done

test "`echo "$UNDER_ME_LIST" | grep 'cauldron$'`" || f_exit 1

TRIES_SILL=$((NUMBER-one))
echo drawinfo 4 "Still $TRIES_SILL to go..."


done

# *** Here ends program *** #
echo draw 2 "$0 is finished."
EDIT 1:: The time now is Sun 13 Apr 2014, 22:53 All times are UTC + 2 (DST in action) :
TYPO in SLEEP processing: Was test $SLEEP, should have been test $PL_SPEED;
also changed default SLEEP from 2/4 to 3/6 and added an elif $PL_SPEED -gt 25;
added a missing 'echo watch request' there too.

Edit 2: The time now is Mon 14 Apr 2014, 15:09
TYPO in SLEEP processing: Was SPEED= - should have been SLEEP= ... :oops:
and in 'if test' 'test' was missing :oops2:
Last edited by Karl Godt on Mon 14 Apr 2014, 13:15, edited 2 times in total.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

crossfire client script about praying

#3 Post by Karl Godt »

When praying it can be boring to hit a key several dozen times to pray up the grace points.

So a short script comes handy :

Code: Select all

#!/bin/ash

# *** Here begins program *** #
echo draw 2 "$0 is started.."

# *** Check for parameters *** #
[ "$*" ] && {
PARAM_1="$1"

# *** implementing 'help' option *** #
test "$PARAM_1" = "help" && {

echo draw 5 "Script to pray given number times."
echo draw 5 "Syntax:"
echo draw 5 "script $0 <number>"
echo draw 5 "For example: 'script $0 50'"
echo draw 5 "will issue 50 times the use_skill praying command."

        exit 0
        }

# *** testing parameters for validity *** #
PARAM_1test="${PARAM_1//[[:digit:]]/}"
test "$PARAM_1test" && {
echo draw 3 "Only :digit: numbers as first option allowed."
        exit 1 #exit if other input than letters
        }

NUMBER=$PARAM_1

} || {
echo draw 3 "Script needs number of praying attempts as argument."
        exit 1
}

test "$1" || {
echo draw 3 "Need <number> ie: script $0 50 ."
        exit 1
}


# *** Actual script to pray multiple times *** #
test $NUMBER -ge 1 || NUMBER=1 #paranoid precaution

for one in `seq 1 1 $NUMBER`
do

echo "issue 1 1 use_skill praying"
sleep 1s

done

# *** Here ends program *** #
echo draw 2 "$0 is finished."

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

crossfire script to kill unwanted pet monsters

#4 Post by Karl Godt »

When cast ing 'charm monsters' or 'summon cult monsters' one might - dependent
on the casting level - get a huge amount of monsters as helping pets of all sorts and kinds.

To reduce the output in the message window, one may want to kill low level pets and keep others.
the 'killpets' command without parameters kills all pets .
killpets accepts a number or a pet name and would kill then the monster with that number or all monsters with that pet name .

So here is one that accepts pet names to keep .
Spaces need to be '_' underscored at the command line of the client . They should get converted back to space - except for killer_bee .
So it is
script $HOME/cf/s/k water_para-elemental
for example - not script $HOME/cf/s/k water para-elemental !
Somehow could not get space passed from the cli of the client to the script .

It has some commented awk lines while experimenting with parameters .
Ended up using bash <<<"LIST" , which does not work in ash.

Code: Select all

#!/bin/bash

# *** Here begins program *** #
echo draw 2 "$0 is started.."
echo draw 3 "with '$*' as arguments ."

# *** Check for parameters *** #
#[ "$*" ] && {
if test "$*"; then
PARAM_1="$1"

# *** implementing 'help' option *** #
test "$PARAM_1" = "help" && {

echo draw 5 "Script to kill pets except the ones"
echo draw 5 "given on parameter line."
echo draw 2 "Syntax:"
echo draw 5 "$0 pet1 pet2 .."
echo draw 2 ":space: ( ) needs to be replaced by underscore (_)"
echo draw 5 "for ex. green slime to green_slime ."
        exit 0
        }

#} || {
else
echo draw 3 "Script needs pets to keep as argument."
        exit 1
#}
fi

test "$1" || {
echo draw 3 "Need <pet_name> ie: script $0 nazgul spectre ."
        exit 1
}


keepPETS="`echo "$*" | sed 's/killer_bee/killer-bee/'`"
keepPETS="`echo "$keepPETS" | tr ' ' '|'`"
keepPETS="`echo "$keepPETS" | tr '_' ' '`"
keepPETS="`echo "$keepPETS" | sed 's/killer-bee/killer_bee/'`"

PETS_KEEP=`echo "$keepPETS" | sed 's/^|*//;s/|*$//'`
echo "PETS_KEEP='$PETS_KEEP'" >>/tmp/cf_pets.rpl

# *** Actual script to kill unwanted pets *** #

OLD_REPLY="";
REPLY="";

echo watch drawinfo
echo "issue 1 1 showpets"

while [ 1 ]; do

read -t 1 REPLY
echo "$REPLY" >>/tmp/cf_pets.rpl

PETS_HAVE="$REPLY
$PETS_HAVE"

test "$REPLY" || break
test "$REPLY" = "$OLD_REPLY" && break
OLD_REPLY="$REPLY"

sleep 0.1s
done

echo unwatch drawinfo

PETS_KILL=`echo "$PETS_HAVE" | grep -v -E "$PETS_KEEP"`
echo "PETS_KILL='$PETS_KILL'" >>/tmp/cf_pets.rpl


# *** example output :watch drawinfo 0 1  vampire - level 11

# *!* #PETS_KILL=`echo "$PETS_KILL" | awk '{print $5}' | sed '/^$/d'` # works not for "green slime"

# *?* #PETS_KILL=`echo "$PETS_KILL" | awk '{print $5" "$6" "$7}' | sed 's/ - .*$//' | sed '/^$/d'`

# *** #PETS_KILL=`echo "$PETS_KILL" | awk '{for(i=n;i<=NF;i++)$(i-(n-1))=$i;NF=NF-(n-1);print $0}' n=5 | sed 's/ - .*$//' | sed '/^$/d'`
# *** #PETS_KILL=`echo "$PETS_KILL" | awk '{$1=$2=$3=$4=""; print $0}'| sed 's/^ *//' | sed 's/ - .*$//' | sed '/^$/d'`
# *** #PETS_KILL=`echo "$PETS_KILL" | awk '{for(i=5;i<=NF;i++){printf "%s ", $i}; printf "\n"}'| sed 's/ - .*$//' | sed '/^$/d'`

#http://stackoverflow.com/questions/2961635/using-awk-to-print-all-columns-from-the-nth-to-the-last

#awk '{out=""; for(i=2;i<=NF;i++){out=$out" "$i}; print $out}'
#awk '{out=$2; for(i=3;i<=NF;i++){out=out" "$i}; print out}'


# *** Using cut with bash buildin <<< *** #
#PETS_KILL=`cut -f5- -d' '       <<<"$PETS_KILL"`
#PETS_KILL=`sed 's/ - level.*//' <<<"$PETS_KILL"`
#PETS_KILL=`sed '/^$/d'          <<<"$PETS_KILL"`
# *** Using cut with bash buildin <<< *** #

# *** Using while read with bash buildin <<< *** #
PETS_KILL=`while read a b c d PETNAME_REST; do echo "$PETNAME_REST";done<<<"$PETS_KILL"`
PETS_KILL=`sed 's/ - level.*//' <<<"$PETS_KILL"`
PETS_KILL=`sed '/^$/d'          <<<"$PETS_KILL"`
# *** Using while read with bash buildin <<< *** #

PETS_KILL=`echo "$PETS_KILL" | sort -u`
echo "$PETS_KILL" >>/tmp/cf_pets.rpl

while read onePET
do

echo draw 3 "Killing $onePET .."
echo "issue 1 1 killpets $onePET"
sleep 1s

done<<EoI
`echo "$PETS_KILL"`
EoI




# *** Here ends program *** #
echo draw 2 "$0 is finished."

Post Reply