ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/brest/pshops/pshop_copier
Revision: 1.1
Committed: Sun Feb 5 00:02:17 2006 UTC (18 years, 4 months ago) by root
Branch point for: UPSTREAM, MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 root 1.1 #!/bin/bash
2     #
3     # creator: josh@woosworld.net
4     # Simple script to replicate changes made to pshop1
5     # to the rest of the pshops and keep the correct
6     # keys and exits working.
7     #
8     # Obviously this is based on some conventions I have
9     # don't use pshop1 anywhere else in the file etc...
10     #
11    
12     #first rename the pshop1 dir so we don't erase it
13     mv pshop1 PSHOP
14    
15     #then remove all the pshop files
16     rm -f pshop*/*
17    
18     #copy PSHOP to all the pshop directories
19     for FILE in pshop*;do
20     if [ -d "$FILE" ]
21     then
22     #copy the files into the pshops directories
23     cp PSHOP/* "$FILE"/
24    
25     #go there
26     cd $FILE
27    
28     #for each file in the pshop directory
29     for MYFILE in *;do
30     #correct the key values on inventory checkers
31     sed s/pshop1/$FILE/ $MYFILE > "$MYFILE"_2
32     rm -f $MYFILE
33     mv "$MYFILE"_2 $MYFILE
34     done
35    
36     #get the pshopnum
37     PSHOPNUM=`echo "$FILE" | cut -d p -f3`
38    
39     #calculate HP and SP based on pshopnum
40     if [ $PSHOPNUM -lt 14 ]
41     then
42     #top row of shops
43     SP="2"
44     TEMPHP=`expr $PSHOPNUM \* 3`
45     HP=`expr $TEMPHP + 1`
46     else
47     #bottom row of shops
48     SP="6"
49     MODPSHOPNUM=`expr $PSHOPNUM - 14`
50     TEMPHP=`expr $MODPSHOPNUM \* 3`
51     HP=`expr $TEMPHP + 1`
52     fi
53    
54     #fix the exit on gfloor
55     while read LINE
56     do
57     if [ "$LINE" == "slaying ../pshops_main" ]
58     then
59     #remove the 2 lines
60     read dummy_hp_line
61     read dummp_sp_line
62    
63     #add the original back
64     echo "$LINE" >> gfloor2
65    
66     #write the new lines
67     echo "hp $HP" >> gfloor2
68     echo "sp $SP" >> gfloor2
69    
70     else
71     #just add it back to the file
72     echo "$LINE" >> gfloor2
73     fi
74     done < gfloor
75    
76     #replace gfloor with gfloor2
77     rm -f gfloor
78     mv gfloor2 gfloor
79    
80     #go back up
81     cd ..
82     fi
83     done
84    
85     #put pshop1 back
86     mv PSHOP pshop1
87    
88     #bye
89     exit 0