Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » !para
!para [message #471168] Wed, 11 July 2012 04:47 Go to previous message
Distrbd21 is currently offline  Distrbd21
Messages: 743
Registered: September 2008
Karma:
Colonel

I'm trying to get it to work with 4.0, but I don't know exactly what I have done wrong.

The server doesn't crash when I do !para or when I get out of a veh, nothing happens I still die ;p

void ObjectHookCall(void *data,GameObject *obj) {
	if (obj->As_SoldierGameObj()) {
		Attach_Script_Once(obj,"Parachute","");
	}
	else if (obj->As_VehicleGameObj()) {
		if (obj->As_PhysicalGameObj() && (Get_Vehicle_Mode(obj) == VEHICLE_TYPE_FLYING)) {
			Attach_Script_Once(obj,"Parachute","");
		}
	}
}

void Parachute::Created(GameObject *obj) {
	isFalling = false;
	floaterID = 0;
	pchuteID = 0;
	fallin = 0;
	health = Commands->Get_Health(obj);
}

void Parachute::Damaged(GameObject *obj,GameObject *damager,float damage) {
	if (!damager && isFalling && (damage < 1000)) {
		Commands->Set_Health(obj,health);
		isFalling = false;
	}
	else {
		health = Commands->Get_Health(obj);
	}
}

void Parachute::Killed(GameObject *obj, GameObject *shooter) {
	if (obj->As_VehicleGameObj()) {
		if (Commands->Get_ID(obj) && obj && obj->As_VehicleGameObj()) {
			VectorClass<GameObject *> *ptr = (VectorClass<GameObject *>*)(obj+0x9AC);
			VectorClass<GameObject *> occupants = (VectorClass<GameObject *>)*ptr;
			int x = occupants.Length();
			for (int i = 0;i < x;i++) {
				if (occupants[i]) {
					Commands->Send_Custom_Event(occupants[i],occupants[i],4612,0,0);
				}
			}
		}
	}
	else if (obj->As_SoldierGameObj()) {
		Commands->Enable_Collisions(obj);
		if (Commands->Find_Object(pchuteID)) {
			Commands->Destroy_Object(Commands->Find_Object(pchuteID));
			pchuteID = 0;
		}
		if (Commands->Find_Object(floaterID)) {
			Commands->Destroy_Object(Commands->Find_Object(floaterID));
			floaterID = 0;
		}
		isFalling = false;
	}
}

void Parachute::Timer_Expired(GameObject *obj,int number) {
	if (number == 1) {
		newpos = Commands->Get_Position(obj);
		if (newpos.Z < pos.Z) {
			fallin += pos.Z - newpos.Z;
			if (fallin > 10 && !isFalling) {
				isFalling = true;
				GameObject *floater = Commands->Create_Object("CnC_Beacon_IonCannon",Commands->Get_Position(obj));
				Commands->Set_Model(floater,"null");
				Commands->Set_Facing(floater,Commands->Get_Facing(obj));
				GameObject *pchute = Commands->Create_Object("Generic_Cinematic",Commands->Get_Position(obj));
				Commands->Set_Model(pchute,"X5D_Parachute");
				Commands->Disable_All_Collisions(pchute);
				Commands->Disable_Physical_Collisions(obj);
				Commands->Attach_To_Object_Bone(obj,floater,"");
				Commands->Attach_To_Object_Bone(pchute,obj,"");
				floaterID = Commands->Get_ID(floater);
				pchuteID = Commands->Get_ID(pchute);
			}
			pos = Commands->Get_Position(obj);
			Commands->Start_Timer(obj, this, 0.1f, 1);
		}
		else {
			Commands->Enable_Collisions(obj);
			if (Commands->Find_Object(pchuteID)) {
				Commands->Destroy_Object(Commands->Find_Object(pchuteID));
				pchuteID = 0;
			}
			if (Commands->Find_Object(floaterID)) {
				Commands->Destroy_Object(Commands->Find_Object(floaterID));
				floaterID = 0;
			}
			Commands->Start_Timer(obj, this, 2.0f, 2);
		}
	}
	else if (number == 2) {
		isFalling = false;
	}
}

void Parachute::Custom(GameObject *obj, int message, int param, GameObject *sender) {
	if (message == CUSTOM_EVENT_VEHICLE_EXITED) {
		Commands->Send_Custom_Event(sender,sender,4612,0,0);
	}
	else if (message == CUSTOM_EVENT_VEHICLE_ENTERED) {
		Commands->Send_Custom_Event(sender,sender,4613,0,0);
	}
	else if (message == 4612) {
		health = Commands->Get_Health(obj);
		fallin = 0;
		pos = Commands->Get_Position(obj);
		Commands->Start_Timer(obj, this, 0.1f, 1);
	}
	else if (message == 4613) {
		isFalling = false;
		if (Commands->Find_Object(pchuteID)) {
			Commands->Destroy_Object(Commands->Find_Object(pchuteID));
			pchuteID = 0;
		}
		if (Commands->Find_Object(floaterID)) {
			Commands->Destroy_Object(Commands->Find_Object(floaterID));
			floaterID = 0;
		}
	}
}


Live Your Life Not Some one Else's.| Sharing Is Caring

http://dsgaming.us/distrbd21/Distrbd21%20siggy.png

Cookie Jar

Suicide
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: set object type for vehicles
Next Topic: Get_Damage_Bone_Name
Goto Forum:
  


Current Time: Fri Dec 20 13:43:49 MST 2024

Total time taken to generate the page: 0.00938 seconds