Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,709 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lite-C fist fight 4 noobs via c_trace #421831
04/25/13 22:14
04/25/13 22:14
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline OP

X
rayp  Offline OP

X

Joined: Jul 2008
Posts: 2,110
Germany
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;
Re: Lite-C fist fight 4 noobs via c_trace [Re: rayp] #421841
04/26/13 06:41
04/26/13 06:41
Joined: Mar 2006
Posts: 1,993
Karlsruhe
PadMalcom Offline
Serious User
PadMalcom  Offline
Serious User

Joined: Mar 2006
Posts: 1,993
Karlsruhe
This sample is surely of great value for the community since questions about c_trace appear frequently.

But you could fix the collision hull of your fantastic model! laugh

Re: Lite-C fist fight 4 noobs via c_trace [Re: PadMalcom] #421878
04/26/13 22:33
04/26/13 22:33
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline OP

X
rayp  Offline OP

X

Joined: Jul 2008
Posts: 2,110
Germany
Thank you Pad.

Quote:
But you could fix the collision hull

But then i need to add a walk animation and and and... ^^

Quote:
fantastic model
Isnt it ? grin


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;
Re: Lite-C fist fight 4 noobs via c_trace [Re: rayp] #421903
04/27/13 16:27
04/27/13 16:27
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
i made a few minor changes and added it to my place in
the workshop. Included walk,punch and punch sound laugh

small clip : http://youtu.be/t7hbqlNXDN0

good work rayp laugh


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: Lite-C fist fight 4 noobs via c_trace [Re: Realspawn] #421995
04/30/13 07:40
04/30/13 07:40
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline OP

X
rayp  Offline OP

X

Joined: Jul 2008
Posts: 2,110
Germany
@Realspawn
Thank you. Please change the changes you made from
Code:
action BoxerEnemy(){
	my.health = 100;
	my.id     = id_boxerenemy;
	while (my.health > 0){ 
		vec_set(my.min_x,vector(-35,-35,-35)); // set bounding box to individual values
	vec_set(my.max_x,vector(35,35,35));
	   draw_text("HULK SMASH !", 10,10, vector(0,255,0));
	   wait (1);
   }
	wait (1);
	ptr_remove(me);
}



to
Code:
action BoxerEnemy(){
        wait (1);
        vec_set(my.min_x,vector(-35,-35,-35)); // set bounding box to individual values
	vec_set(my.max_x,vector(35,35,35));

	my.health = 100;
	my.id     = id_boxerenemy;
	while (my.health > 0){ 
	   draw_text("HULK SMASH !", 10,10, vector(0,255,0));
	   wait (1);
   }
	wait (1);
	ptr_remove(me);
}

Same for boxerplayer. Its not good to set the hull in a while.

Last edited by rayp; 04/30/13 07:41.

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;
Re: Lite-C fist fight 4 noobs via c_trace [Re: rayp] #422007
04/30/13 09:56
04/30/13 09:56
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
will do a.s.a.p.

Done laugh

Last edited by Realspawn; 04/30/13 09:59.

Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: Lite-C fist fight 4 noobs via c_trace [Re: Realspawn] #422019
04/30/13 12:57
04/30/13 12:57
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
Now you need: blocking, Dodging, combat movement and the most improtend... killmoves! ^^



Re: Lite-C fist fight 4 noobs via c_trace [Re: Random] #422070
05/01/13 12:09
05/01/13 12:09
Joined: Jul 2008
Posts: 2,110
Germany
rayp Offline OP

X
rayp  Offline OP

X

Joined: Jul 2008
Posts: 2,110
Germany
If i had too much time i would do a workshop.

Here's a video from my arcade beat em up. I worked a few weeks on it. From time to time ill write some lines. It features a pretty cool fight system (if my player model would have more animations, i could script more attacks grin ).

http://www.youtube.com/watch?v=cDwpfNf85pE

Last edited by rayp; 05/01/13 12:09.

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;

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1