mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- scriptified useflechette CCMD's item finding code.
This commit is contained in:
parent
9e80caa85d
commit
bc47fdfa78
4 changed files with 47 additions and 34 deletions
|
@ -137,8 +137,6 @@ public:
|
|||
double AttackZOffset; // attack height, relative to player center
|
||||
double UseRange; // [NS] Distance at which player can +use
|
||||
double AirCapacity; // Multiplier for air supply underwater.
|
||||
PClassActor *FlechetteType;
|
||||
|
||||
|
||||
// [CW] Fades for when you are being damaged.
|
||||
PalEntry DamageFade;
|
||||
|
@ -156,6 +154,9 @@ public:
|
|||
uint8_t ColorRangeStart; // Skin color range
|
||||
uint8_t ColorRangeEnd;
|
||||
|
||||
// Everything below this point is only used by scripted code.
|
||||
PClassActor *FlechetteType;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
|
|
@ -467,40 +467,17 @@ CCMD (drop)
|
|||
}
|
||||
}
|
||||
|
||||
PClassActor *GetFlechetteType(AActor *other);
|
||||
|
||||
CCMD (useflechette)
|
||||
{ // Select from one of arti_poisonbag1-3, whichever the player has
|
||||
static const ENamedName bagnames[3] =
|
||||
{
|
||||
NAME_ArtiPoisonBag3, // use type 3 first because that's the default when the player has none specified.
|
||||
NAME_ArtiPoisonBag1,
|
||||
NAME_ArtiPoisonBag2
|
||||
};
|
||||
if (who == nullptr) return;
|
||||
IFVIRTUALPTR(who, APlayerPawn, GetFlechetteItem)
|
||||
{
|
||||
VMValue params[] = { who };
|
||||
AActor *cls;
|
||||
VMReturn ret((void**)&cls);
|
||||
VMCall(func, params, 1, &ret, 1);
|
||||
|
||||
if (who == NULL)
|
||||
return;
|
||||
|
||||
PClassActor *type = who->FlechetteType;
|
||||
if (type != NULL)
|
||||
{
|
||||
AActor *item;
|
||||
if ( (item = who->FindInventory (type) ))
|
||||
{
|
||||
SendItemUse = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The default flechette could not be found, or the player had no default. Try all 3 types then.
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
AActor *item;
|
||||
if ( (item = who->FindInventory (bagnames[j])) )
|
||||
{
|
||||
SendItemUse = item;
|
||||
break;
|
||||
}
|
||||
if (cls != nullptr) SendItemUse = cls;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class PlayerPawn : Actor native
|
|||
native double AttackZOffset; // attack height, relative to player center
|
||||
native double UseRange; // [NS] Distance at which player can +use
|
||||
native double AirCapacity; // Multiplier for air supply underwater.
|
||||
native Class<Actor> FlechetteType;
|
||||
native Class<Inventory> FlechetteType;
|
||||
native color DamageFade; // [CW] Fades for when you are being damaged.
|
||||
native double ViewBob; // [SP] ViewBob Multiplier
|
||||
native double FullHeight;
|
||||
|
|
|
@ -320,5 +320,40 @@ extend class PlayerPawn
|
|||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Helper for 'useflechette' CCMD.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
protected virtual Inventory GetFlechetteItem()
|
||||
{
|
||||
// Select from one of arti_poisonbag1-3, whichever the player has
|
||||
static const Class<Inventory> bagtypes[] = {
|
||||
"ArtiPoisonBag3", // use type 3 first because that's the default when the player has none specified.
|
||||
"ArtiPoisonBag1",
|
||||
"ArtiPoisonBag2"
|
||||
};
|
||||
|
||||
if (FlechetteType != NULL)
|
||||
{
|
||||
let item = FindInventory(FlechetteType);
|
||||
if (item != null)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
// The default flechette could not be found, or the player had no default. Try all 3 types then.
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
let item = FindInventory(bagtypes[j]);
|
||||
if (item != null)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue