entWatch4: Add 'sorting' to make it more similiar to old entWatch.
And reset client('owner') when weapon dies.
This commit is contained in:
parent
d0f49b369a
commit
92748fe274
@ -16,6 +16,7 @@ methodmap CConfig < Basic
|
||||
myclass.SetString("sFilter", "");
|
||||
|
||||
myclass.SetInt("iButtonID", 0);
|
||||
myclass.SetInt("iConfigID", 0);
|
||||
myclass.SetInt("iWeaponID", 0);
|
||||
myclass.SetInt("iTriggerID", 0);
|
||||
|
||||
@ -82,6 +83,18 @@ methodmap CConfig < Basic
|
||||
}
|
||||
}
|
||||
|
||||
property int iConfigID
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return this.GetInt("iConfigID");
|
||||
}
|
||||
public set(int value)
|
||||
{
|
||||
this.SetInt("iConfigID", value);
|
||||
}
|
||||
}
|
||||
|
||||
property int iWeaponID
|
||||
{
|
||||
public get()
|
||||
|
@ -137,6 +137,8 @@ public void OnMapStart()
|
||||
|
||||
if (hConfig.GotoFirstSubKey())
|
||||
{
|
||||
int iConfigID;
|
||||
|
||||
do
|
||||
{
|
||||
CConfig config = new CConfig();
|
||||
@ -152,6 +154,7 @@ public void OnMapStart()
|
||||
config.SetColor(sColor);
|
||||
config.SetFilter(sFilter);
|
||||
|
||||
config.iConfigID = iConfigID++;
|
||||
config.iWeaponID = hConfig.GetNum("weaponid");
|
||||
config.iButtonID = hConfig.GetNum("buttonid");
|
||||
config.iTriggerID = hConfig.GetNum("triggerid");
|
||||
@ -228,7 +231,11 @@ public void OnEntitySpawned(int entity)
|
||||
CItem item = new CItem(config);
|
||||
|
||||
if (RegisterItemEntity(item, entity, REGISTER_WEAPON))
|
||||
{
|
||||
g_hArray_Items.Push(item);
|
||||
|
||||
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (config.iButtonID && config.iButtonID == iHammerID)
|
||||
@ -238,7 +245,11 @@ public void OnEntitySpawned(int entity)
|
||||
CItem item = new CItem(config);
|
||||
|
||||
if (RegisterItemEntity(item, entity, REGISTER_BUTTON))
|
||||
{
|
||||
g_hArray_Items.Push(item);
|
||||
|
||||
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (config.iTriggerID && config.iTriggerID == iHammerID)
|
||||
@ -248,7 +259,11 @@ public void OnEntitySpawned(int entity)
|
||||
CItem item = new CItem(config);
|
||||
|
||||
if (RegisterItemEntity(item, entity, REGISTER_TRIGGER))
|
||||
{
|
||||
g_hArray_Items.Push(item);
|
||||
|
||||
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,6 +356,7 @@ public void OnEntityDestroyed(int entity)
|
||||
|
||||
if (item.bWeapon && item.iWeapon == entity)
|
||||
{
|
||||
item.iClient = INVALID_ENT_REFERENCE;
|
||||
item.iWeapon = INVALID_ENT_REFERENCE;
|
||||
|
||||
return;
|
||||
@ -361,6 +377,20 @@ public void OnEntityDestroyed(int entity)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int SortItemsArray(int index1, int index2, Handle array, Handle hndl)
|
||||
{
|
||||
CConfig config1 = view_as<CItem>(g_hArray_Items.Get(index1)).dConfig;
|
||||
CConfig config2 = view_as<CItem>(g_hArray_Items.Get(index2)).dConfig;
|
||||
|
||||
if (config1.iConfigID < config2.iConfigID) return -1;
|
||||
if (config1.iConfigID > config2.iConfigID) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user