Skip to content

Commit 0888f37

Browse files
anzz1pangolp
andauthored
Fix crashes and make options work (#21)
* Fix crashes and make options work * Setting option Buff.MessageTimer = 0 actually disables the timed emotes and phrases now * Fix crash on setting Buff.NumWhispers = 0 (disable whispers) * Fix crash on setting Buff.NumPhrases = 0 (disable random talk) * Update npc_buffer.conf.dist * Remove InhabitType to work with latest core As per commit azerothcore-wotlk@2d4e17f InhabitType was removed from creature_template table * Replace deprecated config api, add enable/disable * Replaced deprecated config api to fix build * add enable/disable option * Update npc_buffer.conf.dist Add enable/disable option * chore. Add files and fix build --------- Co-authored-by: Pagani Walter <paganiwalter@gmail.com>
1 parent 6adbad1 commit 0888f37

File tree

12 files changed

+97
-67
lines changed

12 files changed

+97
-67
lines changed

.gitattributes

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@
3232
## For documentation
3333

3434
# Documents
35-
*.doc diff=astextplain
36-
*.DOC diff=astextplain
35+
*.doc diff=astextplain
36+
*.DOC diff=astextplain
3737
*.docx diff=astextplain
3838
*.DOCX diff=astextplain
3939
*.dot diff=astextplain
4040
*.DOT diff=astextplain
4141
*.pdf diff=astextplain
42-
*.PDF diff=astextplain
43-
*.rtf diff=astextplain
44-
*.RTF diff=astextplain
42+
*.PDF diff=astextplain
43+
*.rtf diff=astextplain
44+
*.RTF diff=astextplain
4545

4646
## DOCUMENTATION
4747
*.markdown text

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ body:
44
- type: markdown
55
attributes:
66
value: |
7-
Thank you for taking the time to fill out a bug report. Remember to fill out all fields including the title above.
8-
An issue that is not properly filled out will be closed.
7+
Thank you for taking the time to fill out a bug report. Remember to fill out all fields including the title above.
8+
An issue that is not properly filled out will be closed.
99
You can read more about the standards for a bug report [here](https://www.azerothcore.org/wiki/issue-tracker-standards).
1010
- type: textarea
1111
id: current
@@ -15,6 +15,7 @@ body:
1515
Description of the problem or issue here.
1616
Include entries of affected creatures / items / quests / spells etc.
1717
If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here.
18+
Never upload files! Use GIST for text and YouTube for videos!
1819
validations:
1920
required: true
2021
- type: textarea
@@ -25,14 +26,6 @@ body:
2526
Tell us what should happen instead.
2627
validations:
2728
required: true
28-
- type: textarea
29-
id: source
30-
attributes:
31-
label: Source
32-
description: |
33-
If you have a source that proves how it is supposed to work, please add that to make it easier for devs to fix the issue.
34-
validations:
35-
required: false
3629
- type: textarea
3730
id: reproduce
3831
attributes:
@@ -68,7 +61,8 @@ body:
6861
attributes:
6962
label: Operating system
7063
description: |
71-
Operating System, i.e. Windows 10 x64, Debian 10 x64, etc
64+
The Operating System the Server is running on.
65+
i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04
7266
validations:
7367
required: true
7468
- type: textarea

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ body:
66
- type: markdown
77
attributes:
88
value: |
9-
Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above.
10-
An issue that is not properly filled out will be closed.
9+
Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above.
10+
An issue that is not properly filled out will be closed.
1111
- type: textarea
1212
id: description
1313
attributes:

.github/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore
2+
23
## Buffer NPC
3-
- Latest build status with azerothcore: [![Build Status](https://github.com/azerothcore/mod-npc-buffer/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-npc-buffer)
4+
5+
- Latest build status with azerothcore:
6+
7+
[![Build Status](https://github.com/azerothcore/mod-npc-buffer/workflows/core-build/badge.svg)](https://github.com/azerothcore/mod-npc-buffer)
48

59
_This module was created for [StygianCore](https://rebrand.ly/stygiancoreproject). A World of Warcraft 3.3.5a Solo/LAN repack by StygianTheBest | [GitHub](https://rebrand.ly/stygiangithub) | [Website](https://rebrand.ly/stygianthebest))_
610
_This module has now being ported to AzerothCore by gtao725 (https://github.com/gtao725/)._

.github/pull_request_template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!-- First of all, THANK YOU for your contribution. -->
2+
3+
## Changes Proposed:
4+
-
5+
-
6+
7+
## Issues Addressed:
8+
<!-- If your fix has a relating issue, link it below -->
9+
- Closes
10+
11+
## SOURCE:
12+
<!-- If you can, include a source that can strengthen your claim -->
13+
14+
## Tests Performed:
15+
<!-- Does it build without errors? Did you test in-game? What did you test? On which OS did you test? Describe any other tests performed -->
16+
-
17+
-
18+
19+
20+
## How to Test the Changes:
21+
<!-- Describe in a detailed step-by-step order how to test the changes -->
22+
23+
1.
24+
2.
25+
3.

conf/conf.sh.dist

Lines changed: 0 additions & 9 deletions
This file was deleted.

conf/npc_buffer.conf.dist

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# BUFFER NPC
44
###################################################################################################
55

6+
# -------------------------------------------------------------------------------------
7+
# Enable the module
8+
# Enable : 1
9+
# Disable: 0
10+
# -------------------------------------------------------------------------------------
11+
Buff.Enable = 1
12+
613
# -------------------------------------------------------------------------------------
714
# Announce the module when the player logs in?
815
# Enable : 1
@@ -51,6 +58,7 @@ Buff.MessageTimer = 60000
5158
# -------------------------------------------------------------------------------------
5259
# How many pharases does the NPC have?
5360
# Default: 3
61+
# Disable: 0
5462
# -------------------------------------------------------------------------------------
5563
Buff.NumPhrases = 4
5664

@@ -66,6 +74,7 @@ BF.P4 = "Those trolls sure now how to dance! I hear they like to party in the mo
6674
# -------------------------------------------------------------------------------------
6775
# How many whispers does the NPC have?
6876
# Default: 3
77+
# Disable: 0
6978
# -------------------------------------------------------------------------------------
7079
Buff.NumWhispers = 10
7180

File renamed without changes.

include.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +0,0 @@
1-
#!/usr/bin/env bash
2-
3-
MOD_NPCBUFFER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )"
4-
5-
source "$MOD_NPCBUFFER_ROOT/conf/conf.sh.dist"
6-
7-
if [ -f "$MOD_NPCBUFFER_ROOT/conf/conf.sh" ]; then
8-
source "$MOD_NPCBUFFER_ROOT/conf/conf.sh"
9-
fi

sql/world/updates/2022_05_24_00.sql

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/NB_loader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
void AddNPCBufferScripts();
22

3-
void Addmod_npc_bufferScripts() {
3+
void Addmod_npc_bufferScripts()
4+
{
45
AddNPCBufferScripts();
56
}

src/npc_buffer.cpp

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ This code and content is released under the [GNU AGPL v3](https://github.com/aze
7070
#include "ScriptedCreature.h"
7171
#include "ScriptedGossip.h"
7272

73+
static bool BFEnableModule;
7374
static bool BFAnnounceModule;
7475
static bool BuffByLevel;
7576
static bool BuffCureRes;
@@ -86,14 +87,15 @@ class BufferConfig : public WorldScript
8687

8788
void OnBeforeConfigLoad(bool /*reload*/) override
8889
{
90+
BFEnableModule = sConfigMgr->GetOption<bool>("Buff.Enable", 1);
8991
BFAnnounceModule = sConfigMgr->GetOption<bool>("Buff.Announce", 1);
9092
BuffByLevel = sConfigMgr->GetOption<bool>("Buff.ByLevel", 1);
9193
BuffCureRes = sConfigMgr->GetOption<bool>("Buff.CureRes", 1);
92-
BuffNumPhrases = sConfigMgr->GetOption<int>("Buff.NumPhrases", 3);
93-
BuffNumWhispers = sConfigMgr->GetOption<int>("Buff.NumWhispers", 3);
94-
BuffMessageTimer = sConfigMgr->GetOption<int>("Buff.MessageTimer", 60000);
95-
BuffEmoteSpell = sConfigMgr->GetOption<int>("Buff.EmoteSpell", 44940);
96-
BuffEmoteCommand = sConfigMgr->GetOption<int>("Buff.EmoteCommand", 3);
94+
BuffNumPhrases = sConfigMgr->GetOption<uint32>("Buff.NumPhrases", 3);
95+
BuffNumWhispers = sConfigMgr->GetOption<uint32>("Buff.NumWhispers", 3);
96+
BuffMessageTimer = sConfigMgr->GetOption<uint32>("Buff.MessageTimer", 60000);
97+
BuffEmoteSpell = sConfigMgr->GetOption<uint32>("Buff.EmoteSpell", 44940);
98+
BuffEmoteCommand = sConfigMgr->GetOption<uint32>("Buff.EmoteCommand", 3);
9799

98100
// Enforce Min/Max Time
99101
if (BuffMessageTimer != 0)
@@ -108,14 +110,13 @@ class BufferConfig : public WorldScript
108110

109111
class BufferAnnounce : public PlayerScript
110112
{
111-
112113
public:
113114
BufferAnnounce() : PlayerScript("BufferAnnounce") {}
114115

115116
void OnLogin(Player *player)
116117
{
117118
// Announce Module
118-
if (BFAnnounceModule)
119+
if (BFEnableModule && BFAnnounceModule)
119120
{
120121
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00BufferNPC |rmodule.");
121122
}
@@ -124,7 +125,6 @@ class BufferAnnounce : public PlayerScript
124125

125126
class buff_npc : public CreatureScript
126127
{
127-
128128
public:
129129
buff_npc() : CreatureScript("buff_npc") {}
130130

@@ -176,6 +176,11 @@ class buff_npc : public CreatureScript
176176

177177
bool OnGossipSelect(Player *player, Creature *creature, uint32 /*uiSender*/, uint32 /* uiAction */)
178178
{
179+
if (!BFEnableModule)
180+
{
181+
return false;
182+
}
183+
179184
// Who are we dealing with?
180185
std::string CreatureWhisper = "Init";
181186
std::string PlayerName = player->GetName();
@@ -296,7 +301,11 @@ class buff_npc : public CreatureScript
296301

297302
// Choose and speak a random phrase to the player
298303
// Phrases are stored in the config file
299-
creature->Whisper(PickWhisper(PlayerName).c_str(), LANG_UNIVERSAL, player);
304+
305+
if (BuffNumWhispers > 0)
306+
{
307+
creature->Whisper(PickWhisper(PlayerName).c_str(), LANG_UNIVERSAL, player);
308+
}
300309

301310
// Emote and Close
302311
creature->HandleEmoteCommand(EMOTE_ONESHOT_FLEX);
@@ -309,35 +318,44 @@ class buff_npc : public CreatureScript
309318
{
310319
NPC_PassiveAI(Creature *creature) : ScriptedAI(creature) {}
311320

312-
uint32 MessageTimer;
321+
uint32 MessageTimer = 0;
313322

314323
// Called once when client is loaded
315324
void Reset()
316325
{
317-
MessageTimer = urand(BuffMessageTimer, 300000); // 1-5 minutes
326+
if (BuffMessageTimer != 0) {
327+
MessageTimer = urand(BuffMessageTimer, 300000); // 1-5 minutes
328+
}
318329
}
319330

320331
// Called at World update tick
321332
void UpdateAI(const uint32 diff)
322333
{
323-
if (MessageTimer <= diff)
334+
if (BFEnableModule && BuffMessageTimer != 0)
324335
{
325-
std::string Message = PickPhrase();
326-
me->Say(Message.c_str(), LANG_UNIVERSAL, NULL);
327-
328-
// Use gesture?
329-
if (BuffEmoteCommand != 0)
336+
if (MessageTimer <= diff)
330337
{
331-
me->HandleEmoteCommand(BuffEmoteCommand);
338+
if (BuffNumPhrases > 0)
339+
{
340+
std::string Message = PickPhrase();
341+
me->Say(Message.c_str(), LANG_UNIVERSAL, NULL);
342+
}
343+
344+
// Use gesture?
345+
if (BuffEmoteCommand != 0)
346+
{
347+
me->HandleEmoteCommand(BuffEmoteCommand);
348+
}
349+
350+
// Alert players?
351+
if (BuffEmoteSpell != 0)
352+
{
353+
me->CastSpell(me, BuffEmoteSpell);
354+
}
355+
356+
MessageTimer = urand(BuffMessageTimer, 300000);
332357
}
333-
334-
// Alert players?
335-
if (BuffEmoteSpell != 0)
336-
{
337-
me->CastSpell(me, BuffEmoteSpell);
338-
}
339-
340-
MessageTimer = urand(BuffMessageTimer, 300000);
358+
else { MessageTimer -= diff; }
341359
}
342360
else
343361
{

0 commit comments

Comments
 (0)