2 registered members (AndrewAMD, Ayumi),
1,405
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: [REQ] converting a code to lite-c
[Re: Cowabanga]
#251510
02/13/09 13:03
02/13/09 13:03
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Hmm, I'll need to think on that one, but it'll be easy enough I think. BUT, do you want it to " need to press left mouse button" to move them, or just purely on contact? [EDIT]Heres the code update to make the enemy move when "hit" by attacking hands. (Making the enemies move when just bumped into too much work. Write a new action to do that.) WHOLE enemy.c(though only one "paragraph" added) action enemy_dummy()
{
set(my,SHADOW);
my.entity_type = 2;
my.emask |= ENABLE_SCAN;
while(1)
{
if(my.hit_by_player == 1) //sucessful attack by player weapon
{
my.move_x = player.move_x;
my.move_y = player.move_y;
my.move_z = player.move_z;
c_move(my, nullvector, my.move_x, USE_BOX | IGNORE_PASSABLE | GLIDE);
if(player.animblend == blend || player.animblend < attack_a || my.animblend > attack_f) my.hit_by_player = 0;
}
else if(my.hit_by_player == 2) //sucessful HAND attack by player
{
my.move_x = player.move_x;
my.move_y = player.move_y;
my.move_z = player.move_z;
c_move(my, nullvector, my.move_x, USE_BOX | IGNORE_PASSABLE | GLIDE);
if(player.animblend == blend || player.animblend < attack_a || my.animblend > attack_f) my.hit_by_player = 0;
}
if((player.animblend >= stand && target_enemy == me && player_lock_on == 0) && (player.animblend < attack_a || player.animblend > attack_f))
target_enemy = NULL;
if(target_enemy == my && vec_dist(my.x, player.x) > 200)
target_enemy = NULL;
wait(1);
}
} PARTIAL player.c(two functions to replace handle_sword_collisions(), found at end of script) function handle_hand_collision()
{
vec_for_vertex(tempV.x, player, 1146); //thumb tip
vec_for_vertex(tempV2.x, player, 1144); //thumb joint
result = c_trace(tempV.x, tempV2.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
if(you != NULL)
{
if(you.entity_type == 2 && you.hit_by_player == 0)
{
if(airborne_attack == 1 && my.animblend == attack_a) my.movement_mode = 2;
you.hit_by_player = 2;
if(target_enemy == NULL) { target_enemy = you; player_lock_on = 1; }
}
}
}
function handle_sword_collision()
{
you = NULL;
if(player_weapon==NULL) { handle_hand_collision(); return; }
vec_for_vertex(tempV.x, player_weapon, 274); //sword base
vec_for_vertex(tempV2.x, player_weapon, 54); //sword tip
result = c_trace(tempV.x, tempV2.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
if(you != NULL)
{
if(you.entity_type == 2 && you.hit_by_player == 0)
{
if(airborne_attack == 1 && my.animblend == attack_a) my.movement_mode = 2;
you.hit_by_player = 1;
if(target_enemy == NULL) { target_enemy = you; player_lock_on = 1; }
}
}
}
Last edited by EvilSOB; 02/13/09 13:53. Reason: research/re-code completed
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: [REQ] converting a code to lite-c
[Re: EvilSOB]
#251515
02/13/09 13:58
02/13/09 13:58
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
A NOTE TO ALL USING MY RE-CODE! I discovered an instability in my code during my last bit of research, if youve already copied my code from above you'll need to change the following. (Ive updated my above code post so this has been fixed there) In ENEMY.C the following line must be changed c_move(my, nullvector, my.move_x, USE_AABB | IGNORE_PASSABLE | GLIDE);
must be changed to
c_move(my, nullvector, my.move_x, USE_BOX | IGNORE_PASSABLE | GLIDE);
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: [REQ] converting a code to lite-c
[Re: Cowabanga]
#251526
02/13/09 14:47
02/13/09 14:47
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
With the two bits of code I just gave you, it should already be running. Face the enemy from close, hit left-mouse click and you will run through the normal attack animations, and it will push the enemy back.
No other mode besides the new enemy.c and the modded handle_???_collision functions.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: [REQ] converting a code to lite-c
[Re: Cowabanga]
#251538
02/13/09 16:10
02/13/09 16:10
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Cool, thanks. And to add the UP DOWN LEFT RIGHT functionality, go to the start of the handle_movement() function in PLAYER.C and add the following just before or after the other big block of if's. [you'll see where I mean, as long as its before the line " if(tempV.x != -1000)"] if(key_cuu == 1 && key_cud == 0 && key_cul == 0 && key_cur == 0) tempV.x = camera.pan;
if(key_cud == 1 && key_cuu == 0 && key_cul == 0 && key_cur == 0) tempV.x = camera.pan + 180;
if(key_cul == 1 && key_cud == 0 && key_cuu == 0 && key_cur == 0) tempV.x = camera.pan + 90;
if(key_cur == 1 && key_cud == 0 && key_cur == 0 && key_cuu == 0) tempV.x = camera.pan - 90;
if(key_cuu == 1 && key_cul == 1 && key_cud == 0 && key_cud == 0) tempV.x = camera.pan + 45;
if(key_cuu == 1 && key_cur == 1 && key_cul == 0 && key_cud == 0) tempV.x = camera.pan - 45;
if(key_cud == 1 && key_cul == 1 && key_cur == 0 && key_cuu == 0) tempV.x = camera.pan + 135;
if(key_cud == 1 && key_cur == 1 && key_cul == 0 && key_cuu == 0) tempV.x = camera.pan - 135;
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: [REQ] converting a code to lite-c
[Re: Cowabanga]
#251544
02/13/09 16:59
02/13/09 16:59
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
No problem. Im just amazed at how much I seem to have learned in the last couple of months, without even noticing it...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|