Jump to content

OnTriggerEnter and OnTriggerLeave script help request


jet4571

Recommended Posts

I made a spa for the player and NPC's to enjoy and would like an automatic swap to bathing suits script for it and because scripting to me looks like gibberish and the tutorials explain things to people who are familiar with scripting(Not me) I am at a complete loss. Script below and probably a complete disaster.

 

 

begin OnTriggerEnter TriggeringRefID
    AddItem AASpaStripArmor 1 1
    AddItem AASpaStripWeapon 1 1
    EquipItem AASpaStripArmor 0 1
    EquipItem AASpaStripWeapon 0 1
End
 
begin OnTriggerLeave TriggeringRefID
    RemoveItem AASpaStripArmor 99
    RemoveItem AASpaStripWeapon 99
End

 

If I change TriggeringRefID to player it should be for the player only but I don't want just the player, I want anyone who enters the spa to equip the bathing suit and probably exclude the player, they can swap outfits on their own.

 

I can do this same exact function in Skyrim and the below link is exactly what I want but no clue on Fallout 3.

http://www.nexusmods.com/skyrim/mods/49878/

Edited by jet4571
Link to comment
Share on other sites

Hm... I have a script kinda like what you're trying to do in one of my NV mods. It makes NPCs equip a piece of armor if they have it - otherwise it gives it to them and then forces them to equip it. It's only for NPCs I think, haven't tested it with the player (they are required to equip the armor before they can activate the door to enter the area), but as you say, the player can always do it themselves manually.

scn ForceOutfitScript

ref obj                                        ; internal reference name for companion/NPC

Begin onTriggerEnter  
set obj to GetActionRef                        ; make "obj" refer to the companion/NPC
if obj.GetItemCount CustomArmor >= 1           ; if they have the armor in their inventory, equip it
obj.EquipItem CustomArmor 0 1
else                                           ; if they don't have it, give one and then equip
obj.AddItem CustomArmor 1                     
obj.EquipItem CustomArmor 0 1
endif

end

I figure it would be easy to just add an OnTriggerLeave block with reverse code (RemoveItem and UnequipItem). Hope that helps a bit :smile:

Link to comment
Share on other sites

Thanks Jokerine that will help. What I am making has allot of new custom models that will be a mod resource. Well what I am doing is really a mod resource just will be playable. I want the spa fully functional so when someone uses it they can see how it works, sitting in water, NPC's wearing a bathing suit when they enter. I have new lights, ported over my Skyrim painting resource, made new fireplaces, a wardrobe, new toilet that you sit on instead of drink from, new bathroom medicine cabinet mirror(not really mirror) and some new building kit pieces for the suburban interiors that allows you to have a second floor landing where the stairs are. Fun stuff you would probably use in your own mods.

 

 

*edit

 

I made some changes to the script and it works on the player as well. I also wanted the weapon removed and adding another if in the same section threw up errors so I removed the "If they already have one" part and just did add and equip. Currently the bathing suit is the vanilla body and the weapon is a tiny invisible cube melee weapon that does 1 damage. both weigh zero so if the 99 remove doesn't work your NPC's wont get a whole lot of stuff that will overencumber if you remove to toss in a trash can. And removing 99 of them wont hurt because the bathing suit and weapon is unique specifically for the spa. If it's something that is normally used and worth some caps it can be a unique version of that armor and weapon.

 

Also when leaving I added an ingestible that heals you, in this case an ice cold Nuka that doesn't have radiation.

 

 

scn AASpaStripScript
 
ref obj                                        ; internal reference name for companion/NPC
 
Begin onTriggerEnter 
 set obj to GetActionRef                        ; make "obj" refer to the companion/NPC                                 
   obj.AddItem AASpaStripArmor 1 1                  
   obj.EquipItem AASpaStripArmor 0 1
   obj.AddItem AASpaStripWeapon 1 1
   obj.EquipItem AASpaStripWeapon 0 1
 endif
end
 
begin OnTriggerLeave
 set obj to GetActionRef                                                             
   obj.RemoveItem AASpaStripArmor 1 1                  
   obj.RemoveItemAASpaStripWeapon 1 1
   obj.AddItem AAIceNukaCola 1 1
   obj.EquipItem AAIceNukaCola 0 1
 endif
end
**Edit

 

Upon further study and looking at something else I managed to get it to equip what you were wearing when you leave the spa. Requires FOSE. It remembers what armor and weapon you had equipped and reequips them when you leave. It still adds the fake weapon because I don't trust NPC's to not equip the one they use. So this should allow players and NPC's to come and go into the spa and equip properly and not remove your weapon from a hotkey.

 

scn AASpaStripScript

ref obj                                        ; internal reference name for companion/NPC
ref gear
ref weap

Begin onTriggerEnter  
 set obj to GetActionRef                        ; make "obj" refer to the companion/NPC                                  
   set gear to obj.GetEquippedObject 2
   set weap to obj.GetEquippedObject 5
   obj.unequipitem gear 1 1 
   obj.unequipitem weap 1 1 
   obj.AddItem AASpaStripArmor 1 1
   obj.EquipItem AASpaStripArmor 0 1
   obj.AddItem AASpaStripWeapon 1 1
   obj.EquipItem AASpaStripWeapon 0 1
 endif
end

begin OnTriggerLeave
 set obj to GetActionRef
   obj.equipitem gear 1 1 
   obj.equipitem weap 1 1                                                              
   obj.RemoveItem AASpaStripArmor 1 1 
   obj.RemoveItem AASpaStripWeapon 1 1                    
   obj.AddItem AASpaBonus 1 1
   obj.EquipItem AASpaBonus 0 1
 endif
end
Yay working scripts and I am clueless on how it does what it does and couldn't have figured this out without help... Again Thanks Jokerine. Edited by jet4571
Link to comment
Share on other sites

Not a problem buddy. Glad to hear my crappy little script was of use! I've never used FOSE so you're already surpassing my knowledge, haha. Looking forward to the new resources! :dance:

Link to comment
Share on other sites

The *bleep* I am surpassing you script wise! I cannot craft my own scripts at all, I need a fully functioning script to start with then I can modify it to suit my purposes after hours of trial and error. The first scrip snippet in this thread is the result of me scripting and only the script name line was omitted. Yes I am that bad lol.

Anyway uploading a preview of the resource as it is right now and will PM you the link. It is named JustAHouse and is on the opposite side of the bridge into Bigtown at Bigtown, no map marker right now and errors in the quick and dirty navmesh. If you are entering Bigtown you can see the house from the bridge. Inside is a basic layout of an interior but there are 2 tubs on the landing above the living room that are sit markers that I was testing. Trying different sit animations to see if I can get the legs to not clip through the bottom of the tub but I don't think it will be possible without either a new sit animation or a special built body that the calves and feet are vertice weighted to the same bones as the thighs so they stick straight out rather than down.

Anyway you can take a look at the new stuff and give suggestions during the development process and maybe a request or two can be done.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...