Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в эту темуОткрыть новую тему
> Потипу Универсальный Мобил...
Natsu
сообщение 14.8.2006, 12:42
Сообщение #1


**

Neophyte
Сообщений: 46
Регистрация: 9.8.2006
Группа: Пользователи
Наличность: 0
Пользователь №: 7.181



Стоит марка JackSkinner'а потому что я в то время от админов руо покрывался... адресс остался, но я его никогда не проверяю... потипу скрипт - мобил со стабами всех функций...
// CMobile Custom, by Jack Skiner ( jackyskiner@hotmail.com )

/*

General Information:
I've decided to write this "framework" for a custom mobile class. I thought that since any normal
shard is going to have its own custom mobile class - why not to make the base same for everyone?
Well so I made it (IMG:style_emoticons/default/smile.gif) The only difference between the custom and universal version is that the first
one includes some of the best and most useful and tested scripts, when the second one is simply
an interface.


Features:
- Ready-to-use frame for a custom mobile class named "CMobile"
- Pre-defined Initialization, constructor, serialization methods.
- Pre-defined events for almost all (most useful) events, including new events from EventSink.
- Good comments, including comments for most of the events
- Built-in Logging
- Built-in IPFilter for players and GMs
- Built-in text-based Tags ( serialization included )


Installation:
- Download and install Silver Ghost's (aka Richard) Logger Utility (http://www.runuo.com/scripts/show.php?f=122)
- Download and install Jack Skiner's (aka me) Tag class (http://www.runuo.com/discussion/viewtopic.php?t=2700)
- Download and install Jack Skiner's (aka me) IPFilter utility (http://www.runuo.com/discussion/viewtopic.php?t=2692) (skip steps 3,4,5,6 from installation)
- Put this file into /Scripts/Custom/ folder (if one doesn't exist - make one )
- Open up /Misc/CharacterCreation.cs and find the following (close to line 200):
private static Mobile CreateMobile( Account a )
{
for ( int i = 0; i < 5; ++i )
if ( a[i] == null )
return a[i] = new Mobile();
return null;
}
... and change "new Mobile();" to "new CMobile();"
- Save the file, and restart the server


*/

// Include:
// Logger
// StringTags
// DoubleTags
// IPFilter
// MOTD http://www.runuo.com/discussion/viewtopic.php?t=1685
//
Код
using System;
using System.Collections;
using Server.Items;
using Server.Logs;
using Server.Spells;

