Bromm83 Posted April 11, 2012 Posted April 11, 2012 I am making a small mod where I need to turn a NPC into a friend for a while, then back to enemy. Will be used on several random NPC and don't want them to lose their factions or anything like that.. Any of you script geniouses willing to help me out?
Chase Roxand Posted April 11, 2012 Posted April 11, 2012 I don't have the GECK to throw together a script right now, but you could back up their disposition and aggression levels, set those to the most peaceful settings (100 disposition, 0 aggression), stop combat, then reset those values after some set amount of time. And put the script on a token so you can apply it to anyone.
Bromm83 Posted April 11, 2012 Author Posted April 11, 2012 I don't have the GECK to throw together a script right now' date=' but you could back up their disposition and aggression levels, set those to the most peaceful settings (100 disposition, 0 aggression), stop combat, then reset those values after some set amount of time. And put the script on a token so you can apply it to anyone. [/quote'] I didn't put it in a token just yet. How does this look so far? scn SexoutNGYieldQuestScript short sYield short sAgg short sDisp ref rYieldTo Begin GameMode if 0 != player.GetCombatTarget set rYieldTo to player.GetCombatTarget endif set sAgg to (rYieldTo.GetAV Aggression) set sDisp to (rYieldTo.GetDisposition player) if IsKeyPressed 38 != sYield set sYield to IsKeyPressed 38 if sYield ;Button pressed player.additem SexoutYieldToken 1 1 endif Label 1 if player.GetItemCount SexoutYieldToken > 1 player.Removeitem SexoutYieldToken 1 1 goto 1 endif endif if player.GetItemCount SexoutYieldToken > 0 rYieldTo.ModAV Aggression 0 rYieldTo.SetDisposition player 100 rYieldTo.Startconversation player, YieldMain endif End
Chase Roxand Posted April 11, 2012 Posted April 11, 2012 Err, not exactly what I meant. Don't know if this'll compile or not: scn SexoutNGYieldTokenScript short sYield short sAgg short sDesp ref rYieldTo float fTimer Begin GameMode if(sYield) if(rYieldTo.getCombatTarget == playerREF) rYieldTo.stopCombat playerREF endif if(fTimer < 20) set fTimer to fTimer + getSecondsPassed) else rYieldTo.setAV Aggression sAgg rYieldTo.setDisposition sDisp rYieldTo.removeItem SexoutNGYieldToken 1 endif else set sYield to 1 set rYieldTo to getContainer set sDisp to rYieldTo.getDisposition playerREF set sAgg to rYieldTo.getAV Aggression rYieldTo.setAV Aggression 0 rYieldTo.setDisposition playerREF 100 rYieldTo.stopCombat rYieldTo.startConversation playerREF, YieldMain endif End This way you can apply it just by adding the token. If you want to apply it to several enemies at once, you could include a variable in the quest script like "sInitConversation" and only start the conversation if that's set to 0 (and you'd set it to 1 on the line after "startConversation", then the "YieldMain" dialog would reset it to 0). EDIT: Timer code was backwards. Fixed it.
Guest Donkey Posted April 11, 2012 Posted April 11, 2012 why not just use startcombat and stopcombat commands ?? stopcombat forces even an hostile npc to stop fighting and resets the state. once startcombat commands is back it will resume what it was doing.
Chase Roxand Posted April 11, 2012 Posted April 11, 2012 why not just use startcombat and stopcombat commands ?? stopcombat forces even an hostile npc to stop fighting and resets the state. once startcombat commands is back it will resume what it was doing. Because of aggression and disposition. They'll start fighting again if those values are too low/high.
Bromm83 Posted April 11, 2012 Author Posted April 11, 2012 It mostly compiled Just a few small corrections. The script I posted was what started as a questscript, then got bogged down with other stuff... Then I'll just keep the buttonstuff in the questscript and make the button just place that token in the NPC instead.
Chase Roxand Posted April 11, 2012 Posted April 11, 2012 Make sure to fix the timer code, if you grabbed it before I fixed it. Also, here's what you could use for the conversation code (in the token script): if(SexoutNGYieldQuest.sInitConversation == 0) set SexoutNGYieldQuest.sInitConversation to 1 rYieldTo.startConversation playerREF, YieldMain endif Just add set SexoutNGYieldQuest.sInitConversation to 0 in the YieldMain conversation result script.
Bromm83 Posted April 11, 2012 Author Posted April 11, 2012 And this would work as a quest script to fire it all off? scn SexoutNGYieldQuestScript short sYield ref rYieldTo Begin GameMode if 0 != player.GetCombatTarget set rYieldTo to player.GetCombatTarget endif if IsKeyPressed 38 != sYield set sYield to IsKeyPressed 38 if sYield ;Button pressed rYieldTo.additem SexoutNGYieldToken 1 1 endif endif End Bonus Question: The code you gave me would give me 20 seconds of non hostility right?
Bromm83 Posted April 11, 2012 Author Posted April 11, 2012 Oki, here is the complete token script. I have added the conversationstarter you suggested, will also use the same variable to fire off the timer once the conversation is over, so that I will have 20 seconds to get away from the NPC before I get attacked again. scn SexoutNGYieldTokenScript short sYield short sAgg short sDisp ref rYieldTo float fTimer Begin GameMode if(sYield) if(rYieldTo.getCombatTarget == playerREF) rYieldTo.stopCombat playerREF endif if(SexoutYield.sInitConversation == 0) if(fTimer < 20) set fTimer to (fTimer + getSecondsPassed) else rYieldTo.setAV Aggression sAgg rYieldTo.setDisposition playerREF sDisp rYieldTo.removeItem SexoutNGYieldToken 1 endif endif else set sYield to 1 set rYieldTo to getContainer set sDisp to rYieldTo.getDisposition playerREF set sAgg to rYieldTo.getAV Aggression rYieldTo.setAV Aggression 0 rYieldTo.setDisposition playerREF 100 rYieldTo.stopCombat if(SexoutYield.sInitConversation == 0) set SexoutYield.sInitConversation to 1 rYieldTo.startConversation playerREF, YieldMain endif endif End And here is the quest script that should fire it off: scn SexoutNGYieldQuestScript short sYield ref rYieldTo short sInitConversation Begin GameMode if 0 != player.GetCombatTarget set rYieldTo to player.GetCombatTarget endif if IsKeyPressed 38 != sYield set sYield to IsKeyPressed 38 if sYield ;Button pressed rYieldTo.additem SexoutNGYieldToken 1 1 endif endif End Thanks alot for the help so far! Playing with several things I have never used in scripts before, so good to get some help early on! =)
Chase Roxand Posted April 11, 2012 Posted April 11, 2012 Correct, 20 seconds. And if you replace the startConversation line with my previous code's post, just add short sInitConversation to the quest script. If you do so, you might also want a timer to the quest script to reset sInitConversation in the event that the NPC is interrupted before the conversation starts. Something like this would do: float fTimer ;... ;... ;... if(sInitConversation) if(fTimer < 20) set fTimer to fTimer + getSecondsPassed else set sInitConversation to 0 set fTimer to 0 endif else set fTimer to 0 endif
Recommended Posts
Archived
This topic is now archived and is closed to further replies.