Elevators Scripting help

Post Reply
Robert
Posts: 33
Joined: Fri Aug 16, 2013 9:14 am

Elevators Scripting help

Post by Robert » Tue Aug 27, 2013 4:30 pm

Here is what I got working so far. they are slow and move up and down correctly doors seems to be backwards need to change that

but this is just for ELEVATOR_METALWORKS_ELVTR_2 ELEVATOR_METALWORKS_ELVTR_1

I haven't script them all yet..
The elevators seem to move every minute and a half unless triggered then they can move on call.

Code: Select all

void CTransportHandler::startElevator(Elevator_t * elevator)
{
	/*
	ELEVATOR_PSOXJA_ELVTR_1					= 1,
	ELEVATOR_PSOXJA_ELVTR_2					= 2,
	ELEVATOR_PSOXJA_ELVTR_3					= 3,
	ELEVATOR_PSOXJA_MVNG_FLR_4				= 4,
	ELEVATOR_PSOXJA_MVNG_FLR_3				= 5,
	ELEVATOR_PSOXJA_MVNG_FLR_1				= 6,
	ELEVATOR_PSOXJA_MVNG_FLR_2				= 7,
	ELEVATOR_PSOXJA_1						= 8,
	ELEVATOR_PSOXJA_2						= 9,
	ELEVATOR_PSOXJA_3						= 10,
	ELEVATOR_PSOXJA_4						= 11,
	ELEVATOR_PSOXJA_5						= 12,
	ELEVATOR_PSOXJA_6						= 13,
	ELEVATOR_PSOXJA_ELVTR_4					= 14,
	ELEVATOR_PSOXJA_ELVTR_5					= 15,
	ELEVATOR_PSOXJA_ELVTR_6					= 16,
	ELEVATOR_PSOXJA_ELVTR_7					= 17,
	ELEVATOR_PSOXJA_DSPPRNG_TLS_4			= 18,
	ELEVATOR_PSOXJA_DSPPRNG_TLS_1			= 19,
	ELEVATOR_PSOXJA_DSPPRNG_TLS_2			= 20,
	ELEVATOR_FORT_GHELSBA_ELVTR				= 21,
	ELEVATOR_PALBOROUGH_MINES_ELVTR			= 22,	// TODO: Verify NPC ID of upper and lower door
	ELEVATOR_DAVOI_ELVTR					= 23,	// in elevators.sql
	ELEVATOR_KUFTAL_TUNNEL_DSPPRNG_RCK		= 24,
	ELEVATOR_PORT_BASTOK_DRWBRDG			= 25,
	ELEVATOR_METALWORKS_ELVTR_1				= 26,
	ELEVATOR_METALWORKS_ELVTR_2				= 27
	
	*/
	uint32 VanaTime = CVanaTime::getInstance()->getVanaTime();
    uint8 tiemoffset = VanaTime; //USING UINT8 TO GET TWO VAULES OF EAITHER 16 OR 144 TO USE FOR UP OR DOWN SWITCHS
	elevator->Elevator->name[8] = 6; //THIS SEEMS TO BE SOME TYPE OF SPEED THE LOWER THE VALUE THE FASTER IT GOES AND THE HIGHER THE SLOWER
    WBUFL(&elevator->Elevator->name[0],4) = VanaTime;
	if ((elevator->LowerDoor != NULL) && (elevator->UpperDoor != NULL)) 
	{   

		
		
		
		if(tiemoffset == 16)//THIS IS A SWITCH OF THE TWO I USE FOR UP OR DOWN
		{
			
	     
		
		    
		   if(elevator->id == ELEVATOR_METALWORKS_ELVTR_1)//SCRIPTING EACH ONE FOR THE WAY THEY ACT IN THIS CASE ONE IS UP WHILE THE OTHER IS DOWN
		     {
				 
                 
			     elevator->Elevator->animation = ANIMATION_ELEVATOR_DOWN; 
			     ShowDebug(CL_GREEN"GOING DOWN\n"CL_RESET );
			
			     zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->Elevator,ENTITY_UPDATE));
				 elevator->LowerDoor->animation = ANIMATION_CLOSE_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->LowerDoor,ENTITY_UPDATE));
		         elevator->UpperDoor->animation = ANIMATION_OPEN_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->UpperDoor,ENTITY_UPDATE));
				
				 
			}
		   if(elevator->id == ELEVATOR_METALWORKS_ELVTR_2)//SCRIPTING EACH ONE FOR THE WAY THEY ACT IN THIS CASE ONE IS UP WHILE THE OTHER IS DOWN
		     {
                 
                 
			     elevator->Elevator->animation = ANIMATION_ELEVATOR_UP; 
			     ShowDebug(CL_GREEN"GOING UP\n"CL_RESET );
			
			     zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->Elevator,ENTITY_UPDATE));
				 elevator->LowerDoor->animation = ANIMATION_OPEN_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->LowerDoor,ENTITY_UPDATE));
		         elevator->UpperDoor->animation = ANIMATION_CLOSE_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->UpperDoor,ENTITY_UPDATE));
				 
				
			 }
		
		}
		if(tiemoffset == 144)//THIS IS A SWITCH OF THE TWO I USE FOR UP OR DOWN
		{
			
	       
		       
		   if(elevator->id == ELEVATOR_METALWORKS_ELVTR_1) //SCRIPTING EACH ONE FOR THE WAY THEY ACT IN THIS CASE ONE IS UP WHILE THE OTHER IS DOWN
		     {
                 
                 
			     elevator->Elevator->animation = ANIMATION_ELEVATOR_UP; 
			     ShowDebug(CL_GREEN"GOING UP\n"CL_RESET );
			
			     zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->Elevator,ENTITY_UPDATE));
				 elevator->LowerDoor->animation = ANIMATION_OPEN_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->LowerDoor,ENTITY_UPDATE));
		         elevator->UpperDoor->animation = ANIMATION_CLOSE_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->UpperDoor,ENTITY_UPDATE));
				 
				
			 }
		    if(elevator->id == ELEVATOR_METALWORKS_ELVTR_2)//SCRIPTING EACH ONE FOR THE WAY THEY ACT IN THIS CASE ONE IS UP WHILE THE OTHER IS DOWN
		     {
                 
                 
			     elevator->Elevator->animation = ANIMATION_ELEVATOR_DOWN; 
			     ShowDebug(CL_GREEN"GOING DOWN\n"CL_RESET );
			
			     zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->Elevator,ENTITY_UPDATE));
				 elevator->LowerDoor->animation = ANIMATION_CLOSE_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->LowerDoor,ENTITY_UPDATE));
		         elevator->UpperDoor->animation = ANIMATION_OPEN_DOOR;
		         zoneutils::GetZone(elevator->zone)->PushPacket(NULL,CHAR_INZONE, new CEntityUpdatePacket(elevator->UpperDoor,ENTITY_UPDATE));
				 
				
			 }
		   
		 }
	
	}
	
	
	
  
	
	  
	
}
AH I think If I Use PChar->loc.p.y at a POS If statement I could then use switch's to use for the doors being open and shut and if the elevator is moving or not in case the users has to pull a lever or something.. ill try that now for ELEVATOR_PALBOROUGH_MINES_ELVTR

User avatar
whasf
Site Admin
Posts: 1312
Joined: Thu Jul 19, 2012 9:11 pm

Re: Elevators Scripting help

Post by whasf » Thu Aug 29, 2013 6:07 pm

Please attach a .patch file (right-click file/tortisesvn/create patch) so we can easily see what you changed.
-- Whasf

Robert
Posts: 33
Joined: Fri Aug 16, 2013 9:14 am

Re: Elevators Scripting help

Post by Robert » Wed Sep 04, 2013 11:48 pm

ill make a patch but the elevators are very strange. the only problem I'm having with them is timing this this code above the elevator will only move every 1 minute and 30 second in real time, that's 1 and a half hours in vanatime I tried all the timers and none of them work but vanatime.

Robert
Posts: 33
Joined: Fri Aug 16, 2013 9:14 am

Re: Elevators Scripting help

Post by Robert » Mon Sep 09, 2013 4:41 am

I created a patch and tried to apply it to darkstar but it didnt work. just mess things up.
I have to many changes..

Post Reply