REO-EE/_module/nss/hb_include.nss
Jaysyn904 f82740bbbd Initial commit
Initial commit
2024-02-22 13:22:03 -05:00

961 lines
27 KiB
Plaintext

#include "hb_const"
#include "x2_inc_itemprop"
#include "x0_i0_position"
int GetIsFireArm(object oObject);
void SetSafePhenoType(int iPheno, object oTarget);
int GetFirearmWeaponType(object oWeapon);
int GetFirearmRoF(object oWeapon);
int GetFirearmAmmoType(object oWeapon);
int GetIsAmmoBolt(object oWeapon);
int GetIsAmmoBullet(object oWeapon);
int GetFirearmMagCap(object oWeapon);
float GetReloadTime(object oTarget, object oWeapon);
int GetFirearmSkill(object oTarget, object oWeapon);
int GetCanQuickReload(object oTarget, object oWeapon);
int GetTotalAmmo(object oTarget, string sAmmoTag);
void ReloadAmmo(object oTarget, object oWeapon, int iCurAmmo);
void ResetReloadVars(object oTarget);
void DestroyAmmo(object oTarget, object oWeapon, int iAmount);
void QuickReloadAmmo(object oTarget, object oWeapon, int iCurAmmo, int bIsDual);
itemproperty GetRefIP(object oTarget, object oWeapon, int iIP, int iIPSub);
void ChangeMode(object oTarget, object oWeapon, int iPheno, string sMode);
int GetHasSuppressor(object oWeapon);
int GetHasIntegralSuppressor(object oWeapon);
void SafePlayAnimation(int iAnim, float fSpeed, float fSeconds, object oWeapon, object oTarget);
int GetIsDualCompatable(object oWeapon, object oWeaponOff);
void DelayEquipWeapon(object oTarget, object oWeapon, int iSlot, int bIsDual);
int GetIsFireArm(object oObject)
{
int iItemType = GetBaseItemType(oObject);
if (iItemType == 6 || iItemType == 7 || iItemType == 8 || iItemType == 11 || iItemType == 61 )
{
return TRUE;
}
else
{
return FALSE;
}
}
void SetSafePhenoType(int iPheno, object oTarget)
{
effect eGhost = EffectCutsceneGhost();
if (GetPhenoType(oTarget) == iPheno)
{
return;
}
else
{
SetPhenoType(iPheno, oTarget);
}
}
int GetFirearmWeaponType(object oWeapon)
{
int ipWeaponTypeSub;
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_WEAPON_TYPE)
{
ipWeaponTypeSub = GetItemPropertySubType(ipLoop);
return ipWeaponTypeSub;
}
else
{
ipLoop = GetNextItemProperty(oWeapon);
}
}
return 99;
}
int GetFirearmRoF(object oWeapon)
{
int ipWeaponTypeSub;
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_ROF)
{
ipWeaponTypeSub = GetItemPropertySubType(ipLoop);
return ipWeaponTypeSub;
}
else
{
ipLoop = GetNextItemProperty(oWeapon);
}
}
return 99;
}
int GetFirearmAmmoType(object oWeapon)
{
int ipWeaponTypeSub;
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_WEAPON_AMMO_TYPE)
{
ipWeaponTypeSub = GetItemPropertySubType(ipLoop);
return ipWeaponTypeSub;
}
else
{
ipLoop = GetNextItemProperty(oWeapon);
}
}
return 99;
}
int GetIsAmmoBullet(object oWeapon)
{
int iAmmoType = GetFirearmAmmoType(oWeapon);
if (iAmmoType == IP_WEAPON_AMMO_556MM || iAmmoType == IP_WEAPON_AMMO_762MM || iAmmoType == IP_WEAPON_AMMO_762X54R)
{
if (GetFirearmRoF(oWeapon) == IP_ROF_SEMIAUTO)
{
return FALSE;
}
else
{
return TRUE;
}
}
else
{
return FALSE;
}
}
int GetIsAmmoBolt(object oWeapon)
{
int iAmmoType = GetFirearmAmmoType(oWeapon);
if (iAmmoType == IP_WEAPON_AMMO_9MM || iAmmoType == IP_WEAPON_AMMO_44_SPECIAL)
{
return TRUE;
}
else
{
if (iAmmoType == IP_WEAPON_AMMO_556MM && GetFirearmRoF(oWeapon) == IP_ROF_SEMIAUTO)
{
return TRUE;
}
else
{
return FALSE;
}
}
}
int GetFirearmMagCap(object oWeapon)
{
int ipWeaponTypeSub;
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_MAG_CAP)
{
ipWeaponTypeSub = GetItemPropertySubType(ipLoop);
return ipWeaponTypeSub;
}
else
{
ipLoop = GetNextItemProperty(oWeapon);
}
}
return 99;
}
float GetReloadTime(object oTarget, object oWeapon)
{
int iSkill = GetFirearmSkill(oTarget, oWeapon);
float fTime = 15.0;
switch (iSkill)
{
case 1:
fTime = 12.0;
break;
case 2:
fTime = 9.0;
break;
case 3:
fTime = 7.0;
break;
case 4:
fTime = 5.0;
break;
case 5:
fTime = 3.0;
break;
case 6:
fTime = 1.0;
break;
case 7:
fTime = 1.0;
break;
}
return fTime;
}
int GetFirearmSkill(object oTarget, object oWeapon)
{
int iWeaponType = GetFirearmWeaponType(oWeapon);
int sSkill = 0;
if (iWeaponType == IP_WEAPON_HOLDOUT_PISTOL || iWeaponType == IP_WEAPON_LIGHT_PISTOL || iWeaponType == IP_WEAPON_HEAVY_PISTOL || iWeaponType == IP_WEAPON_MACHINE_PISTOL)
{
if (GetHasFeat(FEAT_PISTOL_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_PISTOL_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_PISTOL_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_PISTOL_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_PISTOL_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_PISTOL_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_PISTOL_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
else if (iWeaponType == IP_WEAPON_SMG)
{
if (GetHasFeat(FEAT_SMG_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_SMG_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_SMG_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_SMG_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_SMG_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_SMG_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_SMG_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
else if (iWeaponType == IP_WEAPON_SHOTGUN)
{
if (GetHasFeat(FEAT_SHOTGUNS_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_SHOTGUNS_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_SHOTGUNS_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_SHOTGUNS_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_SHOTGUNS_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_SHOTGUNS_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_SHOTGUNS_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
else if (iWeaponType == IP_WEAPON_SPORT_RIFLE || iWeaponType == IP_WEAPON_SNIPER_RIFLE)
{
if (GetHasFeat(FEAT_RIFLES_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_RIFLES_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_RIFLES_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_RIFLES_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_RIFLES_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_RIFLES_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_RIFLES_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
else if (iWeaponType == IP_WEAPON_ASSAULT_RIFLE)
{
if (GetHasFeat(FEAT_ASSAULT_RIFLES_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_ASSAULT_RIFLES_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
else if (iWeaponType == IP_WEAPON_LIGHT_MG || iWeaponType == IP_WEAPON_HEAVY_MG)
{
if (GetHasFeat(FEAT_HEAVY_INTRODUSED, oTarget) == TRUE)
{
sSkill = 1;
}
if (GetHasFeat(FEAT_HEAVY_PRACTICED, oTarget) == TRUE)
{
sSkill = 2;
}
if (GetHasFeat(FEAT_HEAVY_PROFICIANT, oTarget) == TRUE)
{
sSkill = 3;
}
if (GetHasFeat(FEAT_HEAVY_SKILLED, oTarget) == TRUE)
{
sSkill = 4;
}
if (GetHasFeat(FEAT_HEAVY_PROFESSIONAL, oTarget) == TRUE)
{
sSkill = 5;
}
if (GetHasFeat(FEAT_HEAVY_EXPERT, oTarget) == TRUE)
{
sSkill = 6;
}
if (GetHasFeat(FEAT_HEAVY_MASTER, oTarget) == TRUE)
{
sSkill = 7;
}
}
return sSkill;
}
int GetCanQuickReload(object oTarget, object oWeapon)
{
if ( GetFirearmSkill(oTarget, oWeapon) > 4)
{
return 1;
}
else
{
return 0;
}
}
int GetTotalAmmo(object oTarget, string sAmmoTag)
{
object oLoop = GetFirstItemInInventory(oTarget);
int iTotal = 0;
while (oLoop != OBJECT_INVALID)
{
if (GetTag(oLoop) == sAmmoTag)
{
int iTotalAmmo = GetNumStackedItems(oLoop);
iTotal = iTotal + iTotalAmmo;
}
oLoop = GetNextItemInInventory(oTarget);
}
return iTotal;
}
void ReloadAmmo(object oTarget, object oWeapon, int iCurAmmo)
{
int iMaxAmmo = GetFirearmMagCap(oWeapon);
//int iCurAmmo = GetLocalInt(oWeapon, "iCurAmmo");
int iAmmoToLoad = iMaxAmmo - iCurAmmo;
int iTotalAmmo = GetTotalAmmo(oTarget, GetTag(oWeapon) + "round");
if (GetTag(oWeapon) == "556mms")
{
iTotalAmmo = GetTotalAmmo(OBJECT_SELF, "556mmround");
}
if (iTotalAmmo > 0)
{
if (iTotalAmmo < iAmmoToLoad)
{
// load iTotalAmmo
SetLocalInt(oWeapon, "iCurAmmo", iTotalAmmo + iCurAmmo);
DestroyAmmo(oTarget, oWeapon, iTotalAmmo);
}
else if (iTotalAmmo >= iAmmoToLoad)
{
// load iAmmoToLoad
SetLocalInt(oWeapon, "iCurAmmo", iMaxAmmo);
DestroyAmmo(oTarget, oWeapon, iAmmoToLoad);
}
}
else
{
FloatingTextStringOnCreature("Not Enough Ammo To Reload", oTarget, FALSE);
}
}
void ResetReloadVars(object oTarget)
{
SetLocalInt(oTarget, "iIsReloading", 0);
SetCommandable(1, oTarget);
SetLocalInt(oTarget, "iIsDucked", 0);
}
void DestroyAmmo(object oTarget, object oWeapon, int iAmount)
{
string sAmmoTag = GetTag(oWeapon) + "round";
if (GetTag(oWeapon) == "556mms")
{
sAmmoTag = "556mmround";
}
object oLoop = GetFirstItemInInventory(oTarget);
while(oLoop != OBJECT_INVALID)
{
if (GetTag(oLoop) == sAmmoTag)
{
if (GetItemStackSize(oLoop) > iAmount)
{
SetItemStackSize(oLoop, GetItemStackSize(oLoop) - iAmount);
oLoop = OBJECT_INVALID;
return;
}
else if (GetItemStackSize(oLoop) < iAmount)
{
iAmount = iAmount - GetItemStackSize(oLoop);
DestroyObject(oLoop, 0.0);
}
else if (GetItemStackSize(oLoop) == iAmount)
{
DestroyObject(oLoop, 0.0);
return;
}
}
oLoop = GetNextItemInInventory(oTarget);
}
return;
}
void QuickReloadAmmo(object oTarget, object oWeapon, int iCurAmmo, int bIsDual)
{
int iMaxAmmo = GetFirearmMagCap(oWeapon);
//int iCurAmmo = GetLocalInt(oWeapon, "iCurAmmo");
int iAmmoToLoad = iMaxAmmo - iCurAmmo;
int iTotalAmmo = GetTotalAmmo(oTarget, GetTag(oWeapon) + "round");
if (GetTag(oWeapon) == "556mms")
{
iTotalAmmo = GetTotalAmmo(OBJECT_SELF, "556mmround");
}
if (iTotalAmmo > 0)
{
if (iTotalAmmo < iAmmoToLoad)
{
// load iTotalAmmo
SetLocalInt(oWeapon, "iCurAmmo", iTotalAmmo + iCurAmmo);
DestroyAmmo(oTarget, oWeapon, iTotalAmmo);
object oMag = GetLocalObject(oWeapon, "MAG_Child");
if (GetItemPossessor(oMag) != oTarget)
{
//create mag and CR
if (bIsDual == 0)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeapon), oTarget, 1, "CR" + GetTag(oWeapon));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeapon) + "Parent", oWeapon);
SetLocalObject(oWeapon, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
object oMagazine;
if (bIsDual == 1)
{
oMagazine = CreateItemOnObject(GetTag(oWeapon) + "MagOff", oTarget, 1, "");
}
else
{
oMagazine = CreateItemOnObject(GetTag(oWeapon) + "Mag", oTarget, 1, "");
}
SetLocalObject(oMagazine, GetTag(oWeapon) + "MagParent", oWeapon);
SetLocalObject(oWeapon, "MAG_Child", oMagazine);
SetItemStackSize(oMagazine, iTotalAmmo + iCurAmmo);
SetItemCursedFlag(oMagazine, 1);
DelayCommand(1.5, AssignCommand(oTarget, ClearAllActions(TRUE)));
if (bIsDual == 1)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_ARROWS)));
}
else if (GetIsAmmoBullet(oWeapon) == TRUE)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_BOLTS)));
}
else if (GetIsAmmoBolt(oWeapon) == TRUE)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_BULLETS)));
}
}
else
{
SetItemStackSize(oMag, iTotalAmmo + iCurAmmo);
object oWeaponOff = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, OBJECT_SELF);
object oWeaponMain = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, OBJECT_SELF);
if (GetLocalInt(oTarget, "bIsInDualWieldMode") == 1 && GetLocalInt(oWeaponMain, "iCurAmmo") > 0 && GetLocalInt(oWeaponOff, "iCurAmmo") > 0 && GetItemPossessor(GetLocalObject(oWeaponMain, "CR_Child")) != oTarget)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeaponMain), oTarget, 1, "CR" + GetTag(oWeaponMain));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeaponMain) + "Parent", oWeaponMain);
SetLocalObject(oWeaponMain, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
else if (GetLocalInt(oTarget, "bIsInDualWieldMode") != 1 && GetItemPossessor(GetLocalObject(oWeaponMain, "CR_Child")) != oTarget)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeaponMain), oTarget, 1, "CR" + GetTag(oWeaponMain));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeaponMain) + "Parent", oWeaponMain);
SetLocalObject(oWeaponMain, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
}
}
else if (iTotalAmmo >= iAmmoToLoad)
{
// load iAmmoToLoad
SetLocalInt(oWeapon, "iCurAmmo", iMaxAmmo);
DestroyAmmo(oTarget, oWeapon, iAmmoToLoad);
object oMag = GetLocalObject(oWeapon, "MAG_Child");
if (GetItemPossessor(oMag) != oTarget)
{
if (bIsDual == 0)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeapon), oTarget, 1, "CR" + GetTag(oWeapon));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeapon) + "Parent", oWeapon);
SetLocalObject(oWeapon, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
object oMagazine;
if (bIsDual == 1)
{
oMagazine = CreateItemOnObject(GetTag(oWeapon) + "MagOff", oTarget, 1, "");
}
else
{
oMagazine = CreateItemOnObject(GetTag(oWeapon) + "Mag", oTarget, 1, "");
}
SetLocalObject(oMagazine, GetTag(oWeapon) + "MagParent", oWeapon);
SetLocalObject(oWeapon, "MAG_Child", oMagazine);
SetItemStackSize(oMagazine, iMaxAmmo);
SetItemCursedFlag(oMagazine, 1);
DelayCommand(1.5, AssignCommand(oTarget, ClearAllActions(TRUE)));
if (bIsDual == 1)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_ARROWS)));
}
else if (GetIsAmmoBullet(oWeapon) == TRUE)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_BOLTS)));
}
else if (GetIsAmmoBolt(oWeapon) == TRUE)
{
DelayCommand(1.6, AssignCommand(oTarget, ActionEquipItem(oMagazine, INVENTORY_SLOT_BULLETS)));
}
}
else
{
SetItemStackSize(oMag, iMaxAmmo);
object oWeaponOff = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, OBJECT_SELF);
object oWeaponMain = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, OBJECT_SELF);
if (GetLocalInt(oTarget, "bIsInDualWieldMode") == 1 && GetLocalInt(oWeaponMain, "iCurAmmo") > 0 && GetLocalInt(oWeaponOff, "iCurAmmo") > 0 && GetItemPossessor(GetLocalObject(oWeaponMain, "CR_Child")) != oTarget)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeaponMain), oTarget, 1, "CR" + GetTag(oWeaponMain));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeaponMain) + "Parent", oWeaponMain);
SetLocalObject(oWeaponMain, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
else if (GetLocalInt(oTarget, "bIsInDualWieldMode") != 1 && GetItemPossessor(GetLocalObject(oWeaponMain, "CR_Child")) != oTarget)
{
object oChamberedRound = CreateItemOnObject("CR" + GetTag(oWeaponMain), oTarget, 1, "CR" + GetTag(oWeaponMain));
SetLocalObject(oChamberedRound, "CR"+ GetTag(oWeaponMain) + "Parent", oWeaponMain);
SetLocalObject(oWeaponMain, "CR_Child", oChamberedRound);
SetItemCursedFlag(oChamberedRound, 1);
}
}
}
}
else
{
FloatingTextStringOnCreature("Not Enough Ammo To Reload", oTarget, FALSE);
}
}
itemproperty GetRefIP(object oTarget, object oWeapon, int iIP, int iIPSub)
{
object oIPRef = GetObjectByTag("RefIP", 0);
itemproperty ipLoop = GetFirstItemProperty(oIPRef);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == iIP)
{
if (GetItemPropertySubType(ipLoop) == iIPSub)
{
return ipLoop;
}
}
ipLoop = GetNextItemProperty(oIPRef);
}
return ipLoop;
}
void ChangeMode(object oTarget, object oWeapon, int iPheno, string sMode)
{
object oChamberedRound = GetLocalObject(oWeapon, "CR_Child");
object oMag = GetLocalObject(oWeapon, "MAG_Child");
int iMiddle;
int iTop;
//SetCommandable(0, oTarget);
if (sMode == "SingleShot")
{
if (GetHasSuppressor(oWeapon) == TRUE)
{
iMiddle = 4;
iTop = 1;
}
else
{
iMiddle = 1;
iTop = 1;
}
}
else if (sMode == "Burst3")
{
if (GetLocalInt(oWeapon, "iCurAmmo") < 3)
{
FloatingTextStringOnCreature("You Dont Have Enough Ammo To Change Mode", oTarget, FALSE);
return;
}
if (GetHasSuppressor(oWeapon) == TRUE)
{
iMiddle = 4;
iTop = 2;
}
else
{
iMiddle = 2;
iTop = 2;
}
}
else if (sMode == "Burst6")
{
if (GetLocalInt(oWeapon, "iCurAmmo") < 6)
{
FloatingTextStringOnCreature("You Dont Have Enough Ammo To Change Mode", oTarget, FALSE);
return;
}
if (GetHasSuppressor(oWeapon) == TRUE)
{
iMiddle = 4;
iTop = 3;
}
else
{
iMiddle = 3;
iTop = 3;
}
}
SetLocalInt(oTarget, "bIsChangingMode", 1);
object oNewWeapon = CopyItemAndModify(oWeapon, ITEM_APPR_TYPE_WEAPON_COLOR, ITEM_APPR_WEAPON_COLOR_MIDDLE, iMiddle, TRUE);
object oNewWeapon2 = CopyItemAndModify(oNewWeapon, ITEM_APPR_TYPE_WEAPON_COLOR, ITEM_APPR_WEAPON_COLOR_TOP, iTop, TRUE);
SetLocalInt(oNewWeapon2, "iCurAmmo", GetLocalInt(oWeapon, "iCurAmmo"));
DestroyObject(oWeapon, 0.5);
DestroyObject(oNewWeapon);
SetSafePhenoType(iPheno, oTarget);
SetLocalString(oNewWeapon2, "WeaponFireingMode", sMode);
if (GetLocalInt(oWeapon, "iCurAmmo") != 0)
{
SetLocalObject(oNewWeapon2, "MAG_Child", oMag);
SetLocalObject(oMag, GetTag(oNewWeapon2) + "MagParent", oNewWeapon2);
if (GetBaseItemType(oNewWeapon2) != 11)
{
SetLocalObject(oNewWeapon2, "CR_Child", oChamberedRound);
SetLocalObject(oChamberedRound, "CR"+ GetTag(oNewWeapon2) + "Parent", oNewWeapon2);
}
}
//DelayCommand(0.9, SetCommandable(1, oTarget));
if (GetBaseItemType(oNewWeapon2) == 11)
{
DelayCommand(1.1, AssignCommand(oTarget, ActionEquipItem(oNewWeapon2, INVENTORY_SLOT_LEFTHAND)));
}
else
{
DelayCommand(1.1, AssignCommand(oTarget, ActionEquipItem(oNewWeapon2, INVENTORY_SLOT_RIGHTHAND)));
}
}
int GetHasSuppressor(object oWeapon)
{
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_ACCESSORIES)
{
if (GetItemPropertySubType(ipLoop) == IP_ACCESSORIES_SUPPRESSOR)
{
return TRUE;
}
}
ipLoop = GetNextItemProperty(oWeapon);
}
return 0;
}
int GetHasIntegralSuppressor(object oWeapon)
{
itemproperty ipLoop = GetFirstItemProperty(oWeapon);
while (GetIsItemPropertyValid(ipLoop) == TRUE)
{
if (GetItemPropertyType(ipLoop) == IP_INTEGRAL)
{
if (GetItemPropertySubType(ipLoop) == IP_INTEGRAL_SUPPRESSOR)
{
return TRUE;
}
}
ipLoop = GetNextItemProperty(oWeapon);
}
return 0;
}
void SafePlayAnimation(int iAnim, float fSpeed, float fSeconds, object oWeapon, object oTarget)
{
if (GetItemPossessor(oWeapon) == oTarget)
{
AssignCommand(oTarget, PlayAnimation(iAnim, fSpeed ,fSeconds));
}
}
int GetIsDualCompatable(object oWeapon, object oWeaponOff)
{
int iFirearmType = GetFirearmWeaponType(oWeapon);
int iFirearmTypeOff = GetFirearmWeaponType(oWeaponOff);
if (iFirearmType == IP_WEAPON_HOLDOUT_PISTOL || iFirearmType == IP_WEAPON_LIGHT_PISTOL || iFirearmType == IP_WEAPON_HEAVY_PISTOL)
{
if (iFirearmTypeOff == IP_WEAPON_HOLDOUT_PISTOL || iFirearmTypeOff == IP_WEAPON_LIGHT_PISTOL || iFirearmTypeOff == IP_WEAPON_HEAVY_PISTOL)
{
return TRUE;
}
else
{
return FALSE;
}
}
if (iFirearmType == IP_WEAPON_MACHINE_PISTOL || iFirearmType == IP_WEAPON_SMG && GetFirearmRoF(oWeapon) == IP_ROF_SEMIAUTO)
{
if (iFirearmTypeOff == IP_WEAPON_MACHINE_PISTOL || iFirearmTypeOff == IP_WEAPON_SMG && GetFirearmRoF(oWeaponOff) == IP_ROF_SEMIAUTO)
{
return TRUE;
}
else
{
return FALSE;
}
}
return FALSE;
}
void DelayEquipWeapon(object oTarget, object oWeapon, int iSlot, int bIsDual)
{
object oWeaponInRightSlot = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oTarget);
object oWeaponInLeftSlot = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oTarget);
if (bIsDual == 0)
{
if(oWeaponInRightSlot == OBJECT_INVALID)
{
DelayCommand(0.2, AssignCommand(oTarget, ActionEquipItem(oWeapon, iSlot)));
}
}
else if (bIsDual == 1)
{
if(oWeaponInLeftSlot == OBJECT_INVALID)
{
DelayCommand(0.2, AssignCommand(oTarget, ActionEquipItem(oWeapon, iSlot)));
}
}
}