Difference between revisions of "Command an NPC/Creature to Attack"

no edit summary
imported>Phinix
imported>Phinix
 
(5 intermediate revisions by 2 users not shown)
Line 2: Line 2:
[[Category:Scripting]]
[[Category:Scripting]]
This tutorial will explain how to set up a script on a custom NPC/creature so that by activating it you will be able to command it to attack nearby actors (including friendlies.)
This tutorial will explain how to set up a script on a custom NPC/creature so that by activating it you will be able to command it to attack nearby actors (including friendlies.)
*Clipped from my [http://planetelderscrolls.gamespy.com/View.php?view=OblivionMods.Detail&id=601 Phinix Master Summon] mod.


== Create a Global variable ==
== Create a Global variable ==
Line 31: Line 29:
   
   
  begin ScriptEffectUpdate
  begin ScriptEffectUpdate
  if phiAhostile1 == 1
  if globalvar1 == 1
  SetAV Aggression 50
  SetAV Aggression 50
  elseif phiAhostile1 == 2
  elseif globalvar1 == 2
  SetAV Aggression 10
  SetAV Aggression 10
  endif
  endif
Line 39: Line 37:
   
   
  begin ScriptEffectFinish
  begin ScriptEffectFinish
    SetAV Aggression 10
SetAV Aggression 10
  end
  end


Line 54: Line 52:
Now right-click the space on the right and select "New" to bring up the box to add a new spell effect.  
Now right-click the space on the right and select "New" to bring up the box to add a new spell effect.  


For the effect choose "Script Effect" and give it a duration (I use 360 but for this spell it really doesn’t matter since it will stay on until it’s dismissed.)
For the effect choose "Script Effect" and give it a duration of 0, since we're adding it as an Ability which remains constant.


Give it an "Effect Name," then choose any school and visual. Do not check "Effect is Hostile."
Give it an "Effect Name," then choose any school and visual. Do not check "Effect is Hostile."
Line 91: Line 89:
  end
  end
   
   
  beginGameMode
  begin GameMode
  ifactivestat==2
  if activestat == 2
  setbuttontogetbuttonpressed
  set button to getbuttonpressed
  ifbutton>-1
  if button > -1
  ifbutton==0
  if button == 0
  setglobalvar1to1
  set globalvar1 to 1
  setactivestatto0
  set activestat to 0
  elseifbutton==1
  elseif button == 1
  settimerto1.5
  set timer to 1.5
  setglobalvar1to2
  set globalvar1 to 2
  setactivestatto0
  set activestat to 0
  elseifbutton==2
  elseif button == 2
  setactivestatto0
  set activestat to 0
  endif
  endif
  endif
  endif
  endif
  endif
  ifglobalvar1==2
  if globalvar1 == 2
  iftimer==0
  if timer == 0
  setglobalvar1to0
  set globalvar1 to 0
  elseiftimer>0
  elseif timer > 0
  settimertotimer-getSecondsPassed
  set timer to timer - getSecondsPassed
  StopCombatAlarmOnActor
  StopCombatAlarmOnActor
  elseiftimer<0
  elseif timer < 0
  settimerto0
  set timer to 0
  endif
  endif
  endif
  endif
Line 128: Line 126:


Best of luck!
Best of luck!
-Phinix
Anonymous user