Guards Who Call For Help

Post » Wed Aug 26, 2009 12:42 am

Hi. Iv got a bunch of Militia (Custom class) who patrol my city - their patrols are working nicely now.

However there is one problem - the Militia, via their faction, are in a state of hate war with other races. If another race (usual guards chasing me!) arrive at the gates of the city, my gate Militia, all two of them, will attack like lunatics, but other Militia nearby will continue on their patrols, ignoring the violence as two of their own get slaughtered by overwhelming odds, and will only become involved when the enemy get closer to them.

No doubt there is a number somewhere that dictates the distance at which NPC's will detect things, but if this is not easily changeable, is there a way to call other NPC's to the battle?

I don't want every Militia man in the city to rush to the gate, but there are usually about five who should be able to see the violence and respond. There are also several Militia on the walls of the city who could be shooting arrows but do not.

Any ideas?

Cheers

MVK
User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am

Post » Wed Aug 26, 2009 10:26 am

You need to use StartCombat function.

You could set it up in a spell that is cast, the spell would have a certain radius and sets StartCombat on any guard nearby.

You could limit the spell to just those guards by using IsInFaction Guards == 1 or something like that, so it ignores other NPC's.
User avatar
Stace
 
Posts: 3455
Joined: Sun Jun 18, 2006 2:52 pm

Post » Wed Aug 26, 2009 1:22 am

You need to use StartCombat function.

You could set it up in a spell that is cast, the spell would have a certain radius and sets StartCombat on any guard nearby.

You could limit the spell to just those guards by using IsInFaction Guards == 1 or something like that, so it ignores other NPC's.

Thanks FTB, but you'll have to be a little more specific:

I need to make a spell, have the script attached to it and make the effect area large enough to include other NPC guards. I can manage that I think, but what would I put in the script to call the other NPC guards (Yes, they are all in their own custom faction), and how would I make the guards cast the spell as they attack the enemy?

Sorry, pretty new at this still, and feeling my way through the finer details of script/game interaction.

Cheers

MVK
User avatar
Angela
 
Posts: 3492
Joined: Mon Mar 05, 2007 8:33 am

Post » Tue Aug 25, 2009 10:01 pm

Ok, there are two ways I can see this being done. One is to have the Guard cast the spell onto his target which will result in you seeing the Guard cast a spell, which may be a little annoying.

The other way is more complicated and if you have little experience you might want to tackle it further down the line after doing more scripting. It would involve calling two disabled refs next to the Guard and having the one ref cast the spell onto the other, so it happens without the player seeing it. But this would be complicated and require some clever scripting.

Here is a simple and basic example of having the Guard cast the spell on his target, that might work correctly. Probably will require some testing and fine tuning.

There is an issue with StartCombat, in that the NPC that has StartCombat run on them will not give up the chace; so if your expecting the enemies to run away, the guards will likely chace them over the whole of Tamriel if they have to.

ref rTargetshort DoOnceBegin Gamemode     set rTarget to GetCombatTarget ;;;;;Sets the ref rTarget to whom ever the guard is attacking.     If IsInCombat == 1 && DoOnce == 0 ;;;;;Checks if the guard is in combat with someone and hasn't cast spell yet          Cast MySpell rTarget ;;;;;Casts the spell onto the combat target.  Replace MySpell with the ID of your spell with the StartCombat script in it.          Set DoOnce to 1 ;;;;;Stops the guard from casting the spell constantly in a loop     endif          Elseif IsInCombat == 0 && DoOnce == 1 ;;;;;Checks if guard has finished combat                Set DoOnce to 0 ;;;;;Resets script so it's ready for next targetEnd



Here is the spell code that should work.

Begin ScriptEffectStart     If GetInFaction MyGuardFaction == 1 ;;;;;Replace MyGuardFaction with the faction you gave your guards!           StartCombat          Else               Return     EndifEnd

User avatar
Charlie Ramsden
 
Posts: 3434
Joined: Fri Jun 15, 2007 7:53 pm

Post » Tue Aug 25, 2009 11:50 pm

Thanks FTB Ill get on this once Iv ironed out the current Quest I'm working on.

MVK
User avatar
James Rhead
 
Posts: 3474
Joined: Sat Jul 14, 2007 7:32 am


Return to IV - Oblivion