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 nother cog!
Need nother cog!
2002-03-06, 5:43 PM #1
I need a cog that shoots a type of projectile from a ghost position, ALWAYS. its not activated by a switch, it just always shoots at the players. It needs to have auto aim too, and its gotta be synced.

------------------
"Does that compute?

Or do I need to draw you a schematic!?"
2002-03-07, 9:39 AM #2
Try this:

Code:
# firecog.cog
#
# Fire a projectile at players from a ghost.
#
# [SM]
#======================================================================#
symbols

thing		ghost
template	projTemp
flex		fireWait
flex		fireDist
int		fov

flex		speed		local
thing		target		local
thing		proj			local
vector	gpos		local

message	startup
message	pulse

end
#======================================================================#
code
#----------------------------------------------------------------
startup:
	if(!IsServer()) Return;
	gpos=GetThingPos(ghost);
	SetPulse(fireWait);

Return;
#----------------------------------------------------------------
pulse:
	target=FirstThingInView(ghost, fov, 10, 0x400);
	while((VectorDist(GetThingPos(target), gpos) > fireDist || GetThingHealth(target) < 1) && target != -1)
		target=NextThingInView();
	if(target == -1) Return;
	proj=FireProjectile(ghost, projTemp, -1, -1, '0 0 0', '0 0 0', 0, 0x0, 0, 0);
	speed=VectorLen(GetThingVel(proj));
	lvec=VectorNorm(VectorSub(GetThingPos(target), gpos));
	SetThingLook(proj, lvec);
	SetThingVel(proj, VectorScale(lvec, speed));

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


fov is the Field of View in degrees. FOVs above 270 don't seem to work; so use a number lower than that.

I haven't tested it, but this cog *should* work alright in MP. Since this is for a level, the creation of the template will be synced. And only the server will run the firing code.

There you go. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-07, 5:10 PM #3
Whats Firedist, and is the fov for X and Y, or just one of them?

------------------
"Does that compute?

Or do I need to draw you a schematic!?"

[This message has been edited by Dash_rendar (edited March 07, 2002).]

↑ Up to the top!