TKC-Community

Hacking and Art => Vietcong 1 & 2 => Topic started by: smity on January 23, 2007, 12:32:08 pm

Title: Fling Chopa
Post by: smity on January 23, 2007, 12:32:08 pm
i was just working on a map and wonted to make it so u get picked up by a chopa and droped of in a difrent location, do any of u have a script for thins or a script for a bot to drive u ther in a car?
Title: Re: Fling Chopa
Post by: $3R!N63 on January 23, 2007, 02:40:55 pm
now THAT would be cool.
Title: Re: Fling Chopa
Post by: LazyPig on January 23, 2007, 07:11:08 pm
That would certainly be cool :D
I did some scripting but that's a long time ago, it is definitely possible what you want here, and the best place to start is the script sdk, you can find it here: VC Script SDK096 (http://www.vietcong-customs.com/download.php?action=load&fileid=41&sp=1)
Title: Re: Fling Chopa
Post by: Frank P. on January 24, 2007, 05:47:03 pm
I forgot what the map was called I think it had Chips in it but it was NVA Base and a chopper landed in the VC flag and you got on the side rails and itd drop you off at the US flag or vise versa.
Title: Re: Fling Chopa
Post by: bando on September 05, 2007, 12:22:30 pm
i have those scripts and the headers if you re interested
just send me a PM and i ll give them to you.
extraction works for multiplayer coop maps and chopper arrival for solo missions maps.
Title: Re: Fling Chopa
Post by: bando on September 05, 2007, 01:10:12 pm
for exemple , this one is the stream chopper
you can change also the rotor speed etc
if you know about the anims , you can make a cinematic , for exemple , seeing it landing before the extraction or arrival.
have a look at DNP's or rs_khotan mission , that can give you an idea.
people often have tried but failed with simple details , like remplacing the default .inc files,headers etc by the correct ones!

#include <inc\sc_global.h>
#include <inc\sc_def.h>

#define STARTTIME 0
#define ENDTIME 2000
#define LANDTIME 0
#define STARTLOOP 0
#define ENDLOOP 50
//#define ANIMATION "g\\camanims\\stream.anm"
#define ANIMATION "Levels\\Test\\Data\\Test1\\HueyLZ.anm"
//#define ANIMATION "Levels\\NVA_BASE\\data\\TMG-PoTlongKarai\\scripts\\HueyLZ2_anm.scr"

//#define CAMERAANIM "g\\camanims\\camera\\stream_in.anm"
//#define CAMERAANIM "Levels\\Test\\Data\\Test1\\anim1.anm"

#define PSay(who, what) {SC_P_Speech2(who,what,&time);time+=0.1f;}



#define ENGINESOUND 1920

#define SECONDSOUND 2797

#define SOUNDPARAM1 2

#define SOUNDPARAM2 0.85f

//show dust near earth
#define HELIFLAG 0

//in revolutions  per second

#define MAINROTOR_SPEED      4
#define REARROTOR_SPEED   12

s_SC_NOD_transform heliorigtran;

float gsoundtimer=0;

void ChopperRelease(s_SC_OBJ_info *info){
   SC_NOD_SetTransform(info->master_nod,&heliorigtran);   
}

