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 → No idea why this won't work...
No idea why this won't work...
2002-02-24, 5:11 AM #1
I set up a damage cog that checks for a certain.mat file so that all you have to do is place 1 cog in the level, instead of multiple sector or surface damage cogs. It checks out in CogWriter, but I get nothing in level, just walking on lava. Here it is:

Code:
# Jedi Knight Cog Script
#
#
# [YB]
#
# ---Modified LEC cog for surfaces -Tazz
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# 00_surfacedamage.cog
#
# Apply constant amount of damage to a player on a surface
# ========================================================================================

symbols

message		touched

material	damageSurface			# the deadly surface

flex		damageInterval=1.0		# how often damage is applied in seconds.
flex		damage=4.0			# how much damage is applied

thing		victim		local		# actors and players affected.
int		type		local

end

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

code

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

touched:
victim = GetSourceRef();
	If(GetSurfaceMat(GetSenderRef()) == damageSurface)
	{
Print("Got the surface");
		type = GetThingType(victim);
		// If we have an actor (2) or a player (10)
		if ((type==2) || (type==10))
		{
Print("Got the player");
			// Do the damage or healing.
			if (damage > 0)
			{								
				DamageThing(victim, damage, 0x1, victim);
Print("We hurt him");
			}
			else
			{
				HealThing(victim, -damage);
			}
		}
	}
	return;

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

end


thanks in advance

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2002-02-24, 7:43 AM #2
I tried it but I added a startup print message and it wasn't printing at the begging so maybey it's not getting called up. Or maybey its just my machine

lata,
C_T
So young so angry damn that rap music
2002-02-24, 7:59 AM #3
There is a very basic problem with this cog - it cant work; The underlying principle is flawed.

 

A surface will send :Touched, IF 1) the surface is defined in the symbols section, AND 2) an object touches that surface.

A thing will send :Touched, IF 1) the thing is defined in the symbols section (or, if it is captured in the code), AND 2) another thing touches that thing.

 

A thing WILL NOT send :Touched when it touches a surface.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-02-24, 11:39 AM #4
Could someone either fix this or whip one up? I don't know what my problem is... They just won't work today! Here's a new cog:

Code:
# 00_killsurf.cog
#
# Kills the player when they touch the specified surface
#
#
# 2002 Tazz

flags=0x240
symbols

message		touched

int		player		local
surface		surface0=    	mask=0x400
flex		Damage=100000


end

#------------------------------------------------------------------------------------

code


touched:

	player = GetSourceRef();
	If(GetThingType(player != 10) Return;
	DamageThing(player, damage, 0x2, player);
	Return;


end


------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2002-02-24, 1:22 PM #5
Since Im in a hurry, I cant really examine the cog, but the first thing I see is the = after surface0. Remove it, and it should work. If not, add a print statement in touched to see if the cog is even compiling.

------------------
Success is the inverse relationship between effort, gain, and loss.

JK editing resources.
And when the moment is right, I'm gonna fly a kite.
2002-02-24, 1:48 PM #6
I didn't have the = before... I tried a print message. Nothing.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2002-02-25, 5:00 AM #7
The way you have it, the player is going to be killed locally on each computer. And also, you don't need to check the player's thing type when you're already using a mask.

I would code this way:

Code:
# 00_killsurf.cog
#
# Kills a player when he touches the specified surface.
# Modified so that only the local player kills himself.
#
# 2002 [Tazz + SM]
#============================================================#
symbols

message	touched

thing		toucher		local
surface	surface0		mask=0x400

end
#============================================================#
code
#--------------------------------------------------------
touched:
	toucher=GetSourceRef();
	if(toucher != GetLocalPlayerThing()) Return;
	DamageThing(toucher, 1000, 0x2, -1);

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


Not tested, but it should work. Reply if you have problems. Good luck. [http://forums.massassi.net/html/wink.gif]

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-02-25, 5:05 AM #8
Quote:
<font face="Verdana, Arial" size="2">A thing will send :Touched, IF 1) the thing is defined in the symbols section (or, if it is captured in the code), AND 2) another thing touches that thing.</font>


I would add that Mask Flags are important there. Normally, only players and actors can touch things. With a mask, any type of thing can do the touching.

------------------
Each cog better than the next
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!