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 Help w/ some projectile stuff
Need Help w/ some projectile stuff
2001-08-31, 5:35 PM #1
I need help with this projectile stuff I'm going to use later in my cliffhanger cog. The main cog right now is used in the test level. The other cog is the cog attached to the projectile.

Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Player                             local                         
thing        BallA                              local                         
thing        BallB                              local                         
thing        Ghost                              local                         

template     Ball=+cliffjkball1                 local                         
template     Ghost_Pos=+cliffjkghost            local                         
      

sound        FireSound=nosound.wav              local                         

vector       BallPos                            local                         

message      startup                                                          
message      pulse                                                            
message      user0                                                            

end                                                                           


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

code

startup:
	
	Player = GetLocalPlayerThing();
	SetPulse(.1);
	Return;


pulse:

	If(GetAttachFlags(Player) == 0)
	{
	Ghost = CreateThing(Ghost_Pos, Player);
	SetThingLook(Ghost, VectorZ(GetThingLVec(Player)));
	BallA = FireProjectile(Ghost, Ball, FireSound, -1, '0.0 0.2 0.0', '0 0 0', 9999999999, -1, -1, -1);
	DestroyThing(Ghost);
	}
	Return;

user0:
	
	PrintVector(GetParam(0));
	Return;

end



^ Main Cog

This is the projectile cog:

Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

//flags=0x240

symbols

thing        Ball                               local                         

vector       BallPos=0                          local                         
vector       BallPosPulse                       local                         

cog          MainCog=cliffjk.cog                local                         

message      pulse                                                            
message      removed                                                          
message      created                                                          

end                                                                           


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

code

pulse:

	BallPosPulse = GetThingPos(Ball);
	Return;


removed:

	SetPulse(0);
	BallPos = BallPosPulse;
	SendMessageEx(MainCog, user0, BallPos, 0, 0, 0);
	Return;


created:

	Ball = GetSenderRef();
	SetPulse(.001);
	Return;

end


What the problem is, is that the ball cog should report the last known position of the ball 3do thing before it's destroyed, then send it to the main cog for other uses. The problem is, it doesn't. And I don't know why.

Any help would be great!
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-08-31, 7:23 PM #2
Try to put something like
Code:
print(ballpospulse);
in the pulse section, right after the position has been/should have been logged. This way, you can find out where to look for problems.

------------------
The rings do not lie, and you can run no more from me[/b]
No signature for you.
2001-09-01, 11:22 AM #3
The ball should still have position when the removed message is called, so you don't need the pulse. It may be that you can't send a vector as a parameter.

------------------
Truth is in the eye of the beholder
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-09-01, 3:45 PM #4
I put prints in the removed message and others, and they don't work...
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-01, 4:28 PM #5
Your using SendMessageEx , meaning it wants an answer back to the cog , but you don't want that, just use SendMessage.
2001-09-01, 4:32 PM #6
BTW you can have vectors sent in a message.
2001-09-01, 6:06 PM #7
I don't get it...I've got prints in each message on the projectile cog. Nothing gets called...my template is right, too. I don't get it, please help!!
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-01, 7:35 PM #8
So your projectile cog doesn't run at all? Is your template cog-linked?(Thingflag 0x400)

------------------
Truth is in the eye of the beholder
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-09-04, 12:45 PM #9
Let me check the thing flags...
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-04, 1:48 PM #10
First thing is that you can't get head pitch of the player with GetThingLVec. It always return 0 for some stupid reason that his body is bent and he always look straight with his neck. Fire a ghost in front of him and get his z look vector.

In the projectile cog, you don't need to constantly get pos of the ball, you can get it in the removed message only and send that info fine and I never sent a vector as a parameter, because I thought I couldn't so I split the vector as VectorX, VectorY and VectorZ and sent them as a separate parameters.

The third and most importantly you can't define the cog through the symbols section by your own word.
cog MainCog=cliffjk.cgo local
just won't work. Only assigning through JED does and a few cog verbs to get a certain cog.

You may either do
a. Register the cog name in the items.dat entry and call the cog as GetInvCog(player, invEntry);

or

b. Use SendTrigger. Which seems easier for me as you don't need to mess items.dat.

Try fixing those.

------------------
http://millennium.massassi.net/ - Millennium
2001-09-04, 2:02 PM #11
I've made some changes since then. Here's the main cog:

Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Player                             local                         
thing        BallA                              local                         
thing        BallB                              local                         
thing        Ghost                              local                         

template     Ball=+cliffball                    local                         
template     Ghost_Pos=+cliffjkghost            local                         
      

sound        FireSound=nosound.wav              local                         

vector       BallPos                            local                         

message      startup                                                          
message      pulse                                                            
message      user0                                                            

end                                                                           


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

code

startup:
	
	Player = GetLocalPlayerThing();
	SetPulse(.05);
	Return;


pulse:

	If(GetAttachFlags(Player) == 0)
	{
	Ghost = CreateThing(Ghost_Pos, Player);
	SetThingLook(Ghost, VectorZ(GetThingLVec(Player)));
	BallA = FireProjectile(Ghost, Ball, FireSound, -1, '0.0 0.2 0.0', '0 0 0', 9999999999, -1, -1, -1);
	DestroyThing(Ghost);
	}
	Return;

