[CODE] Automatically loaded hash map of weapons and their powerups [message #472004] |
Fri, 20 July 2012 01:43 |
iRANian
Messages: 4308 Registered: April 2011
Karma:
|
General (4 Stars) |
|
|
This code gets run on startup, goes through all powerup definitions and loads a hash map with key = weapon preset, value = powerup preset. It's simple to modify it so the key and value are switched.
Make sure you call the code after the objects preset file has been loaded so in the level load hook or somewhere later, else it can't and won't load shit.
HashTemplateClass<StringClass, StringClass> PowerupTable; // Key is weapon name, value is powerup
void Load_Powerup_Table()
{
for (PowerUpGameObjDef *Def = (PowerUpGameObjDef*)DefinitionMgrClass::Get_First(PowerupDefID);Def;Def = (PowerUpGameObjDef*)DefinitionMgrClass::Get_Next(Def,PowerupDefID))
{
if (Def->GrantWeapon)
{
WeaponDefinitionClass* WeaponDef = (WeaponDefinitionClass*)DefinitionMgrClass::Find_Definition(Def->GrantWeaponID, false);
{
if (WeaponDef)
{
// Console_Output("%s = %s\n", WeaponDef->Get_Name(), Def->Get_Name()); // DEBUG CRAP
PowerupTable.Insert(WeaponDef->Get_Name(), Def->Get_Name());
}
}
}
}
}
bool FirstLoad = true;
void RestoreWeaponsCharacterOnJoin::OnLoadLevel()
{
if (FirstLoad == true)
{
FirstLoad = false;
Load_Powerup_Table();
}
}
Long time and well respected Renegade community member, programmer, modder and tester.
Scripts 4.0 private beta tester since May 2011.
My Renegade server plugins releases
[Updated on: Fri, 20 July 2012 01:43] Report message to a moderator
|
|
|