0 Members and 1 Guest are viewing this topic.
Apanya bang yg bingung? Gw juga bingung.. Hahahahahahaha(Bingung gw knapa gw sering bgt dipanggil om.... Gw kan masih mudaa... :mcred)Nih biar tambah bingung .. Salah satu script BookSkill.. Gw jg nggak tau nih script ngapain. Code: [Select]public class BookSkill : Book, IOmniPlantFeedable, IGameObject, IScriptObject, IScriptLogic, IHasScriptProxy, IObjectUI, IExportableContent, ISkillCallbackUser{ // Fields [Tunable, TunableComment("Description: Minutes before sending kFinishdBoookEvent")] private static float kMinutesBeforeFinished = 20f; private Sim mSimReading; // Methods public IGameObject CloneForOmniPlant() { return base.Clone(); } public override IGameObject Copy(bool movingOut) { BookSkill skill = null; BookSkillData data = base.Data as BookSkillData; if (data != null) { skill = CreateOutOfWorld(data); } return skill; } public static BookSkill CreateOutOfWorld(BookSkillData data) { BookSkill skill = GlobalFunctions.CreateObjectOutOfWorld("BookSkill") as BookSkill; skill.InitBookCommon(data); return skill; } public static ObjectGuid CreateOutOfWorldID(BookSkillData data, ref Simulator.ObjectInitParameters initData) { IGameObject obj2 = GlobalFunctions.CreateObjectOutOfWorld("BookSkill", null, initData); if (obj2 == null) { return ObjectGuid.InvalidObjectGuid; } return obj2.ObjectId; } public void FinishOneUse() { if (!Config.BooksNotMagicScrolls) { base.mOneShotDelete = true; } } public void FinishUnlockSkill(Sim Actor, BookSkillData sData) { Actor.SkillManager.AddElement(sData.SkillGuid); base.BookDialog(Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:SkillUnlockDialogText", new object[] { Actor, sData.Skill }), Actor); } public override void FirstTimeFinished(Sim actor) { BookSkillData sData = base.Data as BookSkillData; if (sData != null) { if (sData.UnlockSkill) { this.FinishUnlockSkill(actor, sData); } if (sData.OneUse) { this.FinishOneUse(); } } } public Skill.SkillLevelUpCallback GetSkillCallback() { return new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback); } public bool IsFeedable() { return true; } public override void LoopDel(StateMachineClient smc, Sim Actor, bool isBookWorm, float deltaTime, float lifeTime) { ReadBook currentInteraction = Actor.CurrentInteraction as ReadBook; if (((currentInteraction != null) && !currentInteraction.mHasSentEventThisInteraction) && (lifeTime > kMinutesBeforeFinished)) { EventTracker.SendEvent(EventTypeId.kReadBook, Actor, this); currentInteraction.mHasSentEventThisInteraction = true; } base.LoopDel(smc, Actor, isBookWorm, deltaTime, lifeTime); } public override void OnLoad() { BookSkillData data; if (BookData.BookSkillDataList.TryGetValue(base.mBookId, out data)) { base.Data = data; } base.OnLoad(); } public static void ProcessCallback(BookSkillData data, BookSkill book) { book.InitBookCommon(data); book.RemoveFromWorld(); } public override void ReadPostLoop(bool succeeded, Sim Actor, InteractionInstance interaction) { BookSkillData data = base.Data as BookSkillData; Skill element = Actor.SkillManager.GetElement(data.SkillGuid); Actor.SkillManager.StopSkillGain(element.Guid); this.mSimReading = null; ReadBook book = interaction as ReadBook; if (succeeded && !book.mHasSentEventThisInteraction) { EventTracker.SendEvent(EventTypeId.kReadBook, Actor, this); book.mHasSentEventThisInteraction = true; } element.UnRegisterForSkillLevelUpEvent(new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback), this); book.RegisteredSkillEvent = false; } public override bool ReadPreLoop(Sim Actor, InteractionInstance inst) { BookSkillData data = base.Data as BookSkillData; Skill skill = Actor.SkillManager.AddElement(data.SkillGuid); ReadBook book = inst as ReadBook; skill.RegisterForSkillLevelUpEvent(new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback), this); book.RegisteredSkillEvent = true; if (skill.GatedFromLevelingUp) { base.BookDialog(Localization.LocalizeString("Gameplay/Objects/BookSkill:LackRequirementsDialogText", new object[] { Actor, data.Skill }), Actor); return false; } float pagesMinNorm = data.PagesMinNorm; if (Actor.TraitManager.HasElement((TraitNames) (-5175480303478029936L))) { pagesMinNorm = data.PagesMinBW; } if (Actor.LotCurrent.GetMetaAutonomyVenueType() == MetaAutonomyVenueType.Library) { pagesMinNorm += base.BookLibraryReadPPMBonus; } float rate = pagesMinNorm * data.SkillPointsPerPage; data = null; Actor.SkillManager.StartSkillGain(skill.Guid, rate); this.mSimReading = Actor; return true; } public void SkillLevelUpCallback(int skillLevel) { BookSkillData data = base.Data as BookSkillData; if (skillLevel >= data.MaxSkill) { this.mSimReading.AddExitReason(ExitReason.Finished); } } public override bool TestReadBook(Sim Actor, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { GreyedOutTooltipCallback callback = null; GreyedOutTooltipCallback callback2 = null; GreyedOutTooltipCallback callback3 = null; GreyedOutTooltipCallback callback4 = null; BookSkillData sData = base.Data as BookSkillData; if (sData == null) { return false; } if (!sData.ChildCanRead && (Actor.SimDescription.Age == 4)) { if (callback == null) { callback = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Actors/Sim:ChildSkillBookFailure", new object[] { Actor }); }; } greyedOutTooltipCallback = callback; return false; } if (((sData.MinSkill > 0) && (sData.MinSkill > Actor.SkillManager.GetSkillLevel(sData.SkillGuid))) || (!sData.ChildCanRead && (Actor.SimDescription.Age == 4))) { if (callback2 == null) { callback2 = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:CannotReadDialogText", new object[] { Actor, sData.Skill }); }; } greyedOutTooltipCallback = callback2; return false; } if (sData.MaxSkill <= Actor.SkillManager.GetSkillLevel(sData.SkillGuid)) { if (callback3 == null) { callback3 = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:SimTooAdvancedText", new object[] { Actor, sData.Skill }); }; } greyedOutTooltipCallback = callback3; return false; } if (Actor.MoodManager.StressInteractionTest()) { if (callback4 == null) { callback4 = delegate { return Localization.LocalizeString("Gameplay/Actors/Sim:StressFailure", new object[] { Actor }); }; } greyedOutTooltipCallback = callback4; return false; } if (isAutonomous) { Skill element = Actor.SkillManager.GetElement(sData.SkillGuid); if (element == null) { return sData.UnlockSkill; } if (element.GatedFromLevelingUp || (sData.MinSkill > Actor.SkillManager.GetSkillLevel(sData.SkillGuid))) { return false; } } return true; }} Sebenernya ini juga ga cocok dibilang sekedar script. Ini memang bener-bener library program, yang harus di-compile terlebih dahulu, serta menggunakan konsep programming OOP. (Waduh.. omongannya tambah jorok nih.. )
public class BookSkill : Book, IOmniPlantFeedable, IGameObject, IScriptObject, IScriptLogic, IHasScriptProxy, IObjectUI, IExportableContent, ISkillCallbackUser{ // Fields [Tunable, TunableComment("Description: Minutes before sending kFinishdBoookEvent")] private static float kMinutesBeforeFinished = 20f; private Sim mSimReading; // Methods public IGameObject CloneForOmniPlant() { return base.Clone(); } public override IGameObject Copy(bool movingOut) { BookSkill skill = null; BookSkillData data = base.Data as BookSkillData; if (data != null) { skill = CreateOutOfWorld(data); } return skill; } public static BookSkill CreateOutOfWorld(BookSkillData data) { BookSkill skill = GlobalFunctions.CreateObjectOutOfWorld("BookSkill") as BookSkill; skill.InitBookCommon(data); return skill; } public static ObjectGuid CreateOutOfWorldID(BookSkillData data, ref Simulator.ObjectInitParameters initData) { IGameObject obj2 = GlobalFunctions.CreateObjectOutOfWorld("BookSkill", null, initData); if (obj2 == null) { return ObjectGuid.InvalidObjectGuid; } return obj2.ObjectId; } public void FinishOneUse() { if (!Config.BooksNotMagicScrolls) { base.mOneShotDelete = true; } } public void FinishUnlockSkill(Sim Actor, BookSkillData sData) { Actor.SkillManager.AddElement(sData.SkillGuid); base.BookDialog(Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:SkillUnlockDialogText", new object[] { Actor, sData.Skill }), Actor); } public override void FirstTimeFinished(Sim actor) { BookSkillData sData = base.Data as BookSkillData; if (sData != null) { if (sData.UnlockSkill) { this.FinishUnlockSkill(actor, sData); } if (sData.OneUse) { this.FinishOneUse(); } } } public Skill.SkillLevelUpCallback GetSkillCallback() { return new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback); } public bool IsFeedable() { return true; } public override void LoopDel(StateMachineClient smc, Sim Actor, bool isBookWorm, float deltaTime, float lifeTime) { ReadBook currentInteraction = Actor.CurrentInteraction as ReadBook; if (((currentInteraction != null) && !currentInteraction.mHasSentEventThisInteraction) && (lifeTime > kMinutesBeforeFinished)) { EventTracker.SendEvent(EventTypeId.kReadBook, Actor, this); currentInteraction.mHasSentEventThisInteraction = true; } base.LoopDel(smc, Actor, isBookWorm, deltaTime, lifeTime); } public override void OnLoad() { BookSkillData data; if (BookData.BookSkillDataList.TryGetValue(base.mBookId, out data)) { base.Data = data; } base.OnLoad(); } public static void ProcessCallback(BookSkillData data, BookSkill book) { book.InitBookCommon(data); book.RemoveFromWorld(); } public override void ReadPostLoop(bool succeeded, Sim Actor, InteractionInstance interaction) { BookSkillData data = base.Data as BookSkillData; Skill element = Actor.SkillManager.GetElement(data.SkillGuid); Actor.SkillManager.StopSkillGain(element.Guid); this.mSimReading = null; ReadBook book = interaction as ReadBook; if (succeeded && !book.mHasSentEventThisInteraction) { EventTracker.SendEvent(EventTypeId.kReadBook, Actor, this); book.mHasSentEventThisInteraction = true; } element.UnRegisterForSkillLevelUpEvent(new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback), this); book.RegisteredSkillEvent = false; } public override bool ReadPreLoop(Sim Actor, InteractionInstance inst) { BookSkillData data = base.Data as BookSkillData; Skill skill = Actor.SkillManager.AddElement(data.SkillGuid); ReadBook book = inst as ReadBook; skill.RegisterForSkillLevelUpEvent(new Skill.SkillLevelUpCallback(this.SkillLevelUpCallback), this); book.RegisteredSkillEvent = true; if (skill.GatedFromLevelingUp) { base.BookDialog(Localization.LocalizeString("Gameplay/Objects/BookSkill:LackRequirementsDialogText", new object[] { Actor, data.Skill }), Actor); return false; } float pagesMinNorm = data.PagesMinNorm; if (Actor.TraitManager.HasElement((TraitNames) (-5175480303478029936L))) { pagesMinNorm = data.PagesMinBW; } if (Actor.LotCurrent.GetMetaAutonomyVenueType() == MetaAutonomyVenueType.Library) { pagesMinNorm += base.BookLibraryReadPPMBonus; } float rate = pagesMinNorm * data.SkillPointsPerPage; data = null; Actor.SkillManager.StartSkillGain(skill.Guid, rate); this.mSimReading = Actor; return true; } public void SkillLevelUpCallback(int skillLevel) { BookSkillData data = base.Data as BookSkillData; if (skillLevel >= data.MaxSkill) { this.mSimReading.AddExitReason(ExitReason.Finished); } } public override bool TestReadBook(Sim Actor, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { GreyedOutTooltipCallback callback = null; GreyedOutTooltipCallback callback2 = null; GreyedOutTooltipCallback callback3 = null; GreyedOutTooltipCallback callback4 = null; BookSkillData sData = base.Data as BookSkillData; if (sData == null) { return false; } if (!sData.ChildCanRead && (Actor.SimDescription.Age == 4)) { if (callback == null) { callback = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Actors/Sim:ChildSkillBookFailure", new object[] { Actor }); }; } greyedOutTooltipCallback = callback; return false; } if (((sData.MinSkill > 0) && (sData.MinSkill > Actor.SkillManager.GetSkillLevel(sData.SkillGuid))) || (!sData.ChildCanRead && (Actor.SimDescription.Age == 4))) { if (callback2 == null) { callback2 = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:CannotReadDialogText", new object[] { Actor, sData.Skill }); }; } greyedOutTooltipCallback = callback2; return false; } if (sData.MaxSkill <= Actor.SkillManager.GetSkillLevel(sData.SkillGuid)) { if (callback3 == null) { callback3 = delegate { return Localization.LocalizeString(Actor.IsFemale, "Gameplay/Objects/BookSkill:SimTooAdvancedText", new object[] { Actor, sData.Skill }); }; } greyedOutTooltipCallback = callback3; return false; } if (Actor.MoodManager.StressInteractionTest()) { if (callback4 == null) { callback4 = delegate { return Localization.LocalizeString("Gameplay/Actors/Sim:StressFailure", new object[] { Actor }); }; } greyedOutTooltipCallback = callback4; return false; } if (isAutonomous) { Skill element = Actor.SkillManager.GetElement(sData.SkillGuid); if (element == null) { return sData.UnlockSkill; } if (element.GatedFromLevelingUp || (sData.MinSkill > Actor.SkillManager.GetSkillLevel(sData.SkillGuid))) { return false; } } return true; }}