ACR Doors

Scripted ALFA systems & related tech discussions (ACR)

Moderators: ALFA Administrators, Staff - Technical

Locked
User avatar
Curmudgeon
Gadfly
Posts: 4312
Joined: Thu Oct 07, 2004 12:07 am
Location: East coast US

ACR Doors

Post by Curmudgeon »

Would it be possible to add variables to let builders easily change the closed/open1/open2 state of doors depending on the hour of day? I see this being useful for city gates, barns, animal enclosures and such.
- Curmudgeon
HDM ALFA 03 - The Silver Marches
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Maxim #12: A soft answer turneth away wrath. Once wrath is looking the other way, shoot it in the head." - The Seventy Maxims of Maximally Effective Mercenaries

"This is not my circus. These are not my monkeys."

Realmslore: Daily Dwarf Common
Zelknolf
Chosen of Forumamus, God of Forums
Posts: 6139
Joined: Tue Jul 05, 2005 7:04 pm

Re: ACR Doors

Post by Zelknolf »

Probably possible, but I can't pick it up immediately, and I can't promise that we'll find any solutions that will perform well when deployed on the scope of ACR doors. No harm in trying, though.

I've created this ticket to track:
http://www.alandfaraway.org/node/2247
FoamBats4All
Githyanki
Posts: 1289
Joined: Sat Feb 04, 2012 6:00 pm

Re: ACR Doors

Post by FoamBats4All »

Looks like we already have a hook to set an ACR door's heartbeat based on a tag. Though it looks like we're using some bitwise operation to pack all of the ACR door variables into one 32-bit integer.

Not sure if it's ACR scope, but setting ACR_DOOR_ON_HEARTBEAT to a script that handles opening/closing at certain times of day shouldn't be difficult.

E.g.:

Code: Select all

const string LAST_HOUR_CHANGED = "DOOR_LAST_HOUR_CHANGED"; 
 
const string CLOSE_HOUR = "DOOR_CLOSE_HOUR"; 
const string OPEN_HOUR = "DOOR_OPEN_HOUR"; 
 
const string LOCK_ON_CLOSE = "DOOR_LOCK_ON_CLOSE"; 
const string UNLOCK_ON_OPEN = "DOOR_UNLOCK_ON_OPEN"; 
 
void main() { 
	object oDoor = OBJECT_SELF; 
	int nLastHourChanged = GetLocalInt( oDoor, LAST_HOUR_CHANGED ); 

	// We only update on hour changes. 
	if ( GetTimeHour() == nLastHourChanged ) return; 
	nLastHourChanged = GetTimeHour(); 

	// Get our change hours. 
	if ( nLastHourChanged == GetLocalInt( oDoor, CLOSE_HOUR ) ) { 
		ActionCloseDoor( oDoor ); 
		if ( GetLocalInt( oDoor, LOCK_ON_CLOSE ) == TRUE ) SetLocked( oDoor, TRUE ); 
	} else if ( nLastHourChanged == GetLocalInt( oDoor, OPEN_HOUR ) ) { 
		ActionOpenDoor( oDoor ); 
		if ( GetLocalInt( oDoor, UNLOCK_ON_OPEN ) == TRUE ) SetLocked( oDoor, FALSE ); 
	} 

	// Store the game hour. 
	SetLocalInt( oDoor, LAST_HOUR_CHANGED, nLastHourChanged ); 
}
Note that the above code is untested, and may not do exactly what you want. The point is, you can do this kind of behavior easily enough in the custom heartbeat script.
Ronan
Dungeon Master
Posts: 4611
Joined: Sun Feb 20, 2005 9:48 am

Re: ACR Doors

Post by Ronan »

A few doors running OnHeartbeats would not be such a bad thing.

As Foam states, I left an OnHB hook in there so builders could add their on HB functionality if desired. The original OnHB event is used to initialize the door, then the heartbeat script is set to local string ACR_DOOR_ON_HEARTBEAT (which is generally nothing, so there is usually no heartbeat script).

However, using DelayCommands would be more performant, and could be added via either module-side scripts or the ACR. You might not want every door in the mod having such a DelayCommand stuck in the queue, but it beats heartbeats, and it shouldn't be used too often anyway.

If I get the chance I'll add the functionality to the ACR.

Has anyone tried out auto-closing since the last update? Doors should no longer close in PC's faces (they were never supposed to, but there was a bug making it possible).
Locked