Skip to content

Commit

Permalink
Merge pull request #1 from sogladev/config
Browse files Browse the repository at this point in the history
add config, custom speed for night elves
  • Loading branch information
sogladev authored Sep 19, 2024
2 parents 4b2aa79 + c0b0545 commit ed52695
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 46 deletions.
36 changes: 11 additions & 25 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,33 @@
[![Build Status](
https://github.com/sogladev/mod-ghost-speed/actions/workflows/core-build.yml/badge.svg?branch=master&event=push)](https://github.com/sogladev/mod-ghost-speed)

This is a module for [AzerothCore](http://www.azerothcore.org) that changes the speed of Ghost
This is a module for [AzerothCore](http://www.azerothcore.org) that changes the speed while dead

- Modifies ghost speed to use custom values
- Modifies Ghost speed to use custom values


## How to install
https://www.azerothcore.org/wiki/installing-a-module

1. Modify value(s) `src/mod_ghost_speed.cpp`
2. Requires source recompilation
3. Modify database (should be done automaticly)

```
amount = 200; // default: 50
```

example values:
```
50 default
200 fast
500 zoom
```

Apply database changes (this should be done automaticly): `data/sql/db-world/base/ghost_speed.sql`
```
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (8326, 'spell_ghost_speed_aura');
```
1. Requires source recompilation
2. Modify config
found in `/etc/modules`, copy `.conf.dist` to `.conf` and edit
3. Apply database changes
this should be done automaticly `data/sql/db-world/base/ghost_speed.sql`

## How to remove

1. Undo database changes: `optional/undo_ghost_speed.sql`
```
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326;
```

2. Remove `mod-ghost-speed` folder

## Resources
ghost speed is set by aura 8326

Night Elves are applied `ID - 20584 Ghost` with Blizzard Default speed of 75 (+50% increase)

Highest speed value is applied

example of usage in the core
- https://github.com/azerothcore/azerothcore-wotlk/blob/a196f7f28aa263dc7f9c532e15839f3b409fb68f/src/server/game/Handlers/CharacterHandler.cpp#L957

Expand Down
42 changes: 42 additions & 0 deletions conf/ghost_speed.conf.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
#

[worldserver]

########################################
# Ghost Speed module configuration
########################################
#
# GhostSpeed.Speed
# Description: Custom BasePoints for 8326 Ghost EFFECT_1 SPELL_AURA_MOD_INCREASE_SPEED
# Default: 200 - Fast
# 50 - Blizzard Default
# 75 - Blizzard Default for Night Elves (+50% racial bonus)
# 500 - Zoom
#
# GhostSpeed.SpeedSwim
# Description: Custom BasePoints for 8326 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
# Default: 200 - Fast
# 50 - Blizzard Default
# 75 - Blizzard Default for Night Elves (+50% racial bonus)
# 500 - Zoom
#
# GhostSpeed.SpeedNightElf
# Description: Custom BasePoints for Night Elf 20584 Ghost EFFECT_1 SPELL_AURA_MOD_INCREASE_SPEED
# Default: 300 - Fast (200 + 50% racial bonus)
# 50 - Blizzard Default
# 75 - Blizzard Default for Night Elves (+50% racial bonus)
# 500 - Zoom
#
# GhostSpeed.SpeedSwimNightElf
# Description: Custom BasePoints for Night Elf 20584 Ghost EFFECT_2 SPELL_AURA_MOD_INCREASE_SWIM_SPEED
# Default: 300 - Fast (200 + 50% racial bonus)
# 50 - Blizzard Default
# 75 - Blizzard Default for Night Elves (+50% racial bonus)
# 500 - Zoom

GhostSpeed.Speed = 200
GhostSpeed.SpeedSwim = 200
GhostSpeed.SpeedNightElf = 300
GhostSpeed.SpeedSwimNightElf = 300
17 changes: 0 additions & 17 deletions conf/my_custom.conf.dist

This file was deleted.

4 changes: 3 additions & 1 deletion data/sql/db-world/base/ghost_speed.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-- modify ghost speed
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326;
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326 AND `ScriptName` = 'spell_ghost_speed_aura';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (8326, 'spell_ghost_speed_aura');
DELETE FROM `spell_script_names` WHERE `spell_id` = 20584 AND `ScriptName` = 'spell_ghost_speed_night_elf_aura';
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES (20584, 'spell_ghost_speed_night_elf_aura');
3 changes: 2 additions & 1 deletion optional/undo_ghost_speed.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326;
DELETE FROM `spell_script_names` WHERE `spell_id` = 8326 AND `ScriptName` = 'spell_ghost_speed_aura';
DELETE FROM `spell_script_names` WHERE `spell_id` = 20584 AND `ScriptName` = 'spell_ghost_speed_night_elf_aura';
51 changes: 49 additions & 2 deletions src/mod_ghost_speed.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/
#include "Config.h"
#include "ScriptMgr.h"
#include "SpellAuraEffects.h"
#include "SpellInfo.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "mod_ghost_speed.h"

GhostSpeed* GhostSpeed::instance()
{
static GhostSpeed instance;
return &instance;
}

class world_ghost_speed : public WorldScript
{
public:
world_ghost_speed() : WorldScript("world_ghost_speed") { }

void OnAfterConfigLoad(bool /*reload*/) override
{
sGhostSpeed->speed = sConfigMgr->GetOption<int32>("GhostSpeed.Speed", 200);
sGhostSpeed->speedSwim = sConfigMgr->GetOption<int32>("GhostSpeed.SpeedSwim", 200);
sGhostSpeed->speedNightElf = sConfigMgr->GetOption<int32>("GhostSpeed.SpeedNightElf", 300);
sGhostSpeed->speedSwimNightElf = sConfigMgr->GetOption<int32>("GhostSpeed.SpeedSwimNightElf", 300);
}
};

// 8326 Ghost
class spell_ghost_speed_aura : public AuraScript
Expand All @@ -13,12 +36,12 @@ class spell_ghost_speed_aura : public AuraScript

void CalculateAmountSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
amount = 200; // default: 50
amount = sGhostSpeed->speed;
}

void CalculateAmountSwimSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
amount = 200; // default: 50
amount = sGhostSpeed->speedSwim;
}

void Register() override
Expand All @@ -28,7 +51,31 @@ class spell_ghost_speed_aura : public AuraScript
}
};

