Skip to content

Commit

Permalink
New effect: Give NPCs a Spraycan or Fire Extinguisher (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
gromchek authored Aug 20, 2023
1 parent 41376aa commit f735c9e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 33 deletions.
52 changes: 52 additions & 0 deletions src/gtasa/effects/custom/ped/GiveNPCsAWeaponEffect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "effects/OneTimeEffect.h"

#include <vector>

#include <CPickups.h>
#include <CStreaming.h>
#include <extensions/ScriptCommands.h>

using namespace plugin;

using weapon_list = std::initializer_list<int>;

class GiveNPCsAWeaponEffect : public OneTimeEffect
{
private:
std::vector<int> weapons;

public:
GiveNPCsAWeaponEffect (weapon_list weaponsList) : weapons (weaponsList) {}

void
OnStart (EffectInstance *inst) override
{
CPlayerPed *player = FindPlayerPed ();

for (auto w : weapons)
{
int m = CPickups::ModelForWeapon (eWeaponType (w));
CStreaming::RequestModel (m, 2);
CStreaming::SetModelIsDeletable (m);
}

CStreaming::LoadAllRequestedModels (false);

for (CPed *ped : CPools::ms_pPedPool)
{
if (ped == player) continue;

auto w = weapons[inst->Random (1, 100000) % weapons.size ()];
Command<eScriptCommands::COMMAND_GIVE_WEAPON_TO_CHAR> (ped, w,
9999);
Command<eScriptCommands::COMMAND_SET_CURRENT_CHAR_WEAPON> (ped, w);
}
}
};

DEFINE_EFFECT (GiveNPCsAWeaponEffect, "effect_give_npcs_an_rpg", GROUP_WEAPONS,
weapon_list{WEAPON_RLAUNCHER});

DEFINE_EFFECT (GiveNPCsAWeaponEffect, "effect_give_npcs_a_sprcan_fire_ex",
GROUP_WEAPONS,
weapon_list{WEAPON_SPRAYCAN, WEAPON_EXTINGUISHER});
33 changes: 0 additions & 33 deletions src/gtasa/effects/custom/ped/GiveNPCsAnRPGEffect.cpp

This file was deleted.

0 comments on commit f735c9e

Please sign in to comment.