forums | blogs | polls | tutorials | downloads | rules | help

Add new comment

im thinking that auto_joiner skrit should be rewrote to be Drianjul specific... as the autojoiner is made for drevin...

//////////////////////////////////////////////////////////////////////////////
//
// File     :  Drianjul_auto_joiner.skrit
// Author	:  DarkElf
//
// Drianjul will automatically join the player's party
// 
// this component has been customized to work exclusively with Drianjul.
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// Public definitions

property bool			initial_party_joiner$	= false;

// Reserved tags
property bool   		_server_only$			= true;
property string 		_doc$					= "Component to have characters auto-join when they are created.";

owner											= GoSkritComponent;

string bDrianjulTracker$ = "drianjul_joined_party";

bool AddToScreenParty$( Go member$ )
{
	if ( Server.GetScreenParty() != NULL )
	{	
		report.reportf( "party_joiner","member[0x%08x]: Successfully Added\n", member$ );
		WorldJournal.RSSetSessionBool( bDrianjulTracker$, true ); // remember that Drianjul has joined during this session
		owner.Go.Mind.SEnable();
		owner.Go.Mind.SSetMayAttack( true );
		owner.Go.Mind.SSetMayBeAttacked( true );
		owner.Go.Aspect.SSetIsVisible( true );
		owner.Go.Aspect.IsInvincible = false;
		owner.Go.Aspect.SSetCurrentLife( owner.Go.Aspect.GetMaxLife() );
		Server.GetScreenParty().Party.RSAddMemberNow( member$ );
		return true;
	}	
	return false;
}

startup state Begin$
{
	trigger OnGoHandleMessage$( WE_ENTERED_WORLD )
	{
		#only( game )
		[[
			owner.Go.Aspect.IsInvincible = true;
			owner.Go.Mind.SSetMayAttack( false );
			owner.Go.Mind.SSetMayBeAttacked( false );
			owner.Go.Mind.SDisable( true ); // true = make this actor invisible
	
			if ( initial_party_joiner$ )
			{
				this.CreateFrameTimer( 1, 0 );
			}
			else
			{
				this.CreateTimer( 1, 0.5 );
			}
		]]
	}

	trigger OnTimer$( 1 )
	{
		// Did Drianjul already join the party during this session?
		if ( WorldJournal.GetSessionBool( bDrianjulTracker$ ) )
		{
			// This is not the first Drianjul encountered! We will stay invisible and braindead; ready for next session.
			SetState Finish$;
		}
		// This is the first copy of Drianjul encountered this session, so
		// attempt to join the party
		else if ( !AddToScreenParty$( owner.Go ) )
		{
			this.CreateTimer( 1, 0.5 );
		}
		else
		{
			// we have successfully joined the party
			SetState Finish$;
		}
	}
}

state Finish$
{
}

and then in template use [drianjul_auto_joiner]