nekollx Posted June 22, 2013 Share Posted June 22, 2013 So been wathing the totorials and well I'm coding a game from scratch in Java 7 so the scripting doesn't even remotely scare me but i've run into a couple of problems finding where to put the scripts for the best effect. So here's my first question.I want to make the BB gun a viable weapon for those of us Vault dwellers who don't want to be cold blooded killers right out of the vault, those guards after all were your friends. So i want to attach a script that if you kill someone with the BB gun it knocks them unconscious instead. Would this be a quest script? Object? See anything off about my code? Right now I'm thinking it would look something like this begin OnhitWith <what the id for a BB, or do i need the ID for the bbGun an any variants?>if (onDeath == true)if (target.IsEssential != 1);//only change flag if their not already essential by default to prevent breaking quest npcstarget.setEssential = 1;;need some kind of timer here before it altomaticallys changes essential back to 0endifif (onActivate == true && target.IsEssential == 1); now long as their essential lets openingthe inventory on interacting with them target.OpenInventoryendifendifend Any help refining my script would be appreciated. Link to comment Share on other sites More sharing options...
pkleiss Posted June 22, 2013 Share Posted June 22, 2013 (edited) First, the OnHitWith block uses the weapon ID, not the projectile. So it would be: Begin OnHitWith WeapBBGun (unless you make your own BBGun for this mod) Second, the OnHitWith Block runs on the NPC being hit, so you'd have to install that script on all potential targets of the BB gun - not very practical and completely conflicting to many other mods. Then, Quest scripts run inside quests, effect scripts run inside effects and object quests run on just about everything else, like NPCs and items. This is a tricky script you want because you can't just add it to every NPC in the game. Instead, you would have to run it on the BB gun and hope to be able to discern the target of the BB - which is very problematic in Fallout 3. I think the best way to do this would be to add an object effect to the BB Gun which uses a script effect. That effect would be to make the recipient essential (if not already) for a timed duration which is defined by the Object effect duration field. The thing about effect scripts is they only have two code blocks: ScriptEffectStart and ScriptEffectFinish, so handling a time is not possible from within the script as there is no GameMode blocks allowed.. scn BBgunNoKillScript (effect script type)ref myselfShort NotGameEssentialBegin ScriptEffectStart set myself to GetSelf If myself.IsEssential == 0 SetEssential Myself 1 Set NotGameEssential to 1 EndIfEnd Begin ScriptEffectFinnish If NotGameEssential SetEssential Myself 0 Set NotGameEssential to 0 EndIfEnd The trick here is to guess properly just how long to make the effect last. Plus, if the target gets attacked by some other means, they still can't be killed until the effect wears off. Also, the NotGameEssential is a check to insure that the effect doesn't remove the essential flag on NPCs that are supposed to be essential. In other words, the effect will only be removed from targets who (1) were not essential prior to being shot by the BB gun and (2) were made essential by the script start portion of the script. Understand that you could hit the same target twice with the BB gun and it would only be essential on the second shot and that is different from a target that is always supposed to be essential. The last caveat is that I haven't scripted for about three years, so I may be rusty. Regardless, this needs to be tested. Finally, if this doesn't work, you may have to create an effect script which adds a token item to the target's inventory that then runs a script that DOES have a GameMode block and can run a timer before disabling and deleting itself. Edited June 22, 2013 by pkleiss Link to comment Share on other sites More sharing options...
nekollx Posted June 24, 2013 Author Share Posted June 24, 2013 so created the script and object effect, tied the object effect to the weapon but i can't find a way to actual tie the script to the objectEffect it doenst show up no matter what i do in the new ipions as a valid script to attach Link to comment Share on other sites More sharing options...
pkleiss Posted June 24, 2013 Share Posted June 24, 2013 (edited) In the upper right corner of the scripting window there is a drop down menu used to select the script type. In this case, you need to select effect (as opposed to Object or Quest). Then it will appear in the base effect choser. Edited June 24, 2013 by pkleiss Link to comment Share on other sites More sharing options...
nekollx Posted June 25, 2013 Author Share Posted June 25, 2013 looks like it was the positite i set it as a object effect (instead of just a effect) andi could tied the cript directly to the target. Now i'm tinkering with the object effect to see if there is a item in targets inventory but there doesn't seem to be a "if actor possesses" or similar but there doesnt seem to be one but there is a GetPerk but even if imake some sort o BBKO perk im not seing how that would gell with the attached object script. Maybe i should do it all in the object script itself, is there a codei can add to the script that would do something like: target.addItem BBToken and something else to the effect of begin OnWakeFromUnconsiousif (Target.hasitem BBToken)Target.setEssential 0target.remove item BBToken This would add the token on hit if they don't have it and remove it after they wake and sent them non essntial Then all i would need is a global script target ongamestartif (player.activate AND Target.hasitem BBToken)target.openinventory Link to comment Share on other sites More sharing options...
Recommended Posts