mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- scriptified cht_Takeweaps.
This commit is contained in:
parent
bc86ec4c51
commit
f218e95c4d
4 changed files with 53 additions and 37 deletions
|
@ -793,19 +793,28 @@ void G_BuildTiccmd (ticcmd_t *cmd)
|
||||||
//[Graf Zahl] This really helps if the mouse update rate can't be increased!
|
//[Graf Zahl] This really helps if the mouse update rate can't be increased!
|
||||||
CVAR (Bool, smooth_mouse, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
CVAR (Bool, smooth_mouse, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
|
|
||||||
|
static int LookAdjust(int look)
|
||||||
|
{
|
||||||
|
look <<= 16;
|
||||||
|
if (players[consoleplayer].playerstate != PST_DEAD && // No adjustment while dead.
|
||||||
|
players[consoleplayer].ReadyWeapon != NULL) // No adjustment if no weapon.
|
||||||
|
{
|
||||||
|
auto scale = players[consoleplayer].ReadyWeapon->FOVScale;
|
||||||
|
if (scale > 0) // No adjustment if it is non-positive.
|
||||||
|
{
|
||||||
|
look = int(look * scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return look;
|
||||||
|
}
|
||||||
|
|
||||||
void G_AddViewPitch (int look, bool mouse)
|
void G_AddViewPitch (int look, bool mouse)
|
||||||
{
|
{
|
||||||
if (gamestate == GS_TITLELEVEL)
|
if (gamestate == GS_TITLELEVEL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
look <<= 16;
|
look = LookAdjust(look);
|
||||||
if (players[consoleplayer].playerstate != PST_DEAD && // No adjustment while dead.
|
|
||||||
players[consoleplayer].ReadyWeapon != NULL && // No adjustment if no weapon.
|
|
||||||
players[consoleplayer].ReadyWeapon->FOVScale > 0) // No adjustment if it is non-positive.
|
|
||||||
{
|
|
||||||
look = int(look * players[consoleplayer].ReadyWeapon->FOVScale);
|
|
||||||
}
|
|
||||||
if (!level.IsFreelookAllowed())
|
if (!level.IsFreelookAllowed())
|
||||||
{
|
{
|
||||||
LocalViewPitch = 0;
|
LocalViewPitch = 0;
|
||||||
|
@ -845,14 +854,9 @@ void G_AddViewAngle (int yaw, bool mouse)
|
||||||
if (gamestate == GS_TITLELEVEL)
|
if (gamestate == GS_TITLELEVEL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
yaw <<= 16;
|
yaw = LookAdjust(yaw);
|
||||||
if (players[consoleplayer].playerstate != PST_DEAD && // No adjustment while dead.
|
|
||||||
players[consoleplayer].ReadyWeapon != NULL && // No adjustment if no weapon.
|
|
||||||
players[consoleplayer].ReadyWeapon->FOVScale > 0) // No adjustment if it is non-positive.
|
|
||||||
{
|
|
||||||
yaw = int(yaw * players[consoleplayer].ReadyWeapon->FOVScale);
|
|
||||||
}
|
|
||||||
LocalViewAngle -= yaw;
|
LocalViewAngle -= yaw;
|
||||||
if (yaw != 0)
|
if (yaw != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -416,29 +416,7 @@ void cht_DoCheat (player_t *player, int cheat)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHT_TAKEWEAPS:
|
case CHT_TAKEWEAPS:
|
||||||
if (player->morphTics || player->mo == NULL || player->mo->health <= 0)
|
cht_Takeweaps(player);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Take away all weapons that are either non-wimpy or use ammo.
|
|
||||||
AInventory **invp = &player->mo->Inventory, **lastinvp;
|
|
||||||
for (item = *invp; item != NULL; item = *invp)
|
|
||||||
{
|
|
||||||
lastinvp = invp;
|
|
||||||
invp = &(*invp)->Inventory;
|
|
||||||
if (item->IsKindOf(NAME_Weapon))
|
|
||||||
{
|
|
||||||
AWeapon *weap = static_cast<AWeapon *> (item);
|
|
||||||
if (!(weap->WeaponFlags & WIF_WIMPY_WEAPON) ||
|
|
||||||
weap->AmmoType1 != NULL)
|
|
||||||
{
|
|
||||||
item->Destroy ();
|
|
||||||
invp = lastinvp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg = GStrings("TXT_CHEATIDKFA");
|
msg = GStrings("TXT_CHEATIDKFA");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -613,6 +591,15 @@ void cht_Take (player_t *player, const char *name, int amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cht_Takeweaps(player_t *player)
|
||||||
|
{
|
||||||
|
IFVIRTUALPTR(player->mo, APlayerPawn, CheatTakeWeaps)
|
||||||
|
{
|
||||||
|
VMValue params[3] = { player->mo };
|
||||||
|
VMCall(func, params, 1, nullptr, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DSuicider : public DThinker
|
class DSuicider : public DThinker
|
||||||
{
|
{
|
||||||
DECLARE_CLASS(DSuicider, DThinker)
|
DECLARE_CLASS(DSuicider, DThinker)
|
||||||
|
|
|
@ -16,5 +16,6 @@ void cht_Take (player_t *player, const char *item, int amount=1);
|
||||||
void cht_SetInv(player_t *player, const char *item, int amount = 1, bool beyondMax = false);
|
void cht_SetInv(player_t *player, const char *item, int amount = 1, bool beyondMax = false);
|
||||||
void cht_Suicide (player_t *player);
|
void cht_Suicide (player_t *player);
|
||||||
FString cht_Morph (player_t *player, PClassActor *morphclass, bool quickundo);
|
FString cht_Morph (player_t *player, PClassActor *morphclass, bool quickundo);
|
||||||
|
void cht_Takeweaps(player_t *player);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -426,4 +426,28 @@ extend class PlayerPawn
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void CheatTakeWeaps()
|
||||||
|
{
|
||||||
|
if (player.morphTics || health <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Do not mass-delete directly from the linked list. That can cause problems.
|
||||||
|
Array<Inventory> collect;
|
||||||
|
// Take away all weapons that are either non-wimpy or use ammo.
|
||||||
|
for(let item = Inv; item; item = item.Inv)
|
||||||
|
{
|
||||||
|
let weap = Weapon(item);
|
||||||
|
if (weap && (!weap.bWimpy_Weapon || weap.AmmoType1 != null))
|
||||||
|
{
|
||||||
|
collect.Push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Destroy them in a second loop. We have to look out for indirect destructions here as will happen with powered up weapons.
|
||||||
|
for(int i = 0; i < collect.Size(); i++)
|
||||||
|
{
|
||||||
|
let item = collect[i];
|
||||||
|
if (item) item.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue