AlexScorpion Posted February 9, 2011 Share Posted February 9, 2011 I'll cut right to the chase here : I'm currently learning how to script and have been experimenting with a few things here. I'm trying to summon custom NPC's using a Vertibird. i'm done with the first part ... i've created a menubased script which let's me do just that scn 1SquadRadioScript int ibutton ref r1SquadSniper Begin OnEquip showmessage 1SquadSummonMenu end Begin GameMode set iButton to GetButtonPressed if iButton == -1 return elseif iButton == 0 playsound WPNAlienBlasterFire2D elseif iButton == 1 placeatme 1TacticalSquadVertibird 1 elseif iButton == 2 PlaceAtMe 1TacticalSquadVertibird 1 set r1SquadSniper to 0 endif Now there is a second script attached to a verbird activator with a line "placeatme 1SquadSniper 3" ...and it works fine ... but now there are two things that i cannot acomplish 1. I would like to be able to summon no more than 3 combatants ... so when there are allready 3 alive ones in scene the script would result in 0 2. How to dismiss the summoned troops ?? tried with disable and remove and GetIsID xxx => 1 remove them all but the problem is that i cannot find anywhere how to get actor count of the custom NPC's in the current scene and i cannot find a command on how to remove them And lastly .. how do you assign custom Variables to custom groups of actors ??? Thanks in Advance Alex Link to comment Share on other sites More sharing options...
Skevitj Posted February 9, 2011 Share Posted February 9, 2011 (edited) GetFirstRef and GetNextRef (NVSE) should be able to create a script which will loop through all actors in the current cell and allow you determine the number of ones stemming from a specific base objects (the combatants). It would be rather clunky and just seems like overkill though. Maybe the best solution is just the simplest: Have a global variable which is incremented every time one is spawned and decremented every time one is destroyed. There is always the chance that I've completely missinterpreted what you're after and these are way too simplistic. With #2 I'm not entirely sure what you're saying. I'm guessing the script that is going to be responsible for removing the NPC is on the NPC? I haven't had a whole lot of luck dealing with placeatme cleanup from a global script, although the GetNextRef loop may be able to make that easy enough. If they're to be destroyed as soon as they die:begin ondeathset combat to combat-1 --If using a variable to keep track of the numberdisablemarkfordeleteendshould take care of it. Those three lines can be call from anywhere though and should achieve the effect you're after, OFC they'll need the ref of the NPC to be destroyed if being called from a script not on the NPC. What do you mean custom variables to custom groups of units? Edited February 9, 2011 by Skevitj Link to comment Share on other sites More sharing options...
AlexScorpion Posted February 9, 2011 Author Share Posted February 9, 2011 thanks for the reply .. what i meant ... was somethinmg ike this .... a vertibird comes and drops off troops .... "dismissing troops" vertibird comes and picks up troops like in this mod here http://www.fallout3nexus.com/downloads/file.php?id=5717 ... i've checked all of the scripts but i still cannot apply something like that on one NPC ... i don't get how he controlls it through variables .... nothing seems to be pointing in their direction and there are no conditions specified in the menu's Link to comment Share on other sites More sharing options...
Skevitj Posted February 9, 2011 Share Posted February 9, 2011 I haven't looked at it, but something like this seems like it would achieve it: To summon troops:Vertibird is "summoned"... Once animations are finished it spawns the troops and flies away... To pickup troops:Vertibird is summoned... a global variable is set when the animations are finished which causese an ai package on the troops to activate causing them to go activate the vertibird. When the activate the vertibird the bird script then destroys the troop, when all are destroyed it then flies away. Something like that a bit closer? Link to comment Share on other sites More sharing options...
AlexScorpion Posted February 9, 2011 Author Share Posted February 9, 2011 well the full two scripts look like this scn CRISquadRadioTrEffectScript short button short doonce short herobutton ; 0 = nada ; 1 = Have selected button, shall summon ship begin scripteffectstart set CRISquadType to 0 if isininterior == 1 showmessage CRISquadRadioBeaconMessageIndoor player.additem CRISquadRadioTransceiver 1 else showmessage CRISquadRadioBeaconMessage set doonce to 1 endif ;Reset Squad count to Zero if CRISquadAssault < 0 set CRISquadAssault to 0 endif end begin scripteffectupdate set button to getbuttonpressed ; Cancel Button ;============= if button == 0 && doonce == 1 player.additem CRISquadRadioTransceiver 1 playsound QSTToneSequenceFail ;set doonce to 2 ;SUMMON ASSAULT SQUAD ;============== elseif button == 1 && doonce == 1 if CRISquadAssault < 6 ;Squadlimitation max. 6 units! set CRISquadAssault to (CRISquadAssault + 3) if CRISquadAssault > 8 playsound QSTToneSequenceFail showmessage CRISquadSoldierLimit set CRISquadAssault to 6 else set CRISquadType to 1 placeatme CRISquadVertibirdTransport 1 player.additem CRISquadRadioTransceiver 1 playsound CRISquadRadioSummonSoldiers endif else playsound QSTToneSequenceFail showmessage CRISquadSoldierLimit endif ;SUMMON HEAVY SQUAD ;============== elseif button == 2 && doonce == 1 ;playsound QSTToneSequenceFail ;showmessage CRISquadHeavyUnderCunstruction if CRISquadAssault < 6 ;Squadlimitation max. 6 units! set CRISquadAssault to (CRISquadAssault + 3) if CRISquadAssault > 8 playsound QSTToneSequenceFail showmessage CRISquadSoldierLimit set CRISquadAssault to 6 else ;showmessage CRISquadHeavyUnderCunstruction ;playsound QSTToneSequenceFail set CRISquadType to 2 placeatme CRISquadVertibirdTransportHeavy 1 player.additem CRISquadRadioTransceiver 1 playsound CRISquadRadioSummonSoldiers endif else playsound QSTToneSequenceFail showmessage CRISquadSoldierLimit endif ;==========================Hero Menu============================================= elseif button == 3 && doonce == 1 && CRISquadHeroOnlyOnce == 0 showmessage CRISquadRadioHeoresMessage set doonce to 2 player.additem CRISquadRadioTransceiver 1 ;If there is a hero, no heroes can be summoned ;====================================== elseif button == 3 && doonce == 1 && CRISquadHeroOnlyOnce == 1 playsound QSTToneSequenceFail player.additem CRISquadRadioTransceiver 1 showmessage CRISquadHeroesLimit ;Cancel Heromenu ;=============== elseif button == 0 && doonce == 2 ;player.additem CRISquadRadioTransceiver 1 playsound QSTToneSequenceFail ;Summon CRI Hunter ;================= elseif button == 1 && doonce == 2 playsound CRISquadRadioSummonSoldiers set CRISquadHeroType to 1 placeatme CRISquadVertibirdTransportHero 1 set CRISquadHeroOnlyOnce to 1 ;Summon Master Akayama ;===================== elseif button == 2 && doonce == 2 playsound CRISquadRadioSummonSoldiers set CRISquadHeroType to 2 placeatme CRISquadVertibirdTransportHero 1 set CRISquadHeroOnlyOnce to 1 ;==========================Hero Menu end=========================================== ;CRI Crate ;============== elseif button == 4 && doonce == 1 playsound CRISquadRadioSummonSoldiers player.additem CRISquadRadioTransceiver 1 placeatme CRISquadVertibirdTransportCrate 1 ;Dismiss SQUAD ;============== elseif button == 5 && doonce == 1 set CRISquadType to 6 placeatme CRISquadVertibirdTransport 1 player.additem CRISquadRadioTransceiver 1 set CRISquadAssault to 0 set CRISquadHeroOnlyOnce to 0 set CRISquadTeam to 0 set CRISquadAlpha to 0 set CRISquadBravo to 0 endif end begin scripteffectfinish set CRISquadDismiss to 0 ;player.additem CRISquadRadioTransceiver 1 end scn CRISquadAssaultSoldierBravoScript ;Variables ;======== short doOnceGetClothes short WeaponPercent short HeadgearPercent float timer short usingpistol ;short mk23using short setteamcountonce Begin GameMode ;setting teamcount. To spawn bravo team properly ;==================================== if setteamcountonce == 0 set CRISquadBravo to (CRISquadBravo + 1) set setteamcountonce to 1 endif ;Equipping holster if mk 23 pistol in in inventory ;======================================= if doOnceGetClothes == 0 ;Script for equipping holster which is rigged on the back ;=============================================== if getequipped CRISquadAssaultArmorMod2bravo == 1 additem CRISquadWalsterPistolSD 1 1 equipitem CRISquadWalsterPistolSD 0 1 endif if getequipped CRISquadAssaultArmorBravo == 1 additem CRISquadHolster1PistolBack 1 1 equipitem CRISquadHolster1PistolBack 0 1 endif set doOnceGetClothes to 1 endif ;======================Drug Effects===================================== ;Regeneration ;============ If CRISquadDrugEffect ==1 && CRISquadDrugEffectOnce == 1 PlayIdle 3rdP2HHStimpak if IsIdlePlaying == 1 playsound NPCHumanUsingPsycho set CRISquadDrugEffectOnce to 0 endif ;Adrenaline ;=========== elseif CRISquadDrugEffect ==2 && CRISquadDrugEffectOnce == 1 PlayIdle 3rdP2HHStimpak if IsIdlePlaying == 1 playsound NPCHumanUsingPsycho set CRISquadDrugEffectOnce to 0 endif endif ;IF there is no medic remove all drug effects ;==================================== if CRISquadMedicChosen == 0 ;IF there is no medic remove all drug effects set CRISquadDrugEffect to 3 ;On Dismmiss all Drug effects will be removed from player ;============================================== player.removespell CRISquadAdrinalineEffect player.removespell CRISquadNoDrugsEffect player.removespell CRISquadRegenEffect endif ;========================Dug Effects End==================================== ;Equipping MK23 halster ;==================== if doOnceGetClothes == 0 && getequipped CRISquadAssaultArmorMod2 == 1 additem CRISquadWalsterPistolSD 1 1 equipitem CRISquadWalsterPistolSD 0 1 elseif doOnceGetClothes == 0 && getequipped CRISquadFullTacticalMask == 1 additem CRISquadMask 1 1 equipitem CRISquadMask 0 1 endif set doOnceGetClothes to 1 ;===========Switching between AI Packages (Group Commands)==================== if GetIsCurrentPackage CRIFollowIndividualShort !=1 && GetIsCurrentPackage CRIFollowIndividualLong != 1 && GetIsCurrentPackage CRIFollowIndividualWait != 1 ;refreshes AI Packages avery 3 seconds ;=============================== if timer < 3 set timer to timer + GetSecondsPassed else ;3 seconds have passed, do something special ;Group Waiting ;============ if CRISquadFollowingDistanceGroup == 2 evp ;Group Long Distance ;================= elseif CRISquadFollowingDistanceGroup == 1 evp ;Group Long Distance ;================= elseif CRISquadFollowingDistanceGroup == 0 evp endif set timer to 0 endif endif ;If the player moved too far away and the soldier is not dead the soldier will be automaticaly moved to player ;======================================================================================== if Getdistance Player > 5000 && getdead==0 && CRISquadFollowingDistanceGroup != 2 && GetIsCurrentPackage CRIFollowIndividualWait != 1 moveto player endif ;Sneacking too if the player is sneacking ;================================ if player.IsSneaking == 1 SetForceSneak 1 else SetForceSneak 0 endif ;Dismissing the squad ;=================== if CRISquadDismiss == 1 set CRISquadMedicChosen to 0 ;On Dismmiss all Drug effects will be removed from player ;============================================== player.removespell CRISquadAdrinalineEffect player.removespell CRISquadNoDrugsEffect player.removespell CRISquadRegenEffect disable endif ;=====================Switching between AI Packages End=========================== ;Testing Squad Count. If global variable was resetet coz of reloading the game or smg it sets it back to right value. ;If Soldier is alive but globel is zero it add 1 count ;=========================================================================================== ;if CRISquadAssault ==0 ; set CRISquadAssault to (CRISquadAssault +1 ) ;endif End GameMode begin OnStartCombat ;Allows CRIs to talk to player during the battle ;==================================== SetPlayerTeammate 1 end begin ondeath ;teamcount -1 ;=============== set CRISquadBravo to (CRISquadBravo - 1) ;Squad count, as soon as CRISquadAssault is aqual 0 you may spawn squad again. ==================================================================== set CRISquadAssault to (CRISquadAssault - 1) ;As soon as medic is dead you cant hire new one ======================================= if GetEquipped CRISquadMedicArmor ==1 set CRISquadMedicChosen to 0 ;If medic dies all drug effects will be removed from player player.removespell CRISquadAdrinalineEffect player.removespell CRISquadNoDrugsEffect player.removespell CRISquadRegenEffect endif ;There is a bud in the game where the compagnons holding the weapon very strange after moving to aq new space (quick travel) ;here is the solutin. ;=================================================================================== if IsPlayerMovingIntoNewSpace == 1 evp endif end scn CRISquadVertibirdTransportAssaultScript short DoOnce short timer short hero short squad ;short Heavysquad ;short Dismiss ; The chain will be activated by setting DoOnce to 1 via a external script ; ;**************************************** Begin gameMode ;Depending on CRISquadType variable chosing the right squad to spawn. if CRISquadType == 1 ;Assault set squad to 1 elseif CRISquadType == 6 set squad to 6 endif ;linkedRef = me if (doOnce == 0) set timer to 1 set doOnce to 2 setangle x 0 setangle y 0 elseif (doOnce == 2) if (timer <= 0) if ( HasLoaded3D != 0 ) playgroup Forward 0 set doOnce to 3 endif else set timer to timer - GetSecondsPassed endif elseif (doOnce == 3) if (isAnimPlaying Forward == 0) set timer to 3 ; 3 seconds while vertibird is on ground before it enables its xmarker set doOnce to 4 endif elseif (doOnce == 4) if (timer <= 0) ;if (linkedRef.getDestroyed == 0) ; Spawn Assault Soldiers! ;===================== If squad == 1 ;Spawn Team Alpha ;==================================================== if CRISquadTeam == 0 set crisquadteam to 1 ;Squad Units limitation max. 6 if CRISquadAssault == 8 ;spawning alpha or bravo teamate depending on which is dead ;================================================== if crisquadAlpha == 2 placeatme CRISquadAssaultSoldier1 1 2 4 elseif crisquadBravo == 2 placeatme CRISquadAssaultSoldier1Beta 1 2 4 endif set CRISquadAssault to 6 ;============================================================================ elseif CRISquadAssault == 7 if crisquadAlpha == 1 && crisquadBravo == 3 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 0 4 endif if crisquadAlpha == 2 && crisquadBravo == 2 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 endif if crisquadAlpha == 3 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1beta 1 2 4 placeatme CRISquadAssaultSoldier2beta 1 2 4 endif ;============================================================================= set CRISquadAssault to 6 else ;============================================================================ if crisquadAlpha == 3 && crisquadBravo == 0 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 0 4 placeatme CRISquadAssaultSoldier3Beta 1 1 4 endif if crisquadAlpha == 2 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier1 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 2 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier1 1 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 3 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier3 1 2 4 endif ;===== if crisquadAlpha == 2 && crisquadBravo == 0 ;placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier3Beta 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1 1 2 4 ;placeatme CRISquadAssaultSoldier2 1 2 4 ;placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 0 ;placeatme CRISquadAssaultSoldier1 1 2 4 ;placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier3Beta 1 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier3 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 0 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier3 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 ;placeatme CRISquadAssaultSoldier1Beta 1 2 4 ;placeatme CRISquadAssaultSoldier3Beta 1 2 4 endif ;============================================================================ endif ;Spawn Team Beta ;=================================================== elseif CRISquadTeam == 1 set crisquadteam to 1 ;Squad Units limitation max. 6 if CRISquadAssault == 8 ;spawning alpha or bravo teamate depending on which is dead ;================================================== if crisquadAlpha == 2 placeatme CRISquadAssaultSoldier1 1 2 4 elseif crisquadBravo == 2 placeatme CRISquadAssaultSoldier1Beta 1 2 4 endif set CRISquadAssault to 6 ;============================================================================ elseif CRISquadAssault == 7 if crisquadAlpha == 1 && crisquadBravo == 3 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 0 4 endif if crisquadAlpha == 2 && crisquadBravo == 2 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 endif if crisquadAlpha == 3 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1beta 1 2 4 placeatme CRISquadAssaultSoldier2beta 1 2 4 endif ;============================================================================= set CRISquadAssault to 6 else ;============================================================================ if crisquadAlpha == 3 && crisquadBravo == 0 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 0 4 placeatme CRISquadAssaultSoldier3Beta 1 1 4 endif if crisquadAlpha == 2 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier1 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 2 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier1 1 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 3 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier3 1 2 4 endif ;===== if crisquadAlpha == 2 && crisquadBravo == 0 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 ;placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier3Beta 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 endif if crisquadAlpha == 1 && crisquadBravo == 0 ;placeatme CRISquadAssaultSoldier1 1 2 4 ;placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier3Beta 3 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 1 placeatme CRISquadAssaultSoldier1 1 2 4 placeatme CRISquadAssaultSoldier2 1 2 4 placeatme CRISquadAssaultSoldier3 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 ;placeatme CRISquadAssaultSoldier2Beta 1 2 4 endif if crisquadAlpha == 0 && crisquadBravo == 0 ;placeatme CRISquadAssaultSoldier1 1 2 4 ;placeatme CRISquadAssaultSoldier2 1 2 4 ;placeatme CRISquadAssaultSoldier3 1 2 4 placeatme CRISquadAssaultSoldier2Beta 1 2 4 placeatme CRISquadAssaultSoldier1Beta 1 2 4 placeatme CRISquadAssaultSoldier3Beta 1 2 4 endif ;============================================================================ endif endif elseif squad == 6 set CRISquadDismiss to 1 set CRISquadAlpha to 0 set CRISquadBravo to 0 endif set timer to 2 ; 2 seconds before vertibird will take off set doOnce to 5 ;else ; set doOnce to 7 ;endif else set timer to (timer - GetSecondsPassed) endif elseif (doOnce == 5) if (timer <=0) if (getDestroyed == 0) playgroup backward 0 set doOnce to 6 else set doOnce to 7 endif else set timer to (timer - GetSecondsPassed) endif elseif (doOnce == 6) if (isAnimPlaying Backward == 0) && (getDestroyed == 0) disable ;disable the vertibird when it's done playing its backward animation markfordelete set doOnce to 7 endif endif End Link to comment Share on other sites More sharing options...
davidlallen Posted February 9, 2011 Share Posted February 9, 2011 I have done something similar to spawn either three enemies or four, but never more. Rather than using placeatme (which dynamically adds objects to the game) I added the four enemies to the game as specific NPCs which are initially disabled. All four of these have reference ID's so that I can enable them or disable them. So I enable three, and if certain conditions are met I enable the fourth. If I needed to disable them at some point I can do that by name. Will this type of technique help? Link to comment Share on other sites More sharing options...
AlexScorpion Posted February 9, 2011 Author Share Posted February 9, 2011 at this point anything will help Link to comment Share on other sites More sharing options...
Skevitj Posted February 10, 2011 Share Posted February 10, 2011 Yeah, I'd also recommend using persistent actors and moveto instead of placeatme. That said, the current scripting handles it fine (apart from a missing markfordelete in the solder's dismiss section of the script), but being able to refer to individual group member by a persistent name should make keeping track of them all a lot easier (and neater). The main bit which stands from what I've seen so far is:;Testing Squad Count. If global variable was resetet coz of reloading the game or smg it sets it back to right value.;If Soldier is alive but globel is zero it add 1 count;===========================================================================================;if CRISquadAssault ==0; set CRISquadAssault to (CRISquadAssault +1 );endifAs far as I understand, all that will achieve is setting CRISquadAssault to 1 if it's ever 0 (while a soilder is active), no matter how many soldiers are active. Scripts are run sequentially, not parallel, so only one will see the 0. Using persistant NPCs should make it trivial to reset the value though, as they can number off directly. If you're not against using NVSE, and are using persistent NPCs, that massive block of code in the CRISquadVertibirdTransportAssaultScript dealing with the placement of new troops just simplified to a 3-4 line loop to enable the first disabled reference in a list of 6 (per troop type, using the list walking and loop functions). Link to comment Share on other sites More sharing options...
AlexScorpion Posted February 10, 2011 Author Share Posted February 10, 2011 thanks ... i'm not against NVSE but i won't use untill it's really needed ... i was able to make some working scripts so you can ignore everything posted above bump again now i'm trying to make my squad switch weapons on command and have no luck :( i've set up a global variable so that id the variable == 0 equip weapons 1 and if variable > 0 equip weapons 2 i have to scripts running 1 menu based and the other is attached to a trooper it looks like this the variable is at the bottom of the trooper script scn AlexSquadCommandsScript int ibutton Begin OnEquip showmessage AlexSquadCommandMessage end Begin GameMode set iButton to GetButtonPressed if iButton == -1 ;noone knows what it means return elseif iButton == 0 ;cancel the menu playsound WPNAlienBlasterFire2D elseif iButton == 1 ;Make your Squad use silenced weapons set AlexSquadweaponchange to 1 elseif iButton == 2 ;make your squad use regular weapons set AlexSquadweaponchange to 0 endif end scn AlextrooperTrooperAssaultScript begin gamemode ;by dismissing the current squad you're resetting the restriction on summoning more troops ========================================================================== if AlexSquadDisableAssault > 0 set AlexSquadDisableAssault to AlexSquadDisableAssault -1 Disable MarkForDelete endif end ;if one soldier died you will be able to summon another to replace him ========================================================= Begin OnDeath set AlexSquadToManySummoned to (AlexSquadToManySummoned - 1) endif end Begin Gamemode if AlexSquadweaponchange == 0 equipitem AlexAssaultCarbine 1 elseif AlexSquadweaponchange > 0 equipitem AlexSilentSMG 1 endif end thanks in advance peeps Link to comment Share on other sites More sharing options...
Skevitj Posted February 11, 2011 Share Posted February 11, 2011 (edited) A better way to do it is to set up a doonce check in the troopers script which will trigger the block. That way you can do removeitem old -> additem new -> equip new once per change in the variable instead of the game trying to re-equip a particular weapon every frame. Something like this: if AlexSquadweaponchange == 0 && !getequipped AlexAssaultCarbine removeitem AlexSilentSMG 1 additem AlexAssaultCarbine 1 equipitem AlexAssaultCarbine elseif AlexSquadweaponchange > 0 && !getequipped AlexSilentSMG removeitem AlexAssaultCarbine 1 additem AlexSilentSMG 1 equipitem AlexSilentSMG 1endif I've been doing a fair amount of C programming lately, so I doubt my syntax is correct, but you get the idea. Having something repeat its function every frame is usually a bad idea, as opposed to something which checks if it needs to make a change, then makes the change and fails on subsequent calls (untill another change is signaled). PS. As an afterthought, I've never tried 'cause I've always assumed it wouldn't work properly, but you aren't running two gamemode blocks are you? The second is just to show there things are? Edited February 11, 2011 by Skevitj Link to comment Share on other sites More sharing options...
Recommended Posts