feat: Core notification system for game events.

- Basic hook scaffolding
- Double XP notification
- Global quest announcements
- Tracks global quest joined
- Global quest started if joined
- Quest ready
- Quest timing out
- Daily blessing ready
- Tell received

Resolves: https://todo.sr.ht/~fierre/termighty/2
Fixes: https://todo.sr.ht/~fierre/termighty/5
Note: https://todo.sr.ht/~fierre/termighty/11 (Quest state not totally tracked)
master
Fierre 4 years ago
parent 2b78192852
commit 5b21c586fb

@ -1,6 +1,9 @@
double.ogg: https://notificationsounds.com/notification-sounds/maybe-one-day-584
tell.ogg: https://notificationsounds.com/message-tones/stairs-567
quest.ogg: https://notificationsounds.com/wake-up-tones/solemn-522
questtime.ogg: https://notificationsounds.com/sound-effects/munchausen-433
globalquest.ogg: https://notificationsounds.com/wake-up-tones/engaged-306
globalqueststart: https://notificationsounds.com/wake-up-tones/insistently-85
Used and distributed under the Creative Commons Attribution License
https://creativecommons.org/licenses/by/4.0/legalcode

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,16 @@
#!/usr/bin/env bash
NOTIFY_LENGTH=5000 #milliseconds
AUDIO="audio/dailyblessing.ogg"
# Send via libnotify if available
if [ -x `which notify-send` ]
then
notify-send "Daily Blessing" "Your daily blessing is ready." --icon=weather-clear --expire-time=$NOTIFY_LENGTH
fi
# Play a sound if available
if [ -x `which ogg123` ]
then
ogg123 -q $AUDIO &
fi

@ -0,0 +1,17 @@
#!/usr/bin/env bash
QUESTID=$1
NOTIFY_LENGTH=5000 #milliseconds
AUDIO="audio/globalquest.ogg"
# Send via libnotify if available
if [ -x `which notify-send` ]
then
notify-send "Global Quest" "Global quest #${QUESTID} starting soon." --icon=applications-games --expire-time=$NOTIFY_LENGTH
fi
# Play a sound if available
if [ -x `which ogg123` ]
then
ogg123 -q $AUDIO &
fi

@ -0,0 +1,17 @@
#!/usr/bin/env bash
QUESTID=$1
NOTIFY_LENGTH=5000 #milliseconds
AUDIO="audio/globalqueststart.ogg"
# Send via libnotify if available
if [ -x `which notify-send` ]
then
notify-send "Global Quest Started!" "Your global quest #${QUESTID} has started." --icon=go-jump --expire-time=$NOTIFY_LENGTH
fi
# Play a sound if available
if [ -x `which ogg123` ]
then
ogg123 -q $AUDIO &
fi

@ -0,0 +1,17 @@
#!/usr/bin/env bash
DURATION=$1
NOTIFY_LENGTH=5000 #milliseconds
AUDIO="audio/questtime.ogg"
# Send via libnotify if available
if [ -x `which notify-send` ]
then
notify-send "Quest Timing Out!" "You are almost out of time on your quest!" --icon=dialog-warning --expire-time=$NOTIFY_LENGTH
fi
# Play a sound if available
if [ -x `which ogg123` ]
then
ogg123 -q $AUDIO &
fi

@ -0,0 +1,17 @@
#!/usr/bin/env bash
SENDER=$1
NOTIFY_LENGTH=5000 #milliseconds
AUDIO="audio/tell.ogg"
# Send via libnotify if available
if [ -x `which notify-send` ]
then
notify-send "Tell" "Tell received from ${SENDER}." --icon=mail-message-new --expire-time=$NOTIFY_LENGTH
fi
# Play a sound if available
if [ -x `which ogg123` ]
then
ogg123 -q $AUDIO &
fi

