Legacy Development Community Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Legacy Development Community Forum

World of Warcraft Development Forums
 
HomeHome  PortalPortal  GalleryGallery  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  

 

 AI for creatures and bosses

Go down 
3 posters
AuthorMessage
Devincean

Devincean


Number of posts : 39
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: AI for creatures and bosses   AI for creatures and bosses EmptyThu Apr 12, 2007 9:07 pm

This is kinda a idea / suggestion...

I know that spells for bosses and creature etc are now done by the sql table rather then script base. My idea is can we still use our old AI's for example attack actions and messages etc and just take out the spell tables in the AI and leave it up to the sql server to handle.

example:
Code:
#Ragnaros AI Module by KremLiN 30.05.2006
from Ludmilla import *          # Import server environment
from random import *            # Randomiser Import
import config as cfg            # Import of configuration constants
reload(cfg) 
import consts as co            # Import of constants
reload(co) 
import const_skills as skill_co # Import of constants (skills)
reload(skill_co) 
import const_spells as spell_co # Import of constants (skills)
reload(spell_co) 
import player_class as player_cls
reload(player_cls)
import support as supporter
reload(supporter)
from time import localtime

ENABLE = TRUE = co.TRUE
DISABLE = FALSE = NULL = co.FALSE

#+non tested molten blast
#+non tested submrged/emerged and son of flame spawned
#+non tested wrath of ragnaros

