November 12 2019 08:30:47
Navigation
· Home
· Articles
· Downloads
· FAQ
· Discussion Forum
· Web Links
· News Categories
· Contact Me
· Photo Gallery
· Search
· Gameservers
Languages
Users Online
· Guests Online: 6

· Members Online: 0

· Total Members: 1,057
· Newest Member: Soul of Minh
Teamspeak 3
Last Seen Users
· Homi12:04:11
· apfelbaum12:20:56
· GONZO15:35:04
· Intruder16:07:12
· Hoods17:28:54
· The ACE 1 day
· sonic 1 day
· Vietmin 2 days
· Confused Master 5 days
· martyr 5 days
· WEZ 1 week
· fayi 2 weeks
· bvda 2 weeks
· Melber 2 weeks
· dim 2 weeks

View Thread: Ando door script
Vietcong.Info » Vietcong General Discussion » Maps & Mapping
Who is here? 1 Guest
Current Rating: (Total: 0 ratings)  
 Print Thread
Ando door script
SGT PEPPER
I'm trying to use Ando's door script. Walk up to door ,enter, door opens but spins 360. Can hit enter and reverse revolution but still spins 360.
case SC_LEV_MES_INITSCENE:

InitScene(info);
SC_SetObjectScript("de_first_aid","levels\\machinegun2\\DATA\\mg\\SCRIPTS\\first aid.C");
SC_SetObjectScript("de_ammobox","levels\\machinegun2\\DATA\\mg\\SCRIPTS\\DE_AmmoBox_.C");
SC_SetObjectScript("_door","levels\\machinegun2\\DATA\\mg\\SCRIPTS\\_Door.C");

Ammo box and first aid works well. Used Ando's script and the .bes he made.
Does anyone know why it spins 360?
Edited by SGT PEPPER on 31-10-2014 02:58
 
Silent Bob
Can you please post the "_Door.C" script?
 
www.vietcong.info
SGT PEPPER
Copied from this site:

// VIETCONG 1
// DOOR script v3.0
// Writen for custom object - DE_door.bes
// made by Ando


/*
______________DESCRIPTION:
MP synchronized door.
Player can use (open /close) door. Use option appears when player is near door and looking at it.
Door has some kind of collision with player. It means that door don’t move through player, it moves back to last position when player is on its way.
Also bots can use that door. Door open/close automatically when they are near enough.







_____________HISTORY:
//2.3 orig trans restored bug fixed
//2.4 completly new and better synchronization
//2.5 AI is using doors automatically
//2.6 created fake collision with player
//2.6 start state option
//2.7 automatic Global variable system
//3.0



*/


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



//____________________________OBJECT PARAMETERS____________________________

//OBJECT STATES: 0 - closed, 1 - open, 2 -opening, 3 - closing, //future: 4-quiet and slow open, 5-quiet and slow close ,6 - locked

#define START_STATE 0
#define CLOSESTRING 2814 //"USE" text for closeing
#define OPENSTRING 2813 //"USE" text for opening
#define CLOSESOUND 2002 //"close" sound
#define OPENSOUND 2001 //"open" sound
#define COLL_SOUND 1484 //sound for collision with player
#define OPENINGTIME 0.8f //
#define ROT_ANGLE -110.0f //door opening angle in degrees
#define dum_sub_obj "Dummy" //dummy object name


//_________________________________________________________________________
#define GVAR_SERVER 600 // 0 - not server, 1 - server
#define GVAR_COUNT 601 // Channel for G-var count
#define GVAR_GPHASE 500
//_________________________________________________________________________





void *dum_sub_obj_id;

int use_string = OPENSTRING;



float val = 0.0f;
float timer = 0.0f;
float dist;

c_Vector3 door_vec;
c_Vector3 player_pos;
c_Vector3 dum_pos;

s_sphere sph2;

s_SC_NOD_transform trans;
s_SC_NOD_transform orig_trans;

int Temp = 0; //global object status
int Temp2 = -1; //local object status. -1 = unknown ststus (for start/restart)
int i_items,j;
int my_gvar_count;
int my_gvar;


BOOL startsound = FALSE;

s_SC_P_getinfo pl_info;

dword player;
dword list[32];