user0:
	
	BallPos = VectorSet(GetParam(0), GetParam(1), GetParam(2));
	PrintVector(BallPos);
	Return;

end


And here's the projectile cog:
Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Ball                               local                         
thing        Player                             local                         

vector       BallPos                            local                         

cog          MainCog=cliffjk.cog                local                         

flex         X                                  local                         
flex         Y                                  local                         
flex         Z                                  local                         

message      pulse                                                            
message      removed                                                          
message      created                                                          

end                                                                           


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

code

pulse:

	BallPos = GetThingPos(GetSenderRef());
	Return;


removed:

	SetPulse(0);
	X = VectorX(BallPos);
	Y = VectorY(BallPos);
	Z = VectorZ(BallPos);
	SendMessageEx(MainCog, user0, X, Y, Z, 0);
	Return;


created:

	Player = GetLocalPlayerThing();
	Ball = GetSenderRef();
	SetPulse(.05);
	Return;

end


The look vec stuff I've got here works fine...I even tested it with different projectiles. And right now, it will send the info correctly, but takes about 10 seconds before it gets printed. Also, when I tried getting the position in removed, it didn't work.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-04, 2:06 PM #12
Also, I can't use sendtrigger since it is local-to-local.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-04, 6:29 PM #13
Dude if you want to send a trigger to a person inpertcular, use

SendTrigger(person, 900, -1, -1, -1, -1);

It will only send the trigger to that persons cog on his comp, I think , Little rusty in that area.
2001-09-04, 10:13 PM #14
You still haven't got what I said.
I was going to fix up those cogs but I still don't get your intention on those cogs.

So, if you can explain what you want to achieve exactly, I may give you some example way of coding those.

------------------
http://millennium.massassi.net/ - Millennium
2001-09-05, 11:28 AM #15
My goal is to make a little mod (for something bigger later) that allows the player to grapple onto ledges, and pull up automatically (like in Theif). I am planning on doing this by having a COG shoot a projectile forward when your in the air. If the projectile hits a surface with about 1 foot of the player, and the surface is 75-90 degrees, shoot out a projectile that fires straight up, and if that one doesn't hit within about 2 meters, fire one at a 45 degree angle up and forward, and if that one hits the same surface as the first one, pull the player up, play keys etc (this part I can do). The projectiles will help to "detect" the shape of the surface and the surroundings, so that you don't end up pulling yourself onto a wall that's right next to the cieling.

In the future, I will incorparate this all into the kyle.cog and such, but as for now I am using level cogs for simplicity.

Right now, the projectile fires at 45 deg, which is incorrect, but I will change that once I get the thing to print the location of the projectile when it hits.

*Phew* Hope that helped explain things!
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-05, 11:35 AM #16
Any btw, SendTrigger CANNOT work here! SendTrigger is for sending from a SERVER cog to a CLIENT cog. These are both local cogs, which makes it like a client to my knowledge. If I'm wrong, please tell me, because I haven't been able to use send trigger!
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-05, 1:16 PM #17
You can control where to trigger with sendtrigger.

SendTrigger(GetLocalPlayerThing(), 0, 0, 0, 0, 0);

will send trigger to yourself and not any other players. And if the target cog is flagged local, neither the results will be broadcasted. As for the Z vector of the player, here is the way I meant.

temp = FireProjectile(player, ghost, -1, -1, '0 0.1 0', '0 0 0', 0, 0, 0, 0);
lookVec = VectorSub(GetThingPos(temp), GetThingPos(player));
zVec = VectorZ(lookVec);
DestroyThing(temp);

That zVec should be used in the SetThingLook of your cog.

And as for the proj cog. This only also works fine.

Code:
removed:


   ballPos = GetThingPos(GetSenderRef());
   SendTrigger(GetLocalPlayerThing(), 987654, VectorX(ballPos), VectorY(ballPos), VectorZ(ballPos), 0);


   return;


And on the other cog on how to receive should look like this.

Code:
trigger:


   if(GetSourceRef() != 987654) return;


   PrintVector(VectorSet(GetParam(0), GetParam(1), GetParam(2)));


   return;


Hope that helps.

------------------
http://millennium.massassi.net/ - Millennium

[This message has been edited by Hideki (edited September 05, 2001).]
2001-09-06, 2:23 PM #18
Thank you Hideki, I'm trying that now...and as for that look vec thing, Its leftovers I don't need. I need to shoot the projectile in the same direction no matter what the player's headpitch, which I already have done.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-06, 2:27 PM #19
Oh wait scratch that last post, I must have been thinking of something else...the VectorZ on the Lvec just gets the direction the player is facing, not the head pitch, so it fires correctly.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-06, 2:59 PM #20
Darn...still won't work! Here's what I have:

Main COG:
Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Player                             local                         
thing        BallA                              local                         
thing        BallB                              local                         
thing        Ghost                              local                         

template     Ball=+cliffball                    local                         
template     Ghost_Pos=+cliffjkghost            local                         
      

sound        FireSound=nosound.wav              local                         

vector       BallPos                            local                         

message      startup                                                          
message      pulse                                                            
message      trigger                                                          

end                                                                           


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

code

startup:
	
	Player = GetLocalPlayerThing();
	SetPulse(.05);
	Return;


pulse:

	If(GetAttachFlags(Player) == 0)
	{
	Ghost = CreateThing(Ghost_Pos, Player);
	SetThingLook(Ghost, VectorZ(GetThingLVec(Player)));
	BallA = FireProjectile(Ghost, Ball, FireSound, -1, '0.0 0.2 0.0', '0 0 0', 9999999999, -1, -1, -1);
	DestroyThing(Ghost);
	}
	Return;

trigger:
	
	If(GetSourceRef() != 0) Return;

	BallPos = VectorSet(GetParam(0), GetParam(1), GetParam(2));
	PrintVector(BallPos);
	Return;

end


And the projectile code:
Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon. E-Mail: ejm_emon@hotmail.com - Zone: EJM_Emon - ICQ: 35960628
# Feel free to use this COG as long as credit is given in the readme file.
#
# Description
# 
#
# This COG is not supported by LucasArts Entertainment Co.

flags=0x240

symbols

thing        Ball                               local                         

vector       BallPos                            local                         
                                                       
message      removed                                                          
message      created                                                          

end                                                                           


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

code

removed:

	BallPos = GetThingPos(Ball);
	SendTrigger(GetLocalPlayerThing(), 0, VectorX(BallPos), VectorY(BallPos), VectorZ(BallPos), 0);
	Return;


created:

	Ball = GetSenderRef();
	Return;

end
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-06, 3:00 PM #21
Oh, and by the way, I tried replacing GetSourceRef() with GetSenderRef(), but with no luck at all.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-07, 8:51 AM #22
Vectorz of the player's lvec will return 0.00000.

Using SetThingLook(missile, vectorz(GetThingLvec(player))); won't do anything.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-09-07, 12:15 PM #23
Yes it does saber master, I'm sure of it. Other wise my projectiles wouldn't fire from infront of me, when it is firing from a new position.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-07, 1:20 PM #24
That is an invalid operation anyway.

SetThingLook will take a vector as a second parenthesis and VectorZ(vec) will return a flex number.

You don't need created message in the projectile cog, removed message will return the ball as GetSenderRef().

The cog seems to be good, maybe some attachflag is not working as you want or something.

------------------
http://millennium.massassi.net/ - Millennium
2001-09-07, 1:33 PM #25
Hmmm about SetThingLook(Ghost, VectorZ(GetThingLVec(Player))); I woulden't of thought that would work , maybe it's defaulting the other vectors as zero, I dunno .

I suggest you use this line of code even if it doesn't make a differnece.

SetThingLook(ghost, VectorSet(VectorX(0,0,0), VectorY(0,0,0), VectorZ(GetThingLVec(Player))));
2001-09-07, 1:39 PM #26
Well I don't even think that code matters... I think when it creates the ghost, it creates it with the same look Zvec as the player or something then, because my projectiles always fire the same way (like when I set it to +bryarbolt or something)
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-07, 2:55 PM #27
If it's a Fireprojectile then it will create the template where your looking, but if it's CreateThing it will create the thing at a certain look vector (proberly 0) no matter where you are looking.
2001-09-07, 3:26 PM #28
Okay, not to worry about that now...I just need to know the best way to send 3 flexes to another COG w/o the 10 second wait I had with SendMessageEx..I think it's because it waits for an answer..so how could I use ReturnEx with that?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-07, 3:48 PM #29
SetThingLook(missile, VectorSet(0, 0, VectorZ(GetThingLVec(player)));

retValue = SendMessageEx(cog, message, param0, param1, param2, param3);


a cog:

message:

ReturnEx(GetParam(0));

------------------
http://millennium.massassi.net/ - Millennium
2001-09-07, 6:21 PM #30
Thank's Hideki. Do I need to do ReturnEx(); for each param that is sent? Like if I send X, Y, and Z flexes, do I need a Return for each, or what?
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-07, 8:40 PM #31
Using SendMessageEx is a waste of loading time for the comp, just use SendMessage and skip all the returnex

Unless you need it returned , I don't see why you would.
2001-09-08, 3:57 PM #32
First off, I put a print in the removed message, and didn't show for 10 seconds. Which means it's not a problem with the SendMessage. Also, Seifer, it's impossible to send variables with SendMessage(). I've already tried it.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2001-09-15, 6:27 AM #33
I didn't really read all of this, just skimmed it. But I can't think of any reason why sendmessage() would be delayed for ten seconds....that just doesn't happen. I think that the ball isn't getting destroyed or something, and maybe its timer runs out after 10 seconds. (?)

I've been trying to think of a way to make a good solid wall climbing cog for awhile now though, and so far haven't really thought of anything that seems like it would work to my liking, so I am kind of interested in where this is going since its in the same vien.
2001-09-15, 12:19 PM #34
Well it's not the send message, it's the removed...I'm gonna try it with something like +bryarbolt with a new cog attached later.
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!