Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела
FAQ Community Calendar Today's Posts Search

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 28.06.2006, 02:43   #1
Dave
Архивный участник
 
Join Date: Jun 2005
Posts: 364
Default [AI HELP]CODING MULTIPLE SKILLS FOR A MOB

Can somone show me code on how to create AI for mobs with multiple skills either with same or different skill type such as ddmagic+physicalspecial+selfddmagic with chance of random use.
Dave is offline  
Old 28.06.2006, 03:19   #2
Cardon
Архивный участник
 
Join Date: Apr 2006
Posts: 65
Default

In a nutshell...

Code:
class skillnpc : warrior
 {
 parameter:
     int Skill1 = 1234;
     int Skill2 = 1234;
     int Skill3 = 1234;
 handler:
     EventHandler SEE_CREATURE(creature) {
          i0 = Rand(3) + 1;
          if (i0 == 1) {
                    AddUseSkillDesire(creature, Skill1, @ST_HEAL, @AMT_MOVE_TO_TARGET, 1000);
          }
          else if (i0 == 1) {
                    AddUseSkillDesire(creature, Skill2, @ST_HEAL, @AMT_MOVE_TO_TARGET, 1000);
          }
          else if (i0 == 1) {
                    AddUseSkillDesire(creature, Skill3, @ST_HEAL, @AMT_MOVE_TO_TARGET, 1000);
          }
     }
 }
A very basic skilled mob AI based randomly. If you look around in ai_merged.txt and read other mob AI's you'll quickly see what can be added to make this much more useful.

That's the basics though.
Cardon is offline  
Old 28.06.2006, 03:56   #3
Dave
Архивный участник
 
Join Date: Jun 2005
Posts: 364
Default Thanks but im not sure how to use that code NASC i think.

here is what i have written. not sure if it will work, im testing it.
Code:
 class hallate_knight_physicalspecial : warrior
parameter_define_begin
   int PhysicalSpecial 1042438
parameter_define_end
handler 1   //  ATTACKED
   variable_begin
      "attacker"
      "damage"
      "myself"
      "_choiceN"
      "_code"
      "_from_choice"
   variable_end

   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  is_pc
   push_const 108
   add
   fetch_i
   push_const 0
   not_equal
   push_reg_sp
   fetch_i
   branch_true L1815
   shift_sp 1
   push_const 9
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  npc_class_id
   push_const 1620
   add
   fetch_i
   func_call 143   //  func[IsInCategory]
   shift_sp -2
   or
L1815
   branch_false L1817
L1816
   shift_sp 1
   push_const 100
   func_call 55   //  func[Rand]
   shift_sp -1
   push_const 10
   less
   push_reg_sp
   fetch_i
   branch_false L1818
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  top_desire_target
   push_const 2412
   add
   fetch_i
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   equal
   and
L1818
   branch_false L1820
L1819
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 155   //  func[Skill_GetConsumeMP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  mp
   push_const 352
   add
   fetch_d
   less
   push_reg_sp
   fetch_i
   branch_false L1821
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 154   //  func[Skill_GetConsumeHP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  hp
   push_const 344
   add
   fetch_d
   less
   and
   push_reg_sp
   fetch_i
   branch_false L1821
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 160   //  func[Skill_InReuseDelay]
   shift_sp -1
   push_const 0
   equal
   and
L1821
   branch_false L1823
L1822
   shift_sp 1
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   push_parameter PhysicalSpecial
   push_const 0
   push_const 1
   push_const 1000000
   func_call 10   //  func[AddUseSkillDesire]
   shift_sp -5
   shift_sp -1
L1823
L1820
L1817
   call_super
handler_end

handler 23   //  CLAN_ATTACKED
   variable_begin
      "attacker"
      "damage"
      "myself"
      "_choiceN"
      "_code"
      "_from_choice"
   variable_end

   shift_sp 1
   func_call 20   //  func[GetLifeTime]
   push_const 7
   greater
   push_reg_sp
   fetch_i
   branch_false L1824
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  is_pc
   push_const 108
   add
   fetch_i
   push_const 0
   not_equal
   push_reg_sp
   fetch_i
   branch_true L1825
   shift_sp 1
   push_const 9
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  npc_class_id
   push_const 1620
   add
   fetch_i
   func_call 143   //  func[IsInCategory]
   shift_sp -2
   or
L1825
   and
   push_reg_sp
   fetch_i
   branch_false L1824
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  p_state
   push_const 2308
   add
   fetch_i
   push_const 3
   not_equal
   and
L1824
   branch_false L1827
L1826
   shift_sp 1
   push_const 100
   func_call 55   //  func[Rand]
   shift_sp -1
   push_const 10
   less
   branch_false L1829
L1828
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 155   //  func[Skill_GetConsumeMP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  mp
   push_const 352
   add
   fetch_d
   less
   push_reg_sp
   fetch_i
   branch_false L1830
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 154   //  func[Skill_GetConsumeHP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  hp
   push_const 344
   add
   fetch_d
   less
   and
   push_reg_sp
   fetch_i
   branch_false L1830
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 160   //  func[Skill_InReuseDelay]
   shift_sp -1
   push_const 0
   equal
   and
L1830
   branch_false L1832
