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 → Respawing Mines
Respawing Mines
2005-08-25, 3:56 PM #1
I'm in the final stages of my egyptian level.
One of the last touches I want to add are
sequence mines that respawn after they
are tripped. In order to acheive this I want
to use a level cog that will generate a
sequence mine at a ghost postition at
startup. Then I want it to wait until the
mine is destroyed. If the mine is destroyed
then a new mine will respawn 20 seconds
later.

I will try and get something whipped up but
I am am just barely getting into cogging and
my abilities in this area are quite limited for
now. It would be great if anyone could help
me with this.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-25, 4:15 PM #2
Code:
# mines that spawn at a ghost position

symbols

message startup
message timer
message removed

thing mineSpawnGhost
template mineTemplate=+seqchrg2
flex respawnDelay=20.0

int mine local
int gonething local

end

# ---

code

startup:
SetTimerEx(0.1, 1, 0, 0);
Return;

# ---

removed:
gonething = GetSenderRef();
if(gonething == mine) // just checking
{
SetTimerEx(respawnDelay, 1, 0, 0);
ReleaseThing(mine);
}
Return;

# ---

timer:
if(GetSenderID() == 1)
{
mine = FireProjectile(mineSpawnGhost, mineTemplate, -1, -1, '0 0 0', '0 0 0', 1.0, 0x30, -1, -1);
CaptureThing(mine);
}
Return;

end


not tested, but I hope it works
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-25, 5:02 PM #3
Your cog caused a crash so something is
wrong with it prodigy. Here's a cog I wrote
which doesn't work but I'm hoping could
give some ideas or is fixable. Thanks for
the cog though prodigy.

Code:
# Jedi Knight Cog Script
#
# mine_respawn.COG
#
# creates a mine at a ghost position and respawns
# it after it is tripped 
#
# 
# jedi I 2005
# ========================================================================================

symbols

thing		ghost=
thing           spawnpoint                      local
thing           mine                            local

template	minetemplate=

sound		respawn_snd=Activate01.wav	local

flex		wait_time=20

message		startup
message		removed
message		timer

end

# ========================================================================================

code

startup:
        // Copy mine position
        mine=GetThingPos(ghost);

	// Create the mine at the ghost position
	spawnpoint = CreateThing(minetemplate, mine);
	SetThingRotVel(spawnpoint, '0 0 0');

	Return;

# .......................................................................................

removed:
        SetTimer(wait_time);

	Return;

# ........................................................................................

timer:
        // Copy mine position
        mine=GetThingPos(ghost);

	// Create the mine at the ghost position
	spawnpoint = CreateThing(minetemplate, mine);
	SetThingRotVel(spawnpoint, '0 0 0');

	// Play the respawn sound
	PlaySoundThing(respawn_snd, mine, 1, 0, 8, 0x0);
 
	Return;
end
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-25, 7:09 PM #4
hmm that's rather odd because I tested it and it works for me
you could try it removing the CaptureThing and ReleaseThing lines.

in the cog you posted I noticed this

"mine=GetThingPos(ghost);"

yet mine is listed as a thing, while getthingpos returns vectors.

where it says spawnpoint = CreateThing(mineteplate, mine); just change mine to ghost

What are the SetThingRotVel's for?
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-25, 10:00 PM #5
Originally posted by ProdigyOddigy:
hmm that's rather odd because I tested it and it works for me
you could try it removing the CaptureThing and RemoveThing lines.

in the cog you posted I noticed this

"mine=GetThingPos(ghost);"

yet mine is listed as a thing, while getthingpos returns vectors.

where it says spawnpoint = CreateThing(mineteplate, mine); just change mine to ghost

What are the SetThingRotVel's for?


Quite honestly I don't know what the heck I'm
doing when it comes to cog. I am just trying to
live and learn I guess. It did crash but it could
have been something else that caused the crash.
I'll gob it again and try and get it to run. I just
assumed that it was the cog that caused the
crash since that's the only change I made to the
level before I gobbed it again. It might have
just been a fluke with my computer.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-25, 10:53 PM #6
I tested it and it worked great. It must
have been my crapy video card. It is a
peice of junk but it's what I have. The
card sometimes has trouble loading on
a 512x384 resolution. It did freeze the
whole computer. I've never seen a cog
do more than crash the game so I ought
to have checked it again before I
assumed the cog had something wrong
with it. I changed my mind about using
them on the side of the pyramid because
by the time you trip them you are way
past them and don't get hit by the blast.
I will just use the cog in some of my empty
halls to spice them up a bit. Thanks a
ton Prodigy! Sorry about the confusion
about the crashing.
If curiosity killed the cat then perhaps Curious George killed the cat.
But Cat's do have nine lives so who knows?
2005-08-26, 8:56 AM #7
No, you couldn't remove the capturething() line... because then after the second sequencer is created, "removed" will never be called.
May the mass times acceleration be with you.

↑ Up to the top!