#!/bin/bash

stdbuf -o 0 tail -f -s .1 Personal* \
| stdbuf -i 0 -o 0 sed "$(xcat ~/servers*/Log/$(date -d "$(ps -C $(basename $(pwd)) -o lstart h)" +%Y%m%d)/$(basename $(pwd))/Persona* $PWD/Persona* 2> /dev/null |grep ",NCID:[0-9]\+:"|awk -F, '{print $3}'|sed 's@\(NCID:[0-9]\+\)\(:.\+\)@s/\1$/\1\2/g@g' |uniq > /tmp/ncid_list

sed -n "$(grep -n "NCID:0[^0-9]" /tmp/ncid_list |tail -1 | awk -F: '{print $1}'),\$p" /tmp/ncid_list )" \
| stdbuf -i 0 highlight - CNE_CZ_ZoneServerMeleeAttack CNE_CZ_ZoneServerMoveSelf CNE_CZ_ZoneServerNowHeight CNE_CZ_ZoneServerTargetUpdate CNE_CZ_ZoneServerSpellCastToLife  CNE_CZ_ZoneServerItemUse "" "" "" CNE_CZ_ZoneServerTalkToNPC CNE_CZ_ZoneServerReplyDialog CNE_CZ_ZoneServerMissionListOp CNE_CZ_ZoneServerSetMissionTrace CNE_CZ_ZoneServerLeaveShop CNE_CZ_ZoneServerCheckNodeExit CNE_CZ_ZoneServerMigrationDone CNE_CZ_ZoneServerSearchTeam  CNE_CZ_ZoneServerEnchantUpdate CNE_CZ_ZoneServerSafeQuitCountDownOver CNE_CZ_ZoneServerUpdateShortcut CNE_CZ_ZoneServerBeginnerTutorialDone CNE_CZ_ZoneServerSpellBreak CNE_CZ_ZoneServerSendPetCmd
