Here's how I'd do it.
------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
[This message has been edited by Descent_pilot (edited July 27, 2002).]
Code:
Try that. I dunno exactly how you want it to run.# armyo.cog
#
# Lord_Grismath (GrismathDynasty@hotmail.com) + [DP&SM]
symbols
message startup
message damaged
message killed
message touched
message playeraction
thing com0
thing com1
thing com2
thing com3
thing telething
thing tghost local
vector tempvec local
vector tempvec2 local
vector motionVector local
model tmodel local
template ghtemp=ghost local
template camera_tpl=+FarSight local
template comTemp0
template comTemp1
template comTemp2
template comTemp3
int player local
int X=0 local
int poss=0 local
int comnum=-1 local
int camera=-1 local
flex thealth=0 local
flex tempflex local
end
#==============================================================#
code
#------------------------------------------------------
startup:
Sleep(1);
player = GetLocalPlayerThing();
Print("Generalship Cog Implemented");
call goto_camera;
Return;
#------------------------------------------------------
damaged:
if(GetThingHealth(player) < 1)
{
SetThingHealth(player, 100);
call return_player;
poss = 0;
ReturnEx(0);
}
Return;
#------------------------------------------------------
playeraction:
if(poss)
{
ReturnEx(0);
Return;
}
if(GetParam(0) == 0) //Jumping
{
tempflex = 0;
// Only allow motion at one speed. i.e. disable running
if(GetParam(2) != 0) tempflex = 2.8;
motionVector = VectorSet(VectorX(motionVector), tempflex, VectorZ(motionVector));
ReturnEx(0);
}
else if(GetParam(0) == 1) // Crouching
{
tempflex = 0;
if(GetParam(2) != 0) tempflex = 2.8;
motionVector = VectorSet(VectorX(motionVector), -tempflex, VectorZ(motionVector));
ReturnEx(0);
}
else if(GetParam(0) == 2)
{
// Activation will be allowed, since you're possessing a character.
// call stop_power;
// ReturnEx(0);
}
else if(GetParam(0) == 3)
{
// Firing is also allowed
// ReturnEx(0);
}
else if(GetParam(0) == 4) // Strafe
{
motionVector = VectorSet(GetParam(2), VectorY(motionVector), VectorZ(motionVector));
ReturnEx(0);
}
else if(GetParam(0) == 5) // Turn
{
tempvec = GetThingRotVel(camera);
tempvec = VectorSet(VectorX(tempvec), GetParam(2), VectorZ(tempvec));
SetThingRotVel(camera, tempvec);
ReturnEx(0);
}
else if(GetParam(0) == 6) // Fwd / Bkwd Motion
{
motionVector = VectorSet(VectorX(motionVector), VectorY(motionVector), GetParam(2));
ReturnEx(0);
}
else if(GetParam(0) == 8) // Pitch
{
tempvec = GetThingLVecPYR(camera);
tempflex = VectorX(tempvec) + GetParam(1) / 100;
// Limit the pitch vector (flipping over doesn't work right...)
if(tempflex < -80) tempflex = -80;
else if(tempflex > 80) tempflex = 80;
tempvec = VectorSet(tempflex, VectorY(tempvec), VectorZ(tempvec));
SetThingLookPYR(camera, tempvec);
ReturnEx(0);
}
else if(GetParam(0) == 10) // Select Inventory Item
{
ReturnEx(0);
}
else if(GetParam(0) == 11) // Select Skill
{
ReturnEx(0);
}
else if(GetParam(0) == 12) // Use Inventory Item
{
ReturnEx(0);
}
else if(GetParam(0) == 13) // Use Skill
{
ReturnEx(0);
}
else if(GetParam(0) == 14) // Other Actions
{
if(GetParam(2) == 0) // Cycle Camera
{
Print("3rd person only...wraa");
ReturnEx(0); // This ReturnEx() is useless.
}
ReturnEx(1);
}
else
{
ReturnEx(0);
}
// Add up the various velocities.
tempvec = GetThingLVec(camera);
tempvec = VectorScale(tempvec, VectorZ(motionVector) / 3);
tempvec2 = GetThingUVec(camera);
tempvec2 = VectorScale(tempvec2, VectorY(motionVector) / 3);
tempvec = VectorAdd(tempvec, tempvec2);
tempvec2 = GetThingRVec(camera);
tempvec2 = VectorScale(tempvec2, VectorX(motionVector) / 3);
tempvec = VectorAdd(tempvec, tempvec2);
SetThingVel(camera, tempvec);
Return;
#------------------------------------------------------
goto_camera:
Print("Camera Activating...");
motionVector = VectorSet(0, 0, 0);
camera = FireProjectile(player, camera_tpl, -1, -1, '0 06 02', '0 0 0', 0, 0, 0, 0);
SetThingLook(camera, GetThingLVec(player));
SetCurrentCamera(0);
SetCameraFocus(0, camera);
TeleportThing(player, telething);
StopThing(player);
SetActionCog(GetSelfCog(), 0x7FFFFFFF);
poss = 0;
Print("Camera Activated");
Return;
#------------------------------------------------------
killed:
if(GetSenderRef() != player) Return;
return_player:
if(poss == 1)
{
tghost = CreateThing(ghtemp, player);
tmodel = GetThingModel(player);
thealth = GetThingHealth(player);
TeleportThing(player, telething);
com0[comnum] = CreateThing(comTemp0[comnum], tghost);
SetThingHealth(com0[comnum], thealth);
Call stop_camera;
}
Return;
stop_camera;
SetCameraFocus(0, player)
SetCurrentCamera(1);
DestroyThing(camera);
SetActionCog(-1, 0);
Return;
#------------------------------------------------------
touched:
for(X = 0; X < 4; X = X + 1)
{
if(GetSenderRef() == com0[X])
{
if(GetThingHealth(com0[X]) > 0)
{
tmodel = GetThingModel(com0[X]);
thealth = GetThingHealth(com0[X]);
SetThingModel(player, tmodel);
SetThingHealth(player, thealth);
TeleportThing(player, com0[X]);
DestroyThing(com0[X]);
poss = 1;
comnum = X;
call stop_camera;
}
}
}
Return;
#------------------------------------------------------
end------------------
The Sniper Missions. Current project, The Sniper Missions
The Magician Saber System.
[This message has been edited by Descent_pilot (edited July 27, 2002).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack
SATNRT, JK Pistol Mod, Aliens TC, Firearms
Completed
Judgement Day (HLP), My level pack
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)