my code stock.com

Andreas Spegel

Kill Enemies from Vehicle #1
by Andreas Spegel

Einfaches Script um Gegner zu Töten während man in einem Vehicle ist.

Snippet options

Download: Download snippet as kill-enemies-from-vehicle-1.xml.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

        <!-- Custom Behavior for Vehicle Quests -->
            <CustomBehavior File="RunCode" Type="Definition"><![CDATA[ 
                private List<WoWUnit> Targets
                {
                    get { return (ObjectManager.GetObjectsOfType<WoWUnit>().Where(u => (u.Entry == 52386 || u.Entry == 52338) && u.IsAlive).OrderBy(u => u.Distance).ToList()); }
                }
                       
                private async Task DoVehicleQuest(int QuestID)
                {   
                    Func <bool> HasQuest = () => StyxWoW.Me.QuestLog.GetQuestById((uint)QuestID) != null;
                    Func <bool> IsCompleted = () => StyxWoW.Me.QuestLog.GetQuestById((uint)QuestID).IsCompleted;
                    if (!HasQuest() && !IsCompleted()) return;
                    if (Bots.Grind.LevelBot.BehaviorFlags.HasFlag(Bots.Grind.BehaviorFlags.Combat))
                          	Bots.Grind.LevelBot.BehaviorFlags &= ~Bots.Grind.BehaviorFlags.Combat;                    
                    PlayerQuest quest = StyxWoW.Me.QuestLog.GetQuestById((uint)QuestID);
                    Logging.Write(System.Windows.Media.Colors.Yellow, "[Profile]: Doing Quest '{1}' (QuestID: {0})", QuestID, quest.Name);
                    TreeRoot.StatusText = "Doing Quest '"+ quest.Name +"' (QuestID: " + QuestID + ")";
                    TreeRoot.GoalText = "Doing Quest '"+ quest.Name +"' (QuestID: " + QuestID + ")";             
                    while (HasQuest())
                    {                    
                        if (!Me.InVehicle) 
                        {
                           	if (!Bots.Grind.LevelBot.BehaviorFlags.HasFlag(Bots.Grind.BehaviorFlags.Combat))
                           	    Bots.Grind.LevelBot.BehaviorFlags |= Bots.Grind.BehaviorFlags.Combat;                        
                           	return; 
                        }
                        if (HasQuest() && IsCompleted())
                        {
                          	Lua.DoString("VehicleExit()");
                           	await CommonCoroutines.SleepForRandomUiInteractionTime();
                           	if (!Bots.Grind.LevelBot.BehaviorFlags.HasFlag(Bots.Grind.BehaviorFlags.Combat))
                           	    Bots.Grind.LevelBot.BehaviorFlags |= Bots.Grind.BehaviorFlags.Combat;
                           	return;
                        }
                        var target_ = Targets.FirstOrDefault();  
                        if (target_ == null)
                        {
                            TreeRoot.StatusText = "Waiting for Ride to End.";
                            await Coroutine.Wait(60000, () => (Me.IsActuallyInCombat || !Me.InVehicle));
                        }
                        if (target_ != null)
                        {
                            TreeRoot.StatusText = "Attacking: " + target_.SafeName;
                            target_.Target();
                            if (target_.Distance <= 2) {                            
                                Lua.DoString("CastPetAction(2)");
                            }else if (target_.Entry == 52338)  { 
                                Lua.DoString("CastPetAction(1)");
                            }else if (target_.Entry == 52386)  { 
                                Lua.DoString("CastPetAction(3)");
                            }
                            await Coroutine.Sleep(600);
                        }
                        await Coroutine.Yield();
                    }
                    return; 
                }                    	
            ]]></CustomBehavior>  
        <!-- Custom Behavior for Vehicle Quests -->
        
        
        <CustomBehavior File="RunCode" Code="await DoVehicleQuest(13975)" /> 

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.