Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for spellcast command's -x flag for all spells #293

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
13421bd
SpellsLvl01: add support for -x spellcast flag
meszaros-lajos-gyorgy Oct 13, 2023
0d1ad32
SpellsLvl02: extract conditions that check spellcasts' -x flag into v…
meszaros-lajos-gyorgy Oct 13, 2023
1721114
SpellsLvl03: add support for -x spellcast flag
meszaros-lajos-gyorgy Oct 13, 2023
b54b528
Spells: Prevent loop sounds of spells with spellcast -x flag
meszaros-lajos-gyorgy Oct 13, 2023
81a1934
SpellsLvl04: Add support for -x spellcast flag
meszaros-lajos-gyorgy Oct 13, 2023
8de7c0c
SpellsLvl01: Wrap more sound related functions with checks for spellc…
meszaros-lajos-gyorgy Oct 13, 2023
cfa4083
SpellsLvl02: Wrap more sound related functions with checks for spellc…
meszaros-lajos-gyorgy Oct 13, 2023
a63450d
SpellsLvl03: Wrap more sound related functions with checks for spellc…
meszaros-lajos-gyorgy Oct 13, 2023
d12d6d0
SpellsLvl05: Wrap more sound related functions with checks for spellc…
meszaros-lajos-gyorgy Oct 14, 2023
9953856
SpellsLvl06: Wrap sound related functions with checks for spellcast -…
meszaros-lajos-gyorgy Oct 14, 2023
af9cf90
SpellsLvl07: Wrap sound related functions with checks for spellcast -…
meszaros-lajos-gyorgy Oct 14, 2023
bf23d43
SpellsLvl01: Remove extra space after if keyword
meszaros-lajos-gyorgy Oct 14, 2023
11dca3a
SpellsLvl08: Wrap sound related functions with checks for spellcast -…
meszaros-lajos-gyorgy Oct 14, 2023
70fa40d
SpellsLvl09: Wrap sound related functions with checks for spellcast -…
meszaros-lajos-gyorgy Oct 14, 2023
9256ffb
SpellsLvl10: Wrap sound related functions with checks for spellcast -…
meszaros-lajos-gyorgy Oct 14, 2023
07e16a5
Spells: Simplify emitsSound conditions
meszaros-lajos-gyorgy Oct 15, 2023
31551cf
Spell: Extract emitsSound's logic into a method
meszaros-lajos-gyorgy Oct 15, 2023
2736b66
spells: Restore whitespace
meszaros-lajos-gyorgy Oct 15, 2023
cef5377
spells: Restore whitespace
meszaros-lajos-gyorgy Oct 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/game/magic/spells/SpellsLvl01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,19 @@ void MagicSightSpell::End() {
if(emitsSound) {
ARX_SOUND_Stop(m_snd_loop);
m_snd_loop = audio::SourcedSample();
}

Entity * caster = entities.get(m_caster);
if(caster && emitsSound) {
ARX_SOUND_PlaySFX(g_snd.SPELL_VISION_START, &caster->pos);
Entity * caster = entities.get(m_caster);
if(caster) {
ARX_SOUND_PlaySFX(g_snd.SPELL_VISION_START, &caster->pos);
}
}
}

void MagicSightSpell::Update() {

if(m_caster == EntityHandle_Player) {
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);
if(emitsSound && m_caster == EntityHandle_Player) {
Vec3f pos = ARX_PLAYER_FrontPos();
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);

if(emitsSound) {
ARX_SOUND_RefreshPosition(m_snd_loop, pos);
}
ARX_SOUND_RefreshPosition(m_snd_loop, pos);
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/game/magic/spells/SpellsLvl02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,10 @@ void DetectTrapSpell::End() {
}

void DetectTrapSpell::Update() {

if(m_caster == EntityHandle_Player) {
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);
if(emitsSound && m_caster == EntityHandle_Player) {
Vec3f pos = ARX_PLAYER_FrontPos();
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);

if(emitsSound) {
ARX_SOUND_RefreshPosition(m_snd_loop, pos);
}
ARX_SOUND_RefreshPosition(m_snd_loop, pos);
}
}

Expand Down
20 changes: 9 additions & 11 deletions src/game/magic/spells/SpellsLvl03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ void SpeedSpell::End() {
if(emitsSound) {
ARX_SOUND_Stop(m_snd_loop);
m_snd_loop = audio::SourcedSample();
}

Entity * target = entities.get(m_target);
if(target && emitsSound) {
ARX_SOUND_PlaySFX(g_snd.SPELL_SPEED_END, &target->pos);
Entity * target = entities.get(m_target);
if(target) {
ARX_SOUND_PlaySFX(g_snd.SPELL_SPEED_END, &target->pos);
}
}

m_trails.clear();
Expand All @@ -113,12 +113,10 @@ void SpeedSpell::End() {

void SpeedSpell::Update() {

if(m_caster == EntityHandle_Player) {
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);

if(emitsSound) {
ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos);
}
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);

if(emitsSound && m_caster == EntityHandle_Player) {
ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos);
}

for(SpeedTrail & trail : m_trails) {
Expand Down
4 changes: 1 addition & 3 deletions src/game/magic/spells/SpellsLvl06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,7 @@ void SlowDownSpell::End() {
m_targets.clear();
}

void SlowDownSpell::Update() {

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be more going on than what the commit message says. Please split formatting changes into a separate commit.

Copy link
Contributor Author

@meszaros-lajos-gyorgy meszaros-lajos-gyorgy Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have restored the whitespace here and a few other places as it's not necessary for this PR. I'll try to split my commits in the future according to what you wrote.

void SlowDownSpell::Update() {}

Vec3f SlowDownSpell::getPosition() const {
return getTargetPosition();
Expand Down
1 change: 0 additions & 1 deletion src/game/magic/spells/SpellsLvl08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ void EnchantWeaponSpell::End() { }

void EnchantWeaponSpell::Update() { }


bool LifeDrainSpell::CanLaunch() {
return spells.getSpellByCaster(m_caster, m_type) == nullptr;
}
Expand Down
8 changes: 4 additions & 4 deletions src/game/magic/spells/SpellsLvl09.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ void IncinerateSpell::End() {

void IncinerateSpell::Update() {

Entity * target = entities.get(m_target);
if(target) {
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);
bool emitsSound = !(m_flags & SPELLCAST_FLAG_NOSOUND);

if(emitsSound) {
if(emitsSound) {
Entity * target = entities.get(m_target);
if(target) {
ARX_SOUND_RefreshPosition(m_snd_loop, target->pos);
}
}
Expand Down