void *ChopperInit(s_SC_OBJ_info *info){
   s_SC_Heli_Init init;
   s_SC_MWP_Create cinfo;
   s_SC_Car_AddEntry einfo;
   s_SC_NOD_transform tran;
   void *nod,*dum;
   void *heli;
   dword pl;
   int i;

         CLEAR(einfo);
         CLEAR(init);
         
         SC_NOD_GetTransform(info->master_nod,&heliorigtran);
         nod = SC_NOD_Get(info->master_nod,"UH1B_Body_LOD1");

         init.master_nod=info->master_nod;
         init.eng_snd_id = ENGINESOUND;
         init.snd2_id=SECONDSOUND;
         init.snd2_turndown_dist=SOUNDPARAM1;
         init.snd2_zerodist_volume=SOUNDPARAM2;
         init.flags=HELIFLAG;
         heli = SC_HELI_Create(nod,&init);


         einfo.entry_dist = 2.0f;
         einfo.entry_name_nr = 2120;
         einfo.exit_name_nr = 2114;
         einfo.function = 999;

         einfo.min_rx = -DEG_TO_RAD(70.0f);
         einfo.max_rx = DEG_TO_RAD(70.0f);
         einfo.min_rz = -DEG_TO_RAD(115.0f);
         einfo.max_rz = DEG_TO_RAD(115.0f);
         
         
         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_01");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_01");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli1";
         
         SC_HELI_EntryAdd(heli,&einfo);      


         einfo.function = SC_CAR_ENTRY_FUNC_SEAT;
         einfo.disabled_for_PC=TRUE;
         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_02");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_02");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli2";
         
         SC_HELI_EntryAdd(heli,&einfo);      


         dum = SC_NOD_Get(info->master_nod,"S_Entry_03");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_03");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli3";
         
         SC_HELI_EntryAdd(heli,&einfo);      


         einfo.min_rx = -DEG_TO_RAD(70.0f);
         einfo.max_rx = DEG_TO_RAD(70.0f);
         einfo.min_rz =  DEG_TO_RAD(260.0f);
         einfo.max_rz = DEG_TO_RAD(310.0f);


         dum = SC_NOD_Get(info->master_nod,"S_Entry_04");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_04");
               
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli4";
         
         SC_HELI_EntryAdd(heli,&einfo);      


         dum = SC_NOD_Get(info->master_nod,"S_Entry_05");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_05");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli5";
         
         SC_HELI_EntryAdd(heli,&einfo);      


         dum = SC_NOD_Get(info->master_nod,"S_Entry_06");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_06");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli6";
         
         SC_HELI_EntryAdd(heli,&einfo);      
         

         einfo.function = 4;
         einfo.disabled_for_PC=TRUE;
         einfo.min_rx = -DEG_TO_RAD(70.0f);
         einfo.max_rx = DEG_TO_RAD(70.0f);
         einfo.min_rz = -DEG_TO_RAD(120.0f);
         einfo.max_rz = DEG_TO_RAD(120.0f);




         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_07");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_07");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli7";
         
         SC_HELI_EntryAdd(heli,&einfo);   

         dum = SC_NOD_Get(info->master_nod,"S_Entry_08");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_08");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);

         einfo.stg_dir = "heli8";
         
         SC_HELI_EntryAdd(heli,&einfo);   
         
         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_09");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_09");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli9";
         
         SC_HELI_EntryAdd(heli,&einfo);   

         einfo.min_rx = -DEG_TO_RAD(70.0f);
         einfo.max_rx = DEG_TO_RAD(70.0f);
         einfo.min_rz =  DEG_TO_RAD(270.0f);
         einfo.max_rz = DEG_TO_RAD(320.0f);

         dum = SC_NOD_Get(info->master_nod,"S_Entry_10");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_10");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli10";
         
         SC_HELI_EntryAdd(heli,&einfo);   

         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_11");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_11");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli11";
         
         SC_HELI_EntryAdd(heli,&einfo);
         

         dum = SC_NOD_Get(info->master_nod,"S_Entry_12");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_12");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli12";
         
         SC_HELI_EntryAdd(heli,&einfo);
         
         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_13");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_13");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli13";
         
         SC_HELI_EntryAdd(heli,&einfo);
         
         
         dum = SC_NOD_Get(info->master_nod,"S_Entry_14");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_14");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli14";
         
         SC_HELI_EntryAdd(heli,&einfo);

         dum = SC_NOD_Get(info->master_nod,"S_Entry_15");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_01");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli15";
      
         SC_HELI_EntryAdd(heli,&einfo);

         dum = SC_NOD_Get(info->master_nod,"S_Entry_16");
         einfo.rz = SC_NOD_GetWorldRotZ(dum) - SC_NOD_GetWorldRotZ(info->master_nod);
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.entry);
         einfo.target = einfo.entry;
         dum = SC_NOD_Get(info->master_nod,"S_Pos_01");
         SC_NOD_GetPosInOtherSpace(nod,dum,&einfo.view);
         einfo.stg_dir = "heli16";
         SC_HELI_EntryAdd(heli,&einfo);
         
         CLEAR(cinfo);
         cinfo.weap_type = 20;
         
         cinfo.nod_base = SC_NOD_Get(info->master_nod,"mount");
         cinfo.nod_rotate_x = SC_NOD_Get(info->master_nod,"Kloub_LOD01");
         cinfo.nod_rotate_z = cinfo.nod_rotate_x;
         cinfo.nod_fpv_camera = SC_NOD_Get(info->master_nod,"fpv");
         cinfo.nod_rotate_last = cinfo.nod_fpv_camera;
         cinfo.nod_muzzle = SC_NOD_Get(info->master_nod,"muzzle");
         
         cinfo.rotate_zmin = -DEG_TO_RAD(75.0f);
         cinfo.rotate_zmax = DEG_TO_RAD(75.0f);
         cinfo.rotate_xmin = -DEG_TO_RAD(40.0f);
         cinfo.rotate_xmax = DEG_TO_RAD(40.0f);
         cinfo.rotate_speed = 0.3f;

         cinfo.link_at = SC_MPW_LINK_AT_HELI;
         cinfo.link_ptr = heli;
         cinfo.link_entry_index = 12;
   
         SC_MWP_Create(&cinfo);

         cinfo.nod_base = SC_NOD_Get(info->master_nod,"mount_2");
         cinfo.nod_rotate_x = SC_NOD_Get(info->master_nod,"Kloub_2_LOD01");
         cinfo.nod_rotate_z = cinfo.nod_rotate_x;
         cinfo.nod_fpv_camera = SC_NOD_Get(info->master_nod,"fpv_2");
         cinfo.nod_rotate_last = cinfo.nod_fpv_camera;
         cinfo.nod_muzzle = SC_NOD_Get(info->master_nod,"muzzle_2");
         cinfo.link_entry_index = 13;
         SC_MWP_Create(&cinfo);
         return heli;
}

