Here is a very simple example of fist fights via c_trace. U can move a boxer around. Press space to punch. Go to the second model and punch it dead.

You can use the very pro boxer model (lol) i made in your commercial games of course. grin

Here's the download to an example project
http://www.file-upload.net/download-7520339/rayps_fistfight_litec_viactrace_4noobs.rar.html




And here's the source (main.c)
Code:
/*
 Fist Fight via c_trace Lite-C example by rayp 2013 germany
 free 2 use
 
 as simple as it can be !
*/
#include <acknex.h>
#include <default.c>

#define anm             skill100
#define animation_frame skill99
#define health          skill98
#define id              skill97

#define id_boxerenemy   5000

#define anm_idle        1000
#define anm_punch       1001
#define anm_walk        1002

STRING* str_anm_idle  = "idle";
STRING* str_anm_walk  = "walk";
STRING* str_anm_punch = "punch";

VECTOR dist;

action BoxerEnemy(){
	my.health = 100;
	my.id     = id_boxerenemy;
	while (my.health > 0){ 
	   draw_text("Iam alive...punch me to dead!", 10,10, vector(0,0,255));
	   wait (1);
   }
	wait (1);
	ptr_remove(me);
}

void boxerplayer_ctrace(){
	VECTOR trace_target;
   var scale = 150;      
   vec_for_angle (trace_target,vector(my.pan,my.tilt,my.roll));
   vec_scale     (trace_target,scale);
   vec_add       (trace_target,vector(my.x,my.y,my.z)); 
   c_ignore (1, 0); 
   trace_mode = IGNORE_PASSABLE | USE_BOX| SCAN_TEXTURE |IGNORE_SPRITES | IGNORE_ME;
   c_trace(my.x,trace_target, trace_mode);
   if(you) if(you.id == id_boxerenemy) {
   	you.health -= 25;
   }
}
void _handle_cam(){
	vec_set(camera.x, my.x);
	camera.z = 500;
	camera.tilt = -90;
	my.pan += mickey.x*time_step;
}
void BoxerPlayer(){
	my.group = 1;
	my.anm = anm_idle;
	while (my) {
		_handle_cam();		
		if (key_w || key_a || key_s || key_d) if (my.anm != anm_walk && my.anm != anm_punch){
			my.animation_frame = 0;
			my.anm = anm_walk;
		}
		if (my.anm == anm_idle) {
			my.animation_frame += time_step *4;
			ent_animate (me, str_anm_idle, my.animation_frame, ANM_CYCLE);
		}
		if (my.anm == anm_punch) {
			my.animation_frame += time_step *4;
			ent_animate (me, str_anm_punch, my.animation_frame, NULL);
		}		
		if (my.anm == anm_walk) {		
			my.animation_frame += time_step *4;
			ent_animate (me, str_anm_walk, my.animation_frame, ANM_CYCLE);		
		   dist.x = (key_w-key_s) * (time_step*4);
		   dist.y = (key_a-key_d) * (time_step*2);		
		   move_mode = GLIDE | IGNORE_ME | IGNORE_SPRITES | IGNORE_PASSABLE;
		   c_move (me, vector (dist.x, dist.y, 0), nullvector, move_mode);
	   }
		if (my.animation_frame >= 100){
			if (my.anm == anm_punch) boxerplayer_ctrace();
			my.animation_frame = 0;
			my.anm = anm_idle;			
		}	   
		if (key_space) if (my.anm != anm_punch){
			my.animation_frame = 0;
			my.anm = anm_punch;
		}
		wait(1);
	}
}

void main(){
	fps_max = 60;	
	level_load("map01.wmb");
   wait (4);
   ent_create("player.mdl", vector(0,0,0), BoxerPlayer);	
}


edit: corrected a bug and re-uploaded.
edit2: U should reduce "scale" from 150 to 50 ^^
edit3: And theres no need 4 SCAN_TEXTURE
edit4: Reuploaded: wmp was full of textures

Last edited by rayp; 04/27/13 00:18.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;