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 → Send Message Problem ( Bot Code )
Send Message Problem ( Bot Code )
2001-04-30, 7:22 PM #1
Hmm well i'll get to the point , i have the bot code ,and this part of it handles dodging projectiles , thats fine , but the thing is , i'm doing this system below to tell the bot how long away the firer is going to fire again.

Code:
projectile2 = FirstThingInView(rbot, 270, 1.0, 0x8);
			
	while(rbot == GetThingParent(projectile2) && projectile2 != -1)
	{projectile2 = NextThingInView();}
	if(getthingtemplate(projectile2) == ghost) projectile2 = NextThingInView();

	if(projectile2 != -1)
	{

		if(!BitTest(botmode, 0x4000 && getthingparent(projectile2)) != rbot)
		{
			target=getthingparent(projectile2);
			botmode=BitSet(botmode,0x4000); // bot has target
			if (!BitTest(botmode,0x20000)) call firetarget2; // if bot not already attacking - attack new target
		}
		dot=ThingViewDot(projectile2, rbot);
		parent=getthingparent(projectile2);
		SendMessageEx(GetThingCaptureCog(projectile2), user1, rbot, -1, -1, -1);
		distance=VectorDist(GetThingPos(parent), GetThingPos(rbot));
		if(dot > 0.85 && dot < 1.15 && HasLOS(rbot, projectile2)) //If it's gonna strike
		{
				if(!BitTest(botmode, 0x4000)) AiSetLookPos(rbot, getthingpos(projectile2));
				call sidestep;
			if(gettemplate(projectile2) == projectile_weap7 || gettemplate(projectile2) == projectile_weap9) call jump;
		}
	}

		if(dot > 0.85 && dot < 1.15 && HasLOS(rbot, projectile2)) //If it's gonna strike
		{
				if(!BitTest(botmode, 0x4000)) AiSetLookPos(rbot, getthingpos(projectile2));
				call sidestep;
			if(gettemplate(projectile2) == projectile_weap7 || gettemplate(projectile2) == projectile_weap9) call jump;
		}

		if(time != -1 && HasLOS(rbot, parent))
		{
		if(time != firetime) time=time+1;
		if(time == firetime) call sidestep;
		if(time == firetime) time=-1; 
		prediction=time-firetime;
		if(prediction > 2 && prediction < 4) call sidestep;
		}


my problem is that it's suppost to send a message to the projectile cog ( each weapon has it's own cog for now ) and it will send back the infromation to the bot giving it the time the bullets been in the air and how long until it the parent fires again ( 10 units = 1 second)

Heres the reciving cog .... ( projectile cog )

Code:
# Jedi Knight Cog Script
#
# 00_SMOKETRAIL.COG
#
# Leave a smoke trail behind a moving object
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

flags=0x240

symbols

thing		bullet				   local
int		time=0				   local                          local
int		firetime=12				   local
thing 	rbot					   local

message     created
message     pulse
message     removed
message	    user1

end

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

code
created:

   bullet = GetSenderRef();
   SetPulse(0.1);          
   Return;

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

pulse:
   
   time=time+1;

return;

removed:

SetPulse(0);
time=0;
   
   Return;

user1:

rbot=getparam(0);
SendMessageEx(GetThingClassCog(rbot), user0, time, firetime, 0, 0);

return;

end   


I've tried all different kinds of SendMessage codes but none seem to work , help ???
2001-05-02, 10:52 AM #2
WOOSH! WAY above my head!
Hey, I'm here! But who cares?
2001-05-02, 12:21 PM #3
Don't have much experience with SendMessage, but just curious.. couldn't you just use SendTrigger?
2001-05-02, 12:45 PM #4
Ok, I assume that the projectile template actually has a cog reference.

You seem to have these two around the wrong way:
Code:
SendMessageEx(GetThingCaptureCog(projectile2), user1, rbot, -1, -1, -1);

SendMessageEx(GetThingClassCog(rbot), user0, time, firetime, 0, 0);


should be:

Code:
SendMessageEx(GetThingClassCog(projectile2), user1, rbot, -1, -1, -1);

SendMessageEx(GetThingCaptureCog(rbot), user0, time, firetime, 0, 0);


As the projectile cog is referenced in the projectile's template, it is the projectile's class cog. And as the bot's cog is not referenced in the bot's template, but is inserted from JED and captures all messages, it's the bot's capture cog.

Hope this helps...

Raynar


------------------
... the Jedi I admire the most, met up with Darth Maul, now he's toast ...
Rbots - a project to develop a working Bot for Jedi Knight... download the latest development version here
Pagewizard_YKS: "making your own lightsaber doesn't make you a nerd... "
Raynar - the man with a 10.75" ePenis
2001-05-02, 4:13 PM #5
Bah - to the dark side you must go! TRIGGERS, I say! [http://forums.massassi.net/html/smile.gif]
2001-05-02, 6:09 PM #6
It can't easily be done with triggers and if I did it would take a lot of useless code and lag to do it , so no ...

Are you sure Raynar ? , it's sending a mesasge to the projectile 2 from the bot and vice versa.

↑ Up to the top!