void Rotors_tick(void *master_nod,float time){
   s_SC_NOD_transform tran;
   void *nod,*dum;
   c_Vector3 vec;

         //alarmsound
         gsoundtimer+= time;
         if (gsoundtimer>5){
            gsoundtimer=0;
            SC_NOD_GetWorldPos(master_nod,&vec);
            SC_SND_PlaySound3D(1918,&vec);
         }

         //mainrotor
         dum = SC_NOD_Get(master_nod,"UH1B_Rotor_Main_LOD1");
         SC_NOD_GetTransform(dum,&tran);
         //tran.rot.z+= (time*20);
         tran.rot.z+=(MAINROTOR_SPEED*6.18*time);
         SC_NOD_SetTransform(dum,&tran);
   
         //rearrotor
         dum = SC_NOD_Get(master_nod,"UH1B_Rotor_Rear_LOD1");
         SC_NOD_GetTransform(dum,&tran);
         //tran.rot.x+= (time*20);
         tran.rot.x+=(REARROTOR_SPEED*6.18*time);
         SC_NOD_SetTransform(dum,&tran);
}



float gtime = 0;
float endtimer,landtimer,starttimer,startloop,endloop;
int status=-1;

BOOL everyoneout(){
   dword pl;
   int i;
   for (i=0;i<6;i++){
      pl = SC_P_GetBySideGroupMember(0,0,i);
      if (SC_P_IsInHeli(pl)) return FALSE;
   }
   return TRUE;
}

float screamtimer=0;
BOOL wasscreamed=FALSE;

int ScriptMain(s_SC_OBJ_info *info){
   s_SC_Heli_Init init;
   s_SC_MWP_Create cinfo;
   s_SC_Car_AddEntry einfo;
   s_SC_NOD_transform tran;
   void *nod,*dum;
   void *heli;
   dword pl;
   int i;
   float time=0;
   

   switch(info->event_type){
      case SC_OBJ_INFO_EVENT_RELEASE:
         SC_sgi(SGI_CHOPPER, 1);
         ChopperRelease(info);
         break;
      case SC_OBJ_INFO_EVENT_INIT:
         
         SC_sgi(SGI_CHOPPER, 1);
         ChopperInit(info);
         
         
         starttimer=SC_ANM_GetFrameTime(ANIMATION,STARTTIME);
         endtimer=SC_ANM_GetFrameTime(ANIMATION,ENDTIME);
         landtimer=SC_ANM_GetFrameTime(ANIMATION,LANDTIME);
         startloop=SC_ANM_GetFrameTime(ANIMATION,STARTLOOP);
         endloop=SC_ANM_GetFrameTime(ANIMATION,ENDLOOP);
         gtime=starttimer;
         return TRUE;         

      
   case SC_OBJ_INFO_EVENT_DOTICK:
      switch (status){
      case -1:
         status=0;
         break;
      case 0:
         Rotors_tick(info->master_nod,info->time);
         
         gtime += info->time;   
      
         if (gtime>startloop){
               status=1;
               return FALSE;
         } else
         if (gtime>landtimer){
               SC_PC_EnableExit(TRUE);
               SC_PC_EnableEnter(FALSE);
               // send message to the ai team to get out of the helicopter
               for (i=1;i<6;i++) SC_P_ScriptMessage(SC_P_GetBySideGroupMember(0,0,i),SCM_EXITHELI,0);            
               status=1;
               screamtimer=5+rand()%5;         
         }
      
         //SC_NOD_SetFromANM(ANIMATION,gtime,info->master_nod);
         break;
      case 1:
         Rotors_tick(info->master_nod,info->time);
         screamtimer-=info->time;
         if (screamtimer<0){
               //screaming at PC to GET OUT
               screamtimer=10+rand()%5;         
               PSay(SC_P_GetBySideGroupMember(0,1,11),5471+rand()%5);
               wasscreamed=TRUE;
         }
         if (everyoneout()) {
            status=2;
            if (wasscreamed) PSay(SC_P_GetBySideGroupMember(0,1,10),5477+rand()%5)
               else PSay(SC_P_GetBySideGroupMember(0,1,10),5460+rand()%10);
         }
         //SC_NOD_SetFromANM(ANIMATION,gtime,info->master_nod);
         break;

      case 2:
         Rotors_tick(info->master_nod,info->time);

         gtime += info->time;   
         if (gtime>endloop){      //chopper will loop until some other script sets SGI_CHOPPER to 2
            if (SC_ggi(SGI_CHOPPER)==2) {
               gtime = LANDTIME;
                status=3;
              }
            else gtime=startloop;
         }
         // We are not going to animate the chopper yet
         //SC_NOD_SetFromANM(ANIMATION,gtime,info->master_nod);
         break;         
      case 3:
         Rotors_tick(info->master_nod,info->time);

         gtime += info->time;   
         SC_NOD_SetFromANM(ANIMATION,gtime,info->master_nod);
         if (gtime>endtimer){
            SC_NOD_GetTransform(info->master_nod,&tran);
            tran.loc.z -= 10000.0f;
            SC_NOD_SetTransform(info->master_nod,&tran);            
            SC_sgi(SGI_CHOPPER,1);
            status=0;
            //ChopperRelease(info);
         }
         if ((SC_ggi(SGI_CHOPPER) == 1) || (gtime >= ENDTIME)) {
            // Restore the chopper's position
            ChopperRelease(info);
            status = 0;
            gtime = 0.0f;
            SC_sgi(SGI_CHOPPER,0);
          }

         break;
      }
      break;
   }// switch(info->event_type)


   return FALSE;

}// int ScriptMain(s_OBJ_info *info)