Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Begin dg_AttackNPCCreatureScript
- short sFlag
- float fCrime
- short sArrest
- if ( MenuMode == 1 )
- return
- endif
- ;are there evil NPCs around?
- if ( NPCCreatureAttack > 0 )
- ;return if dead
- if ( GetHealth <= 0 )
- return
- endif
- ;are we attacking them already
- if( sFlag == 0 )
- ;return if we're trying to kill the player
- if ( GetTarget, Player == 1 )
- return
- endif
- ;if we're close, set to follow player so we attack NPC
- if ( GetDistance, Player < 3600 )
- set fCrime to GetPCCrimeLevel
- AiEscort, Player, 0 0 0 0 0 0
- set sFlag to 1
- set NPCGuardAttack to ( NPCGuardAttack + 1 )
- return
- endif
- endif
- ;we're already attacking the NPCs
- if ( sFlag == 1 )
- ;if the PC crime Level has increased try to arrest him
- if ( fCrime < GetPCCrimeLevel )
- set sArrest to 1
- endif
- endif
- else ;there's no creatures around
- ;switch back to regular AI if necessary
- if( sFlag == 1 )
- if( NPCGuardAttack > 0 )
- set NPCGuardAttack to ( NPCGuardAttack - 1 )
- endif
- set sFlag to 0
- if( GetCurrentAIPackage == 2 )
- StopCombat
- AiWander, 2000, 5, 0, 60, 20, 20, 20, 0, 0, 0, 20
- return
- endif
- endif
- set fCrime to GetPCCrimeLevel
- set sArrest to 0
- endif
- ;are we trying to arrest PC?
- if ( sArrest == 1 )
- ;return if dead
- if ( GetHealth <= 0 )
- return
- endif
- ;don't arrest if we're trying to kill the PC
- if ( GetTarget, Player == 1 )
- return
- endif
- if ( GetDistance, Player < 300 )
- set NPCCreatureAttack to 0
- set fCrime to GetPCCrimeLevel
- set sArrest to 0
- if( GetCurrentAIPackage == 2 )
- StopCombat
- AiWander, 2000, 5, 0, 60, 20, 20, 20, 0, 0, 0, 20
- endif
- ForceGreeting
- endif
- endif
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement