3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: 1 [2]

Author Topic: ValuePrint  (Read 1489 times)

« Reply #15 on: April 12, 2013, 12:48:39 PM »
yes I think should attach script with counter Object.

Can you speak more clearly?
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.

fourdee

« Reply #16 on: April 12, 2013, 01:00:12 PM »
I attached a script to EventonContact and used this script but don't work:
Code: [Select]
int Health = 100;
int Damage = 10;

void Main()
{
     // int result = Health - Damage; //this will be 90
      //result = Health; //this will be 90

   if (Health == 0)// Will never == 0
   {
      iObjectHide (OBJ_44);
      iObjectShow (OBJ_22);
   }
}

Try this instead
Code: [Select]
int Health = 100;
int Damage = 10;
bTakeDamage = false;

void Main()
{
  //You'll need to assign bTakeDamage to an event, eg: user has been shot etc.

   if(bTakeDamage) //eg: Iam being hit, now i take away health
   {
       if(Health >= 10) // Only take health away when its >= 10
       {
            Health -= Damage;
       }
       bTakeDamage = false; //Reset this once damage has been applied
   }
   else if (Health == 0) //Your dead
   {
      iObjectHide (OBJ_44);
      iObjectShow (OBJ_22);
   }
}
« Reply #17 on: April 13, 2013, 01:08:44 PM »
Quote
int Health = 100;
int Damage = 10;
bool bTakeDamage = false;

void Main()
{
  //You'll need to assign bTakeDamage to an event, eg: user has been shot etc.

   if(bTakeDamage) //eg: Iam being hit, now i take away health
   {
       if(Health >= 10) // Only take health away when its >= 10
       {
            Health -= Damage;
       }
       bTakeDamage = false; //Reset this once damage has been applied
   }
   else if (Health == 0) //Your dead
   {
      iObjectHide (OBJ_44);
      iObjectShow (OBJ_22);
   }
}

Thanks  Fourdee. :D

But don't work this code.
I think it Will never ==0, Because no change (iObjectHide (OBJ_44), iObjectShow (OBJ_22)).
« Last Edit: April 13, 2013, 01:10:33 PM by behdadsoft »
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.

fourdee

« Reply #18 on: April 13, 2013, 01:38:46 PM »
Thanks  Fourdee. :D

But don't work this code.
I think it Will never ==0, Because no change (iObjectHide (OBJ_44), iObjectShow (OBJ_22)).
Without seeing your project, i cant help you fix it.
Logically, the script should work as long as you define a event to bTakeDamage.
« Reply #19 on: April 14, 2013, 09:46:19 AM »
this is my Project.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.

fourdee

« Reply #20 on: April 14, 2013, 09:54:30 AM »
Ok, i've had a look and got it working.
I changed a few things:
- Script is now running at all times
- The EventOnContact gives us a ContactForce number in the script
- This ContactForce is then used to start the "bApplyDamage" loop

Theres probably a million different ways to achieve this, but, this is my take on what you have provided.
Have fun.

Code: [Select]
int TEXT_PRINT = OBJ_0;

int Health = 100;
int Damage = 10;

bool bTakeDamage = false;

//----------------------------------------------

void Main()
{
   //This is the eventoninput force amount.
   float ContactForce = IN_66;

   if(ContactForce > 20000)
   {
      bTakeDamage = true; //Damage is now active
   }
   else if(bTakeDamage) //wait for contact force to go lower than 20,000 before we apply damage.
   {
       if(Health >= 10) // Only take health away when its >= 10
       {
            Health -= Damage;
       }
       bTakeDamage = false; //Reset this once damage has been applied
   }
   

   if(Health == 0) //Your dead
   {
      //This should be a switch (eg: done once).
      //But, it will work as a loop for now.
      iObjectHide(OBJ_44);
      iObjectShow(OBJ_22);
   }

   //Print the results, so we can read the numbers :)
   iPrint("Force:  "+ContactForce,0,0,TEXT_PRINT);
   iPrint("Health:  "+Health,0,-5,TEXT_PRINT);
}
« Last Edit: April 14, 2013, 09:59:13 AM by Fourdee »
« Reply #21 on: April 14, 2013, 10:04:19 AM »
Thanks Fourdee.  :D

I guess must use ContactForce in script. In a previous post I asked about it.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
Pages: 1 [2]