@ -1,6 +1,8 @@
#read {modules/gmcp/util.tin};
#variable {doubleXP} {off};
#variable {gqId} {none};
#variable {dailyBlessing} {cooldown};
#NOP ****f* modules.action/Action MAPSTART
#NOP NAME
@ -89,3 +91,115 @@
#action {^Double exp is running} {
#gag {Double exp is running};
};
#NOP ****f* modules.action/Action Global quest declared
#NOP NAME
#NOP Action Global quest declared
#NOP SYNOPSIS
#NOP Process the announced global quest, and notify if it is in range.
#NOP -
#action {^Global Quest: Global quest # %d has been declared for levels %d to %d} {
#local {low} {%2};
#local {high} {%3};
#local {level} {$character[status][level]};
#if {$level >= $low && $level <= $high} {
#local {result} @notifyGlobalQuest{%1};
};
};
#NOP ****f* modules.action/Action Global quest started
#NOP NAME
#NOP Action Global quest started
#NOP SYNOPSIS
#NOP If the character has joined the global quest, notify its start.
#NOP -
#action {^Global Quest: Global quest # %d for levels %d to %d} {
#if {"$gqId" == "%1"} {
#local {result} @notifyGlobalQuestStart{%1};
};
};
#NOP ****f* modules.action/Action You have now joined Global Quest ...
#NOP NAME
#NOP Action You have now joined Global Quest ... (globalquest join)
#NOP SYNOPSIS
#NOP Process the character joining an announced global quest for announcements.
#NOP - ;
#action {^You have now joined Global Quest # %d.} {
#variable {gqId} {%1};
};
#NOP ****f* modules.action/Action Global quest won
#NOP NAME
#NOP Action Global quest won
#NOP SYNOPSIS
#NOP Clear the global quest variable when the global quest is over
#NOP -
#action {^Global Quest: Global Quest # %d has been won} {
#if {$gqId == %1} {
#variable {gqId} {none};
};
};
#NOP ****f* modules.action/Action Daily blessing ready
#NOP NAME
#NOP Action Daily blessing ready
#NOP SYNOPSIS
#NOP Notify the character that a daily blessing is available.
#NOP -
#action {^You are ready to receive a new daily blessing.} {
#variable {dailyBlessing} {ready};
#local {result} @notifyDailyBlessing{};
};
#NOP ****f* modules.action/Action BLESSING: Your daily blessing is available.
#NOP NAME
#NOP Action Daily blessing ready (login banner)
#NOP SYNOPSIS
#NOP Notify the character that a daily blessing is available (login banner).
#NOP -
#action {^BLESSING: Your daily blessing is available.} {
#variable {dailyBlessing} {ready};
#local {result} @notifyDailyBlessing{};
}
#NOP ****f* modules.action/Action Daily blessing cooldown
#NOP NAME
#NOP Action Daily blessing cooldown
#NOP SYNOPSIS
#NOP Set the daily blessing variable to cooldown
#NOP -
#action {^You can receive a new daily blessing in} {
#variable {dailyBlessing} {cooldown};
};
#NOP ****f* modules.action/Action QUEST: You may now quest again.
#NOP NAME
#NOP Action QUEST: You may now quest again.
#NOP SYNOPSIS
#NOP Trigger an immediate refresh of GMCP quest state to be processed.
#NOP SEE ALSO
#NOP modules.gcmp.messaging/Event IAC SB GMCP comm.quest
#NOP -
#action {^QUEST: You may now quest again.} {
#local {result} @sendGMCP{request quest};
};
#NOP ****f* modules.action/Action QUEST: Better hurry
#NOP NAME
#NOP Action QUEST: Better hurry
#NOP SYNOPSIS
#NOP Notify the player that quest time is running out.
#NOP -
#action {^QUEST: Better hurry} {
#local {result} @notifyQuestTime{};
}

@ -11,6 +11,16 @@
#NOP Pull out the GMCP message;
#variable {message[comm][channel]} {%0};
#NOP Pull out the sender;
#local {sender} {$message[comm][channel][player]};
#NOP If it's a tell not from me, run the tell notification hook;
#if {"$message[comm][channel][chan]" == "tell"} {
#if {"$sender" != "$character[base][name]"} {
#local {result} @notifyTellReceived{$sender};
};
};
#NOP Timestmaps are a special #format call - {variable} {%t} {strftime format};
#format {cTime} {%t} {$tsFormat};
@ -36,8 +46,12 @@
#NOP -
#event {IAC SB GMCP comm.quest IAC SE} {
#local {oldStatus} {$quest[status]};
#variable {quest} {%0};
#if {$quest[status] == ready} {
#local {result} @notifyQuest{};
#NOP Only send notification the first time;
#if {"$quest[status]" == "ready"} {
#if {$oldStatus != $quest[status]} {
#local {result} @notifyQuest{};
};
};
};

