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 → A challenge for you all!
A challenge for you all!
2003-07-01, 5:43 PM #1
[http://67.87.115.203:81/brad_s/cogneededforcanon.jpg]
Ok, see that? well this is what I need:
Cog similar to the eweb canon cog in MotS
THIS IS FOR JK
I need it so when you pick up some canon balls, and activate it, you 'get behind' the canon and can SLOWLY turn it and fire it. The projectiles need to be lobbed.
The one who can write one for me gets 1)cookie 2)recognition 3)well, self satisfaction!

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-07-02, 11:05 AM #2
no takers?


------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-07-02, 2:49 PM #3
Well that is rather challenging, even for MotS.

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-07-02, 6:19 PM #4
[http://forums.massassi.net/html/frown.gif]

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-07-02, 10:48 PM #5
Huh? Its not that challenging is it?

I will do it for you. But I got a few questions...

What with the picking up cannon balls? Can you only pick up one, load it then fire? Would it be cooler if you just fired them off without having to load it (but with a delay between shots)

By slowly turn, can it move up and down (pitch) quickly? (If it cant, then its not easily possible... side scrolling is easy however)

Is it ok to just use termal dets that are fired at a rate and speed which can be chosen by the level editor in jed?

------------------
Team Battle.
Team Battle.
2003-07-03, 2:35 AM #6
um, sure, all that sounds fine

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-07-03, 2:40 AM #7
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Emon:
Well that is rather challenging, even for MotS.
</font>


Oh please. Shall I break it down into pseudo-code for you?



------------------
-Blessed Be-
Nothin says lovin like somethin from the Coven
DBZ: The Destruction is Real
-Hell Raiser
2003-07-03, 6:19 AM #8
I was under the impression from his showcase thread that you needed to control the cannon, like key trapping which MotS has, which is harder in JK.

E.g. MotS' "E-web"

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.

[This message has been edited by Emon (edited July 03, 2003).]
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-07-05, 4:46 PM #9
Faking key trapping in JK isn't hard. Brad, do you have a player-using-cannon model and keyframes to go with it? If you've got them made, can you send them 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-06, 3:25 AM #10
SM I think Brad S has gone on a holiday and wont be back for 2 weeks. If you make the cog can you post the code? I'm very interested in seeing how you go about doing it.

------------------
Team Battle.
Team Battle.
2003-07-06, 11:40 AM #11
Ah, too bad he's gone. [http://forums.massassi.net/html/frown.gif]

If I make this cog, I'll upload it to my site as a patch. I'll have to get some models to use, though, because it's no fun testing with out them. [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-06, 7:00 PM #12
Anywho, about seven hours later...

Weapon cog for the items.dat:

Code:
# weap_canon.cog
#
# This is a special inventory cog flagged as a weapon. When the takeWeapon
# trigger is received from class_canon, we will take control of the player's
# weapon keys by setting this cog as the weapon and forwarding the fire
# events to class_canon. This weapon's bin should look like:
#
# weap_canon   116   1  1   0x0   cog=weap_canon.cog
#
# [SM]
#==============================================================#
symbols

thing     player          local

flex      fireWait=0.5    local

int       id              local
int       i               local
int       mode            local
int       takeWeapon=76   local
int       giveWeapon=77   local
int       fireWeapon=78   local
int       ourBin=116      local
int       oldWeap         local
int       weapons         local

message   startup
message   activated
message   deactivated
message   selected
message   deselected
message   autoselect
message   fire
message   trigger

end
#==============================================================#
code
#------------------------------------------------------
startup:
	player = GetLocalPlayerThing();

Return;
#------------------------------------------------------
fire:
	mode = GetSourceRef();
	SendTrigger(-1, fireWeapon, mode, 0, 0, 0);

Return;
#------------------------------------------------------
activated:
	mode = GetSourceRef();
	ActivateWeapon(player, fireWait, mode);

Return;
#------------------------------------------------------
deactivated:
	mode = GetSenderRef();
	DeactivateWeapon(player, mode);

Return;
#------------------------------------------------------
selected:
	// not worried about models or anything
	// just set up this cog to run. What the
	// player looks like doesn't matter.
	jkClearFlags(player, 0x5);
	SetCurInvWeapon(player, ourBin);
	SetMountWait(player, 0);

Return;
#------------------------------------------------------
deselected:
	// no keys, no sounds, nothing.
	// allow the oldWeap to load immediately.
	SetMountWait(player, 0);

Return;
#------------------------------------------------------
autoselect:
	// this should only be called when we have the 0x4
	// flag. Return 1 so we can use this cog.
	ReturnEx(1);

Return;
#------------------------------------------------------
trigger:
	id = GetSourceRef();
	if(id == takeWeapon)
	{
		// assume control of the player's weapon keys
		oldWeap = GetCurWeapon(player);
		SetInvFlags(player, ourBin, 0x4);
		SetInvAvailable(player, ourBin, 1);
		call selected;
		// take away all of the player's default weapons
		weapons = HeapNew(1, 10);
		for(i = weapons; i < 11; i = i + 1)
		{
			if(IsInvAvailable(player, i)) HeapSet(i, 1);
			else HeapSet(i, 0);
			SetInvAvailable(player, i, 0);
		}
	}
	else if(id == giveWeapon)
	{
		// give the player back the weapons he had before
		for(i = weapons; i < 11; i = i + 1) SetInvAvailable(player, i, HeapGet(i));
		HeapFree();
		// give the player back his original weapon.
		SetInvFlags(player, ourBin, 0);
		SetInvAvailable(player, ourBin, 0);
		SelectWeapon(player, oldWeap);
	}

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


And the class cog for the canon template.

Code:
# class_canon.cog
#
# A class cog for the cannon object.
#
# The plan: player activates canon. Real player is made invisible.
# canon gets camera focus, uses real player's attempted movement
# to move itself. actor keyframes would be good.
#
# demo templates:
#
# ghost none orient=(0.000000/0.000000/0.000000) type=ghost move=path
# ghostcam none orient=(0/0/0) type=weapon collide=1 move=physics
#	size=0.001 movesize=0.001 model3d=con0.3do
# canon none orient=(0/0/0) type=cog move=physics physflags=0x42
#	surfdrag=50 mass=200 collide=3 size=0.2 movesize=0.2
#	thingflags=0x400 model3d=canon.3do cog=class_canon.cog
#
# Don't let JED screw up your templates by making one of these the
# first template in your .jkl.
#
# [SM]
#==============================================================#
symbols

message   activated
message   deactivated
message   pulse
message   trigger

thing     ghost                    local
thing     fired                    local
thing     player                   local
thing     canon                    local
thing     cam                      local

vector    thrust                   local
vector    pos1                     local
vector    pos2                     local
vector    mvec                     local
vector    lvec                     local
vector    campos                   local

int       anim                     local
int       i                        local
int       takeWeapon=76            local
int       giveWeapon=77            local
int       fireWeapon=78            local
int       fireMode                 local

template  gtemp=ghost              local
template  wtemp=+bryarbolt         local
template  camtemp=ghostcam         local

sound     fireSound=pistol-1.wav   local

keyframe  stance=kystand0.key      local

end
#==============================================================#
code
#------------------------------------------------------
activated:
	player = GetLocalPlayerThing();
	canon = GetSenderRef();
	ParseArg(player, "soundclass=");
	SetCollideType(player, 0);
	SetThingFlags(player, 0x10);
	ghost = CreateThingAtPos(gtemp, GetThingSector(player), GetThingPos(player), '0 0 0');
	SetThingLook(ghost, GetThingLVec(player));
	cam = CreateThingAtPos(camtemp, GetThingSector(player), GetThingPos(player), '0 0 0');
	SetCameraFocus(0, cam);
	anim = PlayKey(player, stance, 5, 0);
	SendTrigger(-1, takeWeapon, 0, 0, 0, 0);
	SetPulse(0.01);

Return;
#------------------------------------------------------
deactivated:
	SetPulse(0);
	SetThingThrust(canon, '0 0 0');
	SetCameraFocus(0, player);
	ParseArg(player, "soundclass=ky.snd");
	SetCollideType(player, 1);
	ClearThingFlags(player, 0x10);
	DestroyThing(cam);
	for(i = 0; (GetSectorPlayerCount(GetSurfaceSector(i)) == 0 || !(GetSurfaceFlags(i) & 0x1)) && i < GetSurfaceCount(); i =i + 1);
	AttachThingToSurf(player, i);
	SetThingVel(player, '0 0 0');
	SetThingPos(player, GetThingPos(ghost));
	if(ghost != 0 && ghost != -1 && ghost != player) DestroyThing(ghost);
	SendTrigger(-1, giveWeapon, 0, 0, 0, 0);
	StopKey(player, anim, 0.5);

Return;
#------------------------------------------------------
pulse:
	SetThingRotVel(canon, GetThingRotVel(player));
	fired = FireProjectile(player, gtemp, -1, -1, '0 0 0', '0 0 0', 0, 0x0, 0, 0);
	lvec = GetThingLVec(fired);
	DestroyThing(fired);
	SetThingLook(canon, lvec);
	thrust = GetThingThrust(player);
	SetThingThrust(canon, thrust);
	SetThingPos(player, GetThingPos(ghost));
	if(!(GetAttachFlags(player) & 0x1) || VectorZ(thrust) > 0) call deactivated;
	if(GetCurrentCamera() != 0) CycleCamera();
	pos1 = VectorAdd(GetThingPos(canon), VectorSet(0, 0, 0.3));
	pos2 = VectorScale(VectorNorm(GetThingLVec(canon)), -0.4);
	lvec = VectorSub(GetThingPos(canon), GetThingPos(cam));
	campos = VectorAdd(pos2, pos1);
	mvec = VectorSub(campos, GetThingPos(cam));
	SetThingVel(cam, VectorScale(mvec, 6));
	SetThingLook(cam, lvec);
	if(!HasLOS(cam, canon)) TeleportThing(cam, canon);
	if(VectorDist(GetThingPos(canon), GetThingPos(cam)) > 4) TeleportThing(cam, canon);

Return;
#------------------------------------------------------
trigger:
	if(GetSourceRef() == fireWeapon)
	{
		fireMode = GetParam(0);
		FireProjectile(canon, wtemp, fireSound, -1, '0 0.02 0.02', '0 0 0', 1, 0, 0, 0);
	}

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


There still needs to be written an inventory system for the canon balls and a canonball template, but that's easy enough to add.

For these to work, place a canon thing in your level (add the templates to your .jkl). Activate the canon ingame, and class_canon will take over. It will detect the player's movement (though the player doesn't really go anywhere) and move the canon accordingly. When the player presses the jump key, class_canon will bring the player back and stop controlling the canon.

Weap_canon is a simple inventory cog that is used as a weapon for the canon. That way, the canon can be fired with the normal firing keys. The player's other weapons are temporarily taken away so the player can't try to select a different weapon.

Class_canon uses some of the code from my chase cam patch to create its external camera.

I'm posting this now, Hellcat, because Brad won't be back for a while, and you wanted the code. When I get the models for the canon and canonball, I'll write the other templates and cogs. It's kind of pointless to work too much on fine-tuning it now when I don't know what it's going to look like.

Questions, comments?

------------------
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-07, 12:12 AM #13
Thanks!

I never knew about the verb GetThingThrust(player);... very nice.



------------------
Team Battle.
Team Battle.
2003-07-22, 6:34 AM #14
Well, this isnt really reviving an old thread, cuz i just got back from vacation to pick up my messages... i'll see what i can do to get this working...

------------------
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
"Everyone Dies..."
-Fett

My Website
Brad's Highschool Level
Unfinished Levels For Download
2003-07-22, 7:35 AM #15
Brad, can you send me the canon and canonball models? Then I can make sure the cog will work, and write up a canonball template.

------------------
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!