namespace Server
{
public class CMobile : Mobile
{
/ ********************************************************************************
*******************/
// Initialization
/ ********************************************************************************
*******************/
public static void Initialize()
{
// TODO: Add your initialization code here


EventSink.Connected += new ConnectedEventHandler( OnConnect );
EventSink.Login += new LoginEventHandler( OnLogin );
EventSink.Logout += new LogoutEventHandler( OnLogout );
EventSink.Disconnected += new DisconnectedEventHandler( OnDisconnect );
EventSink.HelpRequest += new HelpRequestEventHandler( OnHelpRequest );
EventSink.HungerChanged += new HungerChangedEventHandler( OnHungerChanged );
EventSink.OpenSpellbookRequest += new OpenSpellbookRequestEventHandler( OpenSpellBookRequest );
EventSink.StunRequest += new StunRequestEventHandler( OnStunRequest );
}

public static void OnConnect( ConnectedEventArgs e )
{ (e.Mobile as CMobile).OnConnect(); }

public static void OnLogin( LoginEventArgs e )
{ (e.Mobile as CMobile).OnLogin(); }

public static void OnLogout( LogoutEventArgs e )
{ (e.Mobile as CMobile).OnLogout(); }

public static void OnDisconnect( DisconnectedEventArgs e )
{ (e.Mobile as CMobile).OnDisconnect(); }

public static void OnHelpRequest( HelpRequestEventArgs e )
{ (e.Mobile as CMobile).OnHelpRequest(); }

public static void OnHungerChanged( HungerChangedEventArgs e )
{ (e.Mobile as CMobile).OnHungerChanged( e.OldValue ); }

public static void OpenSpellBookRequest( OpenSpellbookRequestEventArgs e )
{ (e.Mobile as CMobile).OpenSpellBookRequest(); }

public static void OnStunRequest( StunRequestEventArgs e )
{ (e.Mobile as CMobile).OnStunRequest(); }


/ ********************************************************************************
*******************/
// Public Attributes
/ ********************************************************************************
*******************/
// IP Filter
public bool IPFilterEnabled;
public ArrayList IPFilterIPs; // holds IPs as longs

// Tags
StringTags Tags;


/ ********************************************************************************
*******************/
// Constructor(s)/Destructor(s)
/ ********************************************************************************
*******************/
public CMobile() : base()
{
Init();
}

/ ********************************************************************************
*******************/
// Protected Methods
/ ********************************************************************************
*******************/
// This method will be called on constructor and on deserialization
protected void Init()
{
IPFilterEnabled = false;
IPFilterIPs = new ArrayList();
Tags = new StringTags();
}


/ ********************************************************************************
*******************/
// Events
/ ********************************************************************************
*******************/
// OnConnect() gets called before OnLogin()
protected virtual void OnConnect()
{
}


// OnConnect() gets called before OnLogin()
protected virtual void OnLogin()
{
}


// Never gets called?
protected virtual void OnLogout()
{
}


// CMobile's NetState's Dispose() method gets called.
protected virtual void OnDisconnect()
{
}


// Click "Help" button on the paperdoll
protected virtual void OnHelpRequest()
{
}


// Property "Hunger" changes
protected virtual void OnHungerChanged( int oldValue )
{
}


// ?
protected virtual void OpenSpellBookRequest()
{
SendMessage("OpenSpellBookRequest");
}


// ?
protected virtual void OnStunRequest()
{
SendMessage("OnStuntRequest");
}


// Calls before OnDeath(). If returns false - CMobile doesn't die.
public override bool OnBeforeDeath()
{
return base.OnBeforeDeath();
}


// Calls when player dies.
public override void OnDeath( Container c )
{
base.OnDeath(c);
}


// Triggered after a mobile is deleted, use this to stop timers and other stuff associated with the mobile
public override void OnAfterDelete()
{
base.OnAfterDelete();
}


// Gets called when property "Combatant" changes
public override void OnCombatantChange()
{
base.OnCombatantChange();
}


public override void OnDoubleClick( Mobile from )
{
base.OnDoubleClick(from);
}


public override void OnDoubleClickCantSee( Mobile from )
{
base.OnDoubleClickCantSee(from);
}


// Happens when a dead player double clicks this mobile
public override void OnDoubleClickDead( Mobile from )
{
base.OnDoubleClickDead(from);
}


public override void OnDoubleClickOutOfRange( Mobile from )
{
base.OnDoubleClickOutOfRange(from);
}


// Happens when a mobile drops something on to this mobile, have this return true if the drop was allowed, false otherwise.
public override bool OnDragDrop( Mobile from, Item dropped )
{
return base.OnDragDrop(from, dropped);
}


// happens when this player lifts something, return false to prevent
public override bool OnDragLift( Item item )
{
return base.OnDragLift(item);
}


// Happens when this mobile equips something, return false to prevent
public override bool OnEquip( Item item )
{
return base.OnEquip(item);
}


// Happens when an item is added to the mobile (not the mobile's pack)
public override void OnItemAdded( Item item )
{
base.OnItemAdded(item);
}


// ?
public override void OnItemLifted( Mobile from, Item item )
{
base.OnItemLifted(from, item);
}


// When something is removed from the mobile (not their Pack)
public override void OnItemRemoved( Item item )
{
base.OnItemRemoved(item);
}


// ?
public override void OnItemUsed( Mobile from, Item item )
{
base.OnItemUsed(from, item);
}


// Gets called when property "Location" changes
protected override void OnLocationChange( Point3D oldLocation )
{
base.OnLocationChange(oldLocation);
}


// Gets called when property "Map" changes
protected override void OnMapChange( Map oldMap )
{
base.OnMapChange(oldMap);
}


// If returns false - CMobile will be "pushed back" to the old location
protected override bool OnMove( Direction d )
{
return base.OnMove(d);
}


// Happens when a Mobile moves in range of this mobile.
public override void OnMovement( Mobile m )
{
base.OnMovement(m);
}


// If returns false - CMobile will be "pushed back" to the old location
public override bool OnMoveOff( Mobile m )
{
return base.OnMoveOff(m);
}


// If returns false - CMobile will be "pushed back" to the old location
public override bool OnMoveOver( Mobile m )
{
return base.OnMoveOver(m);
}


public override void OnPaperdollRequest()
{
base.OnPaperdollRequest();
}


// ?
public override void OnSaid( SpeechEventArgs e )
{
base.OnSaid(e);
}


public override void OnSingleClick( Mobile from )
{
base.OnSingleClick(from);
}


// ?
public override void OnSpeech( SpeechEventArgs e )
{
base.OnSpeech(e);
}


// Triggrs when this mobile starts to cast a spell
public override void OnSpellCast( Spell spell )
{
base.OnSpellCast(spell);
}


// ?
public override void OnSubItemAdded( Item item )
{
base.OnSubItemAdded(item);
}


// ?
public override void OnSubItemRemoved( Item item )
{
base.OnSubItemRemoved(item);
}


/ ********************************************************************************
*******************/
// Serialization
/ ********************************************************************************
*******************/
public CMobile( Serial serial ) : base( serial )
{
Init();
}


public override void Serialize( GenericWriter w )
{
base.Serialize( w );

w.Write( (int) 0 ); // version

// Serialize IP Filter
w.Write( IPFilterEnabled );
w.Write( IPFilterIPs.Count );
for ( int i = 0; i < IPFilterIPs.Count; i++ ) w.Write( (long)IPFilterIPs[i] );

// Serialize Tags
Tags.Serialize(w);

}


public override void Deserialize( GenericReader r )
{
base.Deserialize( r );

Init();
int version = r.ReadInt();

switch ( version )
{

case 0:
// Deserialize IP Filter
IPFilterEnabled = r.ReadBool();
int count = r.ReadInt();
for ( int i = 0; i < count; i++ ) IPFilterIPs.Add( r.ReadLong() );

// Deserialize Tags
Tags.Deserialize(r);

break;

} // switch

}
} // class CMobile
} // Namespace
Пользователь в офлайнеDelete PostОтправить личное сообщение
Вернуться в начало страницы
+Ответить с цитированием данного сообщения

Ответить в эту темуОткрыть новую тему
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 

- Текстовая версия | Версия для КПК Сейчас: 28.4.2024, 6:46
Designed by Nickostyle