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 → Respawning destroyed 3DO's
Respawning destroyed 3DO's
2003-07-07, 8:10 AM #1
I need a cog that will respawn the destructible barrel after it's been destroyed. I'd like for the cog to not just respawn one of them, but all of the ones in the level. Or, just have it so it will respawn any 3DO in the level when that 3DO is declared in the cog settings. EX: I want the medium sized orange explosive barrels to respawn (10 seconds maybe) after they've blown up, so in the cog where it might say "Item" I'll double click the space and browse for the medium sized orange explosive barrels. Hope it's not too hard to figure out.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-07, 9:53 PM #2
Here you go, [http://forums.massassi.net/html/wink.gif]

Code:
# spawn.cog
#
# A spawn cog for fuel barrels. Do not let JED make your ghost
# template the first template in your JKL or cogs will not be able
# to use it.
#
# [SM]
#==============================================================#
symbols

message	startup
message	removed
message	timer

template	barrel
template	ghost

flex		spawnDelay=10

thing		barrel0=-1
thing		barrel1=-1
thing		barrel2=-1
thing		barrel3=-1
thing		barrel4=-1

thing		ghost0	local
thing		ghost1	local
thing		ghost2	local
thing		ghost3	local
thing		ghost4	local

int		i		local

end
#==============================================================#
code
#------------------------------------------------------
startup:
	// create a ghost for each barrel - we're counting on
	// unused barrel variables being set to -1.
	for(i=0; i < 5 && barrel0 > -1; i=i+1)
	ghost0=CreateThingAtPos(ghost, GetThingSector(barrel0), GetThingPos(barrel0), '0 0 0');

Return;
#------------------------------------------------------
removed:
	// find the exploded barrel and set a thing timer for its ghost
	for(i=0; i < 5 && barrel0 != GetSenderRef(); i=i+1);
	SetTimerEx(spawnDelay, i, 0, 0);

Return;
#------------------------------------------------------
timer:
	// create our barrel at the pos of its ghost
	i = GetSenderID();
	barrel0=CreateThingAtPos(barrel, GetThingSector(ghost0), GetThingPos(ghost0), '0 0 0');
	// reset the barrels pos because CTAP puts the barrel
	// slightly above where it should be
	SetThingPos(barrel0, GetThingPos(ghost0));
	// capture our new barrel so we'll get its removed event
	CaptureThing(barrel0);

Return;
#------------------------------------------------------
end


That should pretty much do what you need. The warning in the header isn't an idle one. I don't think Alex really understood Cog's use of templates - or the fact that Cog can't use the first template in a JKL. So JED will seriously screw up your templates if you're not careful.

But to make a point, a '3do' is a model file with a .3do extension. It's the format used for JK's three-dimensional models. What a lot of editors call a 3do is really a thing (more generally called an object), so be careful to make a distinction. [/soapbox]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-08, 6:39 AM #3
So what you're saying is that I don't need to have any ghost.3do's and that once the barrel.3do gets destroyed, it gets turned into a ghost.3do and the cog uses it?

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-08, 8:30 AM #4
Well the cog works, except when they respawn, they respawn at the player's position and not their original position.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-08, 9:57 AM #5
As a personal preference, you could have saved the barrels pos and Lvec to vectors, then not create any ghosts and whatnot and whalla, a TCS. [http://forums.massassi.net/html/smile.gif] plus you save on 5 things in your level [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/tongue.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-07-08, 2:27 PM #6
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Trige:
So what you're saying is that I don't need to have any ghost.3do's and that once the barrel.3do gets destroyed, it gets turned into a ghost.3do and the cog uses it?
</font>


Not at all. You really misunderstood what I said in my last reply. First, a 3do is a model file that does nothing by itself. A template uses a 3do, and the things that you place in your level are created from templates. The only part of a thing that you 'see' in JED is the 3do, but that doesn't mean they're the same thing. A normal ghost doesn't even use a 3do.

Of course you need ghosts for this cog to work. Just read the code comments and you can see that. As for your problem, you have to use the barrel variables in the order that they're numbered.

Pilot, you're right that having more variables in the cog is better than creating the ghosts in the level, but that's something I like to do to keep the coding simple. BTW, CTAP uses its own orient so the old orient is not preserved.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-08, 4:01 PM #7
Okay, well here's what I did. When I first used the code, I switched from all of the things being barrels, to all of the things being ghosts and in the cog where it says Barrel(template) I put the barrel 3do, and then the ghost(template) I put the ghost 3do. But then nothing happened and the barrels weren't even in the level. So the second run, I changed all of the ghost 3do's to being barrel 3do's and left the settings for the cog as they were. It worked then and the barrels respawned after explosion, except they spawned where the player was at the time. Perhaps I should have the barrel 3do's in the level and in the barrel 3dos' positions I place ghost 3do's also?

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-08, 7:15 PM #8
Can you not understand my explanation? You do know how to place and use cogs in a level with JED, right? No offense, but you don't know too much about what you're doing, and it's frustrating trying to help you. I told you in my first reply what a 3do was...

Quote:
<font face="Verdana, Arial" size="2">where it says Barrel(template) I put the barrel 3do, and then the ghost(template) I put the ghost 3do.</font>


So if a cog has a template variable that needs a value from the level, why on earth would you give it a 3do?!

You place a thing in your level. With JED, view its properties, double-click its template and select your barrel (ex xtank). What you're selecting here is a template. When JK loads your level, it will create a thing from this template. Your level keeps a numbered list of things to create. You can see this number when you view a placed thing's properties in JED. It is this number that you need to give the spawn cog. If you have the placed thing selected, you can go to the placed cogs form, select the next unused barrel variable, and hit the 'Get Selected Item' button.

For the barrel and ghost variables, double-click on the input box for them, and JED will bring up a list of templates for you to select from. Give barrel the same xtank template that you gave your placed thing. Give ghost the 'ghost' template.

Make sure the unused barrel variables are set to -1 and that you used the lowest numbered barrels first. I.e., use barrel0 before barrel1. Notice that at no point did I mention a 3do.

Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-09, 4:18 AM #9
Sorry, I don't mess with cogs a lot (atleast not custom ones). I did however do exactly what you said to do in your last post, and posted the results from that in my previous post (I just worded it wrong, said 3do instead of template). I do know the basics of using cogs, but for some reason the barrels keep respawning from the player's position and not the barrels' original position. If you want, I can send you a screen shot of what it looks like in my cog settings.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-09, 2:35 PM #10
Ok, send me the screenshot.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-09, 4:09 PM #11
[http://www.massassi.net/ec/images/11810.jpg]

Yes, yes, I know that that's a lot of barrels, but I know what I'm doing.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-09, 5:22 PM #12
And nothing happens with that? Open up your jkl file with a text editor. Find the templates section. If the first template in the section is the ghost template, that's why. Add 'blank none orient=(0/0/0)' as the first template. Then see if it works.

You should have said you had so many barrels. Its easy to write a level cog for a few barrels, but for that many? I'll write a class cog that you can just place in your cog folder, but let's get this to work first. And use only one or two copies of this cog at first.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-10, 4:31 AM #13
No, this works, only partially. The barrels respawn where the player is at the time. I'll try what you've said now.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-10, 4:53 AM #14
Still doesn't work right. The barrels keep respawning at the player's position.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-10, 8:02 PM #15
The only way I can see that happening is if you didn't enter the thing values correctly. [http://forums.massassi.net/html/confused.gif]

Can you zip the level and send it to me?

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-11, 9:49 PM #16
Alright, enough with the level cog. If you still haven't got it working, nevermind, save the following cog as 'xtank1' and put it in your project dir's cog folder.
Code:
# xtank1.cog
#
# Class cog for xtanks. Respawns destroyed tanks.
#
# [LEC + SM]
#==============================================================#
flags=0x80
#==============================================================#
symbols

message   created
message   damaged
message   timer

template  barrel_exp=+xtank1_exp   local

thing     barrel                   local

flex      barrelhealth             local
flex      damage                   local
flex      spawnDelay=10            local

end
#==============================================================#
code
#------------------------------------------------------
created:
	SetThingUserData(GetSenderRef(), 30);

Return;
#------------------------------------------------------
damaged:
	barrel = GetSenderRef();
	damage = GetParam(0);
	barrelhealth = GetThingUserData(barrel);
	if(GetParam(1) == 1) Return;
	if(barrelhealth <= damage)
	{
		SetTimerEx(0.5, barrel, 0, 0);
		Return;
	}
	SetThingUserData(barrel, barrelhealth - damage);

Return;
#------------------------------------------------------
timer:
	barrel = GetSenderID();
	KillTimerEx(barrel);
	if(GetThingFlags(barrel) & 0x10)
	{
		ClearThingFlags(barrel, 0x10);
		SetCollideType(barrel, 3);
	}
	else
	{
		CreateThing(barrel_exp, barrel);
		SetThingFlags(barrel, 0x10);
		SetCollideType(barrel, 0);
		SetTimerEx(spawnDelay, barrel, 0, 0);
	}

Return;
#------------------------------------------------------
end

This ought to be foolproof. [http://forums.massassi.net/html/smile.gif]

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-07-12, 8:54 AM #17
I'll give it a try. Sorry I couldn't get the level to ya. I was out of town and couldn't really send it til I got back.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-12, 4:05 PM #18
Woohoo! It works! Thanks for your help SM, I really appreciate it. If I need help with anything else, I'm gonna come right back!

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-13, 2:44 AM #19
Hmm a bit late of a reply maybe but wouldn't it be easier to just put respawn=10 in the template of the barrel? Or wouldn't that work when a thing is destroyed?

------------------
Call me Vedder.
Author of: A Pirate's Tale (Mots SP)
APT homepage
----
<phantom> You're always going to be aloser if you attempt to aspire to massassi standards.
<phantom> They're a bunch of socially inadequate <beep> whores who have little or no lives.
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-07-13, 6:02 AM #20
SM made it so that all of the xtank1 barrel 3do's respawn when there damaged. You don't have to enter their thing number or anything, just add the cog and it will do it.

------------------
The Editor of bad levels such as:

Battle Ground Oasis The Forgotten Tomb
Office Building Arena
SpacePort Oasis
Wookie Camp
Fade to Black
Thriving Desert
Who made you God to say "I'll take your life from you"?
2003-07-14, 6:19 PM #21
Quote:
<font face="Verdana, Arial" size="2">Hmm a bit late of a reply maybe but wouldn't it be easier to just put respawn=10 in the template of the barrel? Or wouldn't that work when a thing is destroyed?</font>


Only items can use respawn. But the flag that 'taken' items use (SITH_TF_DISABLED) would be better to use than what I have. E.g.,

Code:
if(GetThingFlags(barrel) & 0x80000)
{
	ClearThingFlags(barrel, 0x80000);
}
else
{
	CreateThing(barrel_exp, barrel);
	SetThingFlags(barrel, 0x80000);
	SetTimerEx(spawnDelay, barrel, 0, 0);
}


------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!