Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → dystroy an object
dystroy an object
2003-04-16, 4:08 PM #1
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/
2003-04-16, 4:10 PM #2
sorry about the spelling

------------------
see me at: http://www.geocities.com/star_trekguy/
2003-04-16, 5:12 PM #3
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.
Code:
# 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).]
Famous last words - "It seemed like a good idea at the time."
2003-04-16, 9:16 PM #4
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...
Catloaf, meet mouseloaf.
My music
2003-04-17, 11:14 AM #5
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/
2003-04-17, 1:00 PM #6
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:
Code:
Arrived:
     If(GetSenderRef() != Droid) return;
     CurFrame=CurFrame+1;
     if(CurFrame == WhateverFrame[/i])
          { 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).]
Catloaf, meet mouseloaf.
My music
2003-04-17, 4:07 PM #7
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/
2003-04-17, 4:27 PM #8
you could try setting a timer that checks for when the droid has stoped moving.
like this.
Code:
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).]
Famous last words - "It seemed like a good idea at the time."
2003-04-17, 4:36 PM #9
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).]
Catloaf, meet mouseloaf.
My music

↑ Up to the top!