PDA

View Full Version : waypoint cog thingy



2nd_Elmo
12-12-2003, 05:25 AM
I've tried to cog it myself a few times, others have tried it but nothing ever worked.
(unfortunately that was all a long time ago, and I deleted all the cog attempts + it's been a long time that I didn't cog anything)

The problem seems rather easy (at least it does that to me):
I'm in need of a cog that reacts on the player entering a sector.

we have:
- the player (obvious)
- technican (an AI controlled friend)
- a door
- four ghost waypoints (they're also saved as frames. I've tried everything...)

Once the player entered 'sector' a strifle (how much ammo does the strifle-pickup give?) is added to his weapons inventory thing.
The technican begins to move to the first position, continues to the second. Now a door opens (IMPORTANT: it has to open on playeractivation, too), he passes the door to waypoint three, and goes on to four, and then stops there... (A cutscene will be launched so he should be free to go where another cog sends him.)

sounds easy (I think) but it never worked right...

------------------
* Elmo is still Elmo

[This message has been edited by 2nd_Elmo (edited December 12, 2003).]

[SF]pjb
12-12-2003, 06:27 AM
the following cog is untested, but should do what you want. if your nice to it..



#----------------------------------jk cog scrpit---------------------------------
#-------------------------------------[PJB]--------------------------------------
#--- move a actor about, open a door, and just incase.. give the palyer a ST rifle


symbols
thing powerup local
thing player local
int bin=3 local
int ammobin=11 local
sound pickupsnd=thrmlpu2.wav local
sound respawnsnd=Activate01.wav local
flex amount local

int bin_contents=0 local
int autopickup=0 local
int autoselect_weapon=-1 local
sector trig
message entered
message startup
vector pos1
vector pos2
vector pos3
vector pos4
flex sleep1
flex sleep2
flex sleep3
thing waypoint1
thing waypoint2
thing waypoint3
thing waypoint4
thing actor
thing door
end
code
startup:
pos1=GetThingPos(waypoint1);
pos2=GetThingPos(waypoint2);
pos3=GetThingPos(waypoint3);
return;

entered:
//--st rifle
player = GetSourceRef();
powerup = GetSenderRef();

// Do effects.
PlaySoundThing(pickupsnd, powerup, 1.0, -1, -1, 0);
AddDynamicTint(player, 0.0, 0.0, 0.2);

if(GetInv(player, bin) == 0)
{
// Pickup gun and ammo.
// Print("Stormtrooper Rifle");
jkPrintUNIString(player, bin);

ChangeInv(player, bin, 1.0);

// store the old bin contents
bin_contents = GetInv(player, ammobin);
ChangeInv(player, ammobin, 24.0);

// Check for Auto Pickup
autopickup = GetAutoPickup();
if(autopickup & 1)
{
if(!((autopickup & 4) && (GetWeaponPriority(player, GetCurWeapon(player), 0) >= GetWeaponPriority(player, bin, 0))))
{
if(!((autopickup & 8) && (GetCurWeapon(player) == 10)))
{
SelectWeapon(player, bin);
Return;
}
}
}

// Check for Auto Reload
if(GetAutoReload() & 1)
{
if(!bin_contents)
{
if(!((GetAutoReload() & 2) && (GetCurWeapon(player) == 10)))
{
// Try to autoselect and see if the best weapon is an energy cell weapon
autoselect_weapon = AutoSelectWeapon(player, 2);
if((autoselect_weapon == 2) || (autoselect_weapon == 3))
SelectWeapon(player, autoselect_weapon);
}
}
}
}
else
if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
{
// Pickup ammo only.
// Print("Energy Cells");
jkPrintUNIString(player, ammobin);

// store the old bin contents
bin_contents = GetInv(player, ammobin);

ChangeInv(player, ammobin, 24.0);

// Check for Auto Reload
if(GetAutoReload() & 1)
{
if(!bin_contents)
{
if(!((GetAutoReload() & 2) && (GetCurWeapon(player) == 10)))
{
// Try to autoselect and see if the best weapon is an energy cell weapon
autoselect_weapon = AutoSelectWeapon(player, 2);
if((autoselect_weapon == 2) || (autoselect_weapon == 3))
SelectWeapon(player, autoselect_weapon);
}
}
}
}
//-end strifle
AISetMovePos(actor, pos1);
AISetMoveThing(actor, waypoint1);
sleep(sleep1);
AISetMovePos(actor, pos2);
AISetMoveThing(actor, waypoint2);
movetoframe(door,1,5);
sleep(sleep2);
AISetMovePos(actor, pos3);
AISetMoveThing(actor, waypoint3);
movetoframe(door,0,5);
sleep(sleep3);
AISetMovePos(actor, pos4);
AISetMoveThing(actor, waypoint4);
return;
end


------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's (http://www.geocities.com/SF_PJB1)

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD

[SF]pjb
12-12-2003, 06:32 AM
oh, and if you want the door to open by a palyer too. just give it the following door cog (to prevent HOM)



Jedi Knight Cog Script
#
# 00_Door.cog
#
# Generic Door Script
#
# [IS]
# [PJB]
#
# modifed by PJB on the 12, december, 2003 to NOt change sector adjoins.
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ================================================== ======================================

symbols
message startup
message activate
message arrived
message timer
message blocked

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

sector doorSector local
int numDoors=0 local
int doorStatus local
int moveStatus local
int i local
end

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

code

startup:
for (i=0; i<=3; i=i+1)
if (door0[i] >= 0) numDoors = numDoors + 1;

doorSector = GetThingSector(door0);
SetSectorLight(doorSector, lightValue, 0.0); // add some light to door sector
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[i] >= 0) MoveToFrame(door0[i], 1, moveSpeed);
return;

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

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

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

CheckStatus:
moveStatus = 0;
doorStatus = 0;

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

end


------------------
I am pjb.
Another post......
another moment of my life wasted.....
at least i made a level.
PJB's JK page's (http://www.geocities.com/SF_PJB1)

-the PJB jedi rule book-
rule one, "never trust a bartender with bad grammar"-kyle katarn in JO

Rule Two, "Gravity is a crule misstress" -kyle katarn in MotS, and the alternatior MK I in AJTD

2nd_Elmo
12-12-2003, 09:34 AM
just looking at it I'd say, yes that would make the actor move... the player blocking (even accidently) the actor would screw it all up.

okay, tested it now... I get the weapon, but then nothing happens, the technican doesn't move AND the door doesn't open. I told you it's strange...

------------------
* Elmo is still Elmo

[This message has been edited by 2nd_Elmo (edited December 12, 2003).]

Edward
12-12-2003, 12:40 PM
Is the technician out of sight? That would do so that the technician doesn't move...

2nd_Elmo
12-12-2003, 01:03 PM
You and the technican are teleported in the "sector" after a cutscene was played. The technican starts walking and you're supposed to follow him.

Got the technican moving, but the door doesn't open. Now all I need is a cog that opens the door when the technican enters the "door sector". (the player must be able to open the door at any time).

------------------
* Elmo is still Elmo

[This message has been edited by 2nd_Elmo (edited December 13, 2003).]