patchimage/script.d/mkwii/mkwiimm_items.sh
Christopher Roy Bratusek ea0e6c921d for NSMBW character mods, Mario Kart Wii font, item and kart mods,
don't download the files from the interwebs, instead use files supplied
  and installed with patchimage
2016-08-04 20:42:52 +02:00

152 lines
3.5 KiB
Bash

#!/bin/bash
GAME_TYPE="MKWIIMM"
GAME_NAME="Mario Kart Wiimm"
CSZS="files/Race/Common.szs"
CSZD="files/Race/Common.d"
show_notes () {
echo -e \
"************************************************
${GAME_NAME}
Custom Mario Kart Wii
Source: http://wiiki.wii-homebrew.com/Wiimms_Mario_Kart_Fun
Base Image: Mario Kart Wii (RMC?01)
Supported Versions: EUR, JAP, USA
************************************************"
}
check_input_image_special () {
check_input_image_mkwiimm
ask_input_image_mkwiimm ${IMAGE%/*}
echo -e "type RMC???.wbfs:\n"
read ID
if [[ ! -f ${IMAGE%/*}/${ID} ]]; then
echo "wrong id from user-input given."
exit 1
fi
}
items=( "ballon.brres:Balloon (Battle Object)"
"big_kinoko.brres:Mega Mushroom (Item)"
"bomb.brres:Bob-omb (Item)"
"gesso.brres:Blooper (Item)"
"kart_killer.brres:Bullet Bill (In Use)"
"item_killer.brres:Bullet Bill (Item, when dropped)"
"jugem_reverse.brres:Lakitus Wrong Way Sign"
"jugemu.brres:Lakitu"
"jugemu_signal.brres:Lakitus Countdown Lights"
"kinoko.brres:Super Mushroom (Item) "
"koura_green.brres:Green Shell (Item)"
"koura_red.brres:Red Shell (Item)"
"kumo.brres:Thundercloud (Item)"
"kinoko_p.brres:Golden Mushroom (Item, when dropped)"
"pow_bloc.brres:Pow Block (Item, when dropped)"
"pow_bloc_plane.brres:Pow Block (Item, in use) "
"thunder.brres:Lightning (Item, When dropped)"
"togezo_koura.brres:Spiny Shell (Item)" )
ask_items () {
if [[ -f ${HOME}/.patchimage.choice ]]; then
echo "Your choices from last time can be re-used."
echo "y (yes) or n (no)"
read choice
if [[ ${choice} == y ]]; then
source ${HOME}/.patchimage.choice
fi
fi
if [[ ${choosenitems[@]} == "" ]]; then
for item in "${items[@]}"; do
slot=${item/:*}
desc=${item/*:}
echo -e "\n\nChoose item for ${desc}
orig Original item"
gawk -F \: "/${slot}/"'{print $1 "\t" $3}' < ${PATCHIMAGE_DATABASE_DIR}/mkwiimm_items.db
echo -e "\ntype orig or ???.brres"
read slotid
echo "<<<<<<>>>>>>"
choosenitems=( ${choosenitems[@]} ${slot}:${slotid} )
done
echo ${choosenitems[@]}
echo "choosenitems=( ${choosenitems[@]} )" > ${HOME}/.patchimage.choice
fi
}
download_items () {
for item in ${choosenitems[@]}; do
id=${item/*:}
if [[ ! -f ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${id} ]]; then
echo "unknown Item ${item}"
exit 75
fi
done
}
download_wiimm () {
ask_items
download_items
}
build_mkwiimm () {
rm -rf workdir
echo "*** 5) extracting image"
${WIT} extract ${IMAGE%/*}/${ID} workdir -q || exit 51
if [[ ! -f "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} ]]; then
echo "*** 6) this is the first run, so backing up common.szs
(in ${PATCHIMAGE_RIIVOLUTION_DIR}) for future customizations"
cp workdir/${CSZS} "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*}
else
echo "*** 6) restoring original common.szs"
cp "${PATCHIMAGE_RIIVOLUTION_DIR}"/Common.szs_${ID/.*} workdir/${CSZS}
fi
echo "*** 7) replacing items"
rm -rf workdir/${CSZD}
${SZS} extract workdir/${CSZS} -q || \
( echo "szs caught an erro extracting common.szs" && exit 51 )
for item in ${choosenitems[@]}; do
slot=${item/:*}
newi=${item/*:}
cp ${PATCHIMAGE_DATA_DIR}/mkwiimm_items/${newi} \
workdir/${CSZD}/${slot}
done
${SZS} create -o workdir/${CSZD} -q || \
( echo "szs caught an error rebuilding common.szs" && exit 51 )
rm -rf workdir/${CSZD}
echo "*** 8) rebuilding game"
echo " (storing game in ${PATCHIMAGE_GAME_DIR}/${ID})"
${WIT} cp -o -q -B workdir ${PATCHIMAGE_GAME_DIR}/${ID} || exit 51
rm -rf workdir
}
patch_wiimm () {
build_mkwiimm
}