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 → Need a special cog for sp contest
Need a special cog for sp contest
2007-08-20, 5:23 PM #1
Hi. I am in real need of an item cog that constantly fires a harmless projectile. When it touches a specific 3do, that object will be fully lit. When I activate the player item, it will tell that 3do to do something, like say, be a door that opens.
This projectile should have a range of 0.5 jku or something.
What I really want is environment interaction like in the Thief-games.
Please help :-)
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-21, 10:19 AM #2
If no one has answered this by tonight, I'll try to write something up for you. Also, (and I never got around to helping you out with this) I'll zip and upload the RoX toolkit that I have handy and give you the link. :D
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2007-08-21, 4:56 PM #3
Hey! Thanks! Where will you send the link/files?
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-22, 12:01 AM #4
Ok, I do understand the first part of your request, but why don't you just use the activated message in the highlighted thing's cog? You can check in there if the thing is highlighted or not.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-22, 4:38 AM #5
Yeah, but if I was going to place a lockpick in a small crack in the floor with a poisoned cheese next to it...
That is why I need this, to get more accuracy when interacting with the objects.
I don't know if a touched message would work?
With the activated message I could end up poking the same thing all the time.
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-22, 6:06 AM #6
The touched message only works for players, I'm pretty sure.

As for the RoX files, I tried zipping them this morning and last night, but for some reason, PowerArchiver won't save the compressed files in the zip... :confused:

I'll try again tonight.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2007-08-22, 11:35 AM #7
Ok. Is there no way to do it(the cog)?
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-23, 11:51 PM #8
Hmmm, I see your point...I'll see if I can write up something during work. Don't count on it, though...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 5:26 AM #9
This is a cog for the item that fires the projectile and activates the target things:
Code:
# FILE: item_datadisc.cog

# DESC: Highlights things and activates them upon button press

# AUTH: zagibu@gmx.ch

# DATE: 24.08.2007


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



symbols



template	marker=+marker			local



thing		local_player			local


message		startup

message		activated

message		pulse



end



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



code



startup:

	// Get a reference to the local player thing after having slept for a short while

	Sleep(1);

	local_player = GetLocalPlayerThing();


	// Make the item available

	SetInv(local_player, 46, 1);

	SetInvAvailable(local_player, 46, 1);


	// Start the highlighting pulse
	SetPulse(0.01);


	Return;



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



activated:

	SendTrigger(-1, 7412637, -1, -1, -1, -1);

	Return;

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


pulse:
	FireProjectile(local_player, marker, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);
	Return;

The main idea behind it is, that the projectile will call the damaged message of the things, in there they will light up for a short while and listen for the trigger sent when above cog is activated. If the trigger arrives during this short while, they will do their active stuff, otherwise the lighting up will stop until a new projectile hits them.
You might want to play around with the first vector '0 0 0' in fireprojectile (maybe copy it over from weap_bryar.cog).

I'm going to work on the cogs for the things now, but I have to work some first. And the projectile template has to be defined, too.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 6:35 AM #10
Ok, this is a draft for the second cog. Problem here is, that it must be implemented as class cog, which means you have to add it to the thing's template with the cog= parameter (or something, don't remember). But I don't know how to get a reference to the thing in the trigger message:
Code:
# FILE: class_marker.cog

# DESC: Highlights things and listens for activation

# AUTH: zagibu@gmx.ch

# DATE: 24.08.2007


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



symbols



template	marker=+marker			local


message		damaged

message		timer
message		trigger



end



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



code



damaged:
	if(GetThingTemplate(GetSourceRef()) != marker) ReturnEx(0);


	SetThingLightMode(GetSenderRef(), 0);
	SetThingTimer(0.2);


	ReturnEx(0);

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


timer:
	SetThingLightMode(GetSenderRef(), 3);

	Return;

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


trigger:
	if(GetSourceRef() != 7412637) Return;

	if(GetThingLightMode(REFERENCE_TO_THING) == 0)
	{
		Print("Thing has been activated");
	}

	Return;

I hope you get someone else to help you more...might be able to develop it further in 4 - 5 hours, when my shift is over...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 8:22 AM #11
My solution: use the sourceref() of "created" to get "this" thing in the class cog and create all the things you want to be "viewable" with this system at startup.

Code:
# FILE: class_marker.cog
# DESC: Highlights things and listens for activation
# AUTH: zagibu@gmx.ch
# MODIFIED BY: Grismath
# DATE: 24.08.2007

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

symbols
	template	marker=+marker			local
	message		created
	message		damaged
	message		timer
	message		trigger
	thing		this				local
end

# ======================================================================================== #
code

created:
	this=GetSenderRef();
	Return;

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


damaged:
	if(GetThingTemplate(GetSourceRef()) != marker) ReturnEx(0);

	SetThingLightMode(GetSenderRef(), 0);
	SetThingTimer(0.2);

	ReturnEx(0);

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


timer:
	SetThingLightMode(GetSenderRef(), 3);

	Return;

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


trigger:
	if(GetSourceRef() != 7412637) Return;

	if(GetThingLightMode(this) == 0)
	{
		Print("Thing has been activated");
	}

	Return;


Code:
# FILE: replace_things.cog
# DESC: Replaces all instances of template "replaceMe" with "replaceWith"
# AUTH: Grismath
# DATE: 24.08.2007

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

symbols
	message		startup
	int		i=0				local
	int		thingCount=0			local
	template	replaceMe
	template	replaceWith
end
code
startup:
	Sleep(0.05);
	thingCount = GetThingCount();
	for(i=0; i<thingCount; i=i+1;)
	{
		 if (GetThingType(i) > 1 && GetThingTemplate(i)==replaceMe)
		 {
			CreateThing(replaceWith, i);
			DestroyThing(i);
		 }
	}

	Return;
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2007-08-24, 11:19 AM #12
Hmm, it's not that easy, Grismath, as with class cogs, all things of the same template will use the same cog, thus overriding the this variable everytime a new thing of the same template is created. Also, the SetThingLight verbs do not work, and the only way to "mark" the thing by highlighting it I see is to switch it's model, which means seperate class cogs for all different looking things, cause the models would have to be hardcoded in.

Oh, i've found all this out by trying to implement a test level. Also, I have troubles adding an item with associated cog in an SP level...it seems to be much easier in MP.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 11:32 AM #13
A solution for the "this" issue just came to my mind...don't fire a trigger in the activated part of the item cog, but instead fire another, invisible projectile. This way, you can do the stuff in the damaged message of the class cog, which means you can use GetSource/Sender to get a reference...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 12:09 PM #14
Ok, these actually work. The problem is, that I still can't put an item into an SP level. As you can see, I've tested the class cog with +bryarbolt and +stlaser. I've just put two new crates with the class cog attached in the level, then fired the bryar on one to mark it (that's what the invisible, constantly fired marker would do), then hit it with an strifle bolt to activate it (this simulates the player activating the item and firing the activator projectile).

Note: with the current class cog, you still have to attach different class cogs to different looking items, as the models are hardcoded in the class cog(s). You could work around this by not using SetThingModel, but instead displaying some "selection-explosion-fx" at the target. Maybe use jkSetTarget and jkEndTarget respectively...

BTW: The timer in the class cog is way too long, of course, because I needed time to switch from bryar to strifle ;). Also, there is some ugly debugging stuff in there...
Code:
# FILE: item_marker.cog

# DESC: Highlights things and activates them upon button press. Uses datadisk item slot.

# AUTH: zagibu@gmx.ch

# DATE: 24.08.2007



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



symbols



template	marker=+marker			local

template	activator=+activator		local



thing		local_player			local



message		startup

message		activated

message		deactivated

message		pulse



end



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



code



