2 registered members (AndrewAMD, TipmyPip),
12,709
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
 
X
|
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. Here's the download to an example project http://www.file-upload.net/download-7520339/rayps_fistfight_litec_viactrace_4noobs.rar.htmlAnd here's the source (main.c)
/*
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: Realspawn]
#421995
04/30/13 07:40
04/30/13 07:40
|
Joined: Jul 2008
Posts: 2,110 Germany
rayp
OP
 
X
|
OP
 
X
Joined: Jul 2008
Posts: 2,110
Germany
|
@Realspawn Thank you. Please change the changes you made from
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
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: Realspawn]
#422019
04/30/13 12:57
04/30/13 12:57
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
Now you need: blocking, Dodging, combat movement and the most improtend... killmoves! ^^
|
|
|
|