mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- scriptified invnext and invprev CCMDs.
This commit is contained in:
parent
5c647de70c
commit
577af8860c
3 changed files with 88 additions and 55 deletions
|
@ -372,79 +372,43 @@ CCMD (weapprev)
|
|||
}
|
||||
}
|
||||
|
||||
static void DisplayNameTag(const char *tag)
|
||||
static void DisplayNameTag(AActor *actor)
|
||||
{
|
||||
auto tag = actor->GetTag();
|
||||
if ((displaynametags & 1) && StatusBar && SmallFont)
|
||||
StatusBar->AttachMessage(Create<DHUDMessageFadeOut>(SmallFont, tag,
|
||||
1.5f, 0.80f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID('S', 'I', 'N', 'V'));
|
||||
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, DisplayNameTag, DisplayNameTag)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
DisplayNameTag(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCMD (invnext)
|
||||
{
|
||||
AInventory *next;
|
||||
|
||||
if (who == NULL)
|
||||
return;
|
||||
|
||||
auto old = who->InvSel;
|
||||
if (who->InvSel != NULL)
|
||||
if (who != NULL)
|
||||
{
|
||||
if ((next = who->InvSel->NextInv()) != NULL)
|
||||
IFVM(PlayerPawn, InvNext)
|
||||
{
|
||||
who->InvSel = next;
|
||||
VMValue param = who;
|
||||
VMCall(func, ¶m, 1, nullptr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the first item in the inventory
|
||||
if (!(who->Inventory->ItemFlags & IF_INVBAR))
|
||||
{
|
||||
who->InvSel = who->Inventory->NextInv();
|
||||
}
|
||||
else
|
||||
{
|
||||
who->InvSel = who->Inventory;
|
||||
}
|
||||
}
|
||||
if (who->InvSel) DisplayNameTag(who->InvSel->GetTag());
|
||||
}
|
||||
who->player->inventorytics = 5*TICRATE;
|
||||
if (old != who->InvSel)
|
||||
{
|
||||
S_Sound(CHAN_AUTO, "misc/invchange", 1.0, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (invprev)
|
||||
CCMD(invprev)
|
||||
{
|
||||
AInventory *item, *newitem;
|
||||
|
||||
if (who == NULL)
|
||||
return;
|
||||
|
||||
auto old = who->InvSel;
|
||||
if (who->InvSel != NULL)
|
||||
if (who != NULL)
|
||||
{
|
||||
if ((item = who->InvSel->PrevInv()) != NULL)
|
||||
IFVM(PlayerPawn, InvNext)
|
||||
{
|
||||
who->InvSel = item;
|
||||
VMValue param = who;
|
||||
VMCall(func, ¶m, 1, nullptr, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the last item in the inventory
|
||||
item = who->InvSel;
|
||||
while ((newitem = item->NextInv()) != NULL)
|
||||
{
|
||||
item = newitem;
|
||||
}
|
||||
who->InvSel = item;
|
||||
}
|
||||
if (who->InvSel) DisplayNameTag(who->InvSel->GetTag());
|
||||
}
|
||||
who->player->inventorytics = 5*TICRATE;
|
||||
if (old != who->InvSel)
|
||||
{
|
||||
S_Sound(CHAN_AUTO, "misc/invchange", 1.0, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -457,6 +457,7 @@ class Actor : Thinker native
|
|||
virtual native bool Slam(Actor victim);
|
||||
virtual native void Touch(Actor toucher);
|
||||
native void Substitute(Actor replacement);
|
||||
native ui void DisplayNameTag();
|
||||
|
||||
// Called by PIT_CheckThing to check if two actors actually can collide.
|
||||
virtual bool CanCollideWith(Actor other, bool passive)
|
||||
|
@ -998,7 +999,7 @@ class Actor : Thinker native
|
|||
|
||||
deprecated("2.3") native void A_BulletAttack();
|
||||
native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", double snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, double runspeed = 160.0, class<Actor> pufftype = "BulletPuff");
|
||||
native void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false);
|
||||
native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false);
|
||||
native void A_SoundVolume(int slot, double volume);
|
||||
deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_PlaySound(whattoplay, CHAN_WEAPON); }
|
||||
native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was...
|
||||
|
|
|
@ -1,5 +1,73 @@
|
|||
extend class PlayerPawn
|
||||
{
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
ui void InvNext()
|
||||
{
|
||||
Inventory next;
|
||||
|
||||
let old = InvSel;
|
||||
if (InvSel != NULL)
|
||||
{
|
||||
if ((next = InvSel.NextInv()) != NULL)
|
||||
{
|
||||
InvSel = next;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the first item in the inventory
|
||||
InvSel = FirstInv();
|
||||
}
|
||||
if (InvSel) InvSel.DisplayNameTag();
|
||||
}
|
||||
player.inventorytics = 5*TICRATE;
|
||||
if (old != InvSel)
|
||||
{
|
||||
A_PlaySound("misc/invchange", CHAN_AUTO, 1.0, false, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APlayerPawn :: AddInventory
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
ui void InvPrev()
|
||||
{
|
||||
Inventory item, newitem;
|
||||
|
||||
let old = InvSel;
|
||||
if (InvSel != NULL)
|
||||
{
|
||||
if ((item = InvSel.PrevInv()) != NULL)
|
||||
{
|
||||
InvSel = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the last item in the inventory
|
||||
item = InvSel;
|
||||
while ((newitem = item.NextInv()) != NULL)
|
||||
{
|
||||
item = newitem;
|
||||
}
|
||||
InvSel = item;
|
||||
}
|
||||
if (InvSel) InvSel.DisplayNameTag();
|
||||
}
|
||||
player.inventorytics = 5*TICRATE;
|
||||
if (old != InvSel)
|
||||
{
|
||||
A_PlaySound("misc/invchange", CHAN_AUTO, 1.0, false, ATTN_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APlayerPawn :: AddInventory
|
||||
|
|
Loading…
Reference in a new issue