L1831
   shift_sp 1
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   push_parameter PhysicalSpecial
   push_const 0
   push_const 1
   push_const 1000000
   func_call 10   //  func[AddUseSkillDesire]
   shift_sp -5
   shift_sp -1
L1832
L1829
L1827
   call_super
handler_end

class_end

class hallate_knight_physicalspecial_2 : warrior
parameter_define_begin
   int PhysicalSpecial 1032198
parameter_define_end
handler 1   //  ATTACKED
   variable_begin
      "attacker"
      "damage"
      "myself"
      "_choiceN"
      "_code"
      "_from_choice"
   variable_end

   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  is_pc
   push_const 108
   add
   fetch_i
   push_const 0
   not_equal
   push_reg_sp
   fetch_i
   branch_true L1901
   shift_sp 1
   push_const 9
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  npc_class_id
   push_const 1620
   add
   fetch_i
   func_call 143   //  func[IsInCategory]
   shift_sp -2
   or
L1901
   branch_false L1909
L1902
   shift_sp 1
   push_const 100
   func_call 55   //  func[Rand]
   shift_sp -1
   push_const 10
   less
   push_reg_sp
   fetch_i
   branch_false L1903
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  top_desire_target
   push_const 2412
   add
   fetch_i
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   equal
   and
L1903
   branch_false L1908
L1904
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 155   //  func[Skill_GetConsumeMP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  mp
   push_const 352
   add
   fetch_d
   less
   push_reg_sp
   fetch_i
   branch_false L1905
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 154   //  func[Skill_GetConsumeHP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  hp
   push_const 344
   add
   fetch_d
   less
   and
   push_reg_sp
   fetch_i
   branch_false L1905
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 160   //  func[Skill_InReuseDelay]
   shift_sp -1
   push_const 0
   equal
   and
L1905
   branch_false L10907
L1906
   shift_sp 1
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   push_parameter PhysicalSpecial
   push_const 0
   push_const 1
   push_const 1000000
   func_call 10   //  func[AddUseSkillDesire]
   shift_sp -5
   shift_sp -1
L1907
L1908
L1909
   call_super
handler_end

handler 23   //  CLAN_ATTACKED
   variable_begin
      "attacker"
      "damage"
      "myself"
      "_choiceN"
      "_code"
      "_from_choice"
   variable_end

   shift_sp 1
   func_call 20   //  func[GetLifeTime]
   push_const 7
   greater
   push_reg_sp
   fetch_i
   branch_false L1911
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  is_pc
   push_const 108
   add
   fetch_i
   push_const 0
   not_equal
   push_reg_sp
   fetch_i
   branch_true L1910
   shift_sp 1
   push_const 9
   push_event   //  attacker
   push_const 36
   add
   fetch_i   //  npc_class_id
   push_const 1620
   add
   fetch_i
   func_call 143   //  func[IsInCategory]
   shift_sp -2
   or
L1910
   and
   push_reg_sp
   fetch_i
   branch_false L1911
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  p_state
   push_const 2308
   add
   fetch_i
   push_const 3
   not_equal
   and
L1911
   branch_false L1918
L1912
   shift_sp 1
   push_const 100
   func_call 55   //  func[Rand]
   shift_sp -1
   push_const 10
   less
   branch_false L1917
L1913
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 155   //  func[Skill_GetConsumeMP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  mp
   push_const 352
   add
   fetch_d
   less
   push_reg_sp
   fetch_i
   branch_false L1914
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 154   //  func[Skill_GetConsumeHP]
   shift_sp -1
   push_event   //  myself
   push_const 28
   add
   fetch_i   //  sm
   push_const 2400
   add
   fetch_i   //  hp
   push_const 344
   add
   fetch_d
   less
   and
   push_reg_sp
   fetch_i
   branch_false L1914
   shift_sp 1
   push_parameter PhysicalSpecial
   func_call 160   //  func[Skill_InReuseDelay]
   shift_sp -1
   push_const 0
   equal
   and
L1914
   branch_false L1916
L1915
   shift_sp 1
   push_event   //  attacker
   push_const 36
   add
   fetch_i
   push_parameter PhysicalSpecial
   push_const 0
   push_const 1
   push_const 1000000
   func_call 10   //  func[AddUseSkillDesire]
   shift_sp -5
   shift_sp -1
L1916
L1917
L1918
   call_super
handler_end

class_end



class hallates_knight : hallate_knight_physicalspecial_2 
handler 5      // SEE_CREATURE
     variable_begin
           "creature"
           "myself"
           "_choiceN"
           "_code"
           "_from_choice"
     variable_end

     shift_sp 1
     func_call 20      // func[GetLifeTime]
     push_const 7
     greater
     push_reg_sp
     fetch_i
     branch_false L1892
     shift_sp 1
     push_event      // myself
     push_const 28
     add
     fetch_i      // sm
     push_const 2400
     add
     fetch_i
     func_call 177      // func[InMyTerritory]
     shift_sp -1
     and
L1892
     branch_false L1894
L1893
     shift_sp 1
     push_event      // creature
     push_const 68
     add
     fetch_i
     push_const 1
     push_const 200
     func_call 2      // func[AddAttackDesire]
     shift_sp -3
     shift_sp -1
L1894
handler_end

class_end
Dave is offline  
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 15:37.