Nice work!

I had hoped by now someone would have made a better ragdoll model though tongue
I slightly revised the create ragdoll function, not the prettiest (argument wise), but smaller code wise (less buggy to debug as well)!

Hope someone has use of it, and I'm glad to see after all these years my little contribution is still being used laugh


Code:
ENTITY* RD_SELF = ent_create(NULL, nullvector, NULL);
ENTITY* RD_createBodyPart(STRING* fileName, STRING* boneName, VECTOR* pos, VECTOR* limits, ENTITY* attachBone, ENTITY* ent, VECTOR* attachVec, ENTITY* getPart, var numPart) {
	ENTITY* hingeEnt = ent_create(fileName, pos, RD_setPart);
	// blend angle and position for pelvis:
	RD_blendPose(hingeEnt, ent, boneName);
	// register as a physical object:
	RD_BodyPartInit(hingeEnt);
	// set rotational boundaries:
	if(limits != nullvector) { RD_setHinge(hingeEnt, attachBone, vector(0, 1, 0), limits); }
	
	ENTITY* RD_part = getPart;
	if(getPart != NULL) { if(getPart == RD_SELF) { RD_part = hingeEnt; } vec_for_vertex(attachVec, RD_part, numPart); } // get vertex to attach limb to: 
	
	return hingeEnt;
}

// create ragdoll:
void createRagdoll(ENTITY* ent){
	// vectors:
	VECTOR tempVertex;
	// go on creating the ragdoll PE objects:
	ENTITY* Pelvis = RD_createBodyPart("RD_pelvis.mdl", "pelvis", ent.x, nullvector, NULL, ent, tempVertex, RD_SELF, 14);
	// create bodypart:
	ENTITY* L_leg_up = RD_createBodyPart("RD_leg_up_left.mdl", "left_up_leg", tempVertex, vector(-50, 50, 0), Pelvis, ent, tempVertex, RD_SELF, 9);
	// create lower left part of the leg:
	ENTITY* L_leg_down = RD_createBodyPart("RD_leg_down_left.mdl", "left_low_leg", tempVertex, vector(-10, 90, 0), L_leg_up, ent, tempVertex, Pelvis, 13);
	// create right upper leg:
	ENTITY* R_leg_up = RD_createBodyPart("RD_leg_up_right.mdl", "right_up_leg", tempVertex, vector(-50, 50, 0), Pelvis, ent, tempVertex, RD_SELF, 9);
	// create right lower leg:
	ENTITY* R_leg_down = RD_createBodyPart("RD_leg_down_right.mdl", "right_low_leg", tempVertex, vector(-10, 90, 0), R_leg_up, ent, tempVertex, Pelvis, 15);
	// create stomach:
	ENTITY* Stomach = RD_createBodyPart("RD_abs.mdl", "stomach", tempVertex, vector(-15, 15, 0), Pelvis, ent, tempVertex, RD_SELF, 9);
	// create torso:
	ENTITY* Torso = RD_createBodyPart("RD_torso.mdl", "chest", tempVertex, vector(-20, 20, 0), Stomach, ent, tempVertex, RD_SELF, 9);
	// create head:
	ENTITY* Head = RD_createBodyPart("RD_head.mdl", "neck", tempVertex, nullvector, Torso, ent, tempVertex, Torso, 10);
	RD_set6DJoint(Head, Torso, vector(45, 45, 0), vector(-45, 45, 0), vector(0, -1, 0));
	// createa left upper arm:
	ENTITY* L_arm_up = RD_createBodyPart("RD_arm_up_left.mdl", "left_up_arm", tempVertex, vector(-90, 90, 0), Torso, ent, tempVertex, RD_SELF, 9);
	// createa left lower arm:
	ENTITY* L_arm_down = RD_createBodyPart("RD_arm_down_left.mdl", "left_low_arm", tempVertex, vector(-100, 35, 0), L_arm_up, ent, tempVertex, Torso, 13);
	// createa right upper arm:
	ENTITY* R_arm_up = RD_createBodyPart("RD_arm_up_right.mdl", "right_up_arm", tempVertex, vector(-90, 90, 0), Torso, ent, tempVertex, RD_SELF, 9);	
	// createa right lower arm:
	ENTITY* R_arm_down = RD_createBodyPart("RD_arm_down_right.mdl", "right_low_arm", tempVertex, vector(-100, 35, 0), R_arm_up, ent, nullvector, NULL, 0);
	
	// loop:
	while(ent){		
		// set pelvis to right position
		vec_set(ent.x, Pelvis.x);
		vec_set(ent.pan, Pelvis.pan);
		// update all physics (limb) parts
		RD_updateBoneHinge(L_leg_up, "left_up_leg", ent);
		RD_updateBoneHinge(L_leg_down, "left_low_leg", ent);
		RD_updateBoneHinge(R_leg_up, "right_up_leg", ent);
		RD_updateBoneHinge(R_leg_down, "right_low_leg", ent);
		RD_updateBoneHinge(Stomach, "stomach", ent);
		RD_updateBoneHinge(Torso, "chest", ent);
		RD_updateBoneHinge(Head, "neck", ent);
		RD_updateBoneHinge(L_arm_up, "left_up_arm", ent);
		RD_updateBoneHinge(L_arm_down, "left_low_arm", ent);
		RD_updateBoneHinge(R_arm_up, "right_up_arm", ent);	
		RD_updateBoneHinge(R_arm_down, "right_low_arm", ent);
		// wait one frame:
		wait(1);
	}
}


(just overwrite the above with the current create_ragdoll function)

regards, D.


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/