PDA

View Full Version : dystroy an object



star_trekguy
04-16-2003, 07:08 PM
I would like to make a computer consol that you can shoot at and blow it up. I can't quite get the cog to work. If anyone could give some advice of where to start.


------------------
see me at: http://www.geocities.com/star_trekguy/

star_trekguy
04-16-2003, 07:10 PM
sorry about the spelling

------------------
see me at: http://www.geocities.com/star_trekguy/

DSLS_DeathSythe
04-16-2003, 08:12 PM
heres a cog that will do that.
instead of really destroying the console it makes the console invisible and turns off its collide then creates an explosion.


# Written By DSLS_DeathSythe
symbols
#=====
message startup
message damaged
message timer
thing console=-1 mask=0x448
flex max_dmg=50.0
template exp_tpl
int respawn=1
flex respawn_wait=30.0
flex total_dmg=0.0 local
int dead=0 local
int col_type local
#-----
end
#=====
code
#-----
startup:
if(IsServer())
{
total_dmg = 0.0;
dead = 0;
col_type = GetCollideType(console);
}
return;
#-----
damaged:
damage = GetParam(0);
if(GetParam(1) == 1 || dead == 1)
{
ReturnEx(0);
return;
}
total_dmg = total_dmg + damage;
if(total_dmg > max_dmg)
{
dead = 1;
total_dmg = 0.0;
SetThingFlags(console, 0x10);
SetCollideType(console, 0);
CreateThing(exp_tpl, console);
if(respawn == 1)
SetTimer(respawn_wait);
ReturnEx(0);
return;
}
ReturnEx(0);
return;
#-----
timer:
dead = 0;
ClearThingFlags(console, 0x10);
SetCollideType(console, col_type);
return;
#=====
end

if you dont want the console to respawn then just change the respawn int to 0.

------------------


[This message has been edited by DSLS_DeathSythe (edited April 16, 2003).]

DogSRoOL
04-17-2003, 12:16 AM
There's already an LEC cog that does this. It's called "03_vapExplode.cog". It's used for exploding vaporator 3dos, but works with anything.

------------------
May the forks be with you.
There is a great disturbance in my shorts...

star_trekguy
04-17-2003, 02:14 PM
thanks, I got that to work. I have another question though, how do I know when a droid has stopped moving? I have him move into an elevator when the computer explodes but I have to know when he is there. How do I do that. I've tried using the arrived thing but it didn't work. Any ideas?

------------------
see me at: http://www.geocities.com/star_trekguy/

DogSRoOL
04-17-2003, 04:00 PM
GetCurFrame doesn't seem to work on AI, but the "Arrived" message does. You'll have to keep track of your frame manually with a variable in the "Arrived" message, something like this:


Arrived:
If(GetSenderRef() != Droid) return;
CurFrame=CurFrame+1;
if(CurFrame == WhateverFrame)
{ Block Statement Here }

Just make sure your have "CurFrame=0" before making the droid move (just set it to 0 in your symbols section).

------------------
May the forks be with you.
There is a great disturbance in my shorts...

[This message has been edited by DogSRoOL (edited April 17, 2003).]

star_trekguy
04-17-2003, 07:07 PM
I did that and it still doesn't work. I accedentaly tried it without the droid (it was not assigned a sector) and the elevator moved fine but when I put the droid back, he move to the elevator and nothing happens. I think the cog is not recognizing that the droid has arrived. is there any was to fix this?

------------------
see me at: http://www.geocities.com/star_trekguy/

DSLS_DeathSythe
04-17-2003, 07:27 PM
you could try setting a timer that checks for when the droid has stoped moving.
like this.


timer:
if(IsThingMoving(droid))
{
SetTimer(0.1);
return;
}
else
{
MoveToFrame(elevator, frame, movespeed);
return;
}
return;

or something to that effect. it might work.

------------------


[This message has been edited by DSLS_DeathSythe (edited April 17, 2003).]

DogSRoOL
04-17-2003, 07:36 PM
I always use my above method and it works fine. Maybe you forgot to add something to your symbols?
DeathSythe's method might work, but I have problems with "IsThingMoving" in conjunction with an actor. Perhaps it just depends on what you're doing.

Oh, yeah...
If you use my method, you need to tell the droid to move to his next frame each time in the arrived message (After "CurFrame=Curframe+1"):
AiSetLookFrame(Droid, curframe);
AiSetMoveFrame(Droid, curframe);
------------------
May the forks be with you.
There is a great disturbance in my shorts...

[This message has been edited by DogSRoOL (edited April 17, 2003).]