228 lines
8.9 KiB
Plaintext
228 lines
8.9 KiB
Plaintext
#include "inc_system_const"
|
|
#include "gun_system_const"
|
|
#include "inc_mysql_tables"
|
|
#include "aps_include"
|
|
#include "colors_inc"
|
|
#include "nwnx_funcs_w"
|
|
//#include "nwnx_funcs_l"
|
|
#include "x2_inc_itemprop"
|
|
|
|
/////////////////////////
|
|
// GLOBAL - PROTOTYPES //
|
|
/////////////////////////
|
|
|
|
// Although not a real array, it can be used as one.
|
|
// Returns an integer value stored at index iIndex
|
|
int GetLocalArrayInt(object oObject, string sVarName, int iIndex);
|
|
// Although not a real array, it can be used as one.
|
|
// Returns a string value stored at index iIndex
|
|
string GetLocalArrayString(object oObject, string sVarName, int iIndex);
|
|
// Although not a real array, it can be used as one.
|
|
// Returns an object value stored at index iIndex
|
|
object GetLocalArrayObject(object oObject, string sVarName, int iIndex);
|
|
// Sets an integer value at index iIndex for a variable named sVarName
|
|
void SetLocalArrayInt(object oObject, string sVarName, int iIndex, int iValue);
|
|
// Sets a string value at index iIndex for a variable named sVarName
|
|
void SetLocalArrayString(object oObject, string sVarName, int iIndex, string sValue);
|
|
// Sets an object value at index iIndex for a variable named sVarName
|
|
void SetLocalArrayObject(object oObject, string sVarName, int iIndex, object oData);
|
|
// Deletes an integer value at index iIndex for a variable named sVarName
|
|
void DeleteLocalArrayInt(object oObject, string sVarName, int iIndex);
|
|
// Deletes a string value at index iIndex for a variable named sVarName
|
|
void DeleteLocalArrayString(object oObject, string sVarName, int iIndex);
|
|
// Deletes an object value at index iIndex for a variable named sVarName
|
|
void DeleteLocalArrayObject(object oObject, string sVarName, int iIndex);
|
|
// Sends a message to all players fDistance from oOrigin
|
|
// oOrigin is the origin object (usually a creature) It is used as a reference to the distance between the origin and the other players
|
|
// fDistance is distance players must be from oOrigin to receive the message.
|
|
// sFilterVariable is the name of the variable on all player database items which determines whether or not they actually receive the message
|
|
// sMessage is the actual message sent to players.
|
|
// bPartyOnly = If set to TRUE, only those within range AND in oOrigin's party will see the message. If set to FALSE, everyone in range will see it.
|
|
void SendPlayerAOEMessage(object oOrigin, float fDistance, string sFilterVariable, string sMessage, int bPartyOnly = FALSE);
|
|
|
|
////////////////////////
|
|
// GLOBAL - FUNCTIONS //
|
|
////////////////////////
|
|
|
|
int GetLocalArrayInt(object oObject, string sVarName, int iIndex)
|
|
{
|
|
return GetLocalInt(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
|
|
string GetLocalArrayString(object oObject, string sVarName, int iIndex)
|
|
{
|
|
return GetLocalString(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
|
|
object GetLocalArrayObject(object oObject, string sVarName, int iIndex)
|
|
{
|
|
return GetLocalObject(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
|
|
void SetLocalArrayInt(object oObject, string sVarName, int iIndex, int iValue)
|
|
{
|
|
SetLocalInt(oObject, sVarName + IntToString(iIndex), iValue);
|
|
}
|
|
|
|
void SetLocalArrayString(object oObject, string sVarName, int iIndex, string sValue)
|
|
{
|
|
SetLocalString(oObject, sVarName + IntToString(iIndex), sValue);
|
|
}
|
|
|
|
void SetLocalArrayObject(object oObject, string sVarName, int iIndex, object oData)
|
|
{
|
|
SetLocalObject(oObject, sVarName + IntToString(iIndex), oData);
|
|
}
|
|
|
|
void DeleteLocalArrayInt(object oObject, string sVarName, int iIndex)
|
|
{
|
|
DeleteLocalInt(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
void DeleteLocalArrayString(object oObject, string sVarName, int iIndex)
|
|
{
|
|
DeleteLocalString(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
void DeleteLocalArrayObject(object oObject, string sVarName, int iIndex)
|
|
{
|
|
DeleteLocalObject(oObject, sVarName + IntToString(iIndex));
|
|
}
|
|
|
|
void SendPlayerAOEMessage(object oOrigin, float fDistance, string sFilterVariable, string sMessage, int bPartyOnly = FALSE)
|
|
{
|
|
object oNearest = GetFirstPC();
|
|
while(GetIsObjectValid(oNearest))
|
|
{
|
|
if(GetDistanceBetween(oOrigin, oNearest) <= fDistance && GetArea(oOrigin) == GetArea(oNearest))
|
|
{
|
|
// If bPartyOnly is TRUE, the message is only sent to oOrigin's party members
|
|
if(!bPartyOnly || GetFactionEqual(oOrigin, oNearest) && bPartyOnly)
|
|
SendMessageToPC(oNearest, sMessage);
|
|
}
|
|
oNearest = GetNextPC();
|
|
}
|
|
}
|
|
|
|
void ClearAllFactionMembers(object oMember, object oPlayer)
|
|
{
|
|
//AdjustReputation(oPlayer, oMember, 50);
|
|
|
|
// Clear all faction members' reputations
|
|
object oClear = GetFirstFactionMember(oMember, FALSE);
|
|
while (GetIsObjectValid(oClear) == TRUE)
|
|
{
|
|
ClearPersonalReputation(oPlayer, oClear);
|
|
oClear = GetNextFactionMember(oMember, FALSE);
|
|
}
|
|
}
|
|
|
|
////////////////////////////
|
|
// ITEM DURABILITY SYSTEM //
|
|
////////////////////////////
|
|
|
|
// Returns the cost table ID if oItem has the Item Durability item property.
|
|
// If it doesn't have the item property, return value is -1
|
|
int DCY_CanItemHaveDurability(object oItem);
|
|
|
|
int DCY_CanItemHaveDurability(object oItem)
|
|
{
|
|
itemproperty ipDurability = GetFirstItemProperty(oItem);
|
|
while(GetIsItemPropertyValid(ipDurability))
|
|
{
|
|
int iIPType = GetItemPropertyType(ipDurability);
|
|
|
|
// Is this the Item Durability item property? If so, return the cost table value
|
|
if(iIPType == ITEM_PROPERTY_ITEM_DURABILITY)
|
|
{
|
|
return GetItemPropertyCostTableValue(ipDurability);
|
|
}
|
|
ipDurability = GetNextItemProperty(oItem);
|
|
}
|
|
|
|
// Didn't find the Item Durability item property - return -1
|
|
return -1;
|
|
}
|
|
|
|
///////////////////
|
|
// COMBAT SYSTEM //
|
|
///////////////////
|
|
|
|
// Gathers all information regarding the gun and puts it into s GunInfoStruct, then returns that struct
|
|
struct GunInfoStruct GUN_GetGunInfo(object oItem);
|
|
|
|
struct GunInfoStruct GUN_GetGunInfo(object oItem)
|
|
{
|
|
// Determine which type of ammo the weapon uses.
|
|
itemproperty ipCurItemProperty = GetFirstItemProperty(oItem);
|
|
struct GunInfoStruct stGunInfo;
|
|
|
|
while(GetIsItemPropertyValid(ipCurItemProperty))
|
|
{
|
|
int iPropertyType = GetItemPropertyType(ipCurItemProperty);
|
|
int iPropertySubType = GetItemPropertySubType(ipCurItemProperty);
|
|
|
|
// Store the gun type. (GUN_TYPE_*)
|
|
if(iPropertyType == ITEM_PROPERTY_FIREARM_TYPE)
|
|
{
|
|
stGunInfo.iGunType = GetItemPropertySubType(ipCurItemProperty);
|
|
}
|
|
// Store the gun's firepower. This is found in the iprp_firepowcost.2da file.
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_FIREPOWER)
|
|
{
|
|
int iIndex = GetItemPropertyCostTableValue(ipCurItemProperty);
|
|
stGunInfo.iFirepower = StringToInt(Get2DAString("iprp_firepowcost", "Label", iIndex));
|
|
}
|
|
// Store the gun's range setting. (IP_CONST_FIREARM_RANGE_*)
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_RANGE)
|
|
{
|
|
stGunInfo.iRangeSetting = GetItemPropertySubType(ipCurItemProperty);
|
|
}
|
|
// Store the gun's reload setting. (GUN_RELOAD_SPEED_*)
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_RELOAD_SPEED)
|
|
{
|
|
stGunInfo.iReloadSetting = GetItemPropertySubType(ipCurItemProperty);
|
|
}
|
|
// Store the gun's ammo type. (IP_CONST_FIREARM_AMMO_TYPE_*)
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_AMMO_TYPE)
|
|
{
|
|
stGunInfo.iAmmoType = GetItemPropertySubType(ipCurItemProperty);
|
|
}
|
|
// Store the gun's rate of fire. (GUN_ATTACK_SPEED_*)
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_RATE_OF_FIRE)
|
|
{
|
|
stGunInfo.iRateOfFire = GetItemPropertySubType(ipCurItemProperty);
|
|
}
|
|
// Store the gun's magazine capacity
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_MAGAZINE)
|
|
{
|
|
stGunInfo.iMagazineSize = GetItemPropertyCostTableValue(ipCurItemProperty);
|
|
}
|
|
// Store the gun's critical rating
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_CRITICAL_RATING)
|
|
{
|
|
stGunInfo.iCriticalRating = GetItemPropertyCostTableValue(ipCurItemProperty);
|
|
}
|
|
// Store what bonus ammo types are available to this gun
|
|
else if(iPropertyType == ITEM_PROPERTY_FIREARM_ADDITIONAL_AMMO_CLASSES)
|
|
{
|
|
if(iPropertySubType == IP_CONST_FIREARM_ADDITIONAL_AMMO_CLASSES_ENHANCED) stGunInfo.bEnhancedAvailable = TRUE;
|
|
else if(iPropertySubType == IP_CONST_FIREARM_ADDITIONAL_AMMO_CLASSES_INCENDIARY) stGunInfo.bIncendiaryAvailable = TRUE;
|
|
}
|
|
// Store the item's current durability
|
|
else if(iPropertyType == ITEM_PROPERTY_ITEM_DURABILITY)
|
|
{
|
|
int iIndex = GetItemPropertyCostTableValue(ipCurItemProperty);
|
|
stGunInfo.iDurability = StringToInt(Get2DAString("iprp_duracost", "Label", iIndex));
|
|
}
|
|
|
|
ipCurItemProperty = GetNextItemProperty(oItem);
|
|
}
|
|
|
|
stGunInfo.oGun = oItem;
|
|
|
|
// Return the struct
|
|
return stGunInfo;
|
|
}
|
|
|
|
// Error checking
|
|
//void main(){}
|