Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Working vehicle menus on SP maps, and how to purchase powerups from them and airdrop vehicles  () 1 Vote
Working vehicle menus on SP maps, and how to purchase powerups from them and airdrop vehicles [message #467296] Sat, 12 May 2012 02:46 Go to previous message
Whitedragon is currently offline  Whitedragon
Messages: 832
Registered: February 2003
Location: California
Karma:
Colonel
I've noticed that the way vehicles and powerups are bought on coop servers is kinda ugly, using pokeable objects and chat commands. So here's some code that will allow you to have working vehicle purchase menus on SP maps. You will be able to purchase vehicles from the PT and have them airdropped in, and purchase powerups the same way as beacons. It could also be made to airdrop the powerups if you wanted to.

void Set_Vehicle_Factory_Is_Busy(VehicleFactoryGameObj *VF,bool Busy) {
	if (VF) {
		*((bool*)VF+0x8C8) = Busy; //Set_Is_Busy needs to be added to VehicleFactoryGameObj
		VF->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE,true);
	}
}

int VehiclePurchase(BaseControllerClass *Base,GameObject *Purchaser,unsigned int Cost,unsigned int Preset,const char *Data) {
	DefinitionClass *Def = Find_Definition(Preset);
	if (Def) {
		if (Def->Get_Class_ID() == CID_Vehicle) { //It's a vehicle
			VehicleFactoryGameObj *VF = (VehicleFactoryGameObj*)Base->Find_Building(BuildingConstants::TYPE_VEHICLE_FACTORY);
			if (!Base->Can_Generate_Vehicles() || !VF || VF->Is_Busy()) {
				return 3;
			}
			else if ((unsigned int)VF->Get_Team_Vehicle_Count() >= Get_Vehicle_Limit()) {
				return 3;
			}
			if (Purchase_Item(Purchaser,Cost)) {
				int Team = Base->Get_Player_Type();
				VehicleGameObj *Veh = Commands->Create_Object(Def->Get_Name(),Vector3(0,0,0))->As_VehicleGameObj();
				GameObject *Cin = Commands->Create_Object("Invisible_Object",VehiclePosition[Team]); //Set the position however you want
				Commands->Attach_Script(Cin,"Test_Cinematic",StringClass::getFormattedString("%s_Vehicle_Purchase.txt",Team?"GDI":"Nod")); //Create the cinematic
				Commands->Send_Custom_Event(Veh,Cin,10004,Commands->Get_ID(Veh),0); //Insert vehicle into cinematic at slot 4
				Veh->Lock_Vehicle(Purchaser->As_SoldierGameObj(),30.0f); //Lock vehicle
				Set_Vehicle_Factory_Is_Busy(VF,true);
				//You should attach a script to the vehicle that makes it invincible until it lands. The same script can also be used to make the VF not busy.
				return 0;
			}
			return 2;
		}
		else if (Def->Get_Class_ID() == CID_PowerUp) { //It's a powerup
			PowerUpGameObjDef *PowerUpDef = (PowerUpGameObjDef*)Def;
			if (PowerUpDef->GrantWeapon && Has_Weapon(Purchaser,Get_Definition_Name(PowerUpDef->GrantWeaponID))) {
				return 4; //Stop players from accidentally buying a weapon they already have
			}
			else if (Purchase_Item(Purchaser,Cost)) {
				PowerUpDef->Grant(Purchaser->As_SoldierGameObj());
				return 0;
			}
			return 2;
		}
	}
	return 4;
}


Obviously you'll need a vehicle factory on the map which can be added through leveledit or created in a script with Create_Building.


Black-Cell.net
Network Administrator (2003 - )

DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )

Dragonade, Renegade's first server side modification
Lead coder (2005 - )

[Updated on: Tue, 15 May 2012 02:54]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: server crash (in tt.dll) after dead of ai
Next Topic: level edit .ddb
Goto Forum:
  


Current Time: Wed Dec 18 12:20:24 MST 2024

Total time taken to generate the page: 0.01296 seconds