Skip to content

Commit

Permalink
Fixed|Hexen: Incorrect mana given on collection of fourth-weapon piece
Browse files Browse the repository at this point in the history
IssueID #2045
  • Loading branch information
danij-deng authored and skyjake committed May 12, 2015
1 parent 439e144 commit 05f0b12
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 160 deletions.
17 changes: 11 additions & 6 deletions doomsday/apps/plugins/common/src/g_game.cpp
Expand Up @@ -2810,7 +2810,7 @@ int gsvInvItems[NUM_INVENTORYITEM_TYPES];
#endif

#if __JHEXEN__
int gsvWPieces[4];
int gsvWPieces[WEAPON_FOURTH_PIECE_COUNT + 1];
#endif
}

Expand Down Expand Up @@ -2920,11 +2920,6 @@ static void registerGameStatusCVars()
{"player-weapon-second", READONLYCVAR, CVT_INT, &gsvWeapons[WT_SECOND], 0, 0, 0},
{"player-weapon-third", READONLYCVAR, CVT_INT, &gsvWeapons[WT_THIRD], 0, 0, 0},
{"player-weapon-fourth", READONLYCVAR, CVT_INT, &gsvWeapons[WT_FOURTH], 0, 0, 0},
// Weapon Pieces
{"player-weapon-piece1", READONLYCVAR, CVT_INT, &gsvWPieces[0], 0, 0, 0},
{"player-weapon-piece2", READONLYCVAR, CVT_INT, &gsvWPieces[1], 0, 0, 0},
{"player-weapon-piece3", READONLYCVAR, CVT_INT, &gsvWPieces[2], 0, 0, 0},
{"player-weapon-allpieces", READONLYCVAR, CVT_INT, &gsvWPieces[3], 0, 0, 0},
// Inventory items
{"player-artifact-defender", READONLYCVAR, CVT_INT, &gsvInvItems[IIT_INVULNERABILITY], 0, 0, 0},
{"player-artifact-quartzflask", READONLYCVAR, CVT_INT, &gsvInvItems[IIT_HEALTH], 0, 0, 0},
Expand Down Expand Up @@ -2962,6 +2957,16 @@ static void registerGameStatusCVars()
{NULL, 0, CVT_NULL, 0, 0, 0, 0}
};
Con_AddVariableList(cvars);

#if __JHEXEN__
// Fourth-weapon pieces:
for(int i = 0; i < WEAPON_FOURTH_PIECE_COUNT; ++i)
{
Block const cvarName = String("player-weapon-piece%1").arg(i + 1).toUtf8();
C_VAR_INT(cvarName.constData(), &gsvWPieces[i], READONLYCVAR, 0, 1);
}
C_VAR_INT("player-weapon-allpieces", &gsvWPieces[WEAPON_FOURTH_PIECE_COUNT], READONLYCVAR, 0, 1);
#endif
}

