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 (Martin_HH, steyr, alibaba), 509 guests, and 4 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
Dragon not harming player #455110
10/10/15 07:35
10/10/15 07:35
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I placed a dragon in my game (free "red dragon" model from the Gamestudio resources page: http://au.conitec.net/ ). My player is able to damage the dragon's health by shooting arrows at it. However, when I place the player underneath the fireball that the dragon spews out of its mouth, the fireball is not damaging the player. I am trying to make it so the fireball reduces the player's health on contact.

Here is some code I am using for this so far:

Code:
...

int drgn_damage_fire = 40;

...

void dragon_ctrace()
{
   var fire_top; // vertex #220
   var fire_bottom;  // vertex #235
	
   vec_for_vertex (fire_top, my, 220);
   vec_for_vertex (fire_bottom, my, 235);

   if (c_trace (fire_top, fire_bottom, SCAN_ENTS | SCAN_FLAG2) > 0)
   {	
      //beep(); // DOES BEEP LIKE CRAZY IF UN-COMMENTED
		
      if (you != NULL)
      {	
         beep(); // DOES NOT BEEP AT ALL

         player_health -= drgn_damage_fire * time_step;
            // PLAYER'S HEALTH SHOULD REDUCE HERE, BUT IT IS NOT HAPPENING.
      }

      ...

   }
}

...

function main() // FOR ORIGINAL GAME FILES
{
   ...
  
   player_health = 500;

   ...
}



The c_trace above will sense the player just fine, and beep like crazy if I uncomment the first beep shown above. However, when the fireball shoots out of the dragon's mouth in an animation and touches the player, the second beep above will not sound off at all, and the player's health will not decrease.

Does anyone know why this could be? Why is the fireball not sensing the impact of the player?

Last edited by Ruben; 10/10/15 07:43.
Re: Dragon not harming player [Re: Ruben] #455111
10/10/15 08:19
10/10/15 08:19
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
The trace could be hitting something that's not a model like level geometry.
In this case the first beep function would be called, but not the second one.

Edit:
Oh and are you sure that SCAN_ENTS & SCAN_FLAG2 are valid parameters for c_trace?
I haven't seen them being used with c_trace... If that's the case and if by coincidence
one of them has the same numerical value as IGNORE_YOU that's what could be screwing
you over. (IGNORE_YOU prevents c_trace from changing the you-pointer)

Last edited by Kartoffel; 10/10/15 08:23.

POTATO-MAN saves the day! - Random
Re: Dragon not harming player [Re: Kartoffel] #455125
10/10/15 16:56
10/10/15 16:56
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
I changed the c_trace in the last code to this:

Code:
... 

   if (c_trace (fire_top, fire_bottom, IGNORE_ME | IGNORE_PASSABLE) > 0)
   {	
      //beep(); // DOES BEEP LIKE CRAZY IF UN-COMMENTED
		
      if (you != NULL)
      {	
         beep(); // DOES NOT BEEP AT ALL

         player_health -= drgn_damage_fire * time_step;
            // PLAYER'S HEALTH SHOULD REDUCE HERE, BUT IT IS NOT HAPPENING.
      }

      ...



Still the same result.

The two vertice numbers given in the c_trace are two vertices I took off the fireball itself, that comes out of the dragon's mouth. If I un-comment out the first beep() above, it beeps like crazy, even if the fireball did not even get shot out of the dragon's mouth.

So even if the fireball did not get shot, it is still beeping. Does anyone have any idea why?

Re: Dragon not harming player [Re: Ruben] #455127
10/10/15 17:15
10/10/15 17:15

M
Malice
Unregistered
Malice
Unregistered
M



SET in the c_trace -- Ignore_me | ingore_passable | scan_ents | INGORE_BLOCK | IGNORE_SPRITES | ACTIVATE_SHOOT;

In the fire_ball SET(my,PASSABLE)

In the player add this my.emask |= ENABLE_SCAN | ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_SHOOT ;
my.event = damage_event();

Now damage on the player should be a function of the player or player event.

function damage_event()
{
if(event_type == EVENT_SHOOT)
// -- Do one time one frame damage code here -- //
}

Re: Dragon not harming player [Re: ] #455128
10/10/15 17:36
10/10/15 17:36
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Originally Posted By: Malice
SET in the c_trace -- Ignore_me | ingore_passable | scan_ents | INGORE_BLOCK | IGNORE_SPRITES | ACTIVATE_SHOOT;

In the fire_ball SET(my,PASSABLE)

In the player add this my.emask |= ENABLE_SCAN | ENABLE_IMPACT | ENABLE_ENTITY | ENABLE_SHOOT ;
my.event = damage_event();

Now damage on the player should be a function of the player or player event.

function damage_event()
{
if(event_type == EVENT_SHOOT)
// -- Do one time one frame damage code here -- //
}



And that will work if the fireball is not a separate entity from the dragon itself?

If I open up the dragon .mdl model file, and I play the animation, the fireball is built into the .mdl file as part of the attack animation.

The fireball is not separate from the dragon, like the shooting energy ball is to the basic wizard model used in Gamestudio.

Re: Dragon not harming player [Re: ] #455129
10/10/15 17:57
10/10/15 17:57

M
Malice
Unregistered
Malice
Unregistered
M



Here we go ... ! Mal's gonna rock your code!
#define drng_damage_fire skill1
#define scan_code skill90
Code:
void dragon_ctrace()
{
  
    my.scan_code = 50;   // I'll explain another time 
    my.drng_damage_fire = 20;  // damage to do

    /// PROBLEM NUMBER 1 
    // vec_for_vertex (VECTOR* vector, ENTITY* entity, var number)
   // var fire_top; // vertex #220
   // var fire_bottom;  // vertex #235
// NOT a var but a VECTOR 
   VECTOR fire_top; // vertex #220
   VECTOR fire_bottom;  // vertex #235
	
   vec_for_vertex (fire_top, my, 220);
   vec_for_vertex (fire_bottom, my, 235);


     // MAKE the ent - passable 
     set(my,PASSABLE);

    // FORGET a IF!!
  // if (c_trace (fire_top, fire_bottom, SCAN_ENTS | SCAN_FLAG2) > 0)
  // {	
      //beep(); // DOES BEEP LIKE CRAZY IF UN-COMMENTED

c_trace (fire_top, fire_bottom, IGNORE_ME | IGNORE_PASSABLE | ACTIVATE_SHOOT | IGNORE_BLOCKS | IGNORE_SPRITES)
// IF TIME!!!
 if (HIT_TARGET) 
{	
      if (you != NULL)
      {	
         beep(); // DOES NOT BEEP AT ALL
        /// DO NOT DO DAMAGE ON THE OBJECT SIDE, Use the PLAYER EVENT SYSTEM
         //player_health -= drgn_damage_fire * time_step;
            // PLAYER'S HEALTH SHOULD REDUCE HERE, BUT IT IS NOT HAPPENING.
      }

      ...

   }
}
#define health skill1
//PLAYER TIME
function p_damage_event()
{
if(event_type == EVENT_SHOOT)
{
  if(you.scan_code <100)
  {
   // player_health and drng_damage_fire -- Should be skills not glob-vars
   player_health -= drgn_damage_fire * time_step;
   //my.health-= you.drgn_damage_fire * tstep;
}
}
}
action Ima_Player()
{

my.emask |= ENABLE_SHOOT;
my.event = p_damage_event;
}


Re: Dragon not harming player [Re: ] #455130
10/10/15 18:04
10/10/15 18:04

M
Malice
Unregistered
Malice
Unregistered
M



Using the var not vector is causing the IF(c_trace) to fire however the c_trace is most likly failing

Re: Dragon not harming player [Re: ] #455134
10/10/15 21:57
10/10/15 21:57

M
Malice
Unregistered
Malice
Unregistered
M



Once again I take time to answer, write code, look crap up in the manual and come back to no reply..


Good Luck Ruben
Peace and wet dreams Y'all

Re: Dragon not harming player [Re: ] #455142
10/11/15 04:49
10/11/15 04:49
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Thank you Malice. Your solution worked. I made some minor adjustments to it, but it works fine. Thank you again.

Re: Dragon not harming player [Re: Ruben] #455143
10/11/15 04:51
10/11/15 04:51
Joined: Jun 2010
Posts: 590
California
Ruben Offline OP
User
Ruben  Offline OP
User

Joined: Jun 2010
Posts: 590
California
Sorry Malice. I was gone at work all day. When I posted what I did earlier in the day, it was just before heading out the door, to go to work.

I love video game programming, and wish I could get paid to do this 24/7, but still have to make my bread and butter, until I make that big video game hit that makes me millions. ;-)

Last edited by Ruben; 10/11/15 04:55.
Page 1 of 2 1 2

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