@ -3,11 +3,14 @@
#NOP notifyDouble -- hook point for any notifications of double XP.
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyDouble.sh script hook.
#NOP ARGUMENTS
#NOP %1 - The minutes of double XP remaining
#NOP -
#function {notifyDouble} {
#bell;
#script {result} {hooks/notifyDouble.sh %1};
#system {hooks/notifyDouble.sh %1 > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyQuest
@ -19,6 +22,77 @@
#function {notifyQuest} {
#bell;
#script {result} {hooks/notifyQuest.sh};
#system {hooks/notifyQuest.sh > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyQuestTime
#NOP NAME
#NOP notifyQuestTime -- hook point for notifications for running out of quest time
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyQuestTime.sh script hook.
#NOP -
#function {notifyQuestTime} {
#bell;
#system {hooks/notifyQuestTime.sh > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyGlobalQuest
#NOP NAME
#NOP notifyGlobalQuest -- hook point for notifications for global quest announcements
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyGlobalQuest.sh script hook.
#NOP ARGUMENTS
#NOP %1 - The ID of the announced global quest
#NOP -
#function {notifyGlobalQuest} {
#bell;
#system {hooks/notifyGlobalQuest.sh %1 > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyGlobalQuestStart
#NOP NAME
#NOP notifyGlobalQuestStart -- hook point for any notifications for GQ start
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyGlobalQuestStat.sh script hook.
#NOP ARGUMENTS
#NOP %1 - The ID of the global quest that is starting
#NOP -
#function {notifyGlobalQuestStart} {
#bell;
#system {hooks/notifyGlobalQuestStart.sh %1 > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyDailyBlessing
#NOP NAME
#NOP notifyDailyBlessing -- hook point for any notifications for daily blessing
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyDailyBlessing.sh script hook.
#NOP -
#function {notifyDailyBlessing} {
#bell;
#system {hooks/notifyDailyBlessing.sh > /dev/null 2>&1};
#return {0};
};
#NOP ****f* modules.notifications/Function notifyTellReceived
#NOP NAME
#NOP notifyTellReceived -- hook point for notifications for tells
#NOP SYNOPSIS
#NOP Trigger the terminal bell, and run the notifyTellReceived.sh script hook.
#NOP ARGUMENTS
#NOP %1 - The player who sent the tell
#NOP -
#function {notifyTellReceived} {
#bell;
#system {hooks/notifyTellReceived.sh %1 > /dev/null 2>&1};
#return {0};
};

@ -32,27 +32,30 @@
#NOP -
#ticker {updateInfo} {
#variable {questLine} {No data.};
#NOP Get quest state;
#if {$quest[action] == status && $quest[wait]} {
#format {questLine} {<099><188><g12>QUEST:<088> %s min<099>} {$quest[wait]};
};
#if {$quest[status] == ready} {
#if {"$quest[status]" == "ready"} {
#format {questLine} {<099><168>QUEST: Ready<099>}
};
#if {$quest[action] == status && $quest[timer]} {
#local {remaining} {$quest[timer]};
#if {$remaining < 15} {
#format {questLine} {<099><118>QUEST: %d min<099>} {$remaining};
}
{
#format {questLine} {<099><128>QUEST:<028> %d min<099>} {$remaining};
}
#if {"$quest[action]" == "status"} {
#if {$quest[wait]} {
#format {questLine} {<099><188><g12>QUEST:<088> %+2s min<099>} {$quest[wait]};
};
#if {$quest[timer]} {
#local {remaining} {$quest[timer]};
#if {$remaining < 15} {
#format {questLine} {<099><118>QUEST: %d min<099>} {$remaining};
}
{
#format {questLine} {<099><128>QUEST:<028> %d min<099>} {$remaining};
};
};
};
#NOP Get double state;
#local {doubleLine} {};
#if {$doubleXP == "off"} {
#local {doubleLine} {<099><188><g12>DOUBLE:<088> Inactive<099>};
#local {doubleLine} {<099><188><g12>DOUBLE:<088> Off<099>};
}
{
#format {doubleLine} {<099><128>DOUBLE:<028> %+2s min<099>} {$doubleXP};
@ -72,7 +75,7 @@
#ticker {updateEnemy} {
#variable {enemyLine} {<099><g08>Not in combat.};
#if {"$character[status][enemy]" != ""} {
#if {$character[status][enemy]} {
#local {formatString} {<099><118>FIGHTING:<018> %s (%d%%)<099>};
#format {enemyLine} {$formatString} {$character[status][enemy]}
{$character[status][enemypct]};

Loading…
Cancel
Save