startup:

	// Get a reference to the local player thing after having slept for a short while

	Sleep(5);

	Print("Startup");

	local_player = GetLocalPlayerThing();



	// Make the item available

	SetInv(local_player, 46, 1);

	SetInvAvailable(local_player, 46, 1);



	// Start the highlighting pulse

	SetPulse(0.05);

	Return;



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



activated:

	Print("Activated");

	FireProjectile(local_player, activator, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);

	Return;



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



deactivated:

	Print("Deactivated");

	Return;



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



pulse:

	FireProjectile(local_player, marker, -1, -1, '0 0 0', '0 0 0', 0, 0, 0, 0);

	Return;



end


And the class cog(s):
Code:
# FILE: class_marker.cog

# DESC: Highlights things and listens for activation

# AUTH: zagibu@gmx.ch

# DATE: 24.08.2007



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



symbols

	template	marker=+bryarbolt		local

	template	activator=+stlaser		local



	model		standard=crt6-1.3do		local

	model		marked=crt4-1.3do		local



	message		damaged

	message		timer

end



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



code



damaged:

	if(GetThingTemplate(GetSourceRef()) == marker)

	{

		SetThingModel(GetSenderRef(), marked);

		SetThingTimer(GetSenderRef(), 10);

	}



	if((GetThingTemplate(GetSourceRef()) == activator) && (GetThingModel(GetSenderRef()) == marked))

	{

		Print("Activated");

		// Paste your activation stuff in here using GetSenderRef() as thing reference

	}



	ReturnEx(0);

	Return;



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





timer:

	SetThingModel(GetSenderRef(), standard);



	Return;



end
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 12:38 PM #15
Thanks for all the help. I allready tried something similar, though not as complex.
My main problem now is that my projectiles kills everyone.
I based it off the bryarbolt, then I set the damage to 0.
Still murdering.
Removing damage and mindamage still doesn't work.
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-24, 1:51 PM #16
Maybe it's too fast and kinetic damage kills the ppl? Oh, and could you quickly describe how you got the item in the level...i still can't do it somehow.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-24, 3:00 PM #17
I didn't get as far as picking it up. I just put a damaged message in the things class cog which printed a message on the screen.
I was thinking about using a trigger, right before I got into the projectile-problem.
Kinetic damage... That's probably the problem then. Stupid JK! :) :(
Btw, do you know how to find the coordinates on a menu when making a mouse-controlled menu?
There is no emotion; there is peace. There is no ignorance; there is knowledge. There is no passion; there is serenity. There is no death; there is the Force

-The Jedi Code
2007-08-25, 2:46 AM #18
Yeah, you have to fire a projectile and compare it's position against the menu's position...it's pretty in-depth vector work, though.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2007-08-27, 1:12 PM #19
You should look at Hell Raiser's code on the Hub. You'll have a better chance of getting answers on that if you post on his project forum if it's about mouse menus. He's the JK mouse menu expert.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2007-08-30, 10:33 PM #20
Actually, there's a VERY easy way I used when making my ingame mouse (though not menu, but it can be easily converted)
If you use fireprojectile to create the mouse object, the position you create the object at is relative to the player, not the level. Since a menu would also be relative to the player, the coordinates used to create the cursor are already the coordinates you want. You just have to determine the boundaries (which you would have to do anyway to prevent the mouse from moving off screen...) so that you know what the values truly mean as far as distance on the screen.

I believe I uploaded a flyable ship demo to the Hub a while back if you look under my name. It has the cursor I'm referring to. You can try to interpret the code and take as much as you want. I'd like some credit if you take big chunks of code, but if you only use it for the concepts then you can do whatever you want.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2007-10-01, 3:20 PM #21
Necro topic! :colbert:

Touched: works on every kind of thing (except those thing types with no collision: ghost, item (touched: responds to type player only), corpse, etc) so in a weapon projectile class cog, it will get the thing it's touching.

I now realise that items would also be included in this grand scheme of things. What about FirstThingInView with a narrow FOV?
-Hell Raiser

↑ Up to the top!