Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
enemy won't damage player #125069
04/19/07 20:09
04/19/07 20:09
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I'm trying to work out an enemy code for the AUM ninja code.
I'm placing this function enemy_hit() in the enemy code.
Code:
function enemy_hit()
{
vec_set(temp, player.x);
vec_sub(temp,my.x);
if(vec_dist (player.x, my.x) <= 20)
{
attack_percentage = 0; // reset the "attack" animation frames
while (attack_percentage < 100)
{
vec_for_vertex (weapon_tip, my, 128); // get the value in Med
vec_for_vertex (weapon_base, my, 64); // get the value in Med
if (c_trace (weapon_base, weapon_tip, ignore_me | ignore_passable) > 0) // the enemy has hit something?

{
if (you != null)
{
snd_play (wound_wav, 100, 0);
you.health -= 10 * time_step; // if the enemy has hit the player, decrease its health
}
}
wait (1);
}
}
wait (1);
}


I've tried many variations but the player doesn't take damage. Why, oh why?

Re: enemy won't damage player [Re: JazzDude] #125070
04/19/07 21:40
04/19/07 21:40
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
Just a quick guess, so this may be way off base, but do you set you to anything? just refrencing you or my can be dangerous some times, I sugest defining your entity as something other than you and referencing it that way, you may be making you.health go down, but if you isn't the player, it doesn't do much good.


A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C
Re: enemy won't damage player [Re: Trooper119] #125071
04/19/07 22:27
04/19/07 22:27
Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
tompo Offline
User
tompo  Offline
User

Joined: Mar 2007
Posts: 776
Poor village - Poland ;)
1. vec_set(temp, player.x);vec_sub(temp,my.x); this is useless in this case.
2. I see 2 wait instrucions but only one while?
Where is the firs one? Becouse if firs one is earler than attack_percentage = 0; this is still reseting to 0; or try change this (for test) to while(1)
3. use c_setminmax(me); function and then box
4. c_trace (weapon_base, weapon_tip, ignore_me | ignore_passable | use_box);
if(result != 0) && (you == player) {player.health -= 10 *time_step;}


Never say never.
Re: enemy won't damage player [Re: tompo] #125072
04/19/07 23:36
04/19/07 23:36
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Thanks for the suggestions. It still doesn't work so maybe I missed something. Here's the revision:

Code:
function enemy_hit()
{
c_setminmax(me);
if(vec_dist (player.x, my.x) <= 20)
{
attack_percentage = 0; // reset the "attack" animation frames
while (attack_percentage < 100)
{
vec_for_vertex (weapon_tip, my, 128); // get the value in Med
vec_for_vertex (weapon_base, my, 64); // get the value in Med
if (c_trace (weapon_base, weapon_tip, ignore_me | ignore_passable| use_box) > 0) // the player has hit something?
{
if(result != 0) && (you == player)
{
player.health -= 10 *time_step;
snd_play (wound_wav, 100, 0);
}
}
wait (1);
}
}
}



I'm not getting any errors. This is the last little stumbling block in an enemy code for the K of H code
so I hope I can get it working. If I can, I'll post the player/enemy script on the contributions forum.

Re: enemy won't damage player [Re: JazzDude] #125073
04/19/07 23:45
04/19/07 23:45
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Hey Tompo....I love your avatar. That's me the last two days.

Re: enemy won't damage player [Re: JazzDude] #125074
04/20/07 01:25
04/20/07 01:25
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
You're putting this function in an event right? Not just calling it every frame cycle...

Also, take out use_box from the trace and make sure your vertex numbers are set correctly (vec_for_vertex()).


xXxGuitar511
- Programmer
Re: enemy won't damage player [Re: xXxGuitar511] #125075
04/20/07 01:50
04/20/07 01:50
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Yeah, I tried all that and more. And then tried again to make sure.

This condition if(vec_dist (player.x, my.x) <= 20) seems to be the problem.

I use the same piece of code for the player with the condition set to if (mouse_left == 1) and it works fine.

I need a better way to trigger it.
================================

Stand by...I think I've solved it.

==================================

Drats...another failed inspiration!

Last edited by JazzDude; 04/20/07 03:37.
Re: enemy won't damage player [Re: JazzDude] #125076
04/20/07 04:09
04/20/07 04:09
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
What is the goal in mind? What are you looking for...


xXxGuitar511
- Programmer
Re: enemy won't damage player [Re: xXxGuitar511] #125077
04/20/07 04:23
04/20/07 04:23
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I'm making an enemy AI and in this case the battle is between a mountain man with a tomahawk and a grizzly bear(enemy). I have used the vertices on the two front paws for the weapon tip and base.

I know the trace is working because the sound is triggered. My problem is, why is the player(you) not losing health. I'm thinking the problem maybe isn't in this function at all so I've been trying other approaches like putting the guts of this function into the enemy action and changing the player action. But nothing has worked.

I could probably just use an impact trigger but I'd like the code to serve as a template for other hand-to-hand combat where both opponents are using weapons.

This mountain man will face wolves, pumas, and Indians with knives and tomahawks before he gets back to St. Louie. Since he seems to be immortal at this point, it shouldn't be a problem.

Re: enemy won't damage player [Re: JazzDude] #125078
04/20/07 05:06
04/20/07 05:06
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Ok, I think I found your problem.

Are both models using the same skill# for their health? Even if they both define health with the same name, they only need to use the same skill#


xXxGuitar511
- Programmer
Page 1 of 2 1 2

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

Gamestudio download | chip programmers | 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