Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [CODE] Automatically loaded hash map of weapons and their powerups
[CODE] Automatically loaded hash map of weapons and their powerups [message #472004] Fri, 20 July 2012 01:43
iRANian is currently offline  iRANian
Messages: 4300
Registered: April 2011
Karma: 0
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;


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

Previous Topic: [SSGM 4.0 Plugin] Chat Aliases
Next Topic: [SSGM 4.0 Plugin] Restore Weapons Characters on Join
Goto Forum:

Current Time: Sun Jul 14 15:22:39 MST 2024

Total time taken to generate the page: 0.00525 seconds