Add healing items improvements (#29)
This commit is contained in:
parent
c3bffa6777
commit
d482f0e610
|
@ -988,8 +988,7 @@ static int _ai_check_drugs(Object* critter)
|
|||
}
|
||||
|
||||
int drugPid = drug->pid;
|
||||
if ((drugPid == PROTO_ID_STIMPACK || drugPid == PROTO_ID_SUPER_STIMPACK || drugPid == PROTO_ID_HEALING_POWDER)
|
||||
&& itemRemove(critter, drug, 1) == 0) {
|
||||
if (itemIsHealing(drugPid) && itemRemove(critter, drug, 1) == 0) {
|
||||
if (_item_d_take_drug(critter, drug) == -1) {
|
||||
itemAdd(critter, drug, 1);
|
||||
} else {
|
||||
|
@ -1027,8 +1026,7 @@ static int _ai_check_drugs(Object* critter)
|
|||
}
|
||||
|
||||
if (index < AI_PACKET_CHEM_PRIMARY_DESIRE_COUNT) {
|
||||
if (drugPid != PROTO_ID_STIMPACK && drugPid != PROTO_ID_SUPER_STIMPACK && drugPid != 273
|
||||
&& itemRemove(critter, drug, 1) == 0) {
|
||||
if (!itemIsHealing(drugPid) && itemRemove(critter, drug, 1) == 0) {
|
||||
if (_item_d_take_drug(critter, drug) == -1) {
|
||||
itemAdd(critter, drug, 1);
|
||||
} else {
|
||||
|
|
54
src/item.cc
54
src/item.cc
|
@ -67,6 +67,10 @@ static void explosionsInit();
|
|||
static void explosionsReset();
|
||||
static void explosionsExit();
|
||||
|
||||
static void healingItemsInit();
|
||||
static void healingItemsInitVanilla();
|
||||
static void healingItemsInitCustom();
|
||||
|
||||
typedef struct DrugDescription {
|
||||
int drugPid;
|
||||
int gvar;
|
||||
|
@ -179,6 +183,7 @@ static int gExplosionFrm;
|
|||
static int gExplosionRadius;
|
||||
static int gExplosionDamageType;
|
||||
static int gExplosionMaxTargets;
|
||||
static int gHealingItemPids[HEALING_ITEM_COUNT];
|
||||
|
||||
// 0x4770E0
|
||||
int itemsInit()
|
||||
|
@ -197,6 +202,7 @@ int itemsInit()
|
|||
// SFALL
|
||||
booksInit();
|
||||
explosionsInit();
|
||||
healingItemsInit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3584,3 +3590,51 @@ void explosionSetMaxTargets(int maxTargets)
|
|||
{
|
||||
gExplosionMaxTargets = maxTargets;
|
||||
}
|
||||
|
||||
static void healingItemsInit()
|
||||
{
|
||||
healingItemsInitVanilla();
|
||||
healingItemsInitCustom();
|
||||
}
|
||||
|
||||
static void healingItemsInitVanilla()
|
||||
{
|
||||
gHealingItemPids[HEALING_ITEM_STIMPACK] = PROTO_ID_STIMPACK;
|
||||
gHealingItemPids[HEALING_ITEM_SUPER_STIMPACK] = PROTO_ID_SUPER_STIMPACK;
|
||||
gHealingItemPids[HEALING_ITEM_HEALING_POWDER] = PROTO_ID_HEALING_POWDER;
|
||||
}
|
||||
|
||||
static void healingItemsInitCustom()
|
||||
{
|
||||
char* tweaksFilePath = NULL;
|
||||
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_TWEAKS_FILE_KEY, &tweaksFilePath);
|
||||
if (tweaksFilePath != NULL && *tweaksFilePath == '\0') {
|
||||
tweaksFilePath = NULL;
|
||||
}
|
||||
|
||||
if (tweaksFilePath == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Config tweaksConfig;
|
||||
if (configInit(&tweaksConfig)) {
|
||||
if (configRead(&tweaksConfig, tweaksFilePath, false)) {
|
||||
configGetInt(&gSfallConfig, "Items", "STIMPAK", &(gHealingItemPids[HEALING_ITEM_STIMPACK]));
|
||||
configGetInt(&gSfallConfig, "Items", "SUPER_STIMPAK", &(gHealingItemPids[HEALING_ITEM_SUPER_STIMPACK]));
|
||||
configGetInt(&gSfallConfig, "Items", "HEALING_POWDER", &(gHealingItemPids[HEALING_ITEM_HEALING_POWDER]));
|
||||
}
|
||||
|
||||
configFree(&tweaksConfig);
|
||||
}
|
||||
}
|
||||
|
||||
bool itemIsHealing(int pid)
|
||||
{
|
||||
for (int index = 0; index < HEALING_ITEM_COUNT; index++) {
|
||||
if (gHealingItemPids[index] == pid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,13 @@ typedef enum _WeaponClass {
|
|||
ATTACK_TYPE_COUNT,
|
||||
} WeaponClass;
|
||||
|
||||
typedef enum HealingItem {
|
||||
HEALING_ITEM_STIMPACK,
|
||||
HEALING_ITEM_SUPER_STIMPACK,
|
||||
HEALING_ITEM_HEALING_POWDER,
|
||||
HEALING_ITEM_COUNT,
|
||||
} HealingItem;
|
||||
|
||||
int itemsInit();
|
||||
void itemsReset();
|
||||
void itemsExit();
|
||||
|
@ -143,5 +150,6 @@ int explosionGetDamageType();
|
|||
void explosionSetDamageType(int damageType);
|
||||
int explosionGetMaxTargets();
|
||||
void explosionSetMaxTargets(int maxTargets);
|
||||
bool itemIsHealing(int pid);
|
||||
|
||||
#endif /* ITEM_H */
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#define SFALL_CONFIG_USE_REPAIR_FRM_KEY "Repair"
|
||||
#define SFALL_CONFIG_SCIENCE_REPAIR_TARGET_TYPE_KEY "ScienceOnCritters"
|
||||
#define SFALL_CONFIG_GAME_DIALOG_FIX_KEY "DialogueFix"
|
||||
#define SFALL_CONFIG_TWEAKS_FILE_KEY "TweaksFile"
|
||||
|
||||
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_MULTIPLIER 1
|
||||
#define SFALL_CONFIG_BURST_MOD_DEFAULT_CENTER_DIVISOR 3
|
||||
|
|
Loading…
Reference in New Issue