Author Topic: [C# Example] Events in Stealth  (Read 14096 times)

0 Members and 1 Guest are viewing this topic.

Offline OrichTopic starter

  • Jr. Member
  • **
  • Posts: 77
  • Activity:
    0%
  • Reputation Power: 3
  • Orich has no influence.
  • Respect: +12
  • Referrals: 1
    • View Profile
[C# Example] Events in Stealth
« on: October 09, 2013, 10:02:45 PM »
0
With tonight's release of my .NET DLL for Stealth, I wanted to include an example of how Stealth events are handled.


For this example, we are going to create an event that tells us when a buff has become active or inactive.

First we must create a function that adheres to the delegate prototype
Code: [Select]
// ID = Person who is affected
// Attribute_ID = ID of the buff
// IsEnabled = Boolean, 0=Turned Off ; 1=Turned On

void OnBuff_Debuff(uint ID, ushort Attribute_ID, bool IsEnabled) // Adheres to  "public delegate void OnBuff_DebuffSystemHandler(uint ID, ushort Attribute_ID, bool IsEnabled);"
{
   String buffStatus = (IsEnabled) ? "Turned On" : "Turned Off";
   String outputString = String.Format("Buff ID:{0} has just {1}", Attribute_ID, buffStatus);

   Stealth.Script_AddToSystemJournal(outputString);
}

Now that we have the function we want to run when the event is triggered, all we need to is set the event to our function, and enable the event.

Code: [Select]
//  ... somewhere in your codebase

Stealth.OnBuff_DebuffSystemEvent += OnBuff_Debuff;
Stealth.Script_EnableEvent(TPacketEvent.evBuff_DebuffSystem);



VIOLA!   Now whenever we receive a buff (or debuff), and it falls off, Stealth will display our string in its System Journal window :)

List of Events / Delegate Prototypes

Code: [Select]
// All are typeof(event)
        OnItemInfoEvent;
        OnItemDeletedEvent;
        OnSpeechEvent;
        OnDrawGamePlayerEvent;
        OnMoveRejectionEvent;
        OnDrawContainerEvent;
        OnAddItemToContainerEvent;
        OnAddMultipleItemsInContainerEvent;
        OnRejectMoveItemEvent;
        OnUpdateCharEvent;
        OnDrawObjectEvent;
        OnMenuEvent;
        OnMapMessageEvent;
        OnAllowRefuseAttackEvent;
        OnClilocSpeechEvent;
        OnClilocSpeechAffixEvent;
        OnUnicodeSpeechEvent;
        OnBuff_DebuffSystemEvent;
        OnClientSendResyncEvent;
        OnCharAnimationEvent;
        OnICQDisconnectEvent;
        OnICQConnectEvent;
        OnICQIncomingTextEvent;
        OnICQErrorEvent;
        OnIncomingGumpEvent;
        OnTimer1Event;
        OnTimer2Event;
        OnWindowsMessageEvent;
        OnSoundEvent;
        OnDeathEvent;
        OnQuestArrowEvent;
        OnPartyInviteEvent;


And their delegate prototypes :
Code: [Select]
        public delegate void OnItemInfoHandler(uint ItemID);
        public delegate void OnItemDeletedHandler(uint ID);
        public delegate void OnSpeechHandler(String Text, String SenderName, uint SenderID);
        public delegate void OnDrawGamePlayerHandler(uint ID);
        public delegate void OnMoveRejectionHandler(ushort Xorig, ushort Yorig, Byte Dir, ushort XDest, ushort YDest);
        public delegate void OnDrawContainerHandler(uint ID, ushort ModelGump);
        public delegate void OnAddItemToContainerHandler(uint ObjID, uint ContainerID);
        public delegate void OnAddMultipleItemsInContainerHandler(uint ContainerID);
        public delegate void OnRejectMoveItemHandler(Byte Reason);
        public delegate void OnUpdateCharHandler(uint ID);
        public delegate void OnDrawObjectHandler(uint ID);
        public delegate void OnMenuHandler(uint DialogID, ushort MenuID);
        public delegate void OnMapMessageHandler(uint ID, int centerx, int centery);
        public delegate void OnAllowRefuseAttackHandler(uint ID, bool Attack_OK);
        public delegate void OnClilocSpeechHandler(uint SenderID, String SenderName, uint ClilocID, String TexT);
        public delegate void OnClilocSpeechAffixHandler(uint SenderID, String SenderName, uint ClilocID, String Affix, String ClilocTex);
        public delegate void OnUnicodeSpeechHandler(String Text, String SenderName, uint SenderID);
        public delegate void OnBuff_DebuffSystemHandler(uint ID, ushort Attribute_ID, bool IsEnabled);
        public delegate void OnClientSendResyncHandler();
        public delegate void OnCharAnimationHandler(uint ID, ushort Action);
        public delegate void OnICQDisconnectHandler();
        public delegate void OnICQConnectHandler();
        public delegate void OnICQIncomingTextHandler(uint uin, String Text);
        public delegate void OnICQErrorHandler(String Text);
        public delegate void OnIncomingGumpHandler(uint Serial, uint GumpID, uint X, uint Y);
        public delegate void OnTimer1Handler();
        public delegate void OnTimer2Handler();
        public delegate void OnWindowsMessageHandler(uint lParam);
        public delegate void OnSoundHandler(ushort Sound_ID, ushort X, ushort Y, ushort Z);
        public delegate void OnDeathHandler(bool Dead);
        public delegate void OnQuestArrowHandler(ushort fQuestArrowX, ushort fQuestArrowY, bool fQuestArrowActive);
        public delegate void OnPartyInviteHandler(uint Inviter_ID);



Member of the Stealth development team.
Author of Stealth .NET DLL

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #1 on: November 27, 2013, 06:37:36 AM »
0
where can i find the Attribute ID information.... :P

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [C# Example] Events in Stealth
« Reply #2 on: November 27, 2013, 07:18:51 AM »
0
where can i find the Attribute ID information.... :P
http://docs.polserver.com/packets/index.php?Packet=0xDF But they only know a few.. there are a lot of more.

i found a few more :
Code: [Select]
     1001 : ClientPrint('Attribute : Dismount');
      1002 : ClientPrint('Attribute : Disarm');
      //1003 : PlayerBuff.Buff_ := state;
      //1004 : PlayerBuff.Buff_ := state;
      1005 : ClientPrint('Attribute : Nightsight');
      1006 : ClientPrint('Attribute : Death Strike');
      1007 : ClientPrint('Attribute : Evil Omen');
      //1008 : ClientPrint('Attribute : Unknown');
      1009 : ClientPrint('Attribute : Regeneration');
      1010 : ClientPrint('Attribute : Divine Fury');
      1011 : ClientPrint('Attribute : Enemy of One');
      1012 : ClientPrint('Attribute : Stealth');
      1013 : ClientPrint('Attribute : Active Meditation');
      1014 : ClientPrint('Attribute : Blood Oath as Caster');
      1015 : ClientPrint('Attribute : Blood Oath as Target');
      1016 : ClientPrint('Attribute : Corpse Skin');
      1017 : ClientPrint('Attribute : Mindrot');
      1018 : ClientPrint('Attribute : Pain Strike');
      1019 : ClientPrint('Attribute : Strangle');
      1020 : ClientPrint('Attribute : Gift of Renewal');
      1021 : ClientPrint('Attribute : Attune Weapon');
      1022 : ClientPrint('Attribute : Thunderstorm');
      1023 : ClientPrint('Attribute : Essence of Wind');
      1024 : ClientPrint('Attribute : Ethereal Voyage');
      1025 : ClientPrint('Attribute : Gift of Life');
      1026 : ClientPrint('Attribute : Arcane Emporement');
      1027 : ClientPrint('Attribute : Mortal Strike');
      1028 : ClientPrint('Attribute : Reactive Armor');
      1029 : ClientPrint('Attribute : Protection');
      1030 : ClientPrint('Attribute : Arch Protection');
      1031 : ClientPrint('Attribute : Magic Reflection');
      1032 : ClientPrint('Attribute : Icognito');
      1033 : ClientPrint('Attribute : Disguised');
      1034 : ClientPrint('Attribute : Animal Form');
      1035 : ClientPrint('Attribute : Polimorph');
      1036 : ClientPrint('Attribute : Invisibility');
      1037 : ClientPrint('Attribute : Paralyze');
      1038 : ClientPrint('Attribute : Poison');
      1039 : ClientPrint('Attribute : Bleed');
      1040 : ClientPrint('Attribute : Clumsy');
      1041 : ClientPrint('Attribute : Feeblemind');
      1042 : ClientPrint('Attribute : Weaken');
      1043 : ClientPrint('Attribute : Curse');
      1044 : ClientPrint('Attribute : Mass Curse');
      1045 : ClientPrint('Attribute : Agility');
      1046 : ClientPrint('Attribute : Cunning');
      1047 : ClientPrint('Attribute : Strength');
      1048 : ClientPrint('Attribute : Bless');
      //1049 : PlayerBuff.Buff_ := state;
      //1050 : PlayerBuff.Buff_ := state;
      1085 : ClientPrint('Attribute : Horrific Beast Form');
      1086 : ClientPrint('Attribute : Lich Form');
      1087 : ClientPrint('Attribute : Vampire Form');
      1100 : ClientPrint('Attribute : Unkown Vampire Buff');
      1117 : ClientPrint('Attribute : Unknown_Meditation');
      1124 : ClientPrint('Attribute : Wrath Form');

Basicly the best way would be activate the Event and just print out all Kind of Values it get, then go and cast spells, use abilitys, go to monsters wich have own abilites and collect data

You also could check http://uo2.stratics.com/miscellaneous/buff-and-debuff-icons what buff debugg icons exist and try to get those active for datamining.

You also should keep in mind, that buffs are sended through login when they should stay active. So you should activate event before login to get acurate data or recast buff to get it cought
« Last Edit: November 27, 2013, 07:23:14 AM by Crome969 »

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #3 on: November 28, 2013, 04:13:15 PM »
0
Code: [Select]
               
               // Blue Icon
                case 1013: this.Meditation.Active = IsEnabled; break;
                case 1033: this.Disguised.Active = IsEnabled; break;
                case 1032: this.Incognito.Active = IsEnabled; break;
                case 1012: this.Stealth_.Active = IsEnabled; break;
                case 1054: this.GargoyleFly.Active = IsEnabled; break;
                case 1068: this.Despair.Active = IsEnabled; break;
               
                // Green Icon
                case 1055: this.Inspire.Active = IsEnabled; break;
                case 1056: this.Invigorate.Active = IsEnabled; break;
                case 1057: this.Resilience.Active = IsEnabled; break;
                case 1058: this.Perseverance.Active = IsEnabled; break;
                //case 1000: this.MagicFish.Active = IsEnabled; break;
                case 1045: this.Agility.Active = IsEnabled; break;
                case 1026: this.ArcaneEmpowerment.Active = IsEnabled; break;
                case 1030: this.ArchProtection.Active = IsEnabled; break;
                case 1021: this.AttuneWeapon.Active = IsEnabled; break;
                case 1048: this.Bless.Active = IsEnabled; break;
                case 1014: this.BloodOathCaster.Active = IsEnabled; break;
                case 1046: this.Cunning.Active = IsEnabled; break;
                case 1010: this.DivineFury.Active = IsEnabled; break;
                case 1011: this.EnemyOfOne.Active = IsEnabled; break;
                case 1024: this.EtherealVoyage.Active = IsEnabled; break;
                case 1025: this.GiftOfLift.Active = IsEnabled; break;
                case 1020: this.GiftOfRenewal.Active = IsEnabled; break;
                case 1036: this.Invisibility.Active = IsEnabled; break;
                case 1031: this.MagicReflection.Active = IsEnabled; break;
                case 1005: this.NightSight.Active = IsEnabled; break;
                case 1035: this.Polymorph.Active = IsEnabled; break;
                case 1029: this.Protection.Active = IsEnabled; break;
                case 1028: this.ReactiveArmor.Active = IsEnabled; break;
                case 1047: this.Strength.Active = IsEnabled; break;
                //case 1000: this.GrapesOfWrath.Active = IsEnabled; break;
                case 1050: this.StoneForm.Active = IsEnabled; break;
                case 1052: this.GargoyleBerserk.Active =IsEnabled; break;
                //case 1000: this.HitDualWield.Active = IsEnabled; break;
                //case 1000: this.Block.Active = IsEnabled; break;
                //case 1000: this.DefenseMastery.Active = IsEnabled; break;
                //case 1000: this.Healing.Active = IsEnabled; break;
                //case 1000: this.SpellFocusing.Active = IsEnabled; break;
                //case 1000: this.RageFocusing.Active = IsEnabled; break;
                case 1075: this.Tribulation.Active = IsEnabled; break;
                //case 1000: this.Surge.Active = IsEnabled; break;
                case 1079: this.Feint.Active = IsEnabled; break;
                case 1082: this.Consecrate.Active = IsEnabled; break;
                case 1085: this.HorrificBeast.Active = IsEnabled; break;
                case 1086: this.LichForm.Active = IsEnabled; break;
                case 1087: this.VampricEmbrace.Active = IsEnabled; break;
                case 1125: this.WraithForm.Active = IsEnabled; break;
                case 1088: this.CurseWeapon.Active = IsEnabled; break;
                //case 1000: this.ReaperForm.Active = IsEnabled; break;
                //case 1000: this.ImmolatingWeapon.Active = IsEnabled; break;
                case 1091: this.Enchant.Active = IsEnabled; break;
                //case 1000: this.HonorableExecution.Active = IsEnabled; break;
                case 1093: this.Confidence.Active = IsEnabled; break;
                case 1094: this.Evasion.Active = IsEnabled; break;
                case 1095: this.CounterAttack.Active = IsEnabled; break;
                case 1096: this.LightningStrike.Active = IsEnabled; break;
                case 1097: this.MomentumStrike.Active = IsEnabled; break;
                case 1098: this.OrangePetals.Active = IsEnabled; break;
                //case 1000: this.RoseOfTrinsicPetals.Active = IsEnabled; break;
                case 1100: this.PoisonImmunityResist.Active = IsEnabled; break;
                //case 1000: this.Veterinary.Active = IsEnabled; break;
                case 1102: this.Perfection.Active = IsEnabled; break;
                case 1103: this.Honored.Active = IsEnabled; break;
                //case 1000: this.ManaPhase.Active = IsEnabled; break;
                //case 1000: this.CityTradeDeal.Active = IsEnabled; break;
               
                // Red Icons
                case 1059: this.Debuff_Tribulation.Active = IsEnabled; break;
                case 1060: this.Debuff_Despair.Active = IsEnabled; break;
                //case 1000: this.Debuff_AchievePerfection.Active = IsEnabled; break;
                //case 1000: this.Debuff_Bleed.Active = IsEnabled; break;
                //case 1000: this.Debuff_BloodOath.Active = IsEnabled; break;
                case 1040: this.Debuff_Clumsy.Active = IsEnabled; break;
                case 1016: this.Debuff_CorpseSkin.Active = IsEnabled; break;
                case 1043: this.Debuff_Curse.Active = IsEnabled; break;
                //case 1000: this.Debuff_DeathStrike.Active = IsEnabled; break;
                case 1002: this.Debuff_Disarm.Active = IsEnabled; break;
                case 1001: this.Debuff_Dismount.Active = IsEnabled; break;
                //case 1000: this.Debuff_EssenceOfWind.Active = IsEnabled; break;
                case 1007: this.Debuff_EvilOmen.Active = IsEnabled; break;
                case 1041: this.Debuff_FeebleMinded.Active = IsEnabled; break;
                //case 1000: this.Debuff_Heal.Active = IsEnabled; break;
                //case 1000: this.Debuff_Honored.Active = IsEnabled; break;
                //case 1000: this.Debuff_MassCurse.Active = IsEnabled; break;
                case 1037: this.Debuff_Paralyze.Active = IsEnabled; break;
                case 1017: this.Debuff_Mindrot.Active = IsEnabled; break;
                //case 1000: this.Debuff_MortalStrike.Active = IsEnabled; break;
                case 1018: this.Debuff_PainSpike.Active = IsEnabled; break;
                case 1038: this.Debuff_Poison.Active = IsEnabled; break;
                //case 1000: this.Debuff_Stamina.Active = IsEnabled; break;
                case 1019: this.Debuff_Strangle.Active = IsEnabled; break;
                //case 1000: this.Debuff_Thunderstorm.Active = IsEnabled; break;
                case 1042: this.Debuff_Weaken.Active = IsEnabled; break;
                case 1049: this.Debuff_Sleep.Active = IsEnabled; break;
                case 1051: this.Debuff_SpellPlague.Active = IsEnabled; break;
                //case 1000: this.Debuff_MasSleep.Active = IsEnabled; break;
                //case 1000: this.Debuff_HitLowerAttack.Active = IsEnabled; break;
                //case 1000: this.Debuff_HitLowerDefense.Active = IsEnabled; break;
                //case 1000: this.Debuff_SpellFocusing.Active = IsEnabled; break;
                //case 1000: this.Debuff_RageFocusing.Active = IsEnabled; break;
                //case 1000: this.Debuff_FoceArrow.Active = IsEnabled; break;
                //case 1000: this.Debuff_TalonStrike.Active = IsEnabled; break;
                //case 1000: this.Debuff_PsychicAttack.Active = IsEnabled; break;
                //case 1000: this.Debuff_EnemyOfOne.Active = IsEnabled; break;
                //case 1000: this.Debuff_FandancerFanFire.Active = IsEnabled; break;
                //case 1000: this.Debuff_Rage.Active = IsEnabled; break;
                //case 1000: this.Debuff_Webbing.Active = IsEnabled; break;
                //case 1000: this.Debuff_MedusaStone.Active = IsEnabled; break;
                //case 1000: this.Debuff_DragonSlasherFear.Active = IsEnabled; break;
                //case 1000: this.Debuff_AuraOfNausea.Active = IsEnabled; break;
                //case 1000: this.Debuff_HowlOfCacophony.Active = IsEnabled; break;
                //case 1000: this.Debuff_GazeDespair.Active = IsEnabled; break;
                //case 1000: this.Debuff_HiryuPhysicalResistance.Active = IsEnabled; break;
                //case 1000: this.Debuff_RuneBeetleCorruption.Active = IsEnabled; break;
                //case 1000: this.Debuff_BloodwormAnemia.Active = IsEnabled; break;
                //case 1000: this.Debuff_RotwornBloodDisease.Active = IsEnabled; break;
                //case 1000: this.Debuff_SkillUseDelay.Active = IsEnabled; break;
                //case 1000: this.Debuff_FactionStatLoss.Active = IsEnabled; break;
                case 1119: this.Debuff_HeatOfBattleStatus.Active = IsEnabled; break;
                case 1200: this.Debuff_CriminalStatus.Active = IsEnabled; break;
                //case 1000: this.Debuff_ArmorPierce.Active = IsEnabled; break;
                //case 1000: this.Debuff_SplinteringEffect.Active = IsEnabled; break;
                //case 1000: this.Debuff_SwingSpeed.Active = IsEnabled; break;
                //case 1000: this.Debuff_ArmorCorrupt.Active = IsEnabled; break;
                //case 1000: this.Debuff_Entangle.Active = IsEnabled; break;
                //case 1000: this.Debuff_FallingWalls.Active = IsEnabled; break;
                //case 1000: this.Debuff_Criminal.Active = IsEnabled; break;

According http://http://uo2.stratics.com/miscellaneous/buff-and-debuff-icons..
Updated some attribute ID...I hope i can complete it .... :P

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #4 on: November 28, 2013, 09:14:07 PM »
0
Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScriptDotNet;

namespace Event
{
    class Event
    {
        static void OnBuff_Debuff(uint ID, ushort Attribute_ID, bool IsEnabled)
        {
            String buffStatus = (IsEnabled) ? "Turned On" : "Turned Off";
            String outputString = String.Format("Buff ID:{0} has just {1}", Attribute_ID, buffStatus);

            Console.WriteLine(outputString);
        }

        static void OnTimer1()
        {
            Console.WriteLine("Timer 1 Event Fire");
        }

        static void OnTimer2()
        {
            Console.WriteLine("Timer 2 Event Fire");
        }
        static void OnSpeech(string str1,string str2, uint id)
        {
            Console.WriteLine("On Speech Event");
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Program Started");
            Stealth.OnBuff_DebuffSystemEvent += OnBuff_Debuff;
            Stealth.Script_EnableEvent(TPacketEvent.evBuff_DebuffSystem);
            Stealth.OnTimer1Event += OnTimer1;
            Stealth.Script_EnableEvent(TPacketEvent.evTimer1);
            Stealth.OnTimer2Event += OnTimer2;
            Stealth.Script_EnableEvent(TPacketEvent.evTimer2);
            Stealth.OnSpeechEvent += OnSpeech;
            Console.WriteLine("Waiting for event fire, Press any key to stop");           
            Console.ReadKey();
        }
    }
}

I can fire Buff_Debuff Event but the Timer Event did not fire.....

 :-X :-X

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [C# Example] Events in Stealth
« Reply #5 on: November 28, 2013, 10:18:18 PM »
0
Do you use any Waits in your script? Because most events are only checked, when the script thread in stealth sleeps..

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #6 on: November 29, 2013, 02:53:51 AM »
0
i tried but still fail..

while (i< 100)
{
  Stealth.Script_Wait(1000);
  Console.WriteLine("Waiting...");
  i++;
}

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [C# Example] Events in Stealth
« Reply #7 on: November 29, 2013, 03:57:25 AM »
0
i tried but still fail..

while (i< 100)
{
  Stealth.Script_Wait(1000);
  Console.WriteLine("Waiting...");
  i++;
}

As Workaround you could implement the System.Timer Namespace and using own Timer Events.

http://msdn.microsoft.com/en-us//library/system.timers.timer%28v=vs.110%29.aspx

I using those also lately ( but didnt noticed event timer is buggy ) for logging of data.

In my sample i have foreign classes who use Code and push messages to a String stack. And my timer class reads this Stack and drop message wrapped to gui.

« Last Edit: November 29, 2013, 03:59:06 AM by Crome969 »

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #8 on: November 29, 2013, 04:11:44 AM »
0
Ok..Thanks...

Code: [Select]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using ScriptDotNet;


namespace Event
{
    class Event
    {
         
        static void OnBuff_Debuff(uint ID, ushort Attribute_ID, bool IsEnabled)
        {
            String buffStatus = (IsEnabled) ? "Turned On" : "Turned Off";
            String outputString = String.Format("Buff ID:{0} has just {1}", Attribute_ID, buffStatus);           
            Console.WriteLine(outputString);
        }

        private static void TimerCallback(Object o)
        {           
            Console.WriteLine("In TimerCallback: " + DateTime.Now);           
            GC.Collect();
        }


        static void Main(string[] args)
        {
            Console.WriteLine("Program Started");
            Stealth.OnBuff_DebuffSystemEvent += OnBuff_Debuff;
            Stealth.Script_EnableEvent(TPacketEvent.evBuff_DebuffSystem);
            Timer t = new Timer(TimerCallback, null, 0, 1000);
            Console.WriteLine("Waiting for event fire, Press any key to stop");           
            Console.ReadKey();
        }
    }
}

Offline OrichTopic starter

  • Jr. Member
  • **
  • Posts: 77
  • Activity:
    0%
  • Reputation Power: 3
  • Orich has no influence.
  • Respect: +12
  • Referrals: 1
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #9 on: November 29, 2013, 12:05:44 PM »
0
Do you use any Waits in your script? Because most events are only checked, when the script thread in stealth sleeps..

What? This isn't true at all for C#.

This is only true for Delphi.
Member of the Stealth development team.
Author of Stealth .NET DLL

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: [C# Example] Events in Stealth
« Reply #10 on: November 29, 2013, 01:11:38 PM »
0
Do you use any Waits in your script? Because most events are only checked, when the script thread in stealth sleeps..

What? This isn't true at all for C#.

This is only true for Delphi.
Well you are right .. I remembered this from delphi.. Iam sorry..

Offline rwo001

  • Jr. Member
  • **
  • Posts: 45
  • Activity:
    0%
  • Reputation Power: 1
  • rwo001 has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #11 on: November 30, 2013, 10:28:18 PM »
0
Do you use any Waits in your script? Because most events are only checked, when the script thread in stealth sleeps..

What? This isn't true at all for C#.

This is only true for Delphi.
Well you are right .. I remembered this from delphi.. Iam sorry..
So..Is it bug on ScriptDotNet or something wrong on the script?

Offline OrichTopic starter

  • Jr. Member
  • **
  • Posts: 77
  • Activity:
    0%
  • Reputation Power: 3
  • Orich has no influence.
  • Respect: +12
  • Referrals: 1
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #12 on: December 01, 2013, 01:42:15 AM »
0
Do you use any Waits in your script? Because most events are only checked, when the script thread in stealth sleeps..

What? This isn't true at all for C#.

This is only true for Delphi.
Well you are right .. I remembered this from delphi.. Iam sorry..
So..Is it bug on ScriptDotNet or something wrong on the script?


I can look into it, but it's a bug that doesn't need a fix as far as C# goes.

If you need timers, you should be using the Timer class and not rely on the Delphi implementation.

Consider the following example :

Code: [Select]
Timer timer = new Timer();

timer.Enabled = true;
timer.Tick += new EventHandler(timer_Function);
timer.Interval = 1000; // each timer "tick" = 1000ms = 1 second
timer.Start();


...

void timer_Function(object s, EventArgs e)
{
   ... do something
}
Member of the Stealth development team.
Author of Stealth .NET DLL

Offline JoO

  • Jr. Member
  • **
  • Posts: 19
  • Activity:
    0%
  • Reputation Power: 0
  • JoO has no influence.
  • Respect: 0
  • Referrals: 1
    • View Profile
Re: [C# Example] Events in Stealth
« Reply #13 on: June 27, 2015, 08:19:59 AM »
0
Does anyone have a working snippet that will print the events? I am desperately trying to get the healing icon ID, I am just no good at C#.

Edit: NM I got what I needed with uospy.
« Last Edit: June 27, 2015, 01:44:10 PM by JoO »

Tags: example sample