class AI_Ragnaros:
    bool_ragnaros_submerged = FALSE
    bool_sone_active        = FALSE
    bool_combat_start      = FALSE
    msg1=["Taste the Flames of Sulfuron!"]
    msg2=["By fire be purged!"]
   
    TIMER_SONE_SCAN        = 5000
    BUFF_INDEX_SAVED_TIME  = 0
   
    # function SoneDelete()-delete son of flame around ragnaros if one exit in combat
    def SoneDelete(ptrCls, self):
        _list= self.MapRangeUnitList()
        for _unit_ in _list:
            if _unit_.IsNPC():
                if _unit_.GetEntry() == 12143:
                    _unit_.Die( TRUE ) # this will remove creature from server, if TRUE from DB also
   
    # function ScanForSoneOfFlames()-scan son of flames or one's corpses around of ragnaros and recall ragnaros if son's dies
    def ScanForSoneOfFlames(ptrCls,self):
        life_count = 0
        dist_list = self.MapRangeUnitList()
        for _unit_ in dist_list:
            if _unit_.IsNPC():
                if _unit_.GetEntry() == 12143:
                    if _unit_.IsDead() == FALSE:
                        life_count+=1
        if life_count == 0:
            ptrCls.SoneDelete(self)
            ptrCls.bool_sone_active        = FALSE
            self.CastSpell( self, 20568 )
            ptrCls.bool_ragnaros_submerged  = FALSE
            self.Emote( co.EMOTE_ONESHOT_SUBMERGE )
            return
   
    #calculated distance
    def CalcDist(ptrCls,obj1,obj2):
        return supporter.CalcDist(obj1,obj2)
        #arr1=obj1.GetXYZ()
        #arr2=obj2.GetXYZ()
        #return sqrt( ( arr2[0] - arr1[0] ) * ( arr2[0] - arr1[0] ) + ( arr2[1] - arr1[1] ) * ( arr2[1] - arr1[1] ) )
   
    #if changed agrotarget then cast spell
    def OnEnemyDetected (ptrCls,self, attacker):
        self.Say (attacker, choice (ptrCls.msg2), co.LANG_UNIVERSAL, co.MONSTER_SAY)
        self.CastSpell(attacker,20566)
   
    #summon sone of flame and ragnaros submerged
    def SummonSone(ptrCls,self):
        self.CastSpell(self,21108)
        self.CastSpell(self,20567)
        self.CastSpell(self,21859)
        self.Emote(co.EMOTE_STATE_SUBMERGED)
        ptrCls.bool_ragnaros_submerged  = TRUE
        ptrCls.bool_sone_active        = TRUE
        ptrCls.ScanForSoneOfFlames(self)
   
    #on attacked function
    def OnAttacked (ptrCls,self,attacker):
       
        if ptrCls.bool_combat_start == FALSE:
            ptrCls.bool_combat_start = TRUE
            self.NextThink(180000,2)
       
        self.CastSpell(attacker, 21387) #or self verify tomorrow
        _units = self.MapRangeUnitList()
        melee_units = []
       
        for _unit in _units:
            if _unit.IsPlayer():
                #if ptrCls.CalcDist(self,_unit) <= 5:
                if supporter.CalcDist(self,_unit) <= 5:
                    melee_units.append(_unit)
       
        if melee_units.__len__() == NULL:
            range_units = []
            all_units = self.MapRangeUnitList()
           
            for _unit in all_units:
                if _unit.IsPlayer():
                    #if ptrCls.CalcDist(self,_unit) <= 30:
                    if supporter.CalcDist(self,_unit) <= 30:
                        range_units.append(_unit)
                       
            cur_player = range_units[ randrange( 0, range_units.__len__()-1 ) ]
            self.Say (cur_player, choice (ptrCls.msg1), co.LANG_UNIVERSAL, co.MONSTER_SAY)
            self.CastSpell(cur_player,20565)
           
    #print in console about Ragnaros Initialization AI module #delete this function in release   
    def OnInitNPC (ptrCls,self):
        print "Ragnaros AI Init"
       
        # Initialise our Buffers
        self.SetBufferValue(ptrCls.BUFF_INDEX_SAVED_TIME, ptrCls.TIMER_SONE_SCAN)
       
        #self.Emote(co.EMOTE_ONESHOT_BIRTH)# not find ths emote in consts.py
       
    #timer for summon sone of flames and changes fases combat
    def OnThink (ptrCls,self,val):
   
        if self.isInCombat() == FALSE:
            ptrCls.bool_combat_start = FALSE
            if ptrCls.bool_sone_active == TRUE or ptrCls.bool_ragnaros_submerged == TRUE:
                ptrCls.SoneDelete(self)
                ptrCls.bool_sone_active = FALSE
                self.CastSpell( self, 20568 )
                self.Emote( co.EMOTE_ONESHOT_SUBMERGE )
                ptrCls.bool_ragnaros_submerged = FALSE
                return
               
        if  val == 2:
            ptrCls.SummonSone(self)
            self.NextThink(90000,3)
           
        elif val == 3:
            if bool_sone_active == TRUE:
                self.CastSpell( self, 20568 )
                ptrCls.bool_ragnaros_submerged = FALSE
                self.Emote( co.EMOTE_ONESHOT_SUBMERGE )
                self.NextThink( 180000, 2 )
   
    # called by core on every Creature Update
    def OnUpdate (ptrCls,time_diff,self):
        pass
       
    # -- EOF --

basicly script has alot more then just spells so we just take the spells out and make it so the mob does more then slash and cast spells
Back to top Go down
aceindy
Sherif
aceindy


Number of posts : 305
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses EmptyThu Apr 12, 2007 11:08 pm

Hya,

I think I have been misunderstood;

It's not a problem to have custem AI for special bosses like Raggie, but my point was, it's a bit weird to write 50.000 custom AI's for every single creatures.

That is also the reason why loading of default ai have been moved to bottom of startup_qm.py. If the creature is already registered by custom py, it will automaticaly be skipped when registering default_ai.

So, if you want the script in, just register it before default_ai registers.

Due to instability I recommend to pospone it to c4??

