-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8456c6c
commit 1634608
Showing
7 changed files
with
121 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "includes.h" | ||
|
||
// From engine's mathlib.c | ||
float Length(const vec3_t v) | ||
{ | ||
int i; | ||
float length; | ||
|
||
length = 0; | ||
for (i = 0; i < 3; i++) | ||
length += v[i] * v[i]; | ||
length = static_cast<float>(sqrt(length)); // FIXME | ||
|
||
return length; | ||
} | ||
|
||
void CFeatureGravityField::Init() | ||
{ | ||
CChaosFeature::Init(); | ||
} | ||
|
||
void CFeatureGravityField::ActivateFeature() | ||
{ | ||
CChaosFeature::ActivateFeature(); | ||
m_bActivated = true; | ||
} | ||
|
||
void CFeatureGravityField::DeactivateFeature() | ||
{ | ||
CChaosFeature::DeactivateFeature(); | ||
m_bActivated = false; | ||
} | ||
|
||
void CFeatureGravityField::OnFrame(double time) | ||
{ | ||
if (!m_bActivated) | ||
return; | ||
|
||
if (CLWrapper::GetPausedState()) | ||
return; | ||
|
||
// point of no return | ||
edict_t* e; | ||
for (int i = 1; i < sv->num_edicts; i++) | ||
{ | ||
e = ORIG_EDICT_NUM(i); | ||
if (e && !e->free) | ||
{ | ||
if (e->v.flags & FL_CLIENT) | ||
continue; | ||
|
||
(*sv_player)->v.flags |= FL_GODMODE; // this effect is too crazy for player's health :DDD | ||
|
||
Vector target = (*sv_player)->v.origin - e->v.origin; | ||
|
||
float distance = Length(target); | ||
Vector direction = target / distance; | ||
Vector velocity = direction * MAGNET_SPEED; | ||
|
||
e->v.velocity = velocity; | ||
} | ||
} | ||
} | ||
|
||
const char* CFeatureGravityField::GetFeatureName() | ||
{ | ||
return "Hyper Gravity Field"; | ||
} |
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,42 @@ | ||
/** | ||
* Copyright - ScriptedSnark, 2024. | ||
* CFeatureGravityField.h | ||
* | ||
* Project (GSChaos) header file | ||
* Authors: ScriptedSnark. | ||
* Do not delete this comment block. Respect others' work! | ||
*/ | ||
|
||
#ifdef CFEATUREGRAVITYFIELD_H_RECURSE_GUARD | ||
#error Recursive header files inclusion detected in CFeatureGravityField.h | ||
#else //CFEATUREGRAVITYFIELD_H_RECURSE_GUARD | ||
|
||
#define CFEATUREGRAVITYFIELD_H_RECURSE_GUARD | ||
|
||
#ifndef CFEATUREGRAVITYFIELD_H_GUARD | ||
#define CFEATUREGRAVITYFIELD_H_GUARD | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
|
||
#define MAGNET_SPEED 1500.0f | ||
|
||
class CFeatureGravityField : public CChaosFeature | ||
{ | ||
void Init() override; | ||
void ActivateFeature() override; | ||
void DeactivateFeature() override; | ||
void OnFrame(double time) override; | ||
const char* GetFeatureName() override; | ||
private: | ||
bool m_bActivated; | ||
}; | ||
|
||
#else //!__cplusplus | ||
#error C++ compiler required to compile CFeatureGravityField.h | ||
#endif //__cplusplus | ||
|
||
#endif //CFEATUREGRAVITYFIELD_H_GUARD | ||
|
||
#undef CFEATUREGRAVITYFIELD_H_RECURSE_GUARD | ||
#endif //CFEATUREGRAVITYFIELD_H_RECURSE_GUARD |
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