Member
|
02-15-2014
, 05:26
Re: [THC RPG CS:GO] Total HardCore RPG
|
#31
|
Ok, here is a version with the previous two fixes and a possible regen ammo fix. I haven't had time testing it yet.
Modified on regen_ammo.inc regen_ammo_WeaponFire and Timer_OnRegen_ammoInterval
Code:
public regen_ammo_WeaponFire(client, const String:weapon[])
{
if(IsValidPlayer(client))
if(GetClientTeam(client)!=g_regen_ammoUpgradeConfigCache[UpgradeConfig_TeamLock])
{
if(GetPlayerUpgradeLevel(client,g_moduleregen_ammo)&&!g_bPlayerIsRegeneratingAmmo[client])
{
//originial code
//static ammoCounts[] = { 0, 35, 90, 90, 200, 30, 120, 32, 100, 52, 100, 1, 1, 1, 1, 1 };
static ammoCounts[] = { 0, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 0, 0, 0, 0, 0, 0 };
//ADDED THIS IN TO CREATE MAX AMMO COUNT BASED UPON AMMO TYPE VERY SIMPLE AND SHOULD ACTUALLY BE USED IN CSS VERSION INSTEAD OF CPU INTENSIVE CHECKS
//NO TIME ATM TO MAKE MAX AMMO AMOUNTS POSSIBLY CREATE A CONFIG FILE FOR THIS IN THE FUTURE TOO
//1 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_50AE", 2, 1, 0, 0, "ammo_50AE_max", "ammo_50AE_impulse", 0, 10, 14);
//2 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_762MM", 2, 1, 0, 0, "ammo_762mm_max", "ammo_762mm_impulse", 0, 10, 14);
//3 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_556MM", 2, 1, 0, 0, "ammo_556mm_max", "ammo_556mm_impulse", 0, 10, 14);
//4 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_556MM_SMALL", 2, 1, 0, 0, "ammo_556mm_small_max", "ammo_556mm_impulse", 0, 10, 14);
//5 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_556MM_BOX", 2, 1, 0, 0, &unk_CCACEF, "ammo_556mm_box_impulse", 0, 10, 14);
//6 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_338MAG", 2, 1, 0, 0, "ammo_338mag_max", "ammo_338mag_impulse", 0, 12, 16);
//7 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_9MM", 2, 1, 0, 0, "ammo_9mm_max", "ammo_9mm_impulse", 0, 5, 10);
//8 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_BUCKSHOT", 2, 1, 0, 0, "ammo_buckshot_max", "ammo_buckshot_impulse", 0, 3, 6);
//9 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_45ACP", 2, 1, 0, 0, "ammo_45acp_max", "ammo_45acp_impulse", 0, 6, 10);
//10 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_357SIG", 2, 1, 0, 0, "ammo_357sig_max", "ammo_357sig_impulse", 0, 4, 8);
//11 CAmmoDef::AddAmmoType(ammoDef, &unk_CCAE47, 2, 1, 0, 0, "ammo_357sig_small_max", "ammo_357sig_impulse", 0, 4, 8);
//12 CAmmoDef::AddAmmoType(ammoDef, "BULLET_PLAYER_57MM", 2, 1, 0, 0, "ammo_57mm_max", "ammo_57mm_impulse", 0, 4, 8);
//13 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_HEGRENADE", 64, 1, 0, 0, "ammo_grenade_limit_default", 0, 0, 0, 8);
//14 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_FLASHBANG", 0, 1, 0, 0, "ammo_grenade_limit_flashbang", 0, 0, 0, 8);
//15 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_SMOKEGRENADE", 0, 1, 0, 0, "ammo_grenade_limit_default", 0, 0, 0, 8);
//16 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_MOLOTOV", 8, 0, 0, 0, "ammo_grenade_limit_default", 0, 0, 0, 8);
//17 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_DECOY", 0, 0, 0, 0, "ammo_grenade_limit_default", 0, 0, 0, 8);
//18 CAmmoDef::AddAmmoType(ammoDef, "AMMO_TYPE_TASERCHARGE", 256, 3, 0, 0, 0, 0, 0, 0, 8);
new activeWeapon = GetEntDataEnt2(client, g_iActiveWeaponOffset);
if (activeWeapon != -1)
{
new primary = GetPlayerWeaponSlot(client, _:SlotPrimary);
new secondary = GetPlayerWeaponSlot(client, _:SlotSecondary);
if ((activeWeapon == primary) || (activeWeapon == secondary))
{
new ammoType = GetEntData(activeWeapon, g_iAmmoTypeOffset);
new max_ammo=ammoCounts[ammoType];
if (ammoType != -1){g_bPlayerIsRegeneratingAmmo[client]=true;new Handle:datapack=CreateDataPack();WritePackCell(datapack, client);WritePackCell(datapack, max_ammo);WritePackCell(datapack, ammoType);WritePackCell(datapack, activeWeapon);CreateTimer(g_regen_ammoUpgradeConfigCache[UpgradeConfig_Interval],Timer_OnRegen_ammoInterval,datapack,TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);}
}
}
}
}
}
public Action:Timer_OnRegen_ammoInterval(Handle:timer,Handle:datapack)
{
ResetPack(datapack);
new client=ReadPackCell(datapack);
new max_ammo=ReadPackCell(datapack);
new ammoType=ReadPackCell(datapack);
new oldactiveWeapon=ReadPackCell(datapack);
if(IsClientInGame(client)&&g_bPlayerIsRegeneratingAmmo[client])
{
new activeWeapon = GetEntDataEnt2(client, g_iActiveWeaponOffset);
if (activeWeapon==oldactiveWeapon)
{
new amount=GetEntData(client,g_iAmmoOffset+(ammoType*4),4)+RoundToNearest(g_regen_ammoUpgradeConfigCache[UpgradeConfig_Amount]*GetPlayerUpgradeLevel(client,g_moduleregen_ammo));
if(amount>max_ammo)
{
g_bPlayerIsRegeneratingAmmo[client]=false;
amount=max_ammo;
}
SetEntData(client,g_iAmmoOffset+(ammoType*4),amount,4,true);
return Plugin_Continue;
}
}
CloseHandle(datapack);
return Plugin_Stop;
}
Added to project.inc
Under
Code:
new g_iActiveWeaponOffset;
Added
Code:
new g_iAmmoTypeOffset;
Under
Code:
enum UpgradeConfigs
{
UpgradeConfig_Disable,
UpgradeConfig_TeamLock,
UpgradeConfig_Effects,
UpgradeConfig_MaxLevel,
UpgradeConfig_Cost,
UpgradeConfig_iCost,
Float:UpgradeConfig_Interval,
UpgradeConfig_MinAlpha,
Float:UpgradeConfig_Percent,
Float:UpgradeConfig_Amount,
UpgradeConfig_Suicide,
UpgradeConfig_Unlimited,
UpgradeConfig_Mode,
UpgradeConfig_TotalFreeze,
Float:UpgradeConfig_BaseAmount,
Float:UpgradeConfig_BaseSpeed,
Float:UpgradeConfig_Speed,
String:UpgradeConfig_Sound[64]
}
added
Code:
enum Slots
{
SlotPrimary,
SlotSecondary,
SlotKnife,
SlotGrenade,
SlotC4,
SlotNone
}
Added on helpers.inc
Under
Code:
g_iActiveWeaponOffset=FindSendPropOffs("CAI_BaseNPC", "m_hActiveWeapon");
if(g_iActiveWeaponOffset==-1)
LogMgr_Print(g_moduleCore, LogType_Fatal_Plugin, "InitOffsets", "PLUGIN STOPPED - Reason: could not find the ActiveWeapon offset - PLUGIN STOPPED");
Added
Code:
g_iAmmoTypeOffset = FindSendPropOffs("CBaseCombatWeapon", "m_iPrimaryAmmoType");
if(g_iAmmoTypeOffset==-1)
LogMgr_Print(g_moduleCore, LogType_Fatal_Plugin, "InitOffsets", "PLUGIN STOPPED - Reason: could not find the AmmoTypeOffset offset - PLUGIN STOPPED");
Attached is compiled version with the includes that have been modified.
This also fixes the bug with only regening one type of ammo :/ but.... if the user switches weapons, they will need to fire their new weapon. I will be eventually moving the code of getting the weapon to its own section and calling it from weapon fire. Then also creating an additional timer with a delay under the else statement that closes the datapack and will re-check the new weapon after default time for the give ammo. I will post when im done with that and have tested this further.
**NOTE** I HAVE NOT YET UPDATED THE STOCK MAX_AMMO ACCORDING TO THE AMMO TYPE. IF SOMEONE HAS A LIST OF ALL WEAPONS IN CSGO WITH THEIR AMMO TYPES THAT WOULD BE AWWWEESOME (I lost the copy I thought I had bookmarked and can't find it again)
Last edited by JZServices; 02-15-2014 at 05:32.
|
|