Darth_HaHa Posted December 21, 2007 Share Posted December 21, 2007 Or did I find a script function (something along the lines of "ActionPauseConversation" and "ActionResumeConversation")? Would I be able to use those two functions in a script to talk-fight-talk sequence with an NPC, as opposed to the way the tutorial directs me to? Link to comment Share on other sites More sharing options...
Master Zionosis Posted December 21, 2007 Share Posted December 21, 2007 Yeah, that's what those functions are for, I've never actually used them before but I believe you set a time for how long you want to pause the conversation for and then resume it. Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 22, 2007 Author Share Posted December 22, 2007 So, then how would I use them in a script? Just "ActionPauseConversation" or what? Let's just say scripting is a weak point of mine. Link to comment Share on other sites More sharing options...
stoffe Posted December 22, 2007 Share Posted December 22, 2007 Or did I find a script function (something along the lines of "ActionPauseConversation" and "ActionResumeConversation")? Would I be able to use those two functions in a script to talk-fight-talk sequence with an NPC, as opposed to the way the tutorial directs me to? Those functions are used to briefly pause on a dialog node before moving on to the next while some scripted sequence is being performed. You could for example have a script like... void main() { object oNPC = GetObjectByTag("SomeNPC"); ActionPauseConversation(); ActionMoveToObject(oNPC); ActionResumeConversation(); } ...which would pause on the dialog node it is attached to while the conversing NPC is moving to some other NPC. Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 22, 2007 Author Share Posted December 22, 2007 Okay, thanks. But to use a script the way I want to, I'd have to put one script with a "PauseConversation" command at the dialog line where I want to start combat with the NPC. How would I get the script that check's the NPC's health, then resumes conversation? ((I already studied that tutorial on the Talk-Fight-Talk sequence in the tutrials section)) Link to comment Share on other sites More sharing options...
stoffe Posted December 22, 2007 Share Posted December 22, 2007 But to use a script the way I want to, I'd have to put one script with a "PauseConversation" command at the dialog line where I want to start combat with the NPC. Since ActionPauseConversation() does not take you out of dialog mode it's not really useful for any sequence requiring player interaction. Thus it would only work to use for cinematic combat sequences where the player characters' actions are scripted as well. To put a normal combat sequence in the middle of a conversation you need to end the conversation, turning the NPC(s) hostile in a script on the last node, and then put a script on those NPCs that restarts the conversation (with some variable set so another branch will initiate) when their health is reduced below a certain threshold. Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 22, 2007 Author Share Posted December 22, 2007 What kind of variable would I set, then? The tutorial doesn't make much sense to me, but I think that's because scripting is just way over my head. Link to comment Share on other sites More sharing options...
stoffe Posted December 22, 2007 Share Posted December 22, 2007 What kind of variable would I set, then? The tutorial doesn't make much sense to me, but I think that's because scripting is just way over my head. Local variables should work for this, unless you need to check later in the game if the player has fought this particular NPC. To illustrate with a very bare bones example, when first talking to the NPC he will duly inform the player of his plans to punch them in the face. Unless the player weasels out the fight starts. If the NPC wins its game over since all self-respecting players fight to the death, but if the player beats the NPC down to below 10% health he will surrender, the conversation will start again where the NPC says "Well now, wasn't that fun?". We have a very simple DLG file (ha_brawl.dlg) assigned to the NPCs UTC template, made up of two dialog branches (E = entry nodes (NPC talk), R = reply nodes (player responses)): ¤ (root - ha_brawl.dlg) ¤ E1: Well now, wasn't that fun? (conditional: ha_c_fought) ¤ R1: Quite, I'm done punching for now though. ¤ E2: I'm gonna punch you in the face! ¤ R2: Bring it on! (action: ha_a_fight) ¤ R3: I'm afraid I have to decline. The first, starting at E1, will be available after the fight is over as the ha_c_fought conditional script blocks it out before that. The second, starting at E2, will be available before the fight, and will initiate the fight on the first reply node (R2) via the action script ha_a_fight. For this example, three scripts would be needed, the aforementioned two, and one OnDamaged event script set on the NPC to keep track of their health to end the fight when they get sufficiently hurt, called ha_damaged in this example. These scripts could look something like: ha_a_fight void main() { SetLocalBoolean(OBJECT_SELF, 37, TRUE); SetLocalBoolean(OBJECT_SELF, 38, FALSE); SetMinOneHP(OBJECT_SELF, TRUE); ClearAllActions(); ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_HOSTILE_1); ExecuteScript("k_ai_master", OBJECT_SELF, 1003); } This script starts the fight by turning the NPC hostile to the player and kickstarts their combat AI, while ensuring that they cannot be killed. It also sets Local boolean variable 37 on the dialog owner NPC to indicate that a fight is underway. ha_c_fought int StartingConditional() { return GetLocalBoolean(OBJECT_SELF, 38); } This is a dialog conditional script determining if the dialog branch it is attached to should be available. This script makes the dialog node available if local boolean 38 is set on the dialog owner NPC. This is used to indicate that a fight has been won by the player. ha_damaged void main() { if (GetLocalBoolean(OBJECT_SELF, 37) && !GetLocalBoolean(OBJECT_SELF, 38) && (GetCurrentHitPoints(OBJECT_SELF) < (GetMaxHitPoints(OBJECT_SELF) / 10))) { SetLocalBoolean(OBJECT_SELF, 38, TRUE); CancelCombat(OBJECT_SELF); SurrenderToEnemies(); ChangeToStandardFaction(OBJECT_SELF, STANDARD_FACTION_NEUTRAL); ClearAllActions(); ActionStartConversation(GetFirstPC(), "ha_brawl", FALSE, 0, TRUE); } else { ExecuteScript("k_ai_master", OBJECT_SELF, 1006); } } This script must be set as OnDamaged event script in the UTC template of the NPC. It checks if local boolean variable 37 is set on the NPC (which indicates that a fight is underway), that local boolean variable 38 is not set on the NPC (since this indicates the player has won the fight), and if the NPCs current health is lower than 10% of its max health. If these conditions are met the script sets local boolean variable 38 on the NPC to indicate the player won the fight (which is checked for in the ha_c_fought script above), stops the fight, turns the NPC neutral to the player and restarts the same dialog again. Though since local boolean 38 is now set the ha_c_fought conditional script will now unlock the first (E1) dialog branch which will be used instead for the after-fight banter. Link to comment Share on other sites More sharing options...
Darth_HaHa Posted December 22, 2007 Author Share Posted December 22, 2007 Thanks, stoffe!! I got it to work this time! :D Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.