Post by silentbob on Sept 25, 2008 7:03:54 GMT -8
From Luke ( Indiglow):
copter.c
minefield.c
pilot1.c
pilot2.c
copter.c
#define EXTERN
#include "../../../../../g/machines/uh1d/uh1d.c"
//these must be changed for other chopper then UH1D
#include <inc/sc_def.h>
#include <inc/shigor/library.cxx>
#include <inc/maxovo/!max_multiplayer.h>
#define PARTS_COUNT 3
char OBJECT_NAME[PARTS_COUNT][32] = { "body.l1", "UH1B_Rotor_Main_LOD1", "UH1B_Rotor_Rear_LOD01"};
//these must be changed for other chopper then UH1D
#define ANIMATION "levels\\frenchroute\\data\\frenchroute_mp\\manm\\test.manm"
//path to the animation
#define SYNCH_CHOPPERTIMER 15
dword S_timer;
dword C_timer;
dword MANM;
float animlength;
float gTime=0;
int status=0;
s_SC_NOD_transform current_trans;
s_SC_NOD_transform original_trans[4];
//in revolutions per second
#define MAINROTOR_SPEED 4
#define REARROTOR_SPEED 12
BOOL isserver(){
if (!SC_IsMpGame()) return FALSE;
if (SC_IsMpClient()) return FALSE;
return TRUE;
}
void Rotors_tick(sc_nod master_nod,float time){
s_SC_NOD_transform tran;
sc_nod nod,dum;
c_Vector3 vec;
//mainrotor
dum = SC_NOD_Get(master_nod,OBJECT_NAME[1]);
SC_NOD_GetTransform(dum,&tran);
tran.rot.z+=(MAINROTOR_SPEED*6.18*time);
SC_NOD_SetTransform(dum,&tran);
//rearrotor
dum = SC_NOD_Get(master_nod,OBJECT_NAME[2]);
SC_NOD_GetTransform(dum,&tran);
tran.rot.x+=(REARROTOR_SPEED*6.18*time);
SC_NOD_SetTransform(dum,&tran);
}
int ScriptMain(s_SC_OBJ_info *info) {
int i,j;
char buffer[64];
s_SC_Expl_CreateInfo exploinfo;
s_SC_MarokObjState marokstate;
c_Vector3 vec;
switch(info->message) {
case SC_OBJ_MSG_INIT:
SC_Marok_MakeStatic(SC_NOD_Get(info->master_nod, OBJECT_NAME[0]));
MANM = SC_MANM_Create(ANIMATION);
animlength=SC_MANM_GetLength(MANM,0);
gTime=0;
if (isserver()) {
SC_MP_Synch_Create(SYNCH_CHOPPERTIMER, &S_timer, sizeof(S_timer));
} else {
SC_MP_Synch_Create(SYNCH_CHOPPERTIMER, &C_timer, sizeof(C_timer));
}
SC_NOD_GetTransform(info->master_nod, &original_trans[0]);
for (i=0;i<3;i++)
SC_NOD_GetTransform(SC_NOD_Get(info->master_nod,OBJECT_NAME[i]),&original_trans[i+1]);
if (MAX_MUL_get_actual_mp_mode() == GAME_TYPE_COOP) {
current_trans.loc.x = 0.0;
current_trans.loc.y = 0.0;
current_trans.loc.z = 0.0;
current_trans.rot.x = 0.0;
current_trans.rot.y = 0.0;
current_trans.rot.z = 0.0;
current_trans.scale.x=1;
current_trans.scale.y=1;
current_trans.scale.z=1;
status = 1;
} else {
current_trans.loc.x = 0.0;
current_trans.loc.y = 0.0;
current_trans.loc.z = -1000.0;
current_trans.rot.x = 0.0;
current_trans.rot.y = 0.0;
current_trans.rot.z = 0.0;
current_trans.scale.x=1;
current_trans.scale.y=1;
current_trans.scale.z=1;
status = 2;
SC_DUMMY_Set_DoNotRenHier2(info->master_nod,TRUE);
}
SC_NOD_SetTransform(info->master_nod, ¤t_trans);
// SC_ObjScript_SetFlags(info->master_nod, SC_ObjScript_GetFlags(info->master_nod));
info->next_exe_time = 0.0;
break;
case SC_OBJ_MSG_RELEASE:
SC_MP_Synch_Remove(SYNCH_CHOPPERTIMER);
SC_NOD_SetTransform(info->master_nod, &original_trans[0]);
for (i=0;i<3;i++)
SC_NOD_SetTransform(SC_NOD_Get(info->master_nod,OBJECT_NAME[i]),&original_trans[i+1]);
SC_MANM_Release(MANM);
break;
case SC_OBJ_MSG_JUSTLOADED:
MANM = SC_MANM_Create(ANIMATION);
SC_Marok_MakeStatic(SC_NOD_Get(info->master_nod, OBJECT_NAME[0]));
current_trans.loc.x = 0.0;
current_trans.loc.y = 0.0;
current_trans.loc.z = 0.0;
current_trans.rot.x = 0.0;
current_trans.rot.y = 0.0;
current_trans.rot.z = 0.0;
current_trans.scale.x=1;
current_trans.scale.y=1;
current_trans.scale.z=1;
SC_NOD_SetTransform(info->master_nod, ¤t_trans);
SC_MANM_Set(MANM, 0, SC_NOD_Get(info->master_nod,OBJECT_NAME[0]), gTime);
break;
case SC_OBJ_MSG_HIT:
break;
case SC_OBJ_MSG_DOTICK:
info->next_exe_time = 0.0;
switch (status){
case 1:
//flying
if (isserver()){
gTime += info->elapsed_time;
S_timer = gTime;
SC_MP_Synch_SendChanges(SYNCH_CHOPPERTIMER, TRUE);
// SC_sgf(GVARSYNCED,gTime);
} else {
//gTime = SC_ggf(GVARSYNCED);
gTime = gTime + info->elapsed_time;
if (C_timer>gTime)
gTime = C_timer;
}
SC_MANM_Set(MANM, 0, SC_NOD_Get(info->master_nod,OBJECT_NAME[0]), gTime);
if (gTime > animlength){
//animation ended, so do something about it. now it loops
gTime=0;
//commented code would release the chopper and move it to the original place
/*
Emitor_Release();
SC_NOD_GetWorldPos(SC_NOD_Get(info->master_nod,OBJECT_NAME[0]),&vec);
SC_SND_PlaySound3D(3159,&vec);
gTime=0;
status=2;
SC_NOD_SetTransform(info->master_nod, &original_trans[0]);
for (i=0;i<3;i++)
SC_NOD_SetTransform(SC_NOD_Get(info->master_nod,OBJECT_NAME[i]),&original_trans[i+1]);
SC_MANM_Set(MANM[0], 0, SC_NOD_Get(info->master_nod,OBJECT_NAME[0]), 0);
SC_DUMMY_Set_DoNotRenHier2(info->master_nod,TRUE);*/
return FALSE;
}
}
Rotors_tick(info->master_nod, info->elapsed_time);
break;
}// switch(info->event_type)
return ScriptMain_inc(info);
}// int ScriptMain(s_OBJ_info *info)
minefield.c
#include <inc\sc_global.h>
#include <inc\shigor\library.cxx>
s_SC_Area area;
s_sphere sph;
c_BoxOriented box;
c_Vector3 oldpos;
int bombs=0;
void Init(s_SC_ScriptHelper_info *info){
if (info->event_type==SC_SCRHELPER_EVENTTYPE_INIT)
CLEAR(oldpos);
CLEAR(area);
switch (SC_GetScriptHelper(info->nod_name,&sph,&box)){
case SC_SCRIPTHELPER_TYPE_ERROR:
return;
case SC_SCRIPTHELPER_TYPE_SPHERE:
area.sphs=1;
area.sph=&sph;
break;
case SC_SCRIPTHELPER_TYPE_BOX:
area.boxes=1;
area.box=&box;
break;
}
}
float abs(float x){
if (x>0) return x;
else return -x;
}
void DoExplo(){
s_SC_Expl_CreateInfo exploinfo;
PC_GetPos(&oldpos);
CLEAR(exploinfo);
CLEAR(exploinfo);
exploinfo.author_handle=SC_PC_Get();
exploinfo.damage=100;
exploinfo.marok_impuls=600;
exploinfo.piercing=20;
exploinfo.ptc_id=199;
//exploinfo.flags=SC_EXPLCREATE_FL_DISABLESCENECOL_PLAYERS;
//exploinfo.script_type
//exploinfo.tweap_id
exploinfo.sph.pos = oldpos;
if (bombs<3) {
if (rand()%2)
exploinfo.sph.pos.x+=1+abs(2);
else exploinfo.sph.pos.x-=1+abs(2);
if (rand()%2)
exploinfo.sph.pos.y+=1+abs(2);
else exploinfo.sph.pos.y-=1+abs(2);
}
bombs++;
exploinfo.sph.rad=3;
SC_Explosion_Make(&exploinfo);
}
void Check(s_SC_ScriptHelper_info *info){
sc_player list[8];
if (!SC_PC_Get()) return;
if (!SC_EnumPlayersArea(SC_P_SIDE_ALL, SC_P_GROUP_ALL, list, 8, SC_ENUMPLS_FL_RESPAWNEDONLY |
SC_ENUMPLS_FL_ALIVEONLY| SC_ENUMPLS_FL_PC_ONLY , &area)) return;
if (SC_P_GetDistancePos(SC_PC_Get(),&oldpos)>1){
DoExplo();
}
}
int ScriptMain(s_SC_ScriptHelper_info *info){
switch(info->event_type){
case SC_SCRHELPER_EVENTTYPE_INIT:
Init(info);
info->next_exe_time=0.2f;
break;
case SC_SCRHELPER_EVENTTYPE_RELEASE:
break;
case SC_SCRHELPER_EVENTTYPE_TIMETICK:
Check(info);
break;
case SC_SCRHELPER_EVENTTYPE_JUSTLOADED:
Init(info);
break;
}
return 1;
}
pilot1.c
#define MEMBERID 1
#define NAME_NR 2745
#define VEHICLELINK 0
#define IMMORTAL
#define CLASS 7
#define AIFLAG 15
#include "crew.cxx"
pilot2.c
#define MEMBERID 2
#define NAME_NR 2745
#define VEHICLELINK 1
#define IMMORTAL
#define CLASS 7
#define AIFLAG 15
#include "crew.cxx"