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 → how away is thing from thing
how away is thing from thing
2003-09-04, 2:57 AM #1
hello again.

I need to know now how to check how away is thing a from thing b.
Someone know?

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..
2003-09-04, 7:23 AM #2
dist1=VectorDist((GetThingPos(thingA)), GetThingPos(thingb));

------------------
Call me Vedder.
Author of: A Pirate's Tale (Mots SP)
APT homepage
----
<phantom> You're always going to be aloser if you attempt to aspire to massassi standards.
<phantom> They're a bunch of socially inadequate <beep> whores who have little or no lives.
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-09-04, 7:37 AM #3
Quote:
<font face="Verdana, Arial" size="2">Originally posted by EH_AceCSF:
how away is thing from thing
</font>


English isn't your first language, right?
Edward's Cognative Hazards
2003-09-04, 8:33 AM #4
Location: krakow, Poland

------------------
Call me Vedder.
Author of: A Pirate's Tale (Mots SP)
APT homepage
----
<phantom> You're always going to be aloser if you attempt to aspire to massassi standards.
<phantom> They're a bunch of socially inadequate <beep> whores who have little or no lives.
APT 1, 2, 3/4, 5/6
TDT
DMDMD

http://veddertheshredder.com
2003-09-04, 10:39 AM #5
Code:
# Jedi Knight Cog Script
#
# proxymitydoor.cog
#
# Generic Door Script
#
# [EH_AceTFL]
#
# ========================================================================================

symbols
	message	startup		
	message	activate	
	message	arrived		
	message	timer		
	message	blocked		
	message pulse

	thing		door0		linkid=0 mask=0x405
	thing		door1		linkid=1 mask=0x405
	thing		door2		linkid=2 mask=0x405
	thing		door3		linkid=3 mask=0x405

	float		moveSpeed=8.0
	float		sleepTime=2.0
	float		lightValue=0.5

	int		numDoors=0	local
	int		doorStatus	local
	int		moveStatus	local
	int		i				local
	flex 		dist1	local
	flex 		dist2	local
	flex 		dist3	local
	flex 		dist4	local
	flex		distanse=1

	thing 		player	local
end

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

code

startup:
	player = GetLocalPlayerThing();
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) numDoors = numDoors + 1;
	setpulse(0.1);
	return;

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

activate:
	call CheckStatus;
	if (moveStatus) return;
	if (doorStatus == 0) {					// all pieces are at frame 0
		call OpenDoors;
	}
	return;

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

arrived:
	call CheckStatus;
	if (moveStatus) return;
	if (doorStatus == numDoors) {				// all pieces are at frame 1
		SetTimer(sleepTime);
	} else if (doorStatus == 0) {				// all pieces are at frame 0
	}
	return;

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

blocked:
	call OpenDoors;
	return;

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

timer:
	call CloseDoors;
	return;

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

OpenDoors:
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) MoveToFrame(door0, 1, moveSpeed);
	return;

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

CloseDoors:
	for (i=0; i<=3; i=i+1)
		if (door0 >= 0) MoveToFrame(door0, 0, moveSpeed);
	return;

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

CheckStatus:
	moveStatus = 0;
	doorStatus = 0;

	for (i=0; i<=3; i=i+1) {
		if (door0 >= 0) {
			moveStatus = moveStatus + IsThingMoving(door0);
			doorStatus = doorStatus + GetCurFrame(door0);
		}
	}
	return;

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

pulse:

	dist1=VectorDist((GetThingPos(player)), GetThingPos(door0));
	dist2=VectorDist((GetThingPos(player)), GetThingPos(door1));
	dist3=VectorDist((GetThingPos(player)), GetThingPos(door2));
	dist4=VectorDist((GetThingPos(player)), GetThingPos(door3));
	IF((dist1 < distanse) || (dist2 < distanse) || (dist3 < distanse) || (dist4 < distanse)) 
	{
	if (moveStatus) return;
	if (doorStatus == 0) 
	{	
	call OpenDoors;
	}
	}
	return;
end

Works OK, but 2 problems come.. First - unknown why but door opens at game start.. Then.. When you go away from door they close (its ok) and sometimes open again (unknwon why). if someone can check it..

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..
2003-09-04, 11:29 AM #6
Quote:
<font face="Verdana, Arial" size="2">English isn't your first language, right?</font>

Very tactful... [http://forums.massassi.net/html/rolleyes.gif]


Your code will work, but because you're opening all doors when you're in range of only one, it won't look right unless all of the doors are supposed to open and close at the same time. Another thing is that when you check only the distance like that, one of the doors may be right above you (you won't be able to see it), but it will open anyway.

I'd rewrite the pulse so that it uses a loop to check each door to make sure it's: defined in the symbols section (doorx>-1), within a certain distance from the player, and in sight of the player (with HasLOS()). And if those conditions are met, open just the one door that met the conditions. The loop would then continue to check the other doors...

This would also require you to rewrite a lot of the original code in the cog so that it won't try to open / close all of the doors at the same time.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

[This message has been edited by SaberMaster (edited September 04, 2003).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-09-04, 1:10 PM #7
Untested, but should work...

Code:
# Range-based door cog.
#
# 09/2003 gbk - gbk@insightbb.com
Symbols
Message Startup
Message Pulse
Message Arrived
Message Timer
Message Blocked

Thing Player			Local
Thing Door0	Linkid=0
Thing Door1	Linkid=1
Thing Door2	Linkid=2
Thing Door3	Linkid=3

Flex Range=0.4
Flex Speed=0.4
Flex Rate=0.1

Int Targetframe=1
Int I=0				Local
Int a0=0				Local
Int a1=0				Local
Int a2=0				Local
Int a3=0				Local

End
Code
Startup:
Player = JKgetlocalplayer();
Setpulse(Rate);
Stop;

Pulse:

For(I=0;I<4;I=I+1)
If(Vectordist(Getthingpos(Player), Getthingpos(Door0)) <= Range && a0 != 1) {
a0 = 1;
Movetoframe(Door0, Targetframe, Speed); }
Stop;

Arrived:
If(a0[Getsenderid()] == 1) {
a0[Getsenderid()] = 2;
Movetoframe(Door0[Getsenderid()], 0, Speed); }
Else If(a0[Getsenderid()] == 2) a0[Getsenderid()] = 0; 
Stop;

Blocked:
Stopthing(Door0[Getsenderid()]);
Movetoframe(Door0[Getsenderid()], Targetframe, Speed);
a0[Getsenderid()] = 1;
Stop;
End


I think that the symbols are self-explanitory, so I wont go into it....

------------------
Farewell, dear lady...
And when the moment is right, I'm gonna fly a kite.
2003-09-05, 1:36 AM #8
OK. Im sure you see that i modyficted ORGINAL door cog. So MY door can be opened by ai, GBKs one cant.. Also hmm.. i think that my door have also other good - they dont close when they reach up position. Curent this looks.. WORST (you stand near door and it move up down up down.. Also, why 4 doors? Primary cog have to work also when you have 2 doors (moving left and right..) or more. OK, i dont need NEW cog, i only want to know why my door open at startup..

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..
2003-09-05, 1:46 AM #9
bwt, thanks GBK

------------------
The miners of Kiith Somtaaw sacificed much, and risked all. For their efforts they were brought into the inner most circle of Hiigaren power. Naabal, S'jet, and Sobanii bowed before them. And from that day to this, Somtaaw's children have been known to one and all as Beastslayers..

↑ Up to the top!