Skip to content

Instantly share code, notes, and snippets.

@TheBloke
Last active May 18, 2020 12:47
Show Gist options
  • Save TheBloke/75a28a41b7aa678e8d92c84ef963c7e3 to your computer and use it in GitHub Desktop.
Save TheBloke/75a28a41b7aa678e8d92c84ef963c7e3 to your computer and use it in GitHub Desktop.
exec function zoltan()
{
var template : CEntityTemplate;
var zolt : CNewNPC;
var pos : Vector;
pos = thePlayer.GetWorldPosition() + Vector( 2.5f, 0.0f, 0.0f, 0.0f );
template = (CEntityTemplate)LoadResource('zoltan');
zolt = (CNewNPC)theGame.CreateEntity(template, pos, thePlayer.GetWorldRotation());
zolt.AddTag('findzoltan');
}
exec function zoltweapon()
{
var zolt : CNewNPC;
var weapon_l_id : SItemUniqueId;
var weapon_r_id : SItemUniqueId;
var weapon_l : CItemEntity;
var weapon_r : CItemEntity;
zolt = (CNewNPC)theGame.GetEntityByTag('findzoltan');
if (zolt)
{
weapon_l_id = zolt.GetInventory().GetItemFromSlot('l_weapon');
weapon_r_id = zolt.GetInventory().GetItemFromSlot('r_weapon');
if (weapon_l_id != GetInvalidUniqueId())
{
weapon_l = zolt.GetInventory().GetItemEntityUnsafe(weapon_l_id);
if (weapon_l)
LogChannel('exec', "Zoltan's left weapon is " + weapon_l);
}
else
LogChannel('exec', "COULD NOT FIND ZOLTAN LEFT WEAPON ID");
if (weapon_r_id != GetInvalidUniqueId())
{
weapon_r = zolt.GetInventory().GetItemEntityUnsafe(weapon_r_id);
if (weapon_r)
LogChannel('exec', "Zoltan's right weapon is " + weapon_r);
}
else
LogChannel('exec', "COULD NOT FIND ZOLTAN RIGHT WEAPON ID");
}
else
LogChannel('exec', "COULD NOT FIND ZOLTAN");
}
exec function zoltlistweapons()
{
var zolt : CNewNPC;
var weapon : CItemEntity;
var zoltinventory : CInventoryComponent;
var invContents : array<SItemUniqueId>;
var i : int;
zolt = (CNewNPC)theGame.GetEntityByTag('findzoltan');
if (zolt)
{
zoltinventory = zolt.GetInventory();
zoltinventory.GetAllItems(invContents);
for (i = 0 ; i < invContents.Size() ; i += 1)
{
if (zoltinventory.IsItemWeapon(invContents[i]))
{
weapon = zoltinventory.GetItemEntityUnsafe(invContents[i]);
LogChannel('exec', "Zoltan's weapon is " + weapon);
}
}
}
else
LogChannel('exec', "COULD NOT FIND ZOLTAN");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment