mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
106 lines
2.2 KiB
Text
106 lines
2.2 KiB
Text
|
|
||
|
// Container for utility functions used by ACS and FraggleScript.
|
||
|
|
||
|
class ScriptUtil play
|
||
|
{
|
||
|
|
||
|
//==========================================================================
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//==========================================================================
|
||
|
|
||
|
static int SetWeapon(Actor activator, class<Inventory> cls)
|
||
|
{
|
||
|
if(activator != NULL && activator.player != NULL && cls != null)
|
||
|
{
|
||
|
let item = Weapon(activator.FindInventory(cls));
|
||
|
|
||
|
if(item != NULL)
|
||
|
{
|
||
|
if(activator.player.ReadyWeapon == item)
|
||
|
{
|
||
|
// The weapon is already selected, so setweapon succeeds by default,
|
||
|
// but make sure the player isn't switching away from it.
|
||
|
activator.player.PendingWeapon = WP_NOCHANGE;
|
||
|
return 1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if(item.CheckAmmo(Weapon.EitherFire, false))
|
||
|
{
|
||
|
// There's enough ammo, so switch to it.
|
||
|
activator.player.PendingWeapon = item;
|
||
|
return 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
//==========================================================================
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//==========================================================================
|
||
|
|
||
|
static void SetMarineWeapon(Actor activator, int tid, int marineweapontype)
|
||
|
{
|
||
|
if (tid != 0)
|
||
|
{
|
||
|
let it = ActorIterator.Create(tid, 'ScriptedMarine');
|
||
|
ScriptedMarine marine;
|
||
|
|
||
|
while ((marine = ScriptedMarine(it.Next())) != NULL)
|
||
|
{
|
||
|
marine.SetWeapon(marineweapontype);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
let marine = ScriptedMarine(activator);
|
||
|
if (marine != null)
|
||
|
{
|
||
|
marine.SetWeapon(marineweapontype);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//==========================================================================
|
||
|
//
|
||
|
//
|
||
|
//
|
||
|
//==========================================================================
|
||
|
|
||
|
static void SetMarineSprite(Actor activator, int tid, class<Actor> type)
|
||
|
{
|
||
|
if (type != NULL)
|
||
|
{
|
||
|
if (tid != 0)
|
||
|
{
|
||
|
let it = ActorIterator.Create(tid, 'ScriptedMarine');
|
||
|
ScriptedMarine marine;
|
||
|
|
||
|
while ((marine = ScriptedMarine(it.Next())) != NULL)
|
||
|
{
|
||
|
marine.SetSprite(type);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
let marine = ScriptedMarine(activator);
|
||
|
if (marine != null)
|
||
|
{
|
||
|
marine.SetSprite(type);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Console.Printf ("Unknown actor type: %s\n", type.GetClassName());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|