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 → sector thrust COGS
sector thrust COGS
2002-11-16, 8:25 AM #1
What can I do to this cog to ensure that the player is thrust right up through all the selected sectors? At the moment, the player seems to slowly lose momentum and stop somewhere in the second sector. Removing the 'no gravity' flag made the thrust too weak to get off the ground:

Code:
# Jedi Knight Cog Script
#
# antigrav_lift.cog
#
# Script to start sector thrust by activating switch
#
# Based on code of [DB] with code from mdm10_window.cog
#
# not supported by Lucasarts Inc.


symbols
message     startup
message     activated
message     timer

sector      sector0
sector      sector1
sector      sector2

int		currentThing		local
int		i			local


surface     switch01    mask=0x448  linkid=1

sound    thrustsnd=18particlestream01.wav

vector		playerVec			local
vector		vec0		desc=thrust_direction

int     speed

int      channel=-1  local

end

## Code Section
code
startup:

   SetWallCel(switch01, 0);
   

   return;

activated:

   if (GetSenderID()==1) SetWallCel(switch01, 1);
   if (GetWallCel(switch01)==1)

   {
   
		channel=PlaySoundPos(thrustsnd, GetSectorCenter(sector0), 1.0, 0.5, 1.5, 1);
   		SetSectorFlags(sector0,0x9);
   		SetSectorFLags(sector1,0x9);
   		SetSectorFlags(sector2,0x9);
		SectorThrust(sector0, vec0, speed*20);
		SectorThrust(sector1, vec0, speed*20);
		SectorThrust(sector2, vec0, speed*20);

		currentThing = FirstThingInSector(sector0);
		while (currentThing != -1) 
		{
			call antigravpull;
			currentThing = NextThingInSector(currentThing);
		}
	
		currentThing = FirstThingInSector(sector1);
		while (currentThing != -1) 
		{
			call antigravpull;
			currentThing = NextThingInSector(currentThing);
		}	
   }

   return;

antigravpull:
	if (GetThingType(currentThing) == 10) {
		DetachThing(currentThing);
		playerVec = GetThingVel(currentThing);
		playerVec = VectorAdd(vec0, playerVec);
		SetThingVel(currentThing, playerVec);
	}
	return;

end


[This message has been edited by rob_whatman (edited November 16, 2002).]
2002-11-18, 4:34 AM #2
I have no way of testing it, but from looking at your cog and what you are saying I *think* I know what the problem is.

You need to run the currentthing and its respective while looks in their own loop constantly until the trap is finished. What happens now is that the trap starts, it runs the while loop and finds the player. It then adds the vector approprately and sends them flying. But when they enter the second sector there is nothing looking for them because the while loops have already stopped and won't run until the switch is activated again.

I hope I explained that well enough...I'm sorry if I didn't.

So place the parts that find the player and add thrust to him in a pulse message, and have that pulse started when the switch is activated and ended when the trap stops.

I hope that helps.

↑ Up to the top!