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 → Quick Question!
Quick Question!
2003-07-25, 2:11 AM #1
Hi!
Quick Question and I'm hoping for a Quick Answere...

How do I, in a JK COG, find out if an object has been damaged by a rail detonator?

/Edward


[This message has been edited by Edward (edited July 25, 2003).]
Edward's Cognative Hazards
2003-07-25, 4:07 AM #2
template rail=+raildet
Damaged:
If(GetThingTemplate(GetSourceRef()) == rail)

It could also be GetSenderRef(), and the template could be different, but I don't think so on both accounts.

------------------
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-25, 7:20 AM #3
Nothing happened!
NEXT!!!
Edward's Cognative Hazards
2003-07-25, 10:34 AM #4
that would work, it is getsourceref and not getsenderref

the damaged message goes in the cog that belongs to the thing that might have been damaged by a rail

and for both primary and secondary it is
template rail=raildet
template rail1=raildet2
if(Getthingtemplate(Getsourceref())== rail || rail1)

that all works fine so how are you trying to implement it?

------------------
roses are red, violets are blue, I am schizophrenic, and I am too!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-07-25, 10:44 AM #5
OK! Something happened! The action under the IF activated after it slammed into a wall!

How does the thing slam into a wall? Well, I made it shoot out at speed 10...

/Edward
Edward's Cognative Hazards
2003-07-25, 2:10 PM #6
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Edward:
Nothing happened!
NEXT!!!
</font>


If someone goes to the trouble of helping you, you could be more courteous...

Quote:
<font face="Verdana, Arial" size="2">OK! Something happened! The action under the IF activated after it slammed into a wall!</font>


Did you copy Han's if statement exactly as he posted it? He meant that you should write it out as:
Code:
if(Getthingtemplate(Getsourceref()) == rail || Getthingtemplate(Getsourceref()) == rail1)


Just to make sure because it should have worked the first time.

What is this object that gets damaged, and is this its class cog that you have damaged in?

------------------
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-25, 3:26 PM #7
Just a thought...

Isn't rail detonator damage actually caused by its explosion template, not the detonator itself?

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music
2003-07-25, 11:50 PM #8
Well, yeah... It is a class COG... In the template I have "ball - parent - this - that - cog=ball.cog. And all the symbols are local.
OK, as this Quick Question has gone this far, I guess it is only fair to post the COG...
Code:
# Ball COG
#
# By Edward
symbols

message		touched
message		created
#message		damaged

thing		ball		mask=0x405,local
thing		player		local
thing		maker		local

template	boom=+xtank1_exp	local
template	rail=raildet		local
template	rail1=raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	If(player!=maker) {
	DamageThing(player,100,0x1,ball);
	if(GetThingHealth(player)>100)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	} }
return;
created:
	ball=GetSenderRef();
	maker=GetSourceRef();
return;
damaged:
	ball=GetSenderRef();
	if(Getthingtemplate(Getsourceref())== rail || rail1) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end


But you know... I did have a suspicion about there being something like... GetParam()?

/Edward

[This message has been edited by Edward (edited July 27, 2003).]
Edward's Cognative Hazards
2003-07-27, 12:04 AM #9
Still need help!
Edward's Cognative Hazards
2003-07-27, 8:21 AM #10
you need to correct your if statement to be like sabermasters

------------------
roses are red, violets are blue, I am schizophrenic, and I am too!
roses are red, violets are blue, I am schizophrenic, and I am too!
2003-07-27, 9:14 AM #11
Well, I've changed that and it won't disappear from anything! No slamming against wall nor a blow from a rail!
Code:
update
# Ball COG
#
# By Edward
symbols

message		touched
message		created
#message		damaged

thing		ball		mask=0x405,local
thing		player		local
thing		maker		local

template	boom=+xtank1_exp	local
template	rail=raildet		local
template	rail1=raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	If(player!=maker) {
	DamageThing(player,100,0x1,ball);
	if(GetThingHealth(player)>100)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	} }
return;
created:
	ball=GetSenderRef();
	maker=GetSourceRef();
return;
damaged:
	ball=GetSenderRef();
	if((Getthingtemplate(Getsourceref()) == rail) || (Getthingtemplate(Getsourceref()) == rail1)) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end

