puddlepond Posted March 24 Share Posted March 24 (edited) i'm making a companion. i put this block in their npc script (with a bunch of other blocks that do fire correctly, like the OnCombatEnd block that resets their health and stuff) and none of it works (except part of it, maybe, sort of) Quote short HasBeenHired short L38 short DoOnce short bJimmyKilledByRobots ;condition for the relevant death line int CombatStyleRanged int CombatStyleMelee int IsFollowingDefault int IsFollowingLong int FollowerSwitchAggressive int Waiting ref rKiller BEGIN OnDeath Set rKiller to (aaJimmyCompanion.GetKiller) If rKiller.GetIsCreatureType 6 == 1 Set bJimmyKilledByRobots to 1 EndIf If HasBeenHired == 1 Set HasBeenHired to 0 Player.RemovePerk aaJimmyCompanionPerk ShowMessage aaJimmyFollowerMessagePerkRemove ShowMessage aaJimmyFollowerMessageDead set VNPCFollowers.bHumanoidInParty to 0 Set VNPCFollowers.nCurrentFollowers to (VNPCFollowers.nCurrentFollowers - 1) If VNPCFollowers.nCurrentFollowers == 0 Set VNPCFollowers.bPlayerHasFollower to 0 EndIf EndIf END there's a few things i'd like to fix but what i'm most concerned with is the fact that nothing after "If HasBeenHired == 1" happens at all; his perk is never removed, none of the VNPCFollowers variables are updated, nothing. hiring jimmy sets HasBeenHired to 1 and there's a bunch of dialogue that relies on that being true that works fine, so that's not the issue. as far as i can tell my script is near-identical to the OnDeath blocks for vanilla companions so i don't know what i'm doing wrong. there's another less-pressing matter i'd like sorting out and that's the "bJimmyKilledByRobots" section. i want jimmy to have a unique death groan for if he's killed by a robot, so i added one in his dialogue quest under the "death" topic in the "combat" tab with the condition that the "bJimmyKilledByRobots" variable must equal 1. he never says it, is the thing. what's interesting is that he never says any of his other 2 death groans either even though they work fine when he's killed by anything other than a robot. they're set up with their only conditions being the "GetIsID NPC: 'aaJimmyCompanion'" thing that all his lines have, so it's interesting to me that he doesn't use them when he's killed by a robot when he's not using his special killed-by-a-robot line either, he's just silent. i'd massively appreciate any help in figuring this out. edit: i tried changing setting up the killed by robots line as a regular topic and changing the relevant part of the script to this. Quote BEGIN OnDeath Set rKiller to (aaJimmyCompanion.GetKiller) If rKiller.GetIsCreatureType 6 == 1 Set bJimmyKilledByRobots to 1 aaJimmyCompanionREF.Say aaJimmyKilledByRobotsDeath EndIf it doesn't work. i'm guessing the issue with this new script and the old one is that they can't pass their variables along fast enough in the instant between jimmy dying and jimmy saying his death line for it to have any effect, but i don't know how i'd fix that. i had a similar issue getting him to respond to being given cigarettes in the dialogue quest script that i fixed with SetQuestDelay, but this isn't a quest script so that's not an option. i think the issue might be having to wait for fDyingTimer? i think i could get around that by moving all the bJimmyKilledByRobots variable switching to a JohnnyOnDyingEventHandler, but that still doesn't solve the main issue that none of the OnDeath block works, not just the parts to do with this very specific voice line. edit deux: moving the bJimmyKilledByRobots section to a Johnny event handler fixed the main issue, when Jimmy dies his perk is removed and the relevant variables are updated. he still doesn't say his special death line for being killed by robots. i tried moving the line to a regular topic again and scripting him to say it as part of the event handler but that didn't work either. here's my handler script and function in case there's a mistake i've missed. also i moved the bJimmyKilledByRobots variable to the dialogue quest script since the companion script now wasn't using it at all. Quote scn aaJimmyDeathHandlerScript BEGIN GameMode if GetGameLoaded SetJohnnyOnDyingEventHandler 1 aaJimmyDeathHandlerFunction 0 aaJimmyCompanion EndIf END Quote scn aaJimmyDeathHandlerFunction ref rJimmy ref rKiller BEGIN Function { rJimmy } Set rKiller to aaJimmyCompanion.GetKiller If rKiller.GetIsCreatureType 6 == 1 Set aaJimmyDialogue.bJimmyKilledByRobots to 1 aaJimmyCompanionREF.Say aaJimmyKilledByRobots EndIf END edit trois: i got rid of the death event handler. i tried adding these blocks to his companion script. i figured they'd be less accurate in determining whether he was actually killed by robots but they might have a better chance of actually working. they don't, and i don't know what's wrong. i also moved the killed by robots variable back to the companion script and made sure the death topic conditions reflected that, so that's not the issue. Quote ref rCombatant BEGIN OnStartCombat rCombatant If rCombatant.GetIsCreatureType 6 == 1 Set bJimmyKilledByRobots to 1 EndIf END BEGIN OnCombatEND If aaJimmyCompanionREF.GetDead == 0 Set bJimmyKilledByRobots to 0 EndIf END Edited March 25 by puddlepond Link to comment Share on other sites More sharing options...
Radioactivelad Posted April 4 Share Posted April 4 If your script is saving, then your code is fine and the issue is elsewhere. Do you have dialogue audio in place? Subtitles can be unreliable with non-conversation dialogue. The Say function has a flag to force subtitles to always appear, do that just to be absolutely sure it's not working. Combat topics are unreliable in general though, even more so when you're quickly modifying and checking conditions. You might try a smoke and mirrors approach by having the player's character say the line instead. (this would also ensure it's always heard as well.) Link to comment Share on other sites More sharing options...
sullyvanj93 Posted April 4 Share Posted April 4 Something that has helped me OH SO VERY MUCH when figuring out which part of my script isn't working right is adding in PrintC commands within the different chains you're setting up. Try something like Begin OnDeath printC "Is Dead" *rest of script* and see if the printC command fires correctly, listing your "Is Dead" message in the in-game console. If that's firing, that means the script is recognizing that the NPC did in fact die, and you can move on to the next block, maybe an IF variable. If it didn't print your command after the initial OnDeath, I would say your script isn't attached to the NPC correctly somehow. You can even add a handful of them at once, so it's not quite so tedious of trial and error. Figuring out which part of the script seems to be hanging up can be vital for diagnosing and treating your issues. Link to comment Share on other sites More sharing options...
puddlepond Posted April 5 Author Share Posted April 5 moved back to an event handler and a dedicated topic. here's the function: Quote scn aaJimmyDeathHandlerFunction ref rJimmy ref rKiller BEGIN Function { rJimmy, rKiller } Set rKiller to aaJimmyCompanionREF.GetKiller Print $wahoo1 Print $wahoo2 If rKiller.GetIsCreatureType 6 == 1 Print $wahoo3 Set aaJimmyCompanionREF.bJimmyKilledByRobots to 1 Print $wahoo4 aaJimmyCompanionREF.Say aaJimmyKilledByRobots 1 Print $wahoo5 EndIf END all the wahoos fire but jimmy doesn't say his line. if i'm understanding it correctly wahoo5 should only print after he says his line, but he doesn't and it does anyway. maybe it's just an issue with the subtitles; none of his lines are voiced yet and this is a relatively minor issue, so maybe it'll be easier to fix when i don't have to rely solely on subtitles to know if it's working. Link to comment Share on other sites More sharing options...
sullyvanj93 Posted April 5 Share Posted April 5 (edited) Actually, wahoo5 would fire after the game attempted to say his line, but whether it did or not would not have any affect on the outcome of the Print command. You could put the Wahoo5 print command within the Result Script of the dialogue line itself to see if he is truly saying his line or not? Or just record a test line yourself as a placeholder to see if it comes through in game. The fact that wahoo3 is firing is a good sign, that the script itself seems to be doing what you want it to with the event handler reading your killer properly. I would suggest changing how the wahoos are placed, however. Have additional IF checks, so you know if each piece is firing correctly. Something like this: Set rKiller to aaJimmyCompanionREF.GetKiller Print $wahoo1 If rKiller.GetIsCreatureType 6 == 1 Print $wahoo2 Set aaJimmyCompanionREF.bJimmyKilledByRobots to 1 if aaJimmyCompanionREF.bJimmyKilledByRobots == 1 Print $wahoo3 Set aaJimmyCompanionREF.Say aaJimmyKilledByRobots TO 1 (try to keep the same command format, for your own sanity, and any bystanders as well. Doesn't matter which one, but keep to one if possible) if aaJimmyCompanionREF.Say aaJimmyKilledByRobots == 1 Print $wahoo4 EndIf endif endif END Edited April 5 by sullyvanj93 Link to comment Share on other sites More sharing options...
puddlepond Posted April 6 Author Share Posted April 6 (edited) i can't set "Say" to 1 and i'm not trying to. the 1 after "aaJimmyCompanionREF.Say aaJimmyKilledByRobots" is a flag in the "Say" function that forces subtitles on, it's not a variable that i'm tracking. i took your advice and added a bunch more checks and moved $wahoo5 to the dialogue result script. $wahoo5 doesn't print, but every other $wahoo in this script does. Quote ref rJimmy ref rKiller short bSaidTheLineBart BEGIN Function { rJimmy, rKiller } Set rKiller to aaJimmyCompanionREF.GetKiller Print $wahoo1 If rKiller.GetIsCreatureType 6 == 1 Print $wahoo2 Set aaJimmyCompanionREF.bJimmyKilledByRobots to 1 If aaJimmyCompanionREF.bJimmyKilledByRobots == 1 Print $wahoo3 aaJimmyCompanionREF.Say aaJimmyKilledByRobots 1 Set bSaidTheLineBart to 1 If bSaidTheLineBart == 1 Print $wahoo4 EndIf EndIf EndIf END Edited April 6 by puddlepond Link to comment Share on other sites More sharing options...
sullyvanj93 Posted April 6 Share Posted April 6 If everything in the script is firing, but the line is not being said, then that's where the disconnect is. Are there any conditions of the dialogue line that are not being met? Is the dialogue line marked "say once"? Everything pointing to the correct place within that dialogue quest? Link to comment Share on other sites More sharing options...
puddlepond Posted April 7 Author Share Posted April 7 (edited) the only conditions are the GetIsID condition that all his lines have and the GetScriptVariable condition checking that bJimmyKilledByRobots == 1. i tried removing both of them and it didn't make a difference. it's only marked as "Goodbye". i don't know what the last question means; this line is set up identically to every other line. i tried moving the topic under "Conversation" and "Combat" just in case that did anything (remembering to print $wahoo5 in the result script) and it didn't. i tried moving back to the Death topic and setting up the GetIsID condition paired with a GetIsCreatureType condition that runs on the combat target, and that didn't work either. Edited April 7 by puddlepond Link to comment Share on other sites More sharing options...
Recommended Posts