[edit: oops, for some reason it's on top again...will update as soon as svn start working again ]
[edit: Sending content: T:\svn\Kobold_py\scriptsV3\startup_qm.py
Completed: At revision: 367 ]
Back to top Go down
Devincean

Devincean


Number of posts : 39
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses EmptyThu Apr 12, 2007 11:39 pm

kinda what I am saying bring in AI scripts for bosses only without there spells in the AI lettting the basic spells for the creature load from sql database. For instance I am have been working to try to clean up dragon type ai's basicly which would give a dragon attack primary attacker (rather then by Aggro thus making tank prime target) giving them some basic though process in a fight for example running away staying and fight so forth basicly bring in general scripts for creatuers again

Code:
#
# AI Behavior Module
#
# To disable some handler, comment it out or rename, so loader doesn't find it by name
#
# Rewritten by Cain on 25-01-2006
#
from Ludmilla import *
import consts as co
reload(co)
from random import *

#------------------------------------------------------------------------------
def OnEnemyDetected (self, attacker):
    """ Function is called when NPC 'self' notifies (aggroes) player 'attacker'
        right before the moment when Hate is added.
        Param: (Unit attacker, Unit attacker)
    """
    pass
   
#------------------------------------------------------------------------------
#attack_emotes = [EMOTE_ONESHOT_RUDE, EMOTE_ONESHOT_ROAR, EMOTE_ONESHOT_POINT]
#attack_messages = ["The Brotherhood will not tolerate your actions!",  "Ah, chance to test this freshly sharpened blade!"]
def OnAttacked (self, attacker):
    """ Param: (Unit npc, Unit npc2)
        Function is called when npc is attacked by npc2, just before attack
        reaction game function called. If OnAttacked returns 0 or None, then
        normal reaction for current aiclass is called (attack back or flee).
    """
    # Initialise Variables
    spell_index = int(self.GetLevel())
    spell_list = [8873,8873,9573,16390,16396,17294,18435]
    if spell_index >= spell_list.__len__(): spell_index = spell_list.__len__() - 1

    # Randomly select casting Spell on Creature Level basis
    spell_id = spell_list[randint(0,spell_index)]
   
    #Init Spell Cast
    printLog("Dragon casting spell: index[%s] spell[%s]" % (spell_index, spell_id))
    self.CastSpell(attacker, spell_id)
   
#------------------------------------------------------------------------------
#runaway_messages = ["Sorry, I got to go!", "Whoops, its dinner time!",
#    "See you later!", "Got to go!", "Have a nice day!"]


def OnTakeDamage (self, attacker):
    """ Function is called when NPC 'self' takes damage in combat from npc or
        player 'attacker'
        Param: (Unit attacker, Unit attacker)
    """
#    if 100.0 * self.GetHealth() / self.GetMaxHealth() <= 20:
#        if randrange (100) < 10:
#            self.Say (attacker, choice (runaway_messages), co.LANG_UNIVERSAL)
        # self.Emote is good to

        # Trigger 10 second flee mode when creature ignores damage with 15
        # meters help radius. If no help found, return back and attack.
        #
#        self.Flee (attacker, 10, 15)


#--- END ---
Back to top Go down
Iceman
Developer
Iceman


Number of posts : 462
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses EmptyThu Apr 12, 2007 11:49 pm

i dont understand the point?
can u explain a bit?
its kremlin ai i too have it and yes we know some bosses needs aditional scripting if thats what u wanned to say?

explain plz?
Back to top Go down
Devincean

Devincean


Number of posts : 39
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses EmptyThu Apr 12, 2007 11:54 pm

na what I am asking is without having to rewrite every single Ai script so the spells and what not are current with the spell database etc. can we just take out spells from all custom ai's and use the sql default creature spell database to handle creatures spells and still use custom AI scripts to handle the creatures actions

so basicly when ya encountered a creature:

creature would look for all his spells out of the sql creature_spells table

and the creatures actions would be pulled from python custom scripts (by actions I mean sittings, standing, running away, who the creature should look to attack etc.)

mean this way we only have to right complex spells into a creature's ai... example: Ragnaros have his sons and submersion scripted and his regular fire spells running off his default scripts in creature_spells table
Back to top Go down
Iceman
Developer
Iceman


Number of posts : 462
Registration date : 2006-11-28

AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses EmptyFri Apr 13, 2007 1:09 am

hm yes thats the idea
writing like default behavior for all commong living self flee and shit..
and yet they all have default sql using for their coresponding spells
yes could be done
Back to top Go down
Sponsored content





AI for creatures and bosses Empty
PostSubject: Re: AI for creatures and bosses   AI for creatures and bosses Empty

Back to top Go down
 
AI for creatures and bosses
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Legacy Development Community Forum-
Jump to: