Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f8f7f66
Add subscription events
invalid-email-address Apr 12, 2022
ced79c7
Add configuration options for subscriber events
invalid-email-address Apr 12, 2022
39bda2b
Fix errors
invalid-email-address Apr 14, 2022
1040043
Fix errors
invalid-email-address Apr 14, 2022
bfb6b07
Merge branch 'subs' of github.com:ShortCircuit908/ChaosModRDR into subs
invalid-email-address Apr 14, 2022
6f7110f
Revert modification of vcxproj file
invalid-email-address Apr 14, 2022
bbe3f7d
Add double sub meta effect
invalid-email-address Apr 15, 2022
5b96751
Fix threading issues
invalid-email-address Apr 16, 2022
3a88ba7
Create wolf pack effect
invalid-email-address Apr 16, 2022
706d856
Add weighted voting
invalid-email-address Apr 17, 2022
b49dfb1
Display weighted votes as percentages on overlay
invalid-email-address Apr 17, 2022
2641121
Fix formatting
invalid-email-address Apr 17, 2022
d5e679e
Disable submysterygift event to prevent duplicate events
invalid-email-address Apr 17, 2022
6a0de72
Adjust UI for compactness and readability
invalid-email-address Apr 18, 2022
471401f
Fix calculation
invalid-email-address Apr 18, 2022
39519c9
Add trainsaw laser effect
invalid-email-address Apr 18, 2022
0c5f102
Fix incorrect variable name
invalid-email-address Apr 18, 2022
f5a2674
Weighted voting starts with 1 vote per effect
invalid-email-address Apr 18, 2022
0b55de5
Keep non-timed effects on screen for a time
invalid-email-address Apr 19, 2022
e0702c7
Simplify display time check
invalid-email-address Apr 19, 2022
abfb475
Merge branch 'subs'
invalid-email-address Apr 28, 2022
284c7eb
Merge branch 'ui-adjust'
invalid-email-address Apr 28, 2022
524d609
Merge branch 'weighted-votes'
invalid-email-address Apr 28, 2022
f4187f4
Add multiple timers for use in effects
invalid-email-address Apr 29, 2022
f50f377
Consistent and sensible styling
invalid-email-address Apr 29, 2022
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
158 changes: 51 additions & 107 deletions src/Effects/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#include "../script.h"

std::vector<const char*> Effect::WeaponNames = std::vector<const char*>();
std::vector<Hash> Effect::WeaponHashes = std::vector<Hash>();
std::vector <Hash> Effect::WeaponHashes = std::vector<Hash>();

std::vector<const char*> Effect::weatherNames = std::vector<const char*>();
std::vector<Hash> Effect::weatherHashes = std::vector<Hash>();
std::vector <Hash> Effect::weatherHashes = std::vector<Hash>();

Effect::Effect()
{
internalTimer = 0;
internalTimer = {};
}

Effect::~Effect()
Expand All @@ -18,12 +18,12 @@ Effect::~Effect()

void Effect::OnActivate()
{
internalTimer = 0;
internalTimer = {};
}

void Effect::OnDeactivate()
{
internalTimer = 0;
internalTimer = {};
}

void Effect::OnTick()
Expand All @@ -32,14 +32,19 @@ void Effect::OnTick()

bool Effect::TimerTick(uint32_t maxMs)
{
internalTimer += ChaosMod::GetDeltaTime();
return TimerTick(maxMs, 0);
}

if (internalTimer >= maxMs)
bool Effect::TimerTick(uint32_t maxMs, uint32_t timerIndex)
{
internalTimer[timerIndex] += ChaosMod::GetDeltaTime();

if (internalTimer[timerIndex] >= maxMs)
{
internalTimer = internalTimer % maxMs;
internalTimer[timerIndex] = internalTimer[timerIndex] % maxMs;
return true;
}

return false;
}

Expand All @@ -49,9 +54,9 @@ void LoadModel(Hash model)
//{
// return;
//}

STREAMING::REQUEST_MODEL(model, true);

while (!STREAMING::HAS_MODEL_LOADED(model))
{
WAIT(0);
Expand All @@ -60,112 +65,51 @@ void LoadModel(Hash model)

void InitWeaponHashes()
{
Effect::WeaponNames = {
"WEAPON_REPEATER_CARBINE",
"WEAPON_REVOLVER_CATTLEMAN",
"WEAPON_REVOLVER_CATTLEMAN_JOHN",
"WEAPON_REVOLVER_CATTLEMAN_MEXICAN",
"WEAPON_REVOLVER_CATTLEMAN_PIG",
"WEAPON_REVOLVER_DOUBLEACTION_MICAH",
"WEAPON_REVOLVER_DOUBLEACTION_GAMBLER",
"WEAPON_REVOLVER_DOUBLEACTION_EXOTIC",
"WEAPON_REVOLVER_SCHOFIELD_CALLOWAY",
"WEAPON_REVOLVER_SCHOFIELD_GOLDEN",
"WEAPON_REVOLVER_DOUBLEACTION",
"WEAPON_REVOLVER_SCHOFIELD",
"WEAPON_REVOLVER_LEMAT",
"WEAPON_PISTOL_VOLCANIC",
"WEAPON_PISTOL_M1899",
"WEAPON_PISTOL_MAUSER",
"WEAPON_PISTOL_MAUSER_DRUNK",
"WEAPON_PISTOL_SEMIAUTO",
"WEAPON_REPEATER_WINCHESTER",
"WEAPON_REPEATER_HENRY",
"WEAPON_RIFLE_VARMINT",
"WEAPON_RIFLE_SPRINGFIELD",
"WEAPON_RIFLE_BOLTACTION",
"WEAPON_SHOTGUN_DOUBLEBARREL",
"WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC",
"WEAPON_SHOTGUN_SAWEDOFF",
"WEAPON_SHOTGUN_REPEATING",
"WEAPON_SHOTGUN_PUMP",
"WEAPON_SHOTGUN_SEMIAUTO",
"WEAPON_SNIPERRIFLE_ROLLINGBLOCK",
"WEAPON_SNIPERRIFLE_ROLLINGBLOCK_EXOTIC",
"WEAPON_SNIPERRIFLE_CARCANO",
"WEAPON_MELEE_KNIFE",
"WEAPON_MELEE_KNIFE_JAWBONE",
"WEAPON_MELEE_KNIFE_JOHN",
"WEAPON_MELEE_KNIFE_MICAH",
"WEAPON_MELEE_KNIFE_MINER",
"WEAPON_MELEE_KNIFE_VAMPIRE",
"WEAPON_MELEE_KNIFE_CIVIL_WAR",
"WEAPON_MELEE_KNIFE_BEAR",
"WEAPON_MELEE_BROKEN_SWORD",
"WEAPON_MELEE_CLEAVER",
"WEAPON_MELEE_HATCHET",
"WEAPON_MELEE_MACHETE",
"WEAPON_MELEE_ANCIENT_HATCHET",
"WEAPON_MELEE_HATCHET_VIKING",
"WEAPON_MELEE_HATCHET_HEWING",
"WEAPON_MELEE_HATCHET_HUNTER",
"WEAPON_MELEE_HATCHET_HUNTER_RUSTED",
"WEAPON_MELEE_HATCHET_DOUBLE_BIT",
"WEAPON_MELEE_HATCHET_DOUBLE_BIT_RUSTED",
"WEAPON_THROWN_DYNAMITE",
"WEAPON_THROWN_MOLOTOV",
"WEAPON_THROWN_THROWING_KNIVES",
"WEAPON_THROWN_TOMAHAWK",
"WEAPON_THROWN_TOMAHAWK_ANCIENT",
"WEAPON_REPEATER_EVANS",

/** Should not be removed */
"WEAPON_BOW",
"WEAPON_KIT_CAMERA",
"WEAPON_LASSO",
"WEAPON_FISHINGROD",
"WEAPON_MELEE_LANTERN_ELECTRIC"
};

Effect::WeaponNames = {"WEAPON_REPEATER_CARBINE", "WEAPON_REVOLVER_CATTLEMAN", "WEAPON_REVOLVER_CATTLEMAN_JOHN",
"WEAPON_REVOLVER_CATTLEMAN_MEXICAN", "WEAPON_REVOLVER_CATTLEMAN_PIG",
"WEAPON_REVOLVER_DOUBLEACTION_MICAH", "WEAPON_REVOLVER_DOUBLEACTION_GAMBLER",
"WEAPON_REVOLVER_DOUBLEACTION_EXOTIC", "WEAPON_REVOLVER_SCHOFIELD_CALLOWAY",
"WEAPON_REVOLVER_SCHOFIELD_GOLDEN", "WEAPON_REVOLVER_DOUBLEACTION",
"WEAPON_REVOLVER_SCHOFIELD", "WEAPON_REVOLVER_LEMAT", "WEAPON_PISTOL_VOLCANIC",
"WEAPON_PISTOL_M1899", "WEAPON_PISTOL_MAUSER", "WEAPON_PISTOL_MAUSER_DRUNK",
"WEAPON_PISTOL_SEMIAUTO", "WEAPON_REPEATER_WINCHESTER", "WEAPON_REPEATER_HENRY",
"WEAPON_RIFLE_VARMINT", "WEAPON_RIFLE_SPRINGFIELD", "WEAPON_RIFLE_BOLTACTION",
"WEAPON_SHOTGUN_DOUBLEBARREL", "WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC",
"WEAPON_SHOTGUN_SAWEDOFF", "WEAPON_SHOTGUN_REPEATING", "WEAPON_SHOTGUN_PUMP",
"WEAPON_SHOTGUN_SEMIAUTO", "WEAPON_SNIPERRIFLE_ROLLINGBLOCK",
"WEAPON_SNIPERRIFLE_ROLLINGBLOCK_EXOTIC", "WEAPON_SNIPERRIFLE_CARCANO", "WEAPON_MELEE_KNIFE",
"WEAPON_MELEE_KNIFE_JAWBONE", "WEAPON_MELEE_KNIFE_JOHN", "WEAPON_MELEE_KNIFE_MICAH",
"WEAPON_MELEE_KNIFE_MINER", "WEAPON_MELEE_KNIFE_VAMPIRE", "WEAPON_MELEE_KNIFE_CIVIL_WAR",
"WEAPON_MELEE_KNIFE_BEAR", "WEAPON_MELEE_BROKEN_SWORD", "WEAPON_MELEE_CLEAVER",
"WEAPON_MELEE_HATCHET", "WEAPON_MELEE_MACHETE", "WEAPON_MELEE_ANCIENT_HATCHET",
"WEAPON_MELEE_HATCHET_VIKING", "WEAPON_MELEE_HATCHET_HEWING", "WEAPON_MELEE_HATCHET_HUNTER",
"WEAPON_MELEE_HATCHET_HUNTER_RUSTED", "WEAPON_MELEE_HATCHET_DOUBLE_BIT",
"WEAPON_MELEE_HATCHET_DOUBLE_BIT_RUSTED", "WEAPON_THROWN_DYNAMITE", "WEAPON_THROWN_MOLOTOV",
"WEAPON_THROWN_THROWING_KNIVES", "WEAPON_THROWN_TOMAHAWK", "WEAPON_THROWN_TOMAHAWK_ANCIENT",
"WEAPON_REPEATER_EVANS",

/** Should not be removed */
"WEAPON_BOW", "WEAPON_KIT_CAMERA", "WEAPON_LASSO", "WEAPON_FISHINGROD",
"WEAPON_MELEE_LANTERN_ELECTRIC"};

Effect::WeaponHashes.clear();

for (auto name : Effect::WeaponNames)
{
Effect::WeaponHashes.push_back(GAMEPLAY::GET_HASH_KEY((char*)name));
Effect::WeaponHashes.push_back(GAMEPLAY::GET_HASH_KEY((char*) name));
}
}

void InitWeatherHashes()
{
Effect::weatherNames = {
"SUNNY",
"MISTY",
"FOG",
"CLOUDS",
"OVERCAST",
"OVERCASTDARK",
"DRIZZLE",
"RAIN",
"THUNDER",
"THUNDERSTORM",
"HURRICANE",
"HIGHPRESSURE",
"SHOWER",
"HAIL",
"SLEET",
"SNOWCLEARING",
"SNOWLIGHT",
"SNOW",
"BLIZZARD",
"GROUNDBLIZZARD",
"WHITEOUT",
"SANDSTORM"
};

Effect::weatherNames = {"SUNNY", "MISTY", "FOG", "CLOUDS", "OVERCAST", "OVERCASTDARK", "DRIZZLE", "RAIN", "THUNDER",
"THUNDERSTORM", "HURRICANE", "HIGHPRESSURE", "SHOWER", "HAIL", "SLEET", "SNOWCLEARING",
"SNOWLIGHT", "SNOW", "BLIZZARD", "GROUNDBLIZZARD", "WHITEOUT", "SANDSTORM"};

Effect::weatherHashes.clear();

for (auto name : Effect::weatherNames)
{
Effect::weatherHashes.push_back(GAMEPLAY::GET_HASH_KEY((char*)name));
Effect::weatherHashes.push_back(GAMEPLAY::GET_HASH_KEY((char*) name));
}
}
50 changes: 30 additions & 20 deletions src/Effects/effect.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
#pragma once

#include <natives.h>
#include <types.h>
#include <enums.h>
#include <main.h>
#include <string>
#include <stdint.h>
#include <vector>
#include <map>
#include <windows.h>

#define GET_HASH(str) GAMEPLAY::GET_HASH_KEY((char*)str)

#define M_PI 3.14159265358979323846
#define M_PI 3.14159265358979323846

struct LinearColor
{
LinearColor() {};
LinearColor()
{
};

LinearColor(uint8_t _R, uint8_t _G, uint8_t _B, uint8_t _A)
{
R = _R;
G = _G;
B = _B;
A = _A;
};

uint8_t R = 0;
uint8_t G = 0;
uint8_t B = 0;
uint8_t A = 255;
};


template <typename T>
template<typename T>
inline T Lerp(T min, T max, double alpha)
{
return min + (T)(double(max - min) * alpha);
return min + (T) (double(max - min) * alpha);
}

struct NearbyEntities
Expand All @@ -52,47 +57,52 @@ class Effect
{
public:
Effect();

~Effect();

virtual void OnActivate();

virtual void OnDeactivate();

virtual void OnTick();

std::string ID = "";
std::string name = "";

bool bTimed = false;

/** In seconds */
uint32_t EffectDuration = 0;

uint32_t DeactivationTime = 0;
uint32_t ActivationTime = 0;

uint32_t DisplayTime = 0;

static std::vector<const char*> WeaponNames;
static std::vector<Hash> WeaponHashes;

static std::vector <Hash> WeaponHashes;
static std::vector<const char*> weatherNames;
static std::vector<Hash> weatherHashes;

static std::vector <Hash> weatherHashes;
/**
* Adds delta time to the current internal timer.
* Returns whether time (maxMs) has expired or not
*/
bool TimerTick(uint32_t maxMs);


bool TimerTick(uint32_t maxMs, uint32_t timerIndex);

bool bIsMeta = false;

bool bIsFake = false;
private:
uint32_t internalTimer = 0;
std::map <uint32_t, uint32_t> internalTimer = {};
};

class MetaEffect : public Effect
{
public:
MetaEffect()
MetaEffect() : Effect()
{
bIsMeta = true;
bTimed = true;
Expand Down
Loading