Inside3D!
     

Bomb doesn´t explode

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Stealth Kill



Joined: 29 Dec 2006
Posts: 83

PostPosted: Sat Feb 16, 2008 4:23 am    Post subject: Bomb doesn´t explode Reply with quote

Hi,

I have a problem.
My "bomb" should explode after 30seconds if it touches the "func_bomb_target" brush but it doesnt explode.



Here is my code


Modified Grenate code
Code:
/*
================
W_FireC4
================
*/
void() W_FireC4 =
{
   local   entity bomb, mpuff;
   
   self.currentammo = self.ammo_c4a = self.ammo_c4a - 1;
   
   sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);

   self.punchangle_x = -2;

   bomb = spawn ();
   bomb.owner = self;
   bomb.movetype = MOVETYPE_TOSS;
   bomb.solid = SOLID_BBOX;
   bomb.classname = "bomb";
      
   

   makevectors (self.v_angle);

   if (self.v_angle_x)
      bomb.velocity = v_forward*0 + v_up * 0 + crandom()*v_right*0 + crandom()*v_up*0;
   else
   {
      bomb.velocity = aim(self, 10000);
      bomb.velocity = bomb.velocity * 0;
      bomb.velocity_z = 0;
   }

   bomb.avelocity = '0 0 0';

   bomb.angles = vectoangles(bomb.velocity);
   
   bomb.touch = BombTouch;
   
   setmodel (bomb, "progs/c4.mdl");
   setsize (bomb, '0 0 0', '0 0 0');      
   setorigin (bomb, self.origin);
};


func_bomb_target

Code:

void() func_bomb_target =
{

   self.angles = '0 0 0';
   self.movetype = MOVETYPE_PUSH;
   self.solid = SOLID_NOT;
   
   setmodel (self, self.model);

if (other.classname != "bomb")
{
BombThink;
}

   if (!(self.spawnflags & 1))
      self.model = string_null;
};


i tried with

if (other.touch != "bomb")
{
BombThink;
}

but game crashed.



BombTouch code

Code:

void() BombTouch =
{
   if (other == self.owner)
      return;      // don't explode on owner
   if (other.takedamage == DAMAGE_AIM)
   {
      BombExplode();
      return;
   }

if (other.classname != "func_bomb_target")
{
BombThink;
}

   sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);   // bounce sound
   if (self.velocity == '0 0 0')
      self.avelocity = '0 0 0';
};



BombThink code

Code:
void() BombThink =
{

   local   entity bomb;


   bomb.nextthink = time + 30;
   bomb.think = BombExplode;
};



Bombexplode code is the same as GreanadeExplode.
Back to top
View user's profile Send private message
leileilol



Joined: 15 Oct 2004
Posts: 1321

PostPosted: Sat Feb 16, 2008 5:02 am    Post subject: Reply with quote

Your "BombThink;"'s are missing ()s.
_________________
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Sat Feb 16, 2008 5:11 am    Post subject: Reply with quote

Firstly: you're not actually calling the BombThink function.
Its only a function call if it includes the brackets after it. Otherwise its a useless statement that means absolutly nothing.

BombThink; <- this does feck all
BombThink(); <- this is what you should have used.

Secondly, its quite likly that your bomb will touch your trigger several times (every single frame it moves in, as well as any frames where force_retouch is set). Every frame that it touches, it will reset the nextthink timer - so it'll never blow up if a cunning user manages to find the right triggers elsewhere on the map (force_retouch stuff).

Thirdly, your func_bomb_target is a spawn function. not a touch function. Using 'other' in there is generally a bad plan.

Fourthly, your func_bomb_target is not solid. It cannot be touched. Ever. I don't know wether you wanted it as trigger or bsp, (if trigger, it still cannot be touched, but can do the touching - which your code does not attempt to support - see note 3).

if (other.touch != "bomb")
makes no sense. I don't see why it would crash though.
I guess its frikqcc treating other.touch as a string... but functions should be low enough that they're within the string table.
But still, in that spawn function, 'other' is not set to anything meaningful. I don't see why that would result in a crash. Compiler error sure (with fteqcc definatly) but not crash (frikqcc will compile it, even though it makes no sense).
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Sat Feb 16, 2008 5:31 pm    Post subject: Reply with quote

Frikqcc made some hacks to make the nehahra code compile, I thought I removed them, but I guess some of the newer versions have them in there still. I really need to get around to fixing that. My recommendation is to just use fteqcc however.
Back to top
View user's profile Send private message Send e-mail
Stealth Kill



Joined: 29 Dec 2006
Posts: 83

PostPosted: Wed Apr 16, 2008 7:50 pm    Post subject: Reply with quote

This is my new code

Quote:
void() func_bomb_target =
{

self.movetype = MOVETYPE_PUSH;
self.solid = SOLID_BSP;
setsize (self, self.mins , self.maxs);
setorigin (self, self.origin);
setmodel (self, self.model);
self.classname = "func_bomb_target";
return;

if (other.classname != "bomb")
BombThink();
return;


};


void() BombTouch =
{

sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
if (self.velocity == '0 0 0')
self.avelocity = '0 0 0';
};

void() BombThink =
{

self.nextthink = time + 30;
self.think = BombExplode;

};


it doesn´t explode can someone help?
Back to top
View user's profile Send private message
Electro



Joined: 29 Dec 2004
Posts: 241
Location: Brisbane, Australia

PostPosted: Wed Apr 16, 2008 11:56 pm    Post subject: Reply with quote

Doing a return; at the end of a void function does nothing.... it's already leaving it Wink

Secondly, having the
return;
after
self.classname = "func_bomb_target";

means it's returning out of the function, and your
if (other.classname != "bomb")
is never actually being reached.


Another thing to keep in mind, is that you should probably consider having the func_bomb_target spawn the bomb model. Otherwise when you do BombExplode or whatever, I assume you will be doing a remove... in which case you'll be removing the func_bomb_target. So it wouldn't be reusable from then on (it'd be gone). Could be wrong though, not sure what you're doing with your exploding.
_________________
Unit reporting!
http://www.bendarling.net/
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Elite_Babe1990



Joined: 14 Aug 2008
Posts: 4

PostPosted: Mon Aug 25, 2008 5:54 am    Post subject: Reply with quote

You forgot () <-s
_________________
I may be cte but I can pwn u at halo!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group