void G_ConsoleRegister()
Expand Down
16 changes: 9 additions & 7 deletions doomsday/apps/plugins/common/src/p_user.c
Expand Up @@ -143,9 +143,9 @@ classinfo_t classInfo[NUM_PLAYER_CLASSES] = {
18,
SFX_PLAYER_FIGHTER_FAILED_USE,
{25 * FRACUNIT, 20 * FRACUNIT, 15 * FRACUNIT, 5 * FRACUNIT},
{190, 225, 234},
{ TXT_SKILLF1, TXT_SKILLF2, TXT_SKILLF3, TXT_SKILLF4, TXT_SKILLF5 }

{ TXT_SKILLF1, TXT_SKILLF2, TXT_SKILLF3, TXT_SKILLF4, TXT_SKILLF5 },
{ { { 190, 0 }, "WPIECEF1" }, { { 225, 0 }, "WPIECEF2" }, { { 234, 0 }, "WPIECEF3" } },
"WPFULL0"
},
{ // Cleric
PCLASS_CLERIC, NULL, true,
Expand All @@ -164,8 +164,9 @@ classinfo_t classInfo[NUM_PLAYER_CLASSES] = {
18,
SFX_PLAYER_CLERIC_FAILED_USE,
{10 * FRACUNIT, 25 * FRACUNIT, 5 * FRACUNIT, 20 * FRACUNIT},
{190, 212, 225},
{ TXT_SKILLC1, TXT_SKILLC2, TXT_SKILLC3, TXT_SKILLC4, TXT_SKILLC5 }
{ TXT_SKILLC1, TXT_SKILLC2, TXT_SKILLC3, TXT_SKILLC4, TXT_SKILLC5 },
{ { { 190, 0 }, "WPIECEC1" }, { { 212, 0 }, "WPIECEC2" }, { { 225, 0 }, "WPIECEC3" } },
"WPFULL1"
},
{ // Mage
PCLASS_MAGE, NULL, true,
Expand All @@ -184,8 +185,9 @@ classinfo_t classInfo[NUM_PLAYER_CLASSES] = {
18,
SFX_PLAYER_MAGE_FAILED_USE,
{5 * FRACUNIT, 15 * FRACUNIT, 10 * FRACUNIT, 25 * FRACUNIT},
{190, 205, 224},
{ TXT_SKILLM1, TXT_SKILLM2, TXT_SKILLM3, TXT_SKILLM4, TXT_SKILLM5 }
{ TXT_SKILLM1, TXT_SKILLM2, TXT_SKILLM3, TXT_SKILLM4, TXT_SKILLM5 },
{ { { 190, 0 }, "WPIECEM1" }, { { 205, 0 }, "WPIECEM2" }, { { 224, 0 }, "WPIECEM3" } },
"WPFULL2"
},
{ // Pig
PCLASS_PIG, NULL, false,
Expand Down
19 changes: 10 additions & 9 deletions doomsday/apps/plugins/common/src/player.cpp
Expand Up @@ -1882,16 +1882,17 @@ void Player_UpdateStatusCVars(player_t const *player)
};
for(int i = 0; i < NUM_WEAPON_TYPES; ++i)
{
String cvarName = String("player-weapon-%1").arg(weaponIds[i]);
Con_SetInteger2(cvarName.toUtf8().constData(), player->weapons[i].owned, SVF_WRITE_OVERRIDE);
Block cvarName = String("player-weapon-%1").arg(weaponIds[i]).toUtf8();
Con_SetInteger2(cvarName.constData(), player->weapons[i].owned, SVF_WRITE_OVERRIDE);
}

#if __JHEXEN__
// Weapon pieces.
Con_SetInteger2("player-weapon-piece1", (player->pieces & WPIECE1)? 1 : 0, SVF_WRITE_OVERRIDE);
Con_SetInteger2("player-weapon-piece2", (player->pieces & WPIECE2)? 1 : 0, SVF_WRITE_OVERRIDE);
Con_SetInteger2("player-weapon-piece3", (player->pieces & WPIECE3)? 1 : 0, SVF_WRITE_OVERRIDE);
Con_SetInteger2("player-weapon-allpieces", (player->pieces == 7)? 1 : 0, SVF_WRITE_OVERRIDE);
for(int i = 0; i < WEAPON_FOURTH_PIECE_COUNT; ++i)
{
Block cvarName = String("player-weapon-piece%1").arg(i + 1).toUtf8();
Con_SetInteger2(cvarName.constData(), (player->pieces & (1 << i))? 1 : 0, SVF_WRITE_OVERRIDE);
}
Con_SetInteger2("player-weapon-allpieces", (player->pieces == WEAPON_FOURTH_COMPLETE)? 1 : 0, SVF_WRITE_OVERRIDE);
#endif

// Current ammo amounts.
Expand All @@ -1915,8 +1916,8 @@ void Player_UpdateStatusCVars(player_t const *player)
};
for(int i = 0; i < NUM_AMMO_TYPES; ++i)
{
String cvarName = String("player-ammo-%1").arg(ammoIds[i]);
Con_SetInteger2(cvarName.toUtf8().constData(), player->ammo[i].owned, SVF_WRITE_OVERRIDE);
Block cvarName = String("player-ammo-%1").arg(ammoIds[i]).toUtf8();
Con_SetInteger2(cvarName.constData(), player->ammo[i].owned, SVF_WRITE_OVERRIDE);
}

#if __JHERETIC__ || __JHEXEN__ || __JDOOM64__
Expand Down
74 changes: 40 additions & 34 deletions doomsday/apps/plugins/hexen/include/h2def.h
Expand Up @@ -146,6 +146,30 @@ typedef enum {
NUMARMOR
} armortype_t;

/**
* Player weapon types:
*/
typedef enum {
WT_FIRST,
WT_SECOND,
WT_THIRD,
WT_FOURTH,
NUM_WEAPON_TYPES,

WT_NOCHANGE ///< No pending change.
} weapontype_t;

#define VALID_WEAPONTYPE(val) ((val) >= WT_FIRST && (val) < WT_FIRST + NUM_WEAPON_TYPES)

// Total number of weapon power levels.
#define NUMWEAPLEVELS ( 1 )

// Total number of pieces for the fourth weapon.
#define WEAPON_FOURTH_PIECE_COUNT ( 3 )

// All fourth-weapon pieces in bits.
#define WEAPON_FOURTH_COMPLETE ((WEAPON_FOURTH_PIECE_COUNT << 1) + 1)

/**
* Player Classes
*/
Expand All @@ -161,11 +185,12 @@ typedef enum {

#define VALID_PLAYER_CLASS(c) ((c) >= PCLASS_FIRST && (c) < NUM_PLAYER_CLASSES)

#define PCLASS_INFO(c) (&classInfo[c])
#define PCLASS_INFO(plrClass) (&classInfo[plrClass])

typedef struct classinfo_s{
typedef struct classinfo_s
{
playerclass_t plrClass;
const char* niceName;
char const *niceName;
dd_bool userSelectable;
mobjtype_t mobjType;
int normalState;
Expand All @@ -175,15 +200,20 @@ typedef struct classinfo_s{
int maxArmor;
int autoArmorSave;
fixed_t maxMove;
fixed_t forwardMove[2]; // walk, run.
fixed_t sideMove[2]; // walk, run.
int moveMul; // multiplier for above.
int turnSpeed[3]; // [normal, speed, initial].
int jumpTics; // wait inbetween jumps.
int failUseSound; // sound played when a use fails.
fixed_t forwardMove[2]; ///< walk, run.
fixed_t sideMove[2]; ///< walk, run.
int moveMul; ///< multiplier for above.
int turnSpeed[3]; ///< [normal, speed, initial].
int jumpTics; ///< wait inbetween jumps.
int failUseSound; ///< sound played when a use fails.
int armorIncrement[NUMARMOR];
int pieceX[3]; // temp.
textenum_t skillModeNames[NUM_SKILL_MODES];
struct weaponpiecedata_s
{
Point2Raw offset;
char const *patchName;
} fourthWeaponPiece[WEAPON_FOURTH_PIECE_COUNT];
char const *fourthWeaponCompletePatchName;
} classinfo_t;

DENG_EXTERN_C classinfo_t classInfo[NUM_PLAYER_CLASSES];
Expand Down Expand Up @@ -223,30 +253,6 @@ typedef enum {
NUM_KEY_TYPES
} keytype_t;

/**
* Weapon ids.
*
* The defined weapons, including a marker indicating user has not changed
* weapon.
*/
typedef enum {
WT_FIRST,
WT_SECOND,
WT_THIRD,
WT_FOURTH,
NUM_WEAPON_TYPES,

WT_NOCHANGE // No pending weapon change.
} weapontype_t;

#define WPIECE1 1
#define WPIECE2 2
#define WPIECE3 4

#define VALID_WEAPONTYPE(val) ((val) >= WT_FIRST && (val) < WT_FIRST + NUM_WEAPON_TYPES)

#define NUMWEAPLEVELS 1 // Number of weapon power levels.

/**
* Ammunition types.
*/
Expand Down
10 changes: 8 additions & 2 deletions doomsday/apps/plugins/hexen/include/p_inter.h
Expand Up @@ -40,10 +40,16 @@ dd_bool P_GiveKey(player_t *player, keytype_t keyType);
* @return @c true if the weapon or its ammo was accepted.
*/
dd_bool P_GiveWeapon2(player_t *player, weapontype_t weaponType, playerclass_t matchClass);
dd_bool P_GiveWeapon(player_t *player, weapontype_t weaponType/*, playerclass_t matchClass = player->class_*/);
dd_bool P_GiveWeapon (player_t *player, weapontype_t weaponType/*, playerclass_t matchClass = player->class_*/);

/**
* @param player Player to receive the weapon pieces.
* @param weaponPiece Logical fourth-weapon piece number. Use @c WEAPON_FOURTH_PIECE_COUNT
* to give one of each fourth-weapon piece.
* @param matchClass Only give the piece(s) if the player-class matches.
*/
dd_bool P_GiveWeaponPiece2(player_t *player, int pieceValue, playerclass_t matchClass);
dd_bool P_GiveWeaponPiece(player_t *player, int pieceValue/*, playerclass_t matchClass = player->class_*/);
dd_bool P_GiveWeaponPiece (player_t *player, int pieceValue/*, playerclass_t matchClass = player->class_*/);

dd_bool P_GiveArmor(player_t *player, armortype_t armorType);

Expand Down
4 changes: 1 addition & 3 deletions doomsday/apps/plugins/hexen/src/m_cheat.cpp
Expand Up @@ -412,9 +412,7 @@ D_CMD(CheatReveal)
static void giveAllWeaponsAndPieces(player_t *plr)
{
P_GiveWeapon(plr, NUM_WEAPON_TYPES /*all types*/);
P_GiveWeaponPiece(plr, WPIECE1);
P_GiveWeaponPiece(plr, WPIECE2);
P_GiveWeaponPiece(plr, WPIECE3);
P_GiveWeaponPiece(plr, WEAPON_FOURTH_PIECE_COUNT /*all pieces*/);
}

D_CMD(CheatGive)
Expand Down

0 comments on commit 05f0b12

Please sign in to comment.