Bomb doesn´t explode
Moderator: InsideQC Admins
7 posts
• Page 1 of 1
Bomb doesn´t explode
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
func_bomb_target
i tried with
if (other.touch != "bomb")
{
BombThink;
}
but game crashed.
BombTouch code
BombThink code
Bombexplode code is the same as GreanadeExplode.
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: Select all
/*
================
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: Select all
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: Select all
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: Select all
void() BombThink =
{
local entity bomb;
bomb.nextthink = time + 30;
bomb.think = BombExplode;
};
Bombexplode code is the same as GreanadeExplode.
- Stealth Kill
- Posts: 83
- Joined: Fri Dec 29, 2006 12:34 pm
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).
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).
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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.
- FrikaC
- Site Admin
- Posts: 1026
- Joined: Fri Oct 08, 2004 11:19 pm
This is my new code
it doesn´t explode can someone help?
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?
- Stealth Kill
- Posts: 83
- Joined: Fri Dec 29, 2006 12:34 pm
Doing a return; at the end of a void function does nothing.... it's already leaving it
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.
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.
Benjamin Darling
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
http://www.bendarling.net/
Reflex - In development competitive arena fps combining modern tech with the speed, precision and freedom of 90's shooters.
http://www.reflexfps.net/
- Electro
- Posts: 312
- Joined: Wed Dec 29, 2004 11:25 pm
- Location: Brisbane, Australia
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
