NPCS upgrading weapons

Post » Thu May 19, 2011 12:23 am

Okay, I have a bit of a scripting/leveled list conundrum here, and i'm not sure how to ask it, but I'll try my best. Ehhem. To put it bluntly: I'm looking for a way for NPCS in a custom faction to upgrade their weapons as a questline progresses (multiple quests, not one single quest). This is to be completely independant of random chance or player level.


Okay. Say a questline has me start a city and hire some city guards. They all have hunting rifles for starters. Say there are 70 total guards (large number I know but bear with me. The addon i'm doing this for actually uses this large a number. Oh, and to make things even more complicated, some of these guards already have scripts attached to them. And the ones that don't have one, there's another addon that adds another script to them.)

Okay, the first quest comes up in this questline, and it gets completed. What the quest entails is irrelevant. What is, is that the guards after this quest is completed should now have Sniper Rifles.

2nd quest comes and goes. The guards now have Gauss rifles (don't ask where they get them. This is just an example).

3rd quest comes and goes. The guards now have Alien Disintegrators (again don't ask. Just an example).

And so on and so fourth.


In other words, as you progress in the quest line, ALL the guards get better weapons.


Keep in mind, in order for this to work right this has to work on THE LIVING. Not soldiers that respawn or new spawns after said benchmarks.


And while we're on this subject. Let's take this a step further. Another thing I could use help with.

Say that instead of several different weapons to upgrade to, there's just two or three. HOWEVER, there's only so many of them to go around so instead of ALL the soldiers getting their weapons repalced after the completion of each mission, Only a few, random soldiers have their weapons replaced.

And on top of that, after the third weapon becomes available, some soldiers will become support units instead of regular soldiers, and use this weapon instead of their normal loadout.

Like so:

Mission 0 Complete: All soldiers have AK-47s.

Mission 1 Complete: The G36E becomes available. However, there isn't enough supply to meet demand. So only 10% of all currently living soldiers have G36Es instead of AK-47s. The rest hang on to their AK-47s.

Mission 2 complete: 25% of all currently living soldiers have G36Es instead of AK-47s now. The rest still have the AK-47s.

Mission 3 complete: 50% of all Currently Living Soldiers have G36Es instead of AK-47s now. HOWEVER, of those 50%, 10% of them will instead have the MG36 variant instead of the Normal Variant. (the 10% number of MG36 vs G36E doesn't change at all, as opposed to the AK47s vs G36Es)

Mission 4 complete: 100% of all Currently Living Soldiers have G36s instead of AK-47s now. HOWEVER, %10 of the soldiers will instead have the MG36 variant instead of the Normal Variant.


Yes, this is rather a complicated thing it seems. Plus theres a LOT of soldiers to cover. Not to mention this has to apply to any new soldiers that spawn too (Like say through a Encalve Commander addon)

If anyone has any ideas on how to make this work... I'd be very grateful.
User avatar
Kayla Oatney
 
Posts: 3472
Joined: Sat Jan 20, 2007 9:02 pm

Post » Thu May 19, 2011 5:37 am

First, how to swap weapons. That's pretty straightforward. You pick SomeYourGuardREF and run:

;other stuff;GLOBAL YourQuestStageSHORT tmpVarBEGIN GameMode;other stuffSET tmpVar TO SomeYourGuardREF.GetItemCount WeapHuntingRifleSomeYourGuardREF.RemoveItem WeapHuntingRifle tmpVar 1SET tmpVer TO SomeYourGuardREF.GetItemCount Ammo32CaliberSomeYourGuardREF.RemoveItem Ammo32Caliber tmpVar 1;repeat until SomeYourGuardREF is stripped of all relevant weaponsIF ( YourQuestStage == 2 )  SomeYourGuardREF.AddItem YourStage2Weapon 1 1ENDIF;other stuffEND;other stuff


where YourStage2Weapon is a leveled itemlist similar to:

Items > Leveled Item > YourStage2Weapon
1 1 WithAmmoSniperRifleNPC
1 1 WithAmmoHuntingRifleNPC
1 1 WithAmmoHuntingRifleNPC
1 1 WithAmmoHuntingRifleNPC

Which means 75% chance for a Hunting Rifle and 25% chance for a Sniper Rifle. Note that this method will downgrade weapons for some guards as it doesn't check what they had before everybody's weapons got collected and new weapons issued.

Now, how to pick that SomeYourGuardREF for your script to perform weapon change upon. The classic approach is to have all those NPC being persistant objects (like Rivet City or Tenpenny's guards), so all their names are known beforehand and you simply repeat your script for each. If you decide to create dynamic NPC using PlaceAtMe, you still can track them all using FOSE formlist functions: ListAddForm when creating, ListRemoveNthForm when removing and repeating ListGetNthForm to do with each tracked reference what you want to. If it weren't you who created your NPC (say, after you added your guard template to some common LeveledNPC list) - you must catch their RefID to track. Therefore you have to provide your NPC with some script - set a script to NPC, issue him a scripted token, assign him a scripted ability - otherwise you won't know about his existance and won't be able to change anything about him.
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm


Return to Fallout 3