"Attack" Script?

Post » Fri Jul 23, 2010 4:14 pm

I am currently working on a mod that adds a new fort owned by you and your soldiers. I'll get right to it:

What i want is a script that spawns enemy soldiers just outside my fort at random times, to add more immersive feeling to my war mod.

Could someone please right me up a script for this? I will be very gratefull.

Cheers,

Shadowform.
User avatar
Roddy
 
Posts: 3564
Joined: Fri Jun 15, 2007 11:50 pm

Post » Fri Jul 23, 2010 5:57 am

The best way is to place the NPCs where you want them in the game world, making sure to give them each a unique Id (inthis case, NPCAttackerXX, where XX is their number), and mark them as "InitiallyDisabled", then use a Quest Script something like this:

Short WhichDayShort DayCountShort FightDayShort DoWarBegin GameMode	If ( FightDay != GameDay )		Set FightDay to GameDay		Set DayCount to ( DayCount + 1 )		Set WhichDay to ( GetRandomPercent + 1 )		Set WhichDay to ( WhichDay / 4 )		If ( WhichDay < 5 )			Set WhichDay to 5		EndIf	EndIf	If ( DayCount >= WhichDay )		Set DayCount to 0		Set DoWar to 1	EndIf	If ( DoWar == 1 )		Set DoWar to 0		NPCAttacker01.Resurrect 0		NPCAttacker01.Enable		NPCAttacker02.Resurrect 0		NPCAttacker02.Enable		.		.		.		NPCAttacker11.Resurrect 0		NPCAttacker11.Enable	EndIfEnd


This is a rough script, so may have some errors/bugs, but what it should do is...
1. Check the Game Day
2. If the Day is not the recorded date, increment the passed days by 1, and do a random roll
3. Reduce the random roll by 4 (so a maximum of 25 days)
4. If the roll is less than 5, make it 5
5. If the day count is greater than or equal to the roll, trigger the war and reset the day count
6. Resurrect the NPCs, and enable them

Be aware that Oblivion can act oddly when too many NPCs are in one place at the same time.

This Script also has no clean-up for when you kill the people.
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am


Return to IV - Oblivion