int ScriptMain(s_SC_OBJ_info *info){
switch(info->event_type){
case SC_OBJ_INFO_EVENT_INIT:
SC_NOD_GetTransform(info->master_nod,&orig_trans);
SC_NOD_GetWorldPos(info->master_nod,&door_vec);
dum_sub_obj_id = SC_NOD_GetNoMessage(info->master_nod, dum_sub_obj);


//creating global variable
my_gvar_count = SC_ggi(GVAR_COUNT)+1;
SC_sgi(GVAR_COUNT,my_gvar_count);
my_gvar = my_gvar_count+ 601;

return TRUE;
case SC_OBJ_INFO_EVENT_JUSTLOADED:
break;
case SC_OBJ_INFO_EVENT_RELEASE:
SC_NOD_SetTransform(info->master_nod,&orig_trans);
break;
case SC_OBJ_INFO_EVENT_HIT:
break;
case SC_OBJ_INFO_EVENT_DOTICK:
if (SC_ggi(GVAR_GPHASE) == 1){//restarting
Temp2 = -1; //restores unknown state for door
return TRUE;
break;
}//
//______________start/restart status for server____________
if (Temp2 == -1){ //restores stsrt state
if (SC_ggi(GVAR_SERVER) == 1){
SC_sgi(my_gvar,START_STATE); // status on start/restart
}
}
Temp = SC_ggi(my_gvar);
//_________________________________________AI is useing a door
if (SC_ggi(GVAR_SERVER) == 1){
player = SC_GetNearestPlayer(&door_vec, &dist);
if (dist < 2.8f){//was 2.5 before
SC_P_GetInfo(player, &pl_info);
if(pl_info.member_id != 255){
switch(Temp){
case 0: //
if (dist < 2){
SC_sgi(my_gvar,2);//opening
Temp =2;
}
break;
case 1: //
if (dist > 2.1){
SC_sgi(my_gvar,3);//closeing
Temp =3;
}
break;
}
}
}
}
//__________________________________________end of AI is useing a door
//______________use string__________
val = SC_DOBJ_CameraLooksAt(info->master_nod,2);
if (val<1.0f){
if (Temp == 0 || Temp == 3){
use_string = OPENSTRING;
}
if (Temp == 1 || Temp == 2){
use_string = CLOSESTRING;
}
SC_ACTIVE_Add(info->master_nod,2.0f*val,use_string);
}
//_____________CHANGE OBJECT STATUS________________
if (Temp != Temp2){ //temp- Global state Temp2 - Local state
switch(Temp){
case 0: //set door closed status
SC_NOD_SetTransform(info->master_nod,&orig_trans);
startsound = TRUE;//??????
timer=0;
Temp2=0;
break;
case 1: //set door opened status
trans=orig_trans;
trans.rot.z+= DEG_TO_RAD(ROT_ANGLE);
SC_NOD_SetTransform(info->master_nod,&trans);
startsound = TRUE;//?????
timer=0;
Temp2=1;
break;
case 2: //door is opening
if (Temp2==1){ //last state was oposite movement
timer = (OPENINGTIME-timer);//reverse movement time
}
Temp2=0;
if (startsound){
SC_SND_PlaySound3D(OPENSOUND,&door_vec);
startsound = FALSE;
}
timer+=info->time;
trans=orig_trans;
trans.rot.z+=(DEG_TO_RAD(ROT_ANGLE)*timer/OPENINGTIME);
SC_NOD_SetTransform(info->master_nod,&trans);
// ________FAKE COLLISION WITH PLAYER______________________________
if (SC_ggi(GVAR_SERVER) == 1){// only server
sph2.pos=door_vec;
sph2.rad=2;
i_items=32;
SC_GetPls(&sph2,list,&i_items);
for (j=0;j<i_items;j++) {
SC_P_GetInfo(list[j], &pl_info);
if(pl_info.member_id == 255){
SC_NOD_GetWorldPos(dum_sub_obj_id, &dum_pos);
SC_P_GetPos(list[j], &player_pos);
dist=SC_GetLineDist(&player_pos, &dum_pos,&door_vec);
if (dist < 0.33f){
SC_SND_PlaySound3D(COLL_SOUND,&player_pos); //collision sound
SC_sgi(my_gvar,3); //
}
}
}
}
//_________end of FAKE COLLISION______________________________________
if (timer >= OPENINGTIME){
if (SC_ggi(GVAR_SERVER) == 1) SC_sgi(my_gvar,1); //
}
break;
case 3: //door is closing
if (Temp2==0){ //last state was oposite movement
timer = (OPENINGTIME-timer);//reverse movement time
}
Temp2=1;
if (startsound){
SC_SND_PlaySound3D(CLOSESOUND,&door_vec);
startsound = FALSE;
}
timer+=info->time;
trans=orig_trans;
trans.rot.z+=(DEG_TO_RAD(ROT_ANGLE)*(OPENINGTIME-timer)/OPENINGTIME);
SC_NOD_SetTransform(info->master_nod,&trans);

// ________FAKE COLLISION___________________________________________________
if (SC_ggi(GVAR_SERVER) == 1){// only server
sph2.pos=door_vec;
sph2.rad=2;
i_items=32;
SC_GetPls(&sph2,list,&i_items);
for (j=0;j<i_items;j++) {
SC_P_GetInfo(list[j], &pl_info);
if(pl_info.member_id == 255){
SC_NOD_GetWorldPos(dum_sub_obj_id, &dum_pos);
SC_P_GetPos(list[j], &player_pos);
dist=SC_GetLineDist(&player_pos, &dum_pos,&door_vec);
if (dist < 0.33f){
SC_SND_PlaySound3D(COLL_SOUND,&player_pos); //collision sound
SC_sgi(my_gvar,2); //
}
}
}
}
//_________end of FAKE COLLISION______________________________________
if (timer >= OPENINGTIME){
if (SC_ggi(GVAR_SERVER) == 1) SC_sgi(my_gvar,0); //
}
break;
case 5: //
break;
}
}
break;
case SC_OBJ_INFO_EVENT_USED:
Temp = SC_ggi(my_gvar);
switch(Temp){
case 0: // door is closed
case 3: // door is closing
SC_sgi(my_gvar,2); // start opening
break;
case 1: // door is opened
case 2: // door is opening
SC_sgi(my_gvar,3); // start closing
break;
}
break;
}// switch(info->event_type)
return FALSE;
}// int ScriptMain(s_OBJ_info *info)
 
Ando
SGT PEPPER wrote:
I'm trying to use Ando's door script. Walk up to door ,enter, door opens but spins 360. Can hit enter and reverse revolution but still spins 360.


Probably mode script is without automatic sync. support.
 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Multiplayer Game Script Vietcong Tech Talk 4 22-06-2019 19:31
MP sync. script discussion Maps & Mapping 89 26-04-2016 09:40
ADM script Maps & Mapping 3 03-12-2014 14:23
Waterstation - DM script Maps & Mapping 5 20-07-2013 02:18
Script troubles Maps & Mapping 4 02-02-2013 11:44
Login
Username

Password



Forgotten your password?
Request a new one here.
Render time: 0.08 seconds - 51 Queries 2,648,273 unique visits