-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from Alando1-doom/Weapon-and-item-announcement
Weapon and item announcement
- Loading branch information
Showing
13 changed files
with
245 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
GameInfo | ||
{ | ||
AddEventHandlers = "Toby_SoundBindingsLoaderStaticHandler" | ||
AddEventHandlers = "Toby_SoundQueueStaticHandler" | ||
AddEventHandlers = "ZS_MarkerHandler" | ||
AddEventHandlers = "Toby_MenuStaticHandler" | ||
AddEventHandlers = "Toby_MapAnnouncementStaticHandler" | ||
AddEventHandlers = "Toby_PlayerStatusCheckStaticHandler" | ||
AddEventHandlers = "Toby_SelectionNarrationHandler" | ||
AddEventHandlers = "Toby_TitleScreenHandler" | ||
AddEventHandlers = "hitmarkershandler" | ||
AddEventHandlers = "Toby_SnapToTargetHandler" | ||
AddEventHandlers = "Toby_DropoffDetectorHandler" | ||
AddEventHandlers = "Toby_TargetDetectorStaticHandler" | ||
AddEventHandlers = "Toby_TargetDetectorHandler" | ||
AddEventHandlers = "Toby_ActorsInViewportStaticHandler" | ||
AddEventHandlers = "Toby_QuickTurnHandler" | ||
AddEventHandlers = "TobyEventHandler" //Line Spawner | ||
} | ||
AddEventHandlers = "Toby_QuickTurnHandler" | ||
AddEventHandlers = "TobyEventHandler" //Line Spawner | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
zscript/SelectionNarration/Toby_SelectionNarrationHandler.zs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
class Toby_SelectionNarrationHandler : EventHandler | ||
{ | ||
int maxPlayers; | ||
Array<string> previousWeapon; | ||
Array<string> previousItem; | ||
private ui bool isNotFirstRun; | ||
private ui Toby_SoundBindingsLoaderStaticHandler bindings; | ||
|
||
override void OnRegister() | ||
{ | ||
Toby_Logger.Message("Toby_SelectionNarrationHandler registered!", "Toby_Developer"); | ||
} | ||
|
||
override void UITick() | ||
{ | ||
if (!isNotFirstRun) | ||
{ | ||
isNotFirstRun = true; | ||
bindings = Toby_SoundBindingsLoaderStaticHandler.GetInstance(); | ||
} | ||
} | ||
|
||
override void WorldLoaded(WorldEvent e) | ||
{ | ||
maxPlayers = 8; | ||
for (int i = 0; i < maxPlayers; i++) | ||
{ | ||
previousWeapon.push(""); | ||
previousItem.push(""); | ||
} | ||
} | ||
|
||
override void WorldTick() | ||
{ | ||
DetectAndNarrateWeaponSwitch(); | ||
DetectAndNarrateItemSwitch(); | ||
} | ||
|
||
override void InterfaceProcess(ConsoleEvent e) | ||
{ | ||
Array<String> eventAndArguments; | ||
e.Name.split(eventAndArguments, ":", TOK_KEEPEMPTY); | ||
string event = eventAndArguments[0]; | ||
Array<string> args; | ||
if (eventAndArguments.Size() > 1) | ||
{ | ||
for (int i = 1; i < eventAndArguments.Size(); i++) | ||
{ | ||
args.push(eventAndArguments[i]); | ||
} | ||
} | ||
|
||
if (event == "Toby_SelectionNarrationWeapon") | ||
{ | ||
Toby_SelectionNarrator.NarrateWeaponName(args[0], bindings.weaponsSoundBindingsContainer); | ||
} | ||
|
||
if (event == "Toby_SelectionNarrationItem") | ||
{ | ||
Toby_SelectionNarrator.NarrateItemName(args[0], args[1].ToInt(), bindings.itemsSoundBindingsContainer); | ||
} | ||
} | ||
|
||
private void DetectAndNarrateWeaponSwitch() | ||
{ | ||
for (int i = 0; i < maxPlayers; i++) | ||
{ | ||
if (!players[i].mo) { continue; } | ||
string currentWeapon = players[i].mo.player.ReadyWeapon.GetClassName(); | ||
if (currentWeapon == previousWeapon[i]) { continue; } | ||
if (previousWeapon[i] == "") | ||
{ | ||
previousWeapon[i] = currentWeapon; | ||
continue; | ||
} | ||
if (Cvar.GetCvar("Toby_SelectionNarrationWeapons", players[i]).GetBool()) | ||
{ | ||
EventHandler.SendInterfaceEvent(i, "Toby_SelectionNarrationWeapon:"..currentWeapon); | ||
} | ||
previousWeapon[i] = currentWeapon; | ||
} | ||
} | ||
|
||
private void DetectAndNarrateItemSwitch() | ||
{ | ||
for (int i = 0; i < maxPlayers; i++) | ||
{ | ||
if (!players[i].mo) { continue; } | ||
string currentItem = ""; | ||
int amount = 0; | ||
if (players[i].mo.InvSel) | ||
{ | ||
Inventory inv = players[i].mo.InvSel; | ||
currentItem = inv.GetClassName(); | ||
amount = inv.amount; | ||
} | ||
if (currentItem == previousItem[i]) { continue; } | ||
if (previousItem[i] == "") | ||
{ | ||
previousItem[i] = currentItem; | ||
continue; | ||
} | ||
if (Cvar.GetCvar("Toby_SelectionNarrationItems", players[i]).GetBool()) | ||
{ | ||
EventHandler.SendInterfaceEvent(i, "Toby_SelectionNarrationItem:"..currentItem..":"..amount); | ||
} | ||
previousItem[i] = currentItem; | ||
} | ||
} | ||
|
||
private int GetSbarItemCount(Actor a) | ||
{ | ||
int count = 0; | ||
for(Inventory item = a.inv; item != null; item = item.inv) { | ||
if (item.bInvBar) | ||
{ | ||
count++; | ||
} | ||
} | ||
return count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Toby_SelectionNarrator | ||
{ | ||
ui static void NarrateWeaponName(string weaponName, Toby_SoundBindingsContainer weaponsSoundBindings) | ||
{ | ||
Toby_SoundQueueStaticHandler.Clear(); | ||
|
||
for (int i = 0; i < weaponsSoundBindings.soundBindings.Size(); i++) | ||
{ | ||
string className = weaponsSoundBindings.soundBindings[i].At("ActorClass"); | ||
if (weaponName == className) | ||
{ | ||
string soundName = weaponsSoundBindings.soundBindings[i].At("SoundToPlay"); | ||
Toby_SoundQueueStaticHandler.AddSound(soundName, -1); | ||
break; | ||
} | ||
} | ||
|
||
Toby_SoundQueueStaticHandler.PlayQueue(0); | ||
} | ||
|
||
ui static void NarrateItemName(string itemName, int amount, Toby_SoundBindingsContainer itemsSoundBindings) | ||
{ | ||
Toby_SoundQueueStaticHandler.Clear(); | ||
|
||
for (int i = 0; i < itemsSoundBindings.soundBindings.Size(); i++) | ||
{ | ||
string className = itemsSoundBindings.soundBindings[i].At("ActorClass"); | ||
if (itemName == className) | ||
{ | ||
string soundName = itemsSoundBindings.soundBindings[i].At("SoundToPlay"); | ||
Toby_SoundQueueStaticHandler.AddSound(soundName, -1); | ||
break; | ||
} | ||
} | ||
|
||
Toby_NumberToSoundQueue numberToSoundQueue = Toby_NumberToSoundQueue.Create(); | ||
Toby_SoundQueueStaticHandler.AddQueue(numberToSoundQueue.CreateQueueFromInt(amount)); | ||
|
||
Toby_SoundQueueStaticHandler.PlayQueue(0); | ||
} | ||
} |
Empty file.
41 changes: 41 additions & 0 deletions
41
zscript/SoundBindings/Toby_SoundBindingsLoaderStaticHandler.zs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Toby_SoundBindingsLoaderStaticHandler : StaticEventHandler | ||
{ | ||
ui bool isNotFirstRun; | ||
|
||
ui Toby_SoundBindingsContainer keysSoundBindingsContainer; | ||
ui Toby_SoundBindingsContainer weaponsSoundBindingsContainer; | ||
ui Toby_SoundBindingsContainer itemsSoundBindingsContainer; | ||
ui Toby_SoundBindingsContainer ammoSoundBindingsContainer; | ||
ui Toby_SoundBindingsContainer armorSoundBindingsContainer; | ||
ui Toby_SoundBindingsContainer targetDetectorBindingsContainer; | ||
ui Toby_SoundBindingsContainer mapNamesBindingsContainer; | ||
ui Toby_SoundBindingsContainer actorsInViewportSoundBindings; | ||
ui Toby_SoundBindingsContainer menuSoundBindingsContainer; | ||
|
||
ui static Toby_SoundBindingsLoaderStaticHandler GetInstance() | ||
{ | ||
return Toby_SoundBindingsLoaderStaticHandler(StaticEventHandler.Find("Toby_SoundBindingsLoaderStaticHandler")); | ||
} | ||
|
||
override void OnRegister() | ||
{ | ||
Toby_Logger.Message("Toby_SoundBindingsLoaderStaticHandler registered!", "Toby_Developer"); | ||
} | ||
|
||
override void UITick() | ||
{ | ||
if (!isNotFirstRun) | ||
{ | ||
isNotFirstRun = true; | ||
keysSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_KeyNameSoundBindings"); | ||
weaponsSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_WeaponNameSoundBindings"); | ||
itemsSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_ItemNameSoundBindings"); | ||
ammoSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_AmmoNameSoundBindings"); | ||
armorSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_ArmorNameSoundBindings"); | ||
targetDetectorBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_TargetDetectorSoundBindings"); | ||
mapNamesBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_MapNameSoundBindings"); | ||
actorsInViewportSoundBindings = Toby_SoundBindingsContainer.Create("Toby_ActorsInViewportSoundBindings"); | ||
menuSoundBindingsContainer = Toby_SoundBindingsContainer.Create("Toby_MenuSoundBindings"); | ||
} | ||
} | ||
} |
Oops, something went wrong.