// 20584 Ghost - Night Elf
class spell_ghost_speed_night_elf_aura : public AuraScript
{
PrepareAuraScript(spell_ghost_speed_night_elf_aura);

void CalculateAmountSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
amount = sGhostSpeed->speedNightElf;
}

void CalculateAmountSwimSpeed(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
amount = sGhostSpeed->speedSwimNightElf;
}

void Register() override
{
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSpeed, EFFECT_0, SPELL_AURA_MOD_INCREASE_SPEED);
DoEffectCalcAmount += AuraEffectCalcAmountFn(spell_ghost_speed_night_elf_aura::CalculateAmountSwimSpeed, EFFECT_1, SPELL_AURA_MOD_INCREASE_SWIM_SPEED);
}
};

void AddSC_ghost_speed_spell_script()
{
new world_ghost_speed();
RegisterSpellScript(spell_ghost_speed_aura);
RegisterSpellScript(spell_ghost_speed_night_elf_aura);
}
17 changes: 17 additions & 0 deletions src/mod_ghost_speed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef DEF_GHOSTSPEED_H
#define DEF_GHOSTSPEED_H

class GhostSpeed
{
public:
static GhostSpeed* instance();

int32 speed;
int32 speedSwim;
int32 speedNightElf;
int32 speedSwimNightElf;
};

#define sGhostSpeed GhostSpeed::instance()

#endif

0 comments on commit ed52695

Please sign in to comment.