Jump to content

The wolf answers on scripting


Greywolf

Recommended Posts

Don't format your entire post, especially with color. In almost all cases, it just makes the message harder to read and sets off a whole lot of red flags in the minds of forumgoers.

 

As for your question, look at the scripts applied to the NPCs at Ald Daedroth. They show that NPC A must have a StartCombat command gven to it with NPC B's item ID as an argument in order to initiate combat between NPC A and NPC B. Thus, if you want NPCs with IDs X_XX and Y_YY to fight...

 

Begin X_XX.sc

;  Because i can, damnit!

 

;  The only thing that's really necessary here is the

;  startcombat command -- the "run once, then

;  deactivate" stuff in all the other lines only ensures

;  that the command isn't run every frame.

 

Short DoOnce

;  This is set to 1 after combat has been initiated.

 

If ( DoOnce )

 

  Return

  ;  The payload has been executed once already

  ;  -- there's no need to do it again.  If the script

  ;  runs past this, it means that DoOnce isn't equal

  ;  to 1.

 

EndIf

 

StartCombat Y_YY

Set DoOnce to 1

 

End

 

...Now, if you want to stick more to the definition of the word and have a non-lethal match with less of that cowardly stuff...

 

Begin X_XX.sc

 

Short FightDone

 

If ( FightDone )

 

  Return

; There's nothing left to do after the fight...

 

ElseIf ( GetTarget Y_YY )

; If the fight isn't registered as finished and X_XX is

; still in combat with Y_YY, it must mean the fight is

; underway, right?

 

  If ( GetHealth < 50 )

  ; If X_XX's health drops below 50 -- modify the

  ; number as necessary.

 

    StopCombat

    Y_YY->StopCombat

    Set FightDone to 1

    ; Stop fighting and register the fight as over.

 

  ElseIf ( Y_YY->GetHealth < 50 )

  ; If Y_YY's health drops below 50 -- modify the

  ; number as necessary.

 

    StopCombat

    Y_YY->StopCombat

    Set FightDone to 1

    ; Stop fighting and register the fight as over.

 

  EndIf

 

Else

; If none of these conditionals are true, it must mean

; the fight has not yet begun.

 

  StartCombat Y_YY

  SetFlee 0

  Y_YY->SetFlee 0

  ; Those SetFlees are for lowering the chance of both NPCs

  ; trying to escape.

 

EndIf

 

End

 

...Of course, these are both quite rudimentary -- as you gain more scripting knowledge, it'd be a wise choice to look back on these, if you choose to implement them, and eliminate some of the more obvious flaws.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...