I tried with and without the extra brackets...

/Edward
Edward's Cognative Hazards
2003-07-27, 4:55 PM #12
I don't know if the rail detonator's explosion template is used by other things...
If not, I suggest finding out what it is and changing your template(s) to that. If it is used by other things, make a new one with a new name based on it, and change the explode in the rail detonator's template to the one you just made. Then specify the new template in your cog. And don't worry - explosions do count as things. Everything you see (that's not level architecture) does, in fact.

Another thing - is this a class cog? If not, the created message will NOT be sent, which in turn prevents your "maker" and "ball" variables from being set. I'm not entirely sure how "damaged" will react. If this IS a class cog, messages will be sent by whatever object it's attached to - unless you do something similar to this:
Code:
Startup:
     Player = jkGetLocalPlayer();
     CaptureThing(player);
     Return;
Now, I'm not sure if capturing the player will truncate it's own class cog. My guess is that it won't. Anyway, make sure you filter the touched, created, and damaged messages so they aren't sent by both the player and the rail detonator. If you still need help, I'll rewrite the cog. I see some other stuff that *might* cause problems, but it's easier to re-write it (for me).

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music
2003-07-27, 6:16 PM #13
Quote:
<font face="Verdana, Arial" size="2">Isn't rail detonator damage actually caused by its explosion template, not the detonator itself?</font>


Both the exp and proj cause damage.

Quote:
<font face="Verdana, Arial" size="2">mask=0x405,local</font>


What in the world is that supposed to mean? I know Parsec told you better than that. You can't mask things in a class cog. And making it local on top of that...

Quote:
<font face="Verdana, Arial" size="2">
maker=GetSourceRef();
</font>

There is no source to created.

Quote:
<font face="Verdana, Arial" size="2">
touched:
ball=GetSenderRef();
player=GetSourceRef();
If(player!=maker) {
</font>


maker would have been from created. We don't want to have the maker of the last ball created unless only one ball was created in the game - then it doesn't matter.

Quote:
<font face="Verdana, Arial" size="2">
player=GetSourceRef();
</font>


Actors can also touch things. Don't know if they're a problem though...

Quote:
<font face="Verdana, Arial" size="2">
if(GetThingHealth(player)>100)
</font>


Yeah, right.

Quote:
<font face="Verdana, Arial" size="2">
#message damaged
</font>


Your cog has this and you wonder why damaged doesn't work?

Quote:
<font face="Verdana, Arial" size="2">template rail=raildet local
template rail1=raildet2 local
</font>


Where are the **** plus signs?

Quote:
<font face="Verdana, Arial" size="2">
Another thing - is this a class cog? If not, the created message will NOT be sent,
</font>


Whoa, there. Think again. I can't believe you didn't see anything in that cog, Dogsrool.

Excuse my extreme cynicism, but I'm tired and I can't believe some of that code. Fix what I mentioned, post the corrected code, and we'll take it from there. [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-27, 11:33 PM #14
Nothing has changed...
Code:
# Ball COG
#
# By Edward
symbols

message		touched
message		created
message		damaged

thing		ball		local
thing		player		local
thing		maker		local

template	boom=+xtank1_exp	local
template	rail=+raildet		local
template	rail1=+raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	If(player!=maker) {
	DamageThing(player,100,0x1,ball);
	if(GetThingHealth(player)>100)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	} }
return;
created:
	ball=GetSenderRef();
	maker=GetSourceRef();
return;
damaged:
	ball=GetSenderRef();
	if((Getthingtemplate(Getsourceref()) == rail) || (Getthingtemplate(Getsourceref()) == rail1)) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end

And also, when I restart the level, it crashes...
/Edward
Edward's Cognative Hazards
2003-07-28, 8:51 AM #15
Quote:
<font face="Verdana, Arial" size="2">Nothing has changed...</font>

So I noticed. I just told you what to fix.

------------------
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-28, 11:07 AM #16
Well, I took away the created thing and the if(player!=maker) and I died the moment I shot the thing... Of course I was holding the weapon and the ball's size is 0.3...
Code:
# Ball COG
#
# By Edward
symbols

message		touched
message		damaged

thing		ball		local
thing		player		local

template	boom=+xtank1_exp	local
template	rail=+raildet		local
template	rail1=+raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	DamageThing(player,100,0x1,ball);
	if(GetThingHealth(player)>100)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	}
return;
damaged:
	ball=GetSenderRef();
	if((Getthingtemplate(Getsourceref()) == rail) || (Getthingtemplate(Getsourceref()) == rail1)) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end


/Edward
Edward's Cognative Hazards
2003-07-28, 11:53 AM #17
Ok, reread the list of mistakes that I gave you above...

The player's health is not going to be greater than 100, and you need to use GetThingParent() in the touched message to find your maker.

------------------
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-28, 1:25 PM #18
OK, that didn't work...
Code:
# Ball COG
#
# By Edward
symbols

message		touched
message		damaged

thing		ball		local
thing		player		local
thing		railer		local

template	boom=+xtank1_exp	local
template	rail=+raildet		local
template	rail1=+raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	If(player!=GetThingParent(ball)) {
	DamageThing(player,100,0x1,ball);
	if(GetThingHealth(player)>100)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	} }
return;
damaged:
	ball=GetSenderRef();
	railer=GetSourceRef();
	if((GetThingParent(railer) == rail) || (GetThingParent(railer) == rail1)) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end

And I did some experiments on the last If statement... First GetThingTemplate(GetThingParent) and then this...

/Edward
Edward's Cognative Hazards
2003-07-28, 2:44 PM #19
You don't listen to me do you? I've told you too many times what you need to fix, and you just keep posting another cog with the same mistakes. I'll tell you one more time what you need to fix, you've had more than enough help with this.

Code:
If(player!=GetThingParent(ball))


Correct. That's what I told you to change.

Code:
if((GetThingParent(railer) == rail) || (GetThingParent(railer) == rail1))

What the **** is that supposed to mean? That's senseless.

Code:
DamageThing(player,100,0x1,ball);
if(GetThingHealth(player)>100)


You still haven't changed that. Rethink your logic there.

Quote:
<font face="Verdana, Arial" size="2">And I did some experiments on the last If statement... First GetThingTemplate(GetThingParent) and then this...</font>


Why the hell did you change it from what Han told you to put there?

Seriously, you need to think for yourself here. If you don't understand what's happening, put in some print statements to find out.

------------------
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-29, 12:35 AM #20
Code:
# Ball COG
#
# By Edward
symbols

message		touched
message		damaged

thing		ball		local
thing		player		local
thing		railer		local

template	boom=+xtank1_exp	local
template	rail=+raildet		local
template	rail1=+raildet2		local

end
#
code
touched:
	ball=GetSenderRef();
	player=GetSourceRef();
	If(player!=GetThingParent(ball)) {
	if(GetThingHealth(player)>200)
	{
		CreateThing(boom,ball);
		DestroyThing(ball);
	}
	DamageThing(player,1000,0x1,player); }
return;
damaged:
	ball=GetSenderRef();
	railer=GetSourceRef();
	if(Getthingtemplate(Getsourceref()) == rail || Getthingtemplate(Getsourceref()) == rail1) {
	CreateThing(boom,ball);
	DestroyThing(ball); }
return;
end

I made the test health a little larger because it exploded on a commando. And I couldn't make the ATST fall... What's its health? And, is there some way of testing its MaxHealth?

And the rails won't hurt it!

/Edward
Edward's Cognative Hazards
2003-07-29, 8:43 PM #21
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SaberMaster:
Whoa, there. Think again. I can't believe you didn't see anything in that cog, Dogsrool.</font>
I thought "Created" could only be sent to class cogs...

------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------
Catloaf, meet mouseloaf.
My music
2003-07-29, 11:47 PM #22
You're right, but that is a class cog. I wasn't really contradicting you so much as I was telling you there were a lot more obvious problems.

------------------
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-30, 12:27 AM #23
Whatever happened to good old code commenting and Print() statements for program clarity and debugging purposes respectively?? *shrugs shoulders*... lol

Me-thinks I need a cup of tea before looking at another post. That said, I'm not that hot on class cogs, so I'm not promising anything....

------------------
"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||

↑ Up to the top!