mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- scriptified P_DropItem.
This commit is contained in:
parent
a5fc26b37c
commit
93f91d1039
6 changed files with 91 additions and 95 deletions
|
@ -66,6 +66,7 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, telefogheight)
|
|||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defKickback)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, healthpic)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, berserkpic)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, defaultdropstyle)
|
||||
|
||||
const char *GameNames[17] =
|
||||
{
|
||||
|
|
|
@ -4240,22 +4240,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetTics)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A_DropItem
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_DropItem)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_CLASS (spawntype, AActor);
|
||||
PARAM_INT(amount);
|
||||
PARAM_INT(chance);
|
||||
|
||||
ACTION_RETURN_OBJECT(P_DropItem(self, spawntype, amount, chance));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Common A_Damage handler
|
||||
|
|
|
@ -62,7 +62,6 @@ static FRandom pr_scaredycat ("Anubis");
|
|||
FRandom pr_chase ("Chase");
|
||||
static FRandom pr_facetarget ("FaceTarget");
|
||||
static FRandom pr_railface ("RailFace");
|
||||
static FRandom pr_dropitem ("DropItem");
|
||||
static FRandom pr_look2 ("LookyLooky");
|
||||
static FRandom pr_look3 ("IGotHooky");
|
||||
static FRandom pr_slook ("SlooK");
|
||||
|
@ -79,6 +78,7 @@ static FRandom pr_enemystrafe("EnemyStrafe");
|
|||
// The result is that they tend to 'glide' across the floor
|
||||
// so this CVAR allows to switch it off.
|
||||
CVAR(Bool, nomonsterinterpolation, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||
CVAR(Int, sv_dropstyle, 0, CVAR_SERVERINFO | CVAR_ARCHIVE);
|
||||
|
||||
//
|
||||
// P_NewChaseDir related LUT.
|
||||
|
@ -3178,90 +3178,19 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
CVAR(Int, sv_dropstyle, 0, CVAR_SERVERINFO | CVAR_ARCHIVE);
|
||||
|
||||
AActor *P_DropItem (AActor *source, PClassActor *type, int dropamount, int chance)
|
||||
{
|
||||
if (type != NULL && pr_dropitem() <= chance)
|
||||
IFVM(Actor, A_DropItem)
|
||||
{
|
||||
AActor *mo;
|
||||
double spawnz = 0;
|
||||
|
||||
if (!(i_compatflags & COMPATF_NOTOSSDROPS))
|
||||
{
|
||||
int style = sv_dropstyle;
|
||||
if (style == 0)
|
||||
{
|
||||
style = gameinfo.defaultdropstyle;
|
||||
}
|
||||
if (style == 2)
|
||||
{
|
||||
spawnz = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnz = source->Height / 2;
|
||||
}
|
||||
}
|
||||
mo = Spawn(type, source->PosPlusZ(spawnz), ALLOW_REPLACE);
|
||||
if (mo != NULL)
|
||||
{
|
||||
mo->flags |= MF_DROPPED;
|
||||
mo->flags &= ~MF_NOGRAVITY; // [RH] Make sure it is affected by gravity
|
||||
if (!(i_compatflags & COMPATF_NOTOSSDROPS))
|
||||
{
|
||||
P_TossItem (mo);
|
||||
}
|
||||
if (mo->IsKindOf (RUNTIME_CLASS(AInventory)))
|
||||
{
|
||||
AInventory *inv = static_cast<AInventory *>(mo);
|
||||
ModifyDropAmount(inv, dropamount);
|
||||
inv->ItemFlags |= IF_TOSSED;
|
||||
|
||||
IFVIRTUALPTR(inv, AInventory, SpecialDropAction)
|
||||
{
|
||||
VMValue params[2] = { inv, source };
|
||||
int retval;
|
||||
VMReturn ret(&retval);
|
||||
VMCall(func, params, 2, &ret, 1);
|
||||
if (retval)
|
||||
{
|
||||
// The special action indicates that the item should not spawn
|
||||
inv->Destroy();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mo;
|
||||
}
|
||||
VMValue params[] = { source, type, dropamount, chance };
|
||||
AActor *retval;
|
||||
VMReturn ret((void**)&retval);
|
||||
VMCall(func, params, 4, &ret, 1);
|
||||
return retval;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// P_TossItem
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void P_TossItem (AActor *item)
|
||||
{
|
||||
int style = sv_dropstyle;
|
||||
if (style==0) style = gameinfo.defaultdropstyle;
|
||||
|
||||
if (style==2)
|
||||
{
|
||||
item->Vel.X += pr_dropitem.Random2(7);
|
||||
item->Vel.Y += pr_dropitem.Random2(7);
|
||||
}
|
||||
else
|
||||
{
|
||||
item->Vel.X += pr_dropitem.Random2() / 256.;
|
||||
item->Vel.Y += pr_dropitem.Random2() / 256.;
|
||||
item->Vel.Z = 5. + pr_dropitem() / 64.;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_Pain)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
|
|
|
@ -1082,7 +1082,6 @@ class Actor : Thinker native
|
|||
native void A_Quake(int intensity, int duration, int damrad, int tremrad, sound sfx = "world/quake");
|
||||
native void A_QuakeEx(int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, sound sfx = "world/quake", int flags = 0, double mulWaveX = 1, double mulWaveY = 1, double mulWaveZ = 1, int falloff = 0, int highpoint = 0, double rollIntensity = 0, double rollWave = 0);
|
||||
action native void A_SetTics(int tics);
|
||||
native Actor A_DropItem(class<Actor> item, int dropamount = -1, int chance = 256);
|
||||
native void A_DamageSelf(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
|
||||
native void A_DamageTarget(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
|
||||
native void A_DamageMaster(int amount, name damagetype = "none", int flags = 0, class<Actor> filter = null, name species = "None", int src = AAPTR_DEFAULT, int inflict = AAPTR_DEFAULT);
|
||||
|
|
|
@ -590,5 +590,87 @@ extend class Actor
|
|||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// P_TossItem
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void TossItem ()
|
||||
{
|
||||
int style = sv_dropstyle;
|
||||
if (style==0) style = gameinfo.defaultdropstyle;
|
||||
|
||||
if (style==2)
|
||||
{
|
||||
Vel.X += random2[DropItem](7);
|
||||
Vel.Y += random2[DropItem](7);
|
||||
}
|
||||
else
|
||||
{
|
||||
Vel.X += random2[DropItem]() / 256.;
|
||||
Vel.Y += random2[DropItem]() / 256.;
|
||||
Vel.Z = 5. + random[DropItem]() / 64.;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC A_DropItem
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
Actor A_DropItem(class<Actor> item, int dropamount = -1, int chance = 256)
|
||||
{
|
||||
if (item != NULL && random[DropItem]() <= chance)
|
||||
{
|
||||
Actor mo;
|
||||
double spawnz = 0;
|
||||
|
||||
if (!compat_notossdrops)
|
||||
{
|
||||
int style = sv_dropstyle;
|
||||
if (style == 0)
|
||||
{
|
||||
style = gameinfo.defaultdropstyle;
|
||||
}
|
||||
if (style == 2)
|
||||
{
|
||||
spawnz = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnz = Height / 2;
|
||||
}
|
||||
}
|
||||
mo = Spawn(item, pos + (0, 0, spawnz), ALLOW_REPLACE);
|
||||
if (mo != NULL)
|
||||
{
|
||||
mo.bDropped = true;
|
||||
mo.bNoGravity = false; // [RH] Make sure it is affected by gravity
|
||||
if (!compat_notossdrops)
|
||||
{
|
||||
mo.TossItem ();
|
||||
}
|
||||
let inv = Inventory(mo);
|
||||
if (inv)
|
||||
{
|
||||
inv.ModifyDropAmount(dropamount);
|
||||
inv.bTossed = true;
|
||||
if (inv.SpecialDropAction(self))
|
||||
{
|
||||
// The special action indicates that the item should not spawn
|
||||
inv.Destroy();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return mo;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -371,6 +371,7 @@ struct GameInfoStruct native
|
|||
native Color defaultbloodcolor;
|
||||
native double telefogheight;
|
||||
native int defKickback;
|
||||
native int defaultdropstyle;
|
||||
native TextureID healthpic;
|
||||
